Fixed project wizard and removed JDT/PDE dependency

This commit is contained in:
Eyck Jentzsch 2018-06-04 20:13:22 +02:00
parent c7d8d6c417
commit aee194f777
9 changed files with 168 additions and 247 deletions

View File

@ -130,21 +130,6 @@
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin
id="org.eclipse.jdt.compiler.tool"
download-size="0"
install-size="0"
version="0.0.0"
fragment="true"
unpack="false"/>
<plugin
id="org.eclipse.pde.ui"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin <plugin
id="org.eclipse.equinox.p2.repository" id="org.eclipse.equinox.p2.repository"
download-size="0" download-size="0"
@ -278,13 +263,6 @@
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin
id="org.eclipse.pde.core"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin <plugin
id="org.eclipse.emf.codegen" id="org.eclipse.emf.codegen"
download-size="0" download-size="0"
@ -398,13 +376,6 @@
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin
id="org.eclipse.jdt.junit"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin <plugin
id="org.eclipse.xtext" id="org.eclipse.xtext"
download-size="0" download-size="0"
@ -488,12 +459,6 @@
install-size="0" install-size="0"
version="0.0.0"/> version="0.0.0"/>
<plugin
id="org.eclipse.jdt.debug"
download-size="0"
install-size="0"
version="0.0.0"/>
<plugin <plugin
id="org.eclipse.emf.mwe2.language" id="org.eclipse.emf.mwe2.language"
download-size="0" download-size="0"
@ -578,13 +543,6 @@
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin
id="org.eclipse.jdt.launching"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin <plugin
id="org.eclipse.emf.mwe2.runtime" id="org.eclipse.emf.mwe2.runtime"
download-size="0" download-size="0"
@ -683,13 +641,6 @@
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin
id="org.eclipse.jdt.debug.ui"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin <plugin
id="org.eclipse.equinox.p2.operations" id="org.eclipse.equinox.p2.operations"
download-size="0" download-size="0"
@ -697,13 +648,6 @@
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin
id="org.eclipse.jdt.junit.runtime"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin <plugin
id="org.eclipse.ant.launching" id="org.eclipse.ant.launching"
download-size="0" download-size="0"
@ -1018,13 +962,6 @@
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin
id="org.eclipse.jdt.ui"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin <plugin
id="org.w3c.dom.svg" id="org.w3c.dom.svg"
download-size="0" download-size="0"
@ -1046,13 +983,6 @@
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin
id="org.eclipse.jdt.junit.core"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin <plugin
id="org.eclipse.e4.ui.workbench" id="org.eclipse.e4.ui.workbench"
download-size="0" download-size="0"
@ -1137,12 +1067,6 @@
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin
id="org.eclipse.pde.build"
download-size="0"
install-size="0"
version="0.0.0"/>
<plugin <plugin
id="org.eclipse.ant.core" id="org.eclipse.ant.core"
download-size="0" download-size="0"
@ -1220,13 +1144,6 @@
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin
id="org.eclipse.jdt.core.manipulation"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin <plugin
id="org.eclipse.ui.trace" id="org.eclipse.ui.trace"
download-size="0" download-size="0"
@ -1248,13 +1165,6 @@
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin
id="org.eclipse.pde.launching"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin <plugin
id="org.apache.commons.lang" id="org.apache.commons.lang"
download-size="0" download-size="0"
@ -1290,14 +1200,6 @@
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin
id="org.eclipse.jdt.compiler.apt"
download-size="0"
install-size="0"
version="0.0.0"
fragment="true"
unpack="false"/>
<plugin <plugin
id="org.eclipse.osgi.services" id="org.eclipse.osgi.services"
download-size="0" download-size="0"
@ -1340,13 +1242,6 @@
version="0.0.0" version="0.0.0"
unpack="false"/> unpack="false"/>
<plugin
id="org.eclipse.jdt.core"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin <plugin
id="org.eclipse.ui.editors" id="org.eclipse.ui.editors"
download-size="0" download-size="0"

View File

