forked from mulesoft-labs/raml-for-jax-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
460dbc2
commit 20ccf2c
Showing
26 changed files
with
533 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
299 changes: 154 additions & 145 deletions
299
...erator.eclipse/src/com/mulesoft/jaxrs/raml/generator/popup/actions/PreferencesConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,146 +1,155 @@ | ||
package com.mulesoft.jaxrs.raml.generator.popup.actions; | ||
|
||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import org.eclipse.jface.preference.IPreferenceStore; | ||
import org.raml.model.ActionType; | ||
import org.raml.model.Protocol; | ||
|
||
import com.mulesoft.jaxrs.raml.generator.eclipse.JAXRSTORamlPlagin; | ||
|
||
final class PreferencesConfig implements IEditableRamlConfig { | ||
|
||
public static final String TITLE="title"; | ||
public static final String VERSION="version"; | ||
public static final String BASEURL="baseurl"; | ||
public static final String PROTOCOLS="protocols"; | ||
private static final String SINGLE = "single"; | ||
private static final String SORTED = "sorted"; | ||
private static final String FULL_TREE = "fullTree"; | ||
|
||
protected IPreferenceStore preferences=JAXRSTORamlPlagin.getInstance().getPreferenceStore(); | ||
|
||
|
||
public String getTitle() { | ||
String string = preferences.getString(TITLE); | ||
if (string==null||string.length()==0){ | ||
return "Please type API title here"; | ||
} | ||
return string; | ||
} | ||
|
||
|
||
public String getResponseCode(ActionType type) { | ||
String string = preferences.getString(getResponseCodeKey(type)); | ||
if (string!=null&&string.trim().length()>0){ | ||
return string; | ||
} | ||
return "200"; | ||
} | ||
|
||
|
||
public Set<Protocol> getProtocols() { | ||
String string = preferences.getString(PROTOCOLS); | ||
if (string!=null&&string.length()>0){ | ||
String[] split = string.split(","); | ||
HashSet<Protocol>s=new HashSet<Protocol>(); | ||
for (String str:split){ | ||
s.add(Protocol.valueOf(str)); | ||
} | ||
return s; | ||
} | ||
return Collections.singleton(Protocol.HTTP); | ||
} | ||
|
||
public void setProtocols(Set<Protocol> ps) { | ||
StringBuilder bld=new StringBuilder(); | ||
int a=0; | ||
for (Protocol p:ps){ | ||
bld.append(p.name()); | ||
a++; | ||
if (a!=ps.size()){ | ||
bld.append(","); | ||
} | ||
} | ||
preferences.setValue(PROTOCOLS, bld.toString()); | ||
} | ||
|
||
|
||
|
||
public String getBaseUrl() { | ||
String string = preferences.getString(BASEURL); | ||
if (string==null||string.length()==0){ | ||
return "http://example.com"; | ||
} | ||
return string; | ||
} | ||
|
||
|
||
public void setTitle(String title) { | ||
preferences.putValue(TITLE,title); | ||
} | ||
|
||
|
||
|
||
public void setBaseUrl(String baseUrl) { | ||
preferences.setValue(BASEURL, baseUrl); | ||
} | ||
|
||
|
||
public void setVersion(String value) { | ||
preferences.setValue(VERSION, value); | ||
} | ||
|
||
|
||
public String getVersion() { | ||
String string = preferences.getString(VERSION); | ||
if (string==null||string.length()==0){ | ||
return "v1"; | ||
} | ||
return string; | ||
} | ||
|
||
|
||
public boolean isSingle() { | ||
return preferences.getBoolean(SINGLE); | ||
} | ||
|
||
|
||
|
||
|
||
public void setSingle(boolean selection) { | ||
preferences.setValue(SINGLE, selection); | ||
} | ||
|
||
|
||
|
||
public boolean isSorted() { | ||
return !preferences.getBoolean(SORTED); | ||
} | ||
|
||
|
||
public void setSorted(boolean selection) { | ||
preferences.setValue(SORTED, !selection); | ||
} | ||
|
||
|
||
public void setDefaultResponseCode(ActionType a, String text) { | ||
preferences.putValue(getResponseCodeKey(a), text); | ||
} | ||
|
||
private String getResponseCodeKey(ActionType a) { | ||
return a.name()+".responseCode"; | ||
} | ||
|
||
|
||
public boolean doFullTree() { | ||
return !preferences.getBoolean(FULL_TREE); | ||
} | ||
|
||
|
||
public void setDoFullTree(boolean selection) { | ||
preferences.setValue(FULL_TREE, !selection); | ||
} | ||
package com.mulesoft.jaxrs.raml.generator.popup.actions; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.eclipse.jface.preference.IPreferenceStore; | ||
import org.raml.model.ActionType; | ||
import org.raml.model.Protocol; | ||
|
||
import com.mulesoft.jaxrs.raml.annotation.model.IResourceVisitorExtension; | ||
import com.mulesoft.jaxrs.raml.generator.eclipse.JAXRSTORamlPlagin; | ||
|
||
final class PreferencesConfig implements IEditableRamlConfig { | ||
|
||
public static final String TITLE="title"; | ||
public static final String VERSION="version"; | ||
public static final String BASEURL="baseurl"; | ||
public static final String PROTOCOLS="protocols"; | ||
private static final String SINGLE = "single"; | ||
private static final String SORTED = "sorted"; | ||
private static final String FULL_TREE = "fullTree"; | ||
|
||
protected IPreferenceStore preferences=JAXRSTORamlPlagin.getInstance().getPreferenceStore(); | ||
|
||
|
||
public String getTitle() { | ||
String string = preferences.getString(TITLE); | ||
if (string==null||string.length()==0){ | ||
return "Please type API title here"; | ||
} | ||
return string; | ||
} | ||
|
||
|
||
public String getResponseCode(ActionType type) { | ||
String string = preferences.getString(getResponseCodeKey(type)); | ||
if (string!=null&&string.trim().length()>0){ | ||
return string; | ||
} | ||
return "200"; | ||
} | ||
|
||
|
||
public Set<Protocol> getProtocols() { | ||
String string = preferences.getString(PROTOCOLS); | ||
if (string!=null&&string.length()>0){ | ||
String[] split = string.split(","); | ||
HashSet<Protocol>s=new HashSet<Protocol>(); | ||
for (String str:split){ | ||
s.add(Protocol.valueOf(str)); | ||
} | ||
return s; | ||
} | ||
return Collections.singleton(Protocol.HTTP); | ||
} | ||
|
||
public void setProtocols(Set<Protocol> ps) { | ||
StringBuilder bld=new StringBuilder(); | ||
int a=0; | ||
for (Protocol p:ps){ | ||
bld.append(p.name()); | ||
a++; | ||
if (a!=ps.size()){ | ||
bld.append(","); | ||
} | ||
} | ||
preferences.setValue(PROTOCOLS, bld.toString()); | ||
} | ||
|
||
|
||
|
||
public String getBaseUrl() { | ||
String string = preferences.getString(BASEURL); | ||
if (string==null||string.length()==0){ | ||
return "http://example.com"; | ||
} | ||
return string; | ||
} | ||
|
||
|
||
public void setTitle(String title) { | ||
preferences.putValue(TITLE,title); | ||
} | ||
|
||
|
||
|
||
public void setBaseUrl(String baseUrl) { | ||
preferences.setValue(BASEURL, baseUrl); | ||
} | ||
|
||
|
||
public void setVersion(String value) { | ||
preferences.setValue(VERSION, value); | ||
} | ||
|
||
|
||
public String getVersion() { | ||
String string = preferences.getString(VERSION); | ||
if (string==null||string.length()==0){ | ||
return "v1"; | ||
} | ||
return string; | ||
} | ||
|
||
|
||
public boolean isSingle() { | ||
return preferences.getBoolean(SINGLE); | ||
} | ||
|
||
|
||
|
||
|
||
public void setSingle(boolean selection) { | ||
preferences.setValue(SINGLE, selection); | ||
} | ||
|
||
|
||
|
||
public boolean isSorted() { | ||
return !preferences.getBoolean(SORTED); | ||
} | ||
|
||
|
||
public void setSorted(boolean selection) { | ||
preferences.setValue(SORTED, !selection); | ||
} | ||
|
||
|
||
public void setDefaultResponseCode(ActionType a, String text) { | ||
preferences.putValue(getResponseCodeKey(a), text); | ||
} | ||
|
||
private String getResponseCodeKey(ActionType a) { | ||
return a.name()+".responseCode"; | ||
} | ||
|
||
|
||
public boolean doFullTree() { | ||
return !preferences.getBoolean(FULL_TREE); | ||
} | ||
|
||
|
||
public void setDoFullTree(boolean selection) { | ||
preferences.setValue(FULL_TREE, !selection); | ||
} | ||
|
||
|
||
@Override | ||
public List<IResourceVisitorExtension> getExtensions() { | ||
return new ArrayList<IResourceVisitorExtension>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...aml.generator/src/com/mulesoft/jaxrs/raml/annotation/model/IResourceVisitorExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.mulesoft.jaxrs.raml.annotation.model; | ||
|
||
public interface IResourceVisitorExtension { | ||
|
||
boolean generateSchema(ITypeModel type); | ||
|
||
} |
Oops, something went wrong.