mirror of
				https://github.com/Minres/RDL-Editor.git
				synced 2025-11-03 20:21:46 +00:00 
			
		
		
		
	Fixed project wizard and removed JDT/PDE dependency
This commit is contained in:
		@@ -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);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -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 };
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user