@ -20,8 +20,6 @@ Require-Bundle: com.minres.rdl,
org.eclipse.xtend.lib;resolution:=optional, org.eclipse.xtend.lib;resolution:=optional,
org.eclipse.core.runtime, org.eclipse.core.runtime,
org.eclipse.core.resources, org.eclipse.core.resources,
org.eclipse.jdt.core,
org.eclipse.pde.core,
org.eclipse.ui.forms org.eclipse.ui.forms
Import-Package: org.apache.log4j Import-Package: org.apache.log4j
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-RequiredExecutionEnvironment: JavaSE-1.8

View File

@ -439,16 +439,28 @@
</extension> </extension>
<extension <extension
point="org.eclipse.ui.newWizards"> point="org.eclipse.ui.newWizards">
<category id="com.minres.category" name="MINRES">
</category>
<wizard <wizard
category="com.minres.category" category="com.minres.category"
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:com.minres.rdl.ui.wizard.RDLNewProjectWizard" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.wizard.template.TemplateNewProjectWizard"
id="com.minres.rdl.ui.wizard.RDLNewProjectWizard" id="com.minres.rdl.ui.wizard.RDLNewProjectWizard"
name="RDL Project" name="RDL Project"
icon="icons/new_RDL_proj.gif"
project="true"> project="true">
</wizard> </wizard>
<category </extension>
id="com.minres.category" <extension
name="MINRES"> point="org.eclipse.xtext.ui.projectTemplate">
</category> <projectTemplateProvider
class="com.minres.rdl.ui.wizard.RDLProjectTemplateProvider"
grammarName="com.minres.rdl.RDL">
</projectTemplateProvider>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension targetID="org.eclipse.ui.resourcePerspective">
<newWizardShortcut id="com.minres.rdl.ui.wizard.RDLNewProjectWizard"/>
</perspectiveExtension>
</extension> </extension>
</plugin> </plugin>

View File

