summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2011-08-01 04:24:39 (EDT)
committer Henrik Rentz-Reichert2011-08-01 04:24:39 (EDT)
commit2556d19dc136feab69edf8bfb689925323aa99a8 (patch)
tree69cc7c530a7928344e43cb31f2fb9310284cb5b9
parent79a36d4762e923c7771f06bed91ab33ea4553ee7 (diff)
downloadorg.eclipse.etrice-2556d19dc136feab69edf8bfb689925323aa99a8.zip
org.eclipse.etrice-2556d19dc136feab69edf8bfb689925323aa99a8.tar.gz
org.eclipse.etrice-2556d19dc136feab69edf8bfb689925323aa99a8.tar.bz2
[core.room] re-factoring in new wizard
-rw-r--r--plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/newwizard/EmptyProjectWizard.java17
-rw-r--r--plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/newwizard/ProjectCreator.java105
2 files changed, 75 insertions, 47 deletions
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/newwizard/EmptyProjectWizard.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/newwizard/EmptyProjectWizard.java
index 599cdd1..e13a671 100644
--- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/newwizard/EmptyProjectWizard.java
+++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/newwizard/EmptyProjectWizard.java
@@ -16,6 +16,8 @@
*/
package org.eclipse.etrice.core.ui.newwizard;
+import java.util.List;
+
import org.apache.log4j.Logger;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
@@ -116,6 +118,13 @@ public class EmptyProjectWizard extends Wizard implements INewWizard {
addPage(newProjectCreationPage);
}
+ private List<String> getRequiredBundles() {
+ List<String> requiredBundles = ProjectCreator.getCommonRequiredBundles();
+ requiredBundles.add("org.eclipse.etrice.generator.java;bundle-version=\"0.1.0\"");
+ requiredBundles.add("org.eclipse.etrice.modellib;bundle-version=\"0.1.0\"");
+ return requiredBundles;
+ }
+
@Override
public boolean performFinish() {
WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
@@ -128,6 +137,8 @@ public class EmptyProjectWizard extends Wizard implements INewWizard {
new Path(sourceGenPath.toString()),
modelProjectURI,
runtimeProject,
+ ProjectCreator.getCommonNatureIDs(),
+ ProjectCreator.getCommonBuilderIDs(),
BasicMonitor.toMonitor(progressMonitor)
);
@@ -143,7 +154,8 @@ public class EmptyProjectWizard extends Wizard implements INewWizard {
ProjectCreator.createManifest(URI.createPlatformResourceURI("/"
+ baseName
+ "/META-INF/MANIFEST.MF", true),
- baseName);
+ baseName,
+ getRequiredBundles());
ProjectCreator.findOrCreateContainer(new Path("/"
+ baseName + "/src/workflow"),
@@ -151,7 +163,8 @@ public class EmptyProjectWizard extends Wizard implements INewWizard {
ProjectCreator.createWorkflow(URI.createPlatformResourceURI("/"
+ baseName
+ "/src/workflow/"+baseName+".mwe2", true),
- baseName);
+ baseName,
+ "RoomGenerator");
ProjectCreator.createBuildProperties(URI.createPlatformResourceURI("/"
+baseName+"/build.properties", true),
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/newwizard/ProjectCreator.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/newwizard/ProjectCreator.java
index 4a1027f..469554c 100644
--- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/newwizard/ProjectCreator.java
+++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/newwizard/ProjectCreator.java
@@ -48,31 +48,47 @@ import org.eclipse.jdt.launching.JavaRuntime;
*/
public class ProjectCreator {
- private static final String JAVA_NATURE_ID = JavaCore.NATURE_ID;
- private static final String ORG_ECLIPSE_XTEND_SHARED_UI_XTEND_X_PAND_NATURE = "org.eclipse.xtend.shared.ui.xtendXPandNature";
- private static final String ORG_ECLIPSE_XTEXT_UI_SHARED_XTEXT_NATURE = "org.eclipse.xtext.ui.shared.xtextNature";
- private static final String ORG_ECLIPSE_PDE_PLUGIN_NATURE = "org.eclipse.pde.PluginNature";
-
- private static final String[] requiredBundles = {
- "org.eclipse.etrice.generator.java;bundle-version=\"0.1.0\"",
- "org.eclipse.etrice.generator;bundle-version=\"0.1.0\"",
- "org.eclipse.etrice.modellib;bundle-version=\"0.1.0\"",
- "org.eclipse.emf.mwe2.launch;bundle-version=\"1.0.1\";resolution:=optional",
- "org.eclipse.emf.mwe.utils;bundle-version=\"1.0.0\";visibility:=reexport",
- "org.apache.log4j;bundle-version=\"1.2.15\"",
- "org.apache.commons.logging;bundle-version=\"1.0.4\"",
- "org.eclipse.jface.text;bundle-version=\"3.6.0\"",
- "org.eclipse.jdt.core;bundle-version=\"3.6.0\"",
- "org.eclipse.xtend.util.stdlib;bundle-version=\"1.0.0\"",
- "org.eclipse.core.runtime;bundle-version=\"3.6.0\"",
- "org.eclipse.xtext.generator;bundle-version=\"1.0.0\""
+ private static final String[] commonNatureIDs = {
+ JavaCore.NATURE_ID,
+ "org.eclipse.xtend.shared.ui.xtendXPandNature",
+ "org.eclipse.xtext.ui.shared.xtextNature",
+ "org.eclipse.pde.PluginNature"
};
+ private static final String[] commonBuilderIDs = {
+ "org.eclipse.pde.ManifestBuilder",
+ "org.eclipse.pde.SchemaBuilder",
+ "org.eclipse.xtext.ui.shared.xtextBuilder",
+ "org.eclipse.xtend.shared.ui.xtendBuilder"
+ };
+
+ private static final String[] commonRequiredBundles = {
+ "org.eclipse.etrice.generator;bundle-version=\"0.1.0\"",
+ "org.eclipse.emf.mwe2.launch;bundle-version=\"1.0.1\";resolution:=optional",
+ "org.eclipse.emf.mwe.utils;bundle-version=\"1.0.0\";visibility:=reexport",
+ "org.apache.log4j;bundle-version=\"1.2.15\"",
+ "org.apache.commons.logging;bundle-version=\"1.0.4\"",
+ "org.eclipse.jface.text;bundle-version=\"3.6.0\"",
+ "org.eclipse.jdt.core;bundle-version=\"3.6.0\"",
+ "org.eclipse.xtend.util.stdlib;bundle-version=\"1.0.0\"",
+ "org.eclipse.core.runtime;bundle-version=\"3.6.0\"",
+ "org.eclipse.xtext.generator;bundle-version=\"1.0.0\""
+ };
+
+ public static List<String> getCommonNatureIDs() {
+ return Arrays.asList(commonNatureIDs);
+ }
+ public static List<String> getCommonBuilderIDs() {
+ return Arrays.asList(commonBuilderIDs);
+ }
+
public static IProject createETriceProject(
IPath javaSource,
IPath javaSourceGen,
URI projectLocationURI,
IProject runtimeProject,
+ List<String> naturesToAdd,
+ List<String> buildersToAdd,
Monitor monitor
) {
IProgressMonitor progressMonitor = BasicMonitor
@@ -83,7 +99,7 @@ public class ProjectCreator {
List<IClasspathEntry> classpathEntries = new UniqueEList<IClasspathEntry>();
progressMonitor.beginTask("", 10);
- progressMonitor.subTask("Creating EMF project "
+ progressMonitor.subTask("Creating eTrice project "
+ projectName
+ " ("
+ (projectLocationURI != null ? projectLocationURI
@@ -123,7 +139,7 @@ public class ProjectCreator {
else {
projectDescription = project.getDescription();
project.open(new SubProgressMonitor(progressMonitor, 1));
- if (project.hasNature(JAVA_NATURE_ID)) {
+ if (project.hasNature(JavaCore.NATURE_ID)) {
classpathEntries.addAll(Arrays.asList(javaProject
.getRawClasspath()));
}
@@ -149,17 +165,10 @@ public class ProjectCreator {
{
String[] natureIds = projectDescription.getNatureIds();
if (natureIds == null) {
- natureIds = new String[] {
- JAVA_NATURE_ID,
- ORG_ECLIPSE_PDE_PLUGIN_NATURE,
- ORG_ECLIPSE_XTEXT_UI_SHARED_XTEXT_NATURE,
- ORG_ECLIPSE_XTEND_SHARED_UI_XTEND_X_PAND_NATURE};
+ natureIds = new String[0];
}
- else {
- natureIds = addNature(JAVA_NATURE_ID, natureIds, project);
- natureIds = addNature(ORG_ECLIPSE_PDE_PLUGIN_NATURE, natureIds, project);
- natureIds = addNature(ORG_ECLIPSE_XTEXT_UI_SHARED_XTEXT_NATURE, natureIds, project);
- natureIds = addNature(ORG_ECLIPSE_XTEND_SHARED_UI_XTEND_X_PAND_NATURE, natureIds, project);
+ for (String nature : naturesToAdd) {
+ natureIds = addNature(nature, natureIds, project);
}
projectDescription.setNatureIds(natureIds);
@@ -167,10 +176,9 @@ public class ProjectCreator {
if (builders == null) {
builders = new ICommand[0];
}
- builders = addBuilder("org.eclipse.pde.ManifestBuilder", builders, projectDescription);
- builders = addBuilder("org.eclipse.pde.SchemaBuilder", builders, projectDescription);
- builders = addBuilder("org.eclipse.xtext.ui.shared.xtextBuilder", builders, projectDescription);
- builders = addBuilder("org.eclipse.xtend.shared.ui.xtendBuilder", builders, projectDescription);
+ for (String builder : buildersToAdd) {
+ builders = addBuilder(builder, builders, projectDescription);
+ }
projectDescription.setBuildSpec(builders);
project.setDescription(projectDescription,
@@ -276,20 +284,20 @@ public class ProjectCreator {
}
/**
- * @param javaNatureId
+ * @param natureId
* @param natureIds
* @param project
* @return
* @throws CoreException
*/
- private static String[] addNature(String javaNatureId, String[] natureIds,
+ private static String[] addNature(String natureId, String[] natureIds,
IProject project) throws CoreException {
- if (!project.hasNature(javaNatureId)) {
+ if (!project.hasNature(natureId)) {
String[] oldNatureIds = natureIds;
natureIds = new String[oldNatureIds.length + 1];
System.arraycopy(oldNatureIds, 0, natureIds, 0,
oldNatureIds.length);
- natureIds[oldNatureIds.length] = javaNatureId;
+ natureIds[oldNatureIds.length] = natureId;
}
return natureIds;
}
@@ -397,7 +405,7 @@ public class ProjectCreator {
}
}
- public static void createWorkflow(URI uri, String name) {
+ public static void createWorkflow(URI uri, String name, String generatorName) {
try {
PrintStream workflow = new PrintStream(
URIConverter.INSTANCE.createOutputStream(uri, null),
@@ -417,7 +425,7 @@ public class ProjectCreator {
workflow.println(" directory = destDir");
workflow.println(" }");
workflow.println("");
- workflow.println(" component = @RoomGenerator {");
+ workflow.println(" component = @"+generatorName+" {");
workflow.println(" sourceDir = \"model\"");
workflow.println(" targetDir = destDir");
workflow.println(" }");
@@ -430,7 +438,7 @@ public class ProjectCreator {
}
}
- public static void createManifest(URI uri, String baseName) {
+ public static void createManifest(URI uri, String baseName, List<String> requiredBundles) {
try {
PrintStream manifest = new PrintStream(
URIConverter.INSTANCE.createOutputStream(uri, null),
@@ -441,10 +449,13 @@ public class ProjectCreator {
manifest.println("Bundle-Name: "+baseName);
manifest.println("Bundle-SymbolicName: "+CodeGenUtil.validPluginID(baseName));
manifest.println("Bundle-Version: 0.1.0");
- manifest.print("Require-Bundle:");
- for (int i = 0; i < requiredBundles.length; i++) {
- String sep = (i<requiredBundles.length-1)? ",":"";
- manifest.println(" "+requiredBundles[i]+sep);
+ Iterator<String> it = requiredBundles.iterator();
+ if (it.hasNext()) {
+ manifest.print("Require-Bundle:");
+ manifest.print(" "+it.next());
+ while (it.hasNext()) {
+ manifest.println(",\n "+it.next());
+ }
}
manifest.println("Bundle-RequiredExecutionEnvironment: JavaSE-1.6");
manifest.close();
@@ -455,6 +466,10 @@ public class ProjectCreator {
}
}
+ public static List<String> getCommonRequiredBundles() {
+ return Arrays.asList(commonRequiredBundles);
+ }
+
public static void createModel(URI uri, String baseName) {
try {
PrintStream model = new PrintStream(