From aee194f7776b732771bdd66cf7ef304a5fbbe2dc Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 4 Jun 2018 20:13:22 +0200 Subject: [PATCH] Fixed project wizard and removed JDT/PDE dependency --- .../feature.xml | 105 ------------------ .../com.minres.rdl.ui/META-INF/MANIFEST.MF | 2 - .../com.minres.rdl.ui/plugin.xml | 22 +++- .../com/minres/rdl/ui/wizard/Messages.java | 2 + .../wizard/RDLProjectTemplateProvider.xtend | 87 +++++++++------ .../minres/rdl/ui/wizard/messages.properties | 2 + .../rdl/ui/wizard/HelloWorldProject.java | 95 ---------------- .../ui/wizard/RDLProjectTemplateProvider.java | 6 +- .../com/minres/rdl/ui/wizard/RdlProject.java | 94 ++++++++++++++++ 9 files changed, 168 insertions(+), 247 deletions(-) delete mode 100644 com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/HelloWorldProject.java create mode 100644 com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/RdlProject.java diff --git a/com.minres.rdl.parent/com.minres.rdl.platform.feature/feature.xml b/com.minres.rdl.parent/com.minres.rdl.platform.feature/feature.xml index f93d24a..67f9282 100644 --- a/com.minres.rdl.parent/com.minres.rdl.platform.feature/feature.xml +++ b/com.minres.rdl.parent/com.minres.rdl.platform.feature/feature.xml @@ -130,21 +130,6 @@ version="0.0.0" unpack="false"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + + + + + + + + diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/Messages.java b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/Messages.java index 7e3c31f..33fa588 100644 --- a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/Messages.java +++ b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/Messages.java @@ -7,6 +7,8 @@ public class Messages extends NLS { public static String HelloWorldProject_Label; public static String HelloWorldProject_Description; + public static String RdlProject_Label; + public static String RdlProject_Description; static { // initialize resource bundle diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/RDLProjectTemplateProvider.xtend b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/RDLProjectTemplateProvider.xtend index f4969de..931497d 100644 --- a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/RDLProjectTemplateProvider.xtend +++ b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/RDLProjectTemplateProvider.xtend @@ -3,17 +3,12 @@ */ 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.util.PluginProjectFactory import org.eclipse.xtext.ui.wizard.template.IProjectGenerator import org.eclipse.xtext.ui.wizard.template.IProjectTemplateProvider 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. * @@ -21,47 +16,65 @@ import static org.eclipse.core.runtime.IStatus.* */ class RDLProjectTemplateProvider implements IProjectTemplateProvider { override getProjectTemplates() { - #[new HelloWorldProject] + #[new RdlProject] } } -@ProjectTemplate(label="Hello World", icon="project_template.png", description="

Hello World

-

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.

") -final class HelloWorldProject { - val advanced = check("Advanced:", false) - val advancedGroup = group("Properties") - 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 - path.enabled = advanced.value - if (!advanced.value) { - name.value = "Xtext" - path.value = "rdl" - } - } - - override protected validate() { - if (path.value.matches('[a-z][a-z0-9_]*(/[a-z][a-z0-9_]*)*')) - null - else - new Status(ERROR, "Wizard", "'" + path + "' is not a valid package name") - } +@ProjectTemplate( + label="RDL template", + icon="project_template.png", + description="

RDL

This is a simple project for RDL.

") +final class RdlProject { +// val advanced = check("Advanced:", false) +// val advancedGroup = group("Properties") +// 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 +// path.enabled = advanced.value +// if (!advanced.value) { +// name.value = "Xtext" +// path.value = "rdl" +// } +// } +// +// override protected validate() { +// if (path.value.matches('[a-z][a-z0-9_]*(/[a-z][a-z0-9_]*)*')) +// null +// else +// new Status(ERROR, "Wizard", "'" + path + "' is not a valid package name") +// } override generateProjects(IProjectGenerator generator) { generator.generate(new PluginProjectFactory => [ projectName = projectInfo.projectName location = projectInfo.locationPath - projectNatures += #[JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID] - builderIds += JavaCore.BUILDER_ID + projectNatures += XtextProjectHelper.NATURE_ID //#[JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID] + builderIds += XtextProjectHelper.BUILDER_ID //JavaCore.BUILDER_ID folders += "src" - addFile('''src/«path»/Model.rdl''', ''' - /* - * This is an example model - */ - Hello «name»! + addFile('''src/Model.rdl''', ''' + enum ERRSLICE0_MISSIONERR_ENABLE_ERR25_enum{ + DISABLE = 1'd0; + ENABLE = 1'd1; + }; + 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; ''') ]) } diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/messages.properties b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/messages.properties index 0a4a053..e5ea43e 100644 --- a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/messages.properties +++ b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/messages.properties @@ -1,2 +1,4 @@ HelloWorldProject_Label=Hello World HelloWorldProject_Description=

Hello World

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.

+RdlProject_Label=RDL template +RdlProject_Description=

RDL

This is a simple project for RDL.

diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/HelloWorldProject.java b/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/HelloWorldProject.java deleted file mode 100644 index 1aabef6..0000000 --- a/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/HelloWorldProject.java +++ /dev/null @@ -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 = "

Hello World

\n

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.

") -@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 _function = (PluginProjectFactory it) -> { - it.setProjectName(this.getProjectInfo().getProjectName()); - it.setLocation(this.getProjectInfo().getLocationPath()); - List _projectNatures = it.getProjectNatures(); - Iterables.addAll(_projectNatures, Collections.unmodifiableList(CollectionLiterals.newArrayList(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID))); - List _builderIds = it.getBuilderIds(); - _builderIds.add(JavaCore.BUILDER_ID); - List _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.operator_doubleArrow(_pluginProjectFactory, _function); - generator.generate(_doubleArrow); - } -} diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/RDLProjectTemplateProvider.java b/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/RDLProjectTemplateProvider.java index 613aed2..e7d1025 100644 --- a/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/RDLProjectTemplateProvider.java +++ b/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/RDLProjectTemplateProvider.java @@ -3,7 +3,7 @@ */ 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.IProjectTemplateProvider; @@ -16,7 +16,7 @@ import org.eclipse.xtext.ui.wizard.template.IProjectTemplateProvider; public class RDLProjectTemplateProvider implements IProjectTemplateProvider { @Override public AbstractProjectTemplate[] getProjectTemplates() { - HelloWorldProject _helloWorldProject = new HelloWorldProject(); - return new AbstractProjectTemplate[] { _helloWorldProject }; + RdlProject _rdlProject = new RdlProject(); + return new AbstractProjectTemplate[] { _rdlProject }; } } diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/RdlProject.java b/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/RdlProject.java new file mode 100644 index 0000000..aadd556 --- /dev/null +++ b/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/RdlProject.java @@ -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 = "

RDL

This is a simple project for RDL.

") +@SuppressWarnings("all") +public final class RdlProject extends AbstractProjectTemplate { + @Override + public void generateProjects(final IProjectGenerator generator) { + PluginProjectFactory _pluginProjectFactory = new PluginProjectFactory(); + final Procedure1 _function = (PluginProjectFactory it) -> { + it.setProjectName(this.getProjectInfo().getProjectName()); + it.setLocation(this.getProjectInfo().getLocationPath()); + List _projectNatures = it.getProjectNatures(); + _projectNatures.add(XtextProjectHelper.NATURE_ID); + List _builderIds = it.getBuilderIds(); + _builderIds.add(XtextProjectHelper.BUILDER_ID); + List _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.operator_doubleArrow(_pluginProjectFactory, _function); + generator.generate(_doubleArrow); + } +}