@ -7,6 +7,8 @@ public class Messages extends NLS {
public static String HelloWorldProject_Label; public static String HelloWorldProject_Label;
public static String HelloWorldProject_Description; public static String HelloWorldProject_Description;
public static String RdlProject_Label;
public static String RdlProject_Description;
static { static {
// initialize resource bundle // initialize resource bundle

View File

@ -3,17 +3,12 @@
*/ */
package com.minres.rdl.ui.wizard package com.minres.rdl.ui.wizard
import org.eclipse.core.runtime.Status
import org.eclipse.jdt.core.JavaCore
import org.eclipse.xtext.ui.XtextProjectHelper import org.eclipse.xtext.ui.XtextProjectHelper
import org.eclipse.xtext.ui.util.PluginProjectFactory import org.eclipse.xtext.ui.util.PluginProjectFactory
import org.eclipse.xtext.ui.wizard.template.IProjectGenerator import org.eclipse.xtext.ui.wizard.template.IProjectGenerator
import org.eclipse.xtext.ui.wizard.template.IProjectTemplateProvider import org.eclipse.xtext.ui.wizard.template.IProjectTemplateProvider
import org.eclipse.xtext.ui.wizard.template.ProjectTemplate import org.eclipse.xtext.ui.wizard.template.ProjectTemplate
import static org.eclipse.core.runtime.IStatus.*
/** /**
* Create a list with all project templates to be shown in the template new project wizard. * Create a list with all project templates to be shown in the template new project wizard.
* *
@ -21,47 +16,65 @@ import static org.eclipse.core.runtime.IStatus.*
*/ */
class RDLProjectTemplateProvider implements IProjectTemplateProvider { class RDLProjectTemplateProvider implements IProjectTemplateProvider {
override getProjectTemplates() { override getProjectTemplates() {
#[new HelloWorldProject] #[new RdlProject]
} }
} }
@ProjectTemplate(label="Hello World", icon="project_template.png", description="<p><b>Hello World</b></p> @ProjectTemplate(
<p>This is a parameterized hello world for RDL. You can set a parameter to modify the content in the generated file label="RDL template",
and a parameter to set the package the file is created in.</p>") icon="project_template.png",
final class HelloWorldProject { description="<p><b>RDL</b></p><p>This is a simple project for RDL.</p>")
val advanced = check("Advanced:", false) final class RdlProject {
val advancedGroup = group("Properties") // val advanced = check("Advanced:", false)
val name = combo("Name:", #["Xtext", "World", "Foo", "Bar"], "The name to say 'Hello' to", advancedGroup) // val advancedGroup = group("Properties")
val path = text("Package:", "mydsl", "The package path to place the files in", advancedGroup) // val name = combo("Name:", #["Xtext", "World", "Foo", "Bar"], "The name to say 'Hello' to", advancedGroup)
// val path = text("Package:", "mydsl", "The package path to place the files in", advancedGroup)
override protected updateVariables() { //
name.enabled = advanced.value // override protected updateVariables() {
path.enabled = advanced.value // name.enabled = advanced.value
if (!advanced.value) { // path.enabled = advanced.value
name.value = "Xtext" // if (!advanced.value) {
path.value = "rdl" // name.value = "Xtext"
} // path.value = "rdl"
} // }
// }
override protected validate() { //
if (path.value.matches('[a-z][a-z0-9_]*(/[a-z][a-z0-9_]*)*')) // override protected validate() {
null // if (path.value.matches('[a-z][a-z0-9_]*(/[a-z][a-z0-9_]*)*'))
else // null
new Status(ERROR, "Wizard", "'" + path + "' is not a valid package name") // else
} // new Status(ERROR, "Wizard", "'" + path + "' is not a valid package name")
// }
override generateProjects(IProjectGenerator generator) { override generateProjects(IProjectGenerator generator) {
generator.generate(new PluginProjectFactory => [ generator.generate(new PluginProjectFactory => [
projectName = projectInfo.projectName projectName = projectInfo.projectName
location = projectInfo.locationPath location = projectInfo.locationPath
projectNatures += #[JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID] projectNatures += XtextProjectHelper.NATURE_ID //#[JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID]
builderIds += JavaCore.BUILDER_ID builderIds += XtextProjectHelper.BUILDER_ID //JavaCore.BUILDER_ID
folders += "src" folders += "src"
addFile('''src/«path»/Model.rdl''', ''' addFile('''src/Model.rdl''', '''
/* enum ERRSLICE0_MISSIONERR_ENABLE_ERR25_enum{
* This is an example model DISABLE = 1'd0;
*/ ENABLE = 1'd1;
Hello «name»! };
addrmap {
name = "foo registers";
desc = "this is a bunch of foo regs bla bla bla";
regfile bar_regs {
name = "bar registers";
desc = "this is a bunch of bar regs bla bla bla";
reg {
field { name="field 1"; sw=rw; hw=rw; we; } fld1[9:0] = 10'd0;
field { name="field 2"; sw=rw; hw=r; } fld2[15:15];
field {encode=ERRSLICE0_MISSIONERR_ENABLE_ERR25_enum; sw=rw; hw=r; reset=1'h1;} ERR25[25:25];
} a_reg[2];
} bar;
} foo;
''') ''')
]) ])
} }

View File

@ -1,2 +1,4 @@
HelloWorldProject_Label=Hello World HelloWorldProject_Label=Hello World
HelloWorldProject_Description=<p><b>Hello World</b></p> <p>This is a parameterized hello world for RDL. You can set a parameter to modify the content in the generated file and a parameter to set the package the file is created in.</p> HelloWorldProject_Description=<p><b>Hello World</b></p> <p>This is a parameterized hello world for RDL. You can set a parameter to modify the content in the generated file and a parameter to set the package the file is created in.</p>
RdlProject_Label=RDL template
RdlProject_Description=<p><b>RDL</b></p><p>This is a simple project for RDL.</p>

View File

@ -1,95 +0,0 @@
/**
* generated by Xtext 2.14.0
*/
package com.minres.rdl.ui.wizard;
import com.google.common.collect.Iterables;
import java.util.Collections;
import java.util.List;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.ui.XtextProjectHelper;
import org.eclipse.xtext.ui.util.PluginProjectFactory;
import org.eclipse.xtext.ui.wizard.template.AbstractProjectTemplate;
import org.eclipse.xtext.ui.wizard.template.BooleanTemplateVariable;
import org.eclipse.xtext.ui.wizard.template.GroupTemplateVariable;
import org.eclipse.xtext.ui.wizard.template.IProjectGenerator;
import org.eclipse.xtext.ui.wizard.template.ProjectTemplate;
import org.eclipse.xtext.ui.wizard.template.StringSelectionTemplateVariable;
import org.eclipse.xtext.ui.wizard.template.StringTemplateVariable;
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
@ProjectTemplate(label = "Hello World", icon = "project_template.png", description = "<p><b>Hello World</b></p>\n<p>This is a parameterized hello world for RDL. You can set a parameter to modify the content in the generated file\nand a parameter to set the package the file is created in.</p>")
@SuppressWarnings("all")
public final class HelloWorldProject extends AbstractProjectTemplate {
private final BooleanTemplateVariable advanced = this.check("Advanced:", false);
private final GroupTemplateVariable advancedGroup = this.group("Properties");
private final StringSelectionTemplateVariable name = this.combo("Name:", new String[] { "Xtext", "World", "Foo", "Bar" }, "The name to say \'Hello\' to", this.advancedGroup);
private final StringTemplateVariable path = this.text("Package:", "mydsl", "The package path to place the files in", this.advancedGroup);
@Override
protected void updateVariables() {
this.name.setEnabled(this.advanced.getValue());
this.path.setEnabled(this.advanced.getValue());
boolean _value = this.advanced.getValue();
boolean _not = (!_value);
if (_not) {
this.name.setValue("Xtext");
this.path.setValue("rdl");
}
}
@Override
protected IStatus validate() {
Status _xifexpression = null;
boolean _matches = this.path.getValue().matches("[a-z][a-z0-9_]*(/[a-z][a-z0-9_]*)*");
if (_matches) {
_xifexpression = null;
} else {
_xifexpression = new Status(IStatus.ERROR, "Wizard", (("\'" + this.path) + "\' is not a valid package name"));
}
return _xifexpression;
}
@Override
public void generateProjects(final IProjectGenerator generator) {
PluginProjectFactory _pluginProjectFactory = new PluginProjectFactory();
final Procedure1<PluginProjectFactory> _function = (PluginProjectFactory it) -> {
it.setProjectName(this.getProjectInfo().getProjectName());
it.setLocation(this.getProjectInfo().getLocationPath());
List<String> _projectNatures = it.getProjectNatures();
Iterables.<String>addAll(_projectNatures, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID)));
List<String> _builderIds = it.getBuilderIds();
_builderIds.add(JavaCore.BUILDER_ID);
List<String> _folders = it.getFolders();
_folders.add("src");
StringConcatenation _builder = new StringConcatenation();
_builder.append("src/");
_builder.append(this.path);
_builder.append("/Model.rdl");
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("/*");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("* This is an example model");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("*/");
_builder_1.newLine();
_builder_1.append("Hello ");
_builder_1.append(this.name);
_builder_1.append("!");
_builder_1.newLineIfNotEmpty();
this.addFile(it, _builder, _builder_1);
};
PluginProjectFactory _doubleArrow = ObjectExtensions.<PluginProjectFactory>operator_doubleArrow(_pluginProjectFactory, _function);
generator.generate(_doubleArrow);
}
}

View File

@ -3,7 +3,7 @@
*/ */
package com.minres.rdl.ui.wizard; package com.minres.rdl.ui.wizard;
import com.minres.rdl.ui.wizard.HelloWorldProject; import com.minres.rdl.ui.wizard.RdlProject;
import org.eclipse.xtext.ui.wizard.template.AbstractProjectTemplate; import org.eclipse.xtext.ui.wizard.template.AbstractProjectTemplate;
import org.eclipse.xtext.ui.wizard.template.IProjectTemplateProvider; import org.eclipse.xtext.ui.wizard.template.IProjectTemplateProvider;
@ -16,7 +16,7 @@ import org.eclipse.xtext.ui.wizard.template.IProjectTemplateProvider;
public class RDLProjectTemplateProvider implements IProjectTemplateProvider { public class RDLProjectTemplateProvider implements IProjectTemplateProvider {
@Override @Override
public AbstractProjectTemplate[] getProjectTemplates() { public AbstractProjectTemplate[] getProjectTemplates() {
HelloWorldProject _helloWorldProject = new HelloWorldProject(); RdlProject _rdlProject = new RdlProject();
return new AbstractProjectTemplate[] { _helloWorldProject }; return new AbstractProjectTemplate[] { _rdlProject };
} }
} }

View File

@ -0,0 +1,94 @@
/**
* generated by Xtext 2.14.0
*/
package com.minres.rdl.ui.wizard;
import java.util.List;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.ui.XtextProjectHelper;
import org.eclipse.xtext.ui.util.PluginProjectFactory;
import org.eclipse.xtext.ui.wizard.template.AbstractProjectTemplate;
import org.eclipse.xtext.ui.wizard.template.IProjectGenerator;
import org.eclipse.xtext.ui.wizard.template.ProjectTemplate;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
@ProjectTemplate(label = "RDL template", icon = "project_template.png", description = "<p><b>RDL</b></p><p>This is a simple project for RDL.</p>")
@SuppressWarnings("all")
public final class RdlProject extends AbstractProjectTemplate {
@Override
public void generateProjects(final IProjectGenerator generator) {
PluginProjectFactory _pluginProjectFactory = new PluginProjectFactory();
final Procedure1<PluginProjectFactory> _function = (PluginProjectFactory it) -> {
it.setProjectName(this.getProjectInfo().getProjectName());
it.setLocation(this.getProjectInfo().getLocationPath());
List<String> _projectNatures = it.getProjectNatures();
_projectNatures.add(XtextProjectHelper.NATURE_ID);
List<String> _builderIds = it.getBuilderIds();
_builderIds.add(XtextProjectHelper.BUILDER_ID);
List<String> _folders = it.getFolders();
_folders.add("src");
StringConcatenation _builder = new StringConcatenation();
_builder.append("src/Model.rdl");
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("enum ERRSLICE0_MISSIONERR_ENABLE_ERR25_enum{");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("DISABLE = 1\'d0;");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("ENABLE = 1\'d1;");
_builder_1.newLine();
_builder_1.append("};");
_builder_1.newLine();
_builder_1.append("addrmap {");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("name = \"foo registers\";");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("desc = \"this is a bunch of foo regs bla bla bla\";");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("regfile bar_regs {");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("name = \"bar registers\";");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("desc = \"this is a bunch of bar regs bla bla bla\";");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.newLine();
_builder_1.append("\t ");
_builder_1.append("reg {");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("field { name=\"field 1\"; sw=rw; hw=rw; we; } fld1[9:0] = 10\'d0;");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("field { name=\"field 2\"; sw=rw; hw=r; } fld2[15:15];");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("field {encode=ERRSLICE0_MISSIONERR_ENABLE_ERR25_enum; sw=rw; hw=r; reset=1\'h1;} ERR25[25:25];");
_builder_1.newLine();
_builder_1.append("\t ");
_builder_1.append("} a_reg[2];\t ");
_builder_1.newLine();
_builder_1.append("\t ");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.append("} bar;");
_builder_1.newLine();
_builder_1.append(" ");
_builder_1.newLine();
_builder_1.append("} foo;");
_builder_1.newLine();
this.addFile(it, _builder, _builder_1);
};
PluginProjectFactory _doubleArrow = ObjectExtensions.<PluginProjectFactory>operator_doubleArrow(_pluginProjectFactory, _function);
generator.generate(_doubleArrow);
}
}