Initializr starter custom project type support
This commit is contained in:
@@ -64,7 +64,6 @@ import org.springsource.ide.eclipse.commons.livexp.core.validators.NewProjectNam
|
||||
import org.springsource.ide.eclipse.commons.livexp.core.validators.UrlValidator;
|
||||
import org.springsource.ide.eclipse.commons.livexp.ui.ProjectLocationSection;
|
||||
import org.springsource.ide.eclipse.commons.livexp.util.Filter;
|
||||
import org.springsource.ide.eclipse.commons.livexp.util.Log;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
@@ -76,15 +75,6 @@ public class NewSpringBootWizardModel {
|
||||
private static final String NAME_PROPRTY_ID = "name";
|
||||
private static final String ARTIFACT_PROPERTY_ID = "artifactId";
|
||||
|
||||
private static final Map<String,BuildType> KNOWN_TYPES = new HashMap<>();
|
||||
static {
|
||||
KNOWN_TYPES.put("gradle-project", BuildType.GRADLE); // New version of initialzr app
|
||||
KNOWN_TYPES.put("maven-project", BuildType.MAVEN); // New versions of initialzr app
|
||||
|
||||
KNOWN_TYPES.put("gradle.zip", BuildType.GRADLE); //Legacy, can remove when new initializr app uses "gradle-project" definitively
|
||||
KNOWN_TYPES.put("starter.zip", BuildType.MAVEN); //Legacy, can remove when initializr app uses "maven-project" definitively
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists known query parameters that map onto a String input field. The default values for these
|
||||
* parameters will be pulled from the json spec document.
|
||||
@@ -440,14 +430,23 @@ public class NewSpringBootWizardModel {
|
||||
RadioGroup group = radioGroups.ensureGroup(groupName);
|
||||
group.label("Type:");
|
||||
for (Type type : serviceSpec.getTypeOptions(groupName)) {
|
||||
BuildType bt = KNOWN_TYPES.get(type.getId());
|
||||
BuildType bt = BuildType.valueOf(type.getBuild().toUpperCase());
|
||||
if (bt!=null) {
|
||||
for (ImportStrategy is : bt.getImportStrategies()) {
|
||||
List<ImportStrategy> importStrategies = bt.getImportStrategies();
|
||||
if (importStrategies.size() == 1) {
|
||||
ImportStrategy is = importStrategies.get(0);
|
||||
TypeRadioInfo radio = new TypeRadioInfo(groupName, type, is);
|
||||
radio.setLabel(is.displayName());
|
||||
radio.setLabel(type.getName());
|
||||
group.add(radio);
|
||||
} else {
|
||||
for (ImportStrategy is : importStrategies) {
|
||||
TypeRadioInfo radio = new TypeRadioInfo(groupName, type, is);
|
||||
radio.setLabel(type.getName() + " - " + is.displayName());
|
||||
group.add(radio);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//When a type is selected the 'baseUrl' should be update according to its action.
|
||||
group.getSelection().selection.addListener(new ValueListener<RadioInfo>() {
|
||||
|
||||
@@ -16,8 +16,10 @@ import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -146,6 +148,7 @@ public class InitializrServiceSpec {
|
||||
|
||||
public static class Type extends Option {
|
||||
private String action;
|
||||
private String build;
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
@@ -154,8 +157,18 @@ public class InitializrServiceSpec {
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public String getBuild() {
|
||||
return build;
|
||||
}
|
||||
|
||||
public void setBuild(String build) {
|
||||
this.build = build;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class Dependency extends Nameable implements IdAble{
|
||||
|
||||
private String id;
|
||||
@@ -373,19 +386,24 @@ public class InitializrServiceSpec {
|
||||
if (obj!=null && "action".equals(obj.optString("type"))) {
|
||||
String defaultValue = obj.optString("default", "");
|
||||
JSONArray arr = obj.getJSONArray("values");
|
||||
Type[] options = new Type[arr.length()];
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
List<Type> options = new ArrayList<>(arr.length());
|
||||
for (int i = 0; i < arr.length(); i++) {
|
||||
JSONObject option = arr.getJSONObject(i);
|
||||
options[i] = new Type();
|
||||
String id = option.getString("id");
|
||||
String name = option.getString("name");
|
||||
String action = option.getString("action");
|
||||
options[i].setId(id);
|
||||
options[i].setName(name);
|
||||
options[i].setAction(action);
|
||||
options[i].setDefault(id.equals(defaultValue));
|
||||
JSONObject tags = option.getJSONObject("tags");
|
||||
if ("project".equals(tags.optString("format", null))) {
|
||||
Type type = new Type();
|
||||
type.setId(id);
|
||||
type.setName(name);
|
||||
type.setAction(action);
|
||||
type.setBuild(tags.optString("build"));
|
||||
type.setDefault(id.equals(defaultValue));
|
||||
options.add(type);
|
||||
}
|
||||
}
|
||||
return options;
|
||||
return options.toArray(new Type[options.size()]);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
//ignore
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src/">
|
||||
<attributes>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
||||
Reference in New Issue
Block a user