Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.e4.tools/.classpath7
-rw-r--r--bundles/org.eclipse.e4.tools/.jetproperties4
-rw-r--r--bundles/org.eclipse.e4.tools/.project34
-rw-r--r--bundles/org.eclipse.e4.tools/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--bundles/org.eclipse.e4.tools/META-INF/MANIFEST.MF25
-rw-r--r--bundles/org.eclipse.e4.tools/build.properties5
-rw-r--r--bundles/org.eclipse.e4.tools/icons/full/obj16/Part.gifbin0 -> 342 bytes
-rw-r--r--bundles/org.eclipse.e4.tools/icons/full/obj16/application_view_tile.pngbin0 -> 465 bytes
-rw-r--r--bundles/org.eclipse.e4.tools/icons/full/obj16/class_obj.gifbin0 -> 586 bytes
-rw-r--r--bundles/org.eclipse.e4.tools/icons/full/obj16/plugin.pngbin0 -> 591 bytes
-rw-r--r--bundles/org.eclipse.e4.tools/icons/full/wizban/newclass_wiz.pngbin0 -> 7824 bytes
-rw-r--r--bundles/org.eclipse.e4.tools/org/eclipse/e4/tools/emf/editor3x/templates/HandlerTemplate.java50
-rw-r--r--bundles/org.eclipse.e4.tools/org/eclipse/e4/tools/emf/editor3x/templates/PartTemplate.java89
-rw-r--r--bundles/org.eclipse.e4.tools/org/eclipse/e4/tools/internal/classes/templates/HandlerTemplate.java50
-rw-r--r--bundles/org.eclipse.e4.tools/org/eclipse/e4/tools/internal/classes/templates/PartTemplate.java89
-rw-r--r--bundles/org.eclipse.e4.tools/plugin.xml58
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/ToolsPlugin.java117
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassPage.java376
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassWizard.java144
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewHandlerClassWizard.java133
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewPartClassWizard.java255
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/templates/HandlerTemplate.java50
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/templates/PartTemplate.java89
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/BaseApplicationModelWizard.java187
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewApplicationModelWizard.java27
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewContributionModelWizard.java27
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewModelFilePage.java199
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/E4NewProjectWizard.java606
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/E4NewProjectWizardPage.java31
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/NewApplicationWizardPage.java417
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/PluginContentPage.java363
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/ResourceLocator.java52
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/TemplateOperation.java401
-rw-r--r--bundles/org.eclipse.e4.tools/templates/common/$projectName$.product79
-rw-r--r--bundles/org.eclipse.e4.tools/templates/common/icons/sample.gifbin0 -> 983 bytes
-rw-r--r--bundles/org.eclipse.e4.tools/templates/common/icons/save_edit.gifbin0 -> 639 bytes
-rw-r--r--bundles/org.eclipse.e4.tools/templates/css/default.css0
-rw-r--r--bundles/org.eclipse.e4.tools/templates/handler.txtjet22
-rw-r--r--bundles/org.eclipse.e4.tools/templates/part.txtjet48
-rw-r--r--bundles/org.eclipse.e4.tools/templates/src/handlers/AboutHandler.java25
-rw-r--r--bundles/org.eclipse.e4.tools/templates/src/handlers/OpenHandler.java33
-rw-r--r--bundles/org.eclipse.e4.tools/templates/src/handlers/QuitHandler.java34
-rw-r--r--bundles/org.eclipse.e4.tools/templates/src/handlers/SaveHandler.java67
43 files changed, 4201 insertions, 0 deletions
diff --git a/bundles/org.eclipse.e4.tools/.classpath b/bundles/org.eclipse.e4.tools/.classpath
new file mode 100644
index 00000000..64c5e31b
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.eclipse.e4.tools/.jetproperties b/bundles/org.eclipse.e4.tools/.jetproperties
new file mode 100644
index 00000000..2907c83a
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/.jetproperties
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<jet-settings>
+ <template-container>templates</template-container> <source-container>src</source-container>
+</jet-settings>
diff --git a/bundles/org.eclipse.e4.tools/.project b/bundles/org.eclipse.e4.tools/.project
new file mode 100644
index 00000000..62db1d2d
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.e4.tools</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.emf.codegen.JETBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.emf.codegen.jet.IJETNature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/bundles/org.eclipse.e4.tools/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.e4.tools/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..25961444
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Mon Jul 05 10:09:17 CEST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/bundles/org.eclipse.e4.tools/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.tools/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..756afee3
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/META-INF/MANIFEST.MF
@@ -0,0 +1,25 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Tools
+Bundle-SymbolicName: org.eclipse.e4.tools;singleton:=true
+Bundle-Version: 0.9.0.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.eclipse.ui;bundle-version="3.6.0",
+ org.eclipse.pde.core;bundle-version="3.6.0",
+ org.eclipse.pde.ui;bundle-version="3.6.0",
+ org.eclipse.core.runtime;bundle-version="3.6.0",
+ org.eclipse.e4.ui.model.workbench;bundle-version="0.9.1",
+ org.eclipse.core.resources;bundle-version="3.6.0",
+ org.eclipse.jdt.core;bundle-version="3.6.0",
+ org.eclipse.jdt.launching;bundle-version="3.5.100",
+ org.eclipse.ui.ide;bundle-version="3.6.0",
+ org.eclipse.core.databinding;bundle-version="1.3.100",
+ org.eclipse.core.databinding.beans;bundle-version="1.2.100",
+ org.eclipse.jface.databinding;bundle-version="1.4.0",
+ org.eclipse.core.databinding.property;bundle-version="1.3.0",
+ org.eclipse.jdt.ui;bundle-version="3.6.0"
+Bundle-ActivationPolicy: lazy
+Bundle-Activator: org.eclipse.e4.internal.tools.ToolsPlugin
+Export-Package: org.eclipse.e4.internal.tools.wizards.classes;x-internal:=true,
+ org.eclipse.e4.internal.tools.wizards.model;x-internal:=true,
+ org.eclipse.e4.internal.tools.wizards.project;x-internal:=true
diff --git a/bundles/org.eclipse.e4.tools/build.properties b/bundles/org.eclipse.e4.tools/build.properties
new file mode 100644
index 00000000..e9863e28
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/bundles/org.eclipse.e4.tools/icons/full/obj16/Part.gif b/bundles/org.eclipse.e4.tools/icons/full/obj16/Part.gif
new file mode 100644
index 00000000..610f5844
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/icons/full/obj16/Part.gif
Binary files differ
diff --git a/bundles/org.eclipse.e4.tools/icons/full/obj16/application_view_tile.png b/bundles/org.eclipse.e4.tools/icons/full/obj16/application_view_tile.png
new file mode 100644
index 00000000..3bc0bd32
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/icons/full/obj16/application_view_tile.png
Binary files differ
diff --git a/bundles/org.eclipse.e4.tools/icons/full/obj16/class_obj.gif b/bundles/org.eclipse.e4.tools/icons/full/obj16/class_obj.gif
new file mode 100644
index 00000000..e4c2a836
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/icons/full/obj16/class_obj.gif
Binary files differ
diff --git a/bundles/org.eclipse.e4.tools/icons/full/obj16/plugin.png b/bundles/org.eclipse.e4.tools/icons/full/obj16/plugin.png
new file mode 100644
index 00000000..6187b15a
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/icons/full/obj16/plugin.png
Binary files differ
diff --git a/bundles/org.eclipse.e4.tools/icons/full/wizban/newclass_wiz.png b/bundles/org.eclipse.e4.tools/icons/full/wizban/newclass_wiz.png
new file mode 100644
index 00000000..cc123864
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/icons/full/wizban/newclass_wiz.png
Binary files differ
diff --git a/bundles/org.eclipse.e4.tools/org/eclipse/e4/tools/emf/editor3x/templates/HandlerTemplate.java b/bundles/org.eclipse.e4.tools/org/eclipse/e4/tools/emf/editor3x/templates/HandlerTemplate.java
new file mode 100644
index 00000000..e969a093
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/org/eclipse/e4/tools/emf/editor3x/templates/HandlerTemplate.java
@@ -0,0 +1,50 @@
+package org.eclipse.e4.tools.emf.editor3x.templates;
+
+import org.eclipse.e4.tools.emf.editor3x.wizard.NewHandlerClassWizard.HandlerClass;
+
+public class HandlerTemplate
+{
+ protected static String nl;
+ public static synchronized HandlerTemplate create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ HandlerTemplate result = new HandlerTemplate();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = " " + NL + "package ";
+ protected final String TEXT_2 = ";" + NL + "" + NL + "import org.eclipse.e4.core.di.annotations.Execute;";
+ protected final String TEXT_3 = NL + "import org.eclipse.e4.core.di.annotations.CanExecute;";
+ protected final String TEXT_4 = NL + NL + "public class ";
+ protected final String TEXT_5 = " {" + NL + "\t@Execute" + NL + "\tpublic void ";
+ protected final String TEXT_6 = "() {" + NL + "\t\t//TODO Your code goes here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_7 = NL + "\t" + NL + "\t@CanExecute" + NL + "\tpublic boolean ";
+ protected final String TEXT_8 = "() {" + NL + "\t\t//TODO Your code goes here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_9 = "\t" + NL + "}";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+ HandlerClass domainClass = (HandlerClass)argument;
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( domainClass.getPackageFragment().getElementName() );
+ stringBuffer.append(TEXT_2);
+ if( domainClass.isUseCanExecute() ) {
+ stringBuffer.append(TEXT_3);
+ }
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append( domainClass.getName() );
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append( domainClass.getExecuteMethodName() );
+ stringBuffer.append(TEXT_6);
+ if( domainClass.isUseCanExecute() ) {
+ stringBuffer.append(TEXT_7);
+ stringBuffer.append( domainClass.getCanExecuteMethodName() );
+ stringBuffer.append(TEXT_8);
+ }
+ stringBuffer.append(TEXT_9);
+ return stringBuffer.toString();
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/org/eclipse/e4/tools/emf/editor3x/templates/PartTemplate.java b/bundles/org.eclipse.e4.tools/org/eclipse/e4/tools/emf/editor3x/templates/PartTemplate.java
new file mode 100644
index 00000000..3bcf8475
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/org/eclipse/e4/tools/emf/editor3x/templates/PartTemplate.java
@@ -0,0 +1,89 @@
+package org.eclipse.e4.tools.emf.editor3x.templates;
+
+import org.eclipse.e4.tools.emf.editor3x.wizard.NewPartClassWizard.PartClass;
+
+public class PartTemplate
+{
+ protected static String nl;
+ public static synchronized PartTemplate create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ PartTemplate result = new PartTemplate();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = " " + NL + "package ";
+ protected final String TEXT_2 = ";" + NL + "" + NL + "import javax.inject.Inject;";
+ protected final String TEXT_3 = NL + "import javax.annotation.PostConstruct;";
+ protected final String TEXT_4 = NL + "import javax.annotation.PreDestroy;";
+ protected final String TEXT_5 = NL + "import org.eclipse.e4.ui.di.Focus;";
+ protected final String TEXT_6 = NL + "import org.eclipse.e4.ui.di.Persist;";
+ protected final String TEXT_7 = NL + NL + "public class ";
+ protected final String TEXT_8 = " {" + NL + "\t@Inject" + NL + "\tpublic ";
+ protected final String TEXT_9 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_10 = NL + "\t@PostConstruct" + NL + "\tpublic void ";
+ protected final String TEXT_11 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_12 = NL + "\t";
+ protected final String TEXT_13 = NL + "\t@PreDestroy" + NL + "\tpublic void ";
+ protected final String TEXT_14 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_15 = NL + "\t";
+ protected final String TEXT_16 = NL + "\t@Focus" + NL + "\tpublic void ";
+ protected final String TEXT_17 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_18 = NL + "\t";
+ protected final String TEXT_19 = NL + "\t@Persist" + NL + "\tpublic void ";
+ protected final String TEXT_20 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_21 = NL + "}";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+ PartClass domainClass = (PartClass)argument;
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( domainClass.getPackageFragment().getElementName() );
+ stringBuffer.append(TEXT_2);
+ if( domainClass.isUsePostConstruct() ) {
+ stringBuffer.append(TEXT_3);
+ }
+ if( domainClass.isUsePredestroy() ) {
+ stringBuffer.append(TEXT_4);
+ }
+ if( domainClass.isUseFocus() ) {
+ stringBuffer.append(TEXT_5);
+ }
+ if( domainClass.isUsePersist() ) {
+ stringBuffer.append(TEXT_6);
+ }
+ stringBuffer.append(TEXT_7);
+ stringBuffer.append( domainClass.getName() );
+ stringBuffer.append(TEXT_8);
+ stringBuffer.append( domainClass.getName() );
+ stringBuffer.append(TEXT_9);
+ if( domainClass.isUsePostConstruct() ) {
+ stringBuffer.append(TEXT_10);
+ stringBuffer.append( domainClass.getPostConstructMethodName() );
+ stringBuffer.append(TEXT_11);
+ }
+ stringBuffer.append(TEXT_12);
+ if( domainClass.isUsePredestroy() ) {
+ stringBuffer.append(TEXT_13);
+ stringBuffer.append( domainClass.getPreDestroyMethodName() );
+ stringBuffer.append(TEXT_14);
+ }
+ stringBuffer.append(TEXT_15);
+ if( domainClass.isUseFocus() ) {
+ stringBuffer.append(TEXT_16);
+ stringBuffer.append( domainClass.getFocusMethodName() );
+ stringBuffer.append(TEXT_17);
+ }
+ stringBuffer.append(TEXT_18);
+ if( domainClass.isUsePersist() ) {
+ stringBuffer.append(TEXT_19);
+ stringBuffer.append( domainClass.getPersistMethodName() );
+ stringBuffer.append(TEXT_20);
+ }
+ stringBuffer.append(TEXT_21);
+ return stringBuffer.toString();
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/org/eclipse/e4/tools/internal/classes/templates/HandlerTemplate.java b/bundles/org.eclipse.e4.tools/org/eclipse/e4/tools/internal/classes/templates/HandlerTemplate.java
new file mode 100644
index 00000000..711cdd74
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/org/eclipse/e4/tools/internal/classes/templates/HandlerTemplate.java
@@ -0,0 +1,50 @@
+package org.eclipse.e4.tools.internal.classes.templates;
+
+import org.eclipse.e4.tools.internal.classes.NewHandlerClassWizard.HandlerClass;
+
+public class HandlerTemplate
+{
+ protected static String nl;
+ public static synchronized HandlerTemplate create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ HandlerTemplate result = new HandlerTemplate();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = " " + NL + "package ";
+ protected final String TEXT_2 = ";" + NL + "" + NL + "import org.eclipse.e4.core.di.annotations.Execute;";
+ protected final String TEXT_3 = NL + "import org.eclipse.e4.core.di.annotations.CanExecute;";
+ protected final String TEXT_4 = NL + NL + "public class ";
+ protected final String TEXT_5 = " {" + NL + "\t@Execute" + NL + "\tpublic void ";
+ protected final String TEXT_6 = "() {" + NL + "\t\t//TODO Your code goes here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_7 = NL + "\t" + NL + "\t@CanExecute" + NL + "\tpublic boolean ";
+ protected final String TEXT_8 = "() {" + NL + "\t\t//TODO Your code goes here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_9 = "\t" + NL + "}";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+ HandlerClass domainClass = (HandlerClass)argument;
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( domainClass.getPackageFragment().getElementName() );
+ stringBuffer.append(TEXT_2);
+ if( domainClass.isUseCanExecute() ) {
+ stringBuffer.append(TEXT_3);
+ }
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append( domainClass.getName() );
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append( domainClass.getExecuteMethodName() );
+ stringBuffer.append(TEXT_6);
+ if( domainClass.isUseCanExecute() ) {
+ stringBuffer.append(TEXT_7);
+ stringBuffer.append( domainClass.getCanExecuteMethodName() );
+ stringBuffer.append(TEXT_8);
+ }
+ stringBuffer.append(TEXT_9);
+ return stringBuffer.toString();
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/org/eclipse/e4/tools/internal/classes/templates/PartTemplate.java b/bundles/org.eclipse.e4.tools/org/eclipse/e4/tools/internal/classes/templates/PartTemplate.java
new file mode 100644
index 00000000..d10a2681
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/org/eclipse/e4/tools/internal/classes/templates/PartTemplate.java
@@ -0,0 +1,89 @@
+package org.eclipse.e4.tools.internal.classes.templates;
+
+import org.eclipse.e4.tools.internal.classes.NewPartClassWizard.PartClass;
+
+public class PartTemplate
+{
+ protected static String nl;
+ public static synchronized PartTemplate create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ PartTemplate result = new PartTemplate();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = " " + NL + "package ";
+ protected final String TEXT_2 = ";" + NL + "" + NL + "import javax.inject.Inject;";
+ protected final String TEXT_3 = NL + "import javax.annotation.PostConstruct;";
+ protected final String TEXT_4 = NL + "import javax.annotation.PreDestroy;";
+ protected final String TEXT_5 = NL + "import org.eclipse.e4.ui.di.Focus;";
+ protected final String TEXT_6 = NL + "import org.eclipse.e4.ui.di.Persist;";
+ protected final String TEXT_7 = NL + NL + "public class ";
+ protected final String TEXT_8 = " {" + NL + "\t@Inject" + NL + "\tpublic ";
+ protected final String TEXT_9 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_10 = NL + "\t@PostConstruct" + NL + "\tpublic void ";
+ protected final String TEXT_11 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_12 = NL + "\t";
+ protected final String TEXT_13 = NL + "\t@PreDestroy" + NL + "\tpublic void ";
+ protected final String TEXT_14 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_15 = NL + "\t";
+ protected final String TEXT_16 = NL + "\t@Focus" + NL + "\tpublic void ";
+ protected final String TEXT_17 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_18 = NL + "\t";
+ protected final String TEXT_19 = NL + "\t@Persist" + NL + "\tpublic void ";
+ protected final String TEXT_20 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_21 = NL + "}";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+ PartClass domainClass = (PartClass)argument;
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( domainClass.getPackageFragment().getElementName() );
+ stringBuffer.append(TEXT_2);
+ if( domainClass.isUsePostConstruct() ) {
+ stringBuffer.append(TEXT_3);
+ }
+ if( domainClass.isUsePredestroy() ) {
+ stringBuffer.append(TEXT_4);
+ }
+ if( domainClass.isUseFocus() ) {
+ stringBuffer.append(TEXT_5);
+ }
+ if( domainClass.isUsePersist() ) {
+ stringBuffer.append(TEXT_6);
+ }
+ stringBuffer.append(TEXT_7);
+ stringBuffer.append( domainClass.getName() );
+ stringBuffer.append(TEXT_8);
+ stringBuffer.append( domainClass.getName() );
+ stringBuffer.append(TEXT_9);
+ if( domainClass.isUsePostConstruct() ) {
+ stringBuffer.append(TEXT_10);
+ stringBuffer.append( domainClass.getPostConstructMethodName() );
+ stringBuffer.append(TEXT_11);
+ }
+ stringBuffer.append(TEXT_12);
+ if( domainClass.isUsePredestroy() ) {
+ stringBuffer.append(TEXT_13);
+ stringBuffer.append( domainClass.getPreDestroyMethodName() );
+ stringBuffer.append(TEXT_14);
+ }
+ stringBuffer.append(TEXT_15);
+ if( domainClass.isUseFocus() ) {
+ stringBuffer.append(TEXT_16);
+ stringBuffer.append( domainClass.getFocusMethodName() );
+ stringBuffer.append(TEXT_17);
+ }
+ stringBuffer.append(TEXT_18);
+ if( domainClass.isUsePersist() ) {
+ stringBuffer.append(TEXT_19);
+ stringBuffer.append( domainClass.getPersistMethodName() );
+ stringBuffer.append(TEXT_20);
+ }
+ stringBuffer.append(TEXT_21);
+ return stringBuffer.toString();
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/plugin.xml b/bundles/org.eclipse.e4.tools/plugin.xml
new file mode 100644
index 00000000..56fd224e
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/plugin.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <category
+ id="org.eclipse.e4.tools"
+ name="e4">
+ </category>
+ <category
+ id="org.eclipse.e4.tools.classes"
+ name="Classes"
+ parentCategory="org.eclipse.e4.tools">
+ </category>
+ <category
+ id="org.eclipse.e4.tools.model"
+ name="Model"
+ parentCategory="org.eclipse.e4.tools">
+ </category>
+ <wizard
+ category="org.eclipse.e4.tools"
+ class="org.eclipse.e4.internal.tools.wizards.project.E4NewProjectWizard"
+ icon="platform:/plugin/org.eclipse.pde.ui/icons/etool16/newpprj_wiz.gif"
+ id="org.eclipse.e4.tools.E4NewProjectWizard"
+ name="e4 Application Project"
+ project="true">
+ </wizard>
+ <wizard
+ category="org.eclipse.e4.tools/org.eclipse.e4.tools.model"
+ class="org.eclipse.e4.internal.tools.wizards.model.NewApplicationModelWizard"
+ icon="icons/full/obj16/application_view_tile.png"
+ id="org.eclipse.e4.tools.newappmodel"
+ name="New Application Model">
+ </wizard>
+ <wizard
+ category="org.eclipse.e4.tools/org.eclipse.e4.tools.model"
+ class="org.eclipse.e4.internal.tools.wizards.model.NewContributionModelWizard"
+ icon="icons/full/obj16/plugin.png"
+ id="org.eclipse.e4.tools.newmodelfragment"
+ name="New Model Fragment">
+ </wizard>
+ <wizard
+ category="org.eclipse.e4.tools/org.eclipse.e4.tools.classes"
+ class="org.eclipse.e4.internal.tools.wizards.classes.NewHandlerClassWizard"
+ icon="icons/full/obj16/class_obj.gif"
+ id="org.eclipse.e4.tools.newhandler"
+ name="New Handler Class">
+ </wizard>
+ <wizard
+ category="org.eclipse.e4.tools/org.eclipse.e4.tools.classes"
+ class="org.eclipse.e4.internal.tools.wizards.classes.NewPartClassWizard"
+ icon="icons/full/obj16/Part.gif"
+ id="org.eclipse.e4.tools.newpart"
+ name="New Part Class">
+ </wizard>
+ </extension>
+
+</plugin>
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/ToolsPlugin.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/ToolsPlugin.java
new file mode 100644
index 00000000..9f80ed6b
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/ToolsPlugin.java
@@ -0,0 +1,117 @@
+package org.eclipse.e4.internal.tools;
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.ResourceLocator;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class ToolsPlugin extends AbstractUIPlugin {
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.e4.tools"; //$NON-NLS-1$
+
+ private static ToolsPlugin plugin;
+
+ private ResourceLocator resourceLocator;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
+ * )
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
+ * )
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ToolsPlugin getDefault() {
+ return plugin;
+ }
+
+ public ResourceLocator getResourceLocator() {
+ if (resourceLocator == null) {
+ resourceLocator = new ResourceLocator() {
+
+ public String getString(String key, Object[] substitutions,
+ boolean translate) {
+ return null;
+ }
+
+ public String getString(String key, Object[] substitutions) {
+ return null;
+ }
+
+ public String getString(String key, boolean translate) {
+ return null;
+ }
+
+ public String getString(String key) {
+ return null;
+ }
+
+ public Object getImage(String key) {
+ return null;
+ }
+
+ public URL getBaseURL() {
+ return null;
+ }
+ };
+ }
+ return resourceLocator;
+ }
+
+ public static void log(IStatus status, int nesting, boolean appendLogger) {
+ getDefault().getLog().log(status);
+ }
+
+ /**
+ * Log Throwable Error
+ */
+ public static void logError(Throwable t) {
+ logError(t, 0, true);
+ }
+
+ public static void logError(Throwable t, boolean appendLogger) {
+ logError(t, 0, appendLogger);
+ }
+
+ public static void logError(Throwable t, int nesting) {
+ logError(t, nesting, true);
+ }
+
+ public static void logError(Throwable t, int nesting, boolean appendLogger) {
+ log(newStatus(IStatus.ERROR, t.getMessage(), t), nesting, appendLogger);
+ }
+
+ /**
+ * Create an IStatus
+ *
+ * @return a new IStatus
+ */
+ public static IStatus newStatus(int severity, String message,
+ Throwable exception) {
+ return new Status(severity, PLUGIN_ID, 0, message, exception);
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassPage.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassPage.java
new file mode 100644
index 00000000..2452e1f9
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassPage.java
@@ -0,0 +1,376 @@
+/*******************************************************************************
+ * Copyright (c) 2010 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.e4.internal.tools.wizards.classes;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+import org.eclipse.core.databinding.Binding;
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.UpdateValueStrategy;
+import org.eclipse.core.databinding.beans.BeanProperties;
+import org.eclipse.core.databinding.conversion.Converter;
+import org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaModel;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
+import org.eclipse.jdt.internal.ui.wizards.TypedElementSelectionValidator;
+import org.eclipse.jdt.internal.ui.wizards.TypedViewerFilter;
+import org.eclipse.jdt.ui.JavaElementComparator;
+import org.eclipse.jdt.ui.JavaElementLabelProvider;
+import org.eclipse.jdt.ui.StandardJavaElementContentProvider;
+import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.jface.databinding.wizard.WizardPageSupport;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+
+public abstract class AbstractNewClassPage extends WizardPage {
+ public static class JavaClass {
+ protected PropertyChangeSupport support = new PropertyChangeSupport(this);
+
+ private IPackageFragmentRoot fragmentRoot;
+ private IPackageFragment packageFragment;
+ private String name;
+
+ public JavaClass(IPackageFragmentRoot fragmentRoot) {
+ this.fragmentRoot = fragmentRoot;
+ }
+
+ public IPackageFragmentRoot getFragmentRoot() {
+ return fragmentRoot;
+ }
+
+ public void setFragmentRoot(IPackageFragmentRoot fragmentRoot) {
+ support.firePropertyChange("fragementRoot", this.fragmentRoot, this.fragmentRoot = fragmentRoot);
+ }
+
+ public IPackageFragment getPackageFragment() {
+ return packageFragment;
+ }
+
+ public void setPackageFragment(IPackageFragment packageFragment) {
+ support.firePropertyChange("packageFragment", this.packageFragment, this.packageFragment = packageFragment);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ support.firePropertyChange("name", this.name, this.name = name);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ support.addPropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ support.removePropertyChangeListener(listener);
+ }
+ }
+
+ private JavaClass clazz;
+ private IPackageFragmentRoot froot;
+ private IWorkspaceRoot fWorkspaceRoot;
+
+ protected AbstractNewClassPage(String pageName, String title, String description, IPackageFragmentRoot froot, IWorkspaceRoot fWorkspaceRoot) {
+ super(pageName);
+ this.froot = froot;
+ this.fWorkspaceRoot = fWorkspaceRoot;
+
+ setTitle(title);
+ setDescription(description);
+ }
+
+ public void createControl(Composite parent) {
+ final Image img = new Image(parent.getDisplay(), getClass().getClassLoader().getResourceAsStream("/icons/full/wizban/newclass_wiz.png"));
+ setImageDescriptor(ImageDescriptor.createFromImage(img));
+
+ parent.addDisposeListener(new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent e) {
+ img.dispose();
+ setImageDescriptor(null);
+ }
+ });
+
+ parent = new Composite(parent, SWT.NULL);
+ parent.setLayoutData(new GridData(GridData.FILL_BOTH));
+ parent.setLayout(new GridLayout(3, false));
+
+ clazz = createInstance();
+
+ DataBindingContext dbc = new DataBindingContext();
+ WizardPageSupport.create(this, dbc);
+
+ {
+ Label l = new Label(parent, SWT.NONE);
+ l.setText("Source folder");
+ l.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
+
+ Text t = new Text(parent, SWT.BORDER);
+ t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ t.setEditable(false);
+ final Binding bd = dbc.bindValue(
+ WidgetProperties.text().observe(t),
+ BeanProperties.value("fragmentRoot").observe(clazz),
+ new UpdateValueStrategy(),
+ new UpdateValueStrategy().setConverter(new PackageFragmentRootToStringConverter())
+ );
+
+ Button b = new Button(parent, SWT.PUSH);
+ b.setText("Browse ...");
+ b.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ IPackageFragmentRoot root = choosePackageRoot();
+ if( root != null ) {
+ clazz.setFragmentRoot(root);
+ }
+ bd.updateModelToTarget(); //TODO Find out why this is needed
+ }
+ });
+ }
+
+ {
+ Label l = new Label(parent, SWT.NONE);
+ l.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
+ l.setText("Package");
+
+ Text t = new Text(parent, SWT.BORDER);
+ t.setEditable(false);
+ t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ final Binding bd = dbc.bindValue(
+ WidgetProperties.text().observe(t),
+ BeanProperties.value("packageFragment").observe(clazz),
+ new UpdateValueStrategy(),
+ new UpdateValueStrategy().setConverter(new PackageFragmentToStringConverter())
+ );
+
+ Button b = new Button(parent, SWT.PUSH);
+ b.setText("Browse ...");
+ b.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ IPackageFragment fragment = choosePackage();
+ if( fragment != null ) {
+ clazz.setPackageFragment(fragment);
+ }
+ bd.updateModelToTarget(); //TODO Find out why this is needed
+ }
+ });
+ }
+
+ {
+ Label l = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
+ l.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false, 3, 1));
+ }
+
+ {
+ IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
+
+ Label l = new Label(parent, SWT.NONE);
+ l.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
+ l.setText("Name");
+
+ Text t = new Text(parent, SWT.BORDER);
+ t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ dbc.bindValue(textProp.observe(t), BeanProperties.value("name", String.class).observe(clazz));
+
+ new Label(parent, SWT.NONE);
+ }
+
+ {
+ Label l = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
+ l.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false, 3, 1));
+ }
+
+ createFields(parent, dbc);
+ setControl(parent);
+ }
+
+ private IPackageFragmentRoot choosePackageRoot() {
+ IJavaElement initElement= clazz.getFragmentRoot();
+ Class[] acceptedClasses= new Class[] { IPackageFragmentRoot.class, IJavaProject.class };
+ TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, false) {
+ public boolean isSelectedValid(Object element) {
+ try {
+ if (element instanceof IJavaProject) {
+ IJavaProject jproject= (IJavaProject)element;
+ IPath path= jproject.getProject().getFullPath();
+ return (jproject.findPackageFragmentRoot(path) != null);
+ } else if (element instanceof IPackageFragmentRoot) {
+ return (((IPackageFragmentRoot)element).getKind() == IPackageFragmentRoot.K_SOURCE);
+ }
+ return true;
+ } catch (JavaModelException e) {
+ JavaPlugin.log(e.getStatus()); // just log, no UI in validation
+ }
+ return false;
+ }
+ };
+
+ acceptedClasses= new Class[] { IJavaModel.class, IPackageFragmentRoot.class, IJavaProject.class };
+ ViewerFilter filter= new TypedViewerFilter(acceptedClasses) {
+ public boolean select(Viewer viewer, Object parent, Object element) {
+ if (element instanceof IPackageFragmentRoot) {
+ try {
+ return (((IPackageFragmentRoot)element).getKind() == IPackageFragmentRoot.K_SOURCE);
+ } catch (JavaModelException e) {
+ JavaPlugin.log(e.getStatus()); // just log, no UI in validation
+ return false;
+ }
+ }
+ return super.select(viewer, parent, element);
+ }
+ };
+
+ StandardJavaElementContentProvider provider= new StandardJavaElementContentProvider();
+ ILabelProvider labelProvider= new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT);
+ ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), labelProvider, provider);
+ dialog.setValidator(validator);
+ dialog.setComparator(new JavaElementComparator());
+ dialog.setTitle(NewWizardMessages.NewContainerWizardPage_ChooseSourceContainerDialog_title);
+ dialog.setMessage(NewWizardMessages.NewContainerWizardPage_ChooseSourceContainerDialog_description);
+ dialog.addFilter(filter);
+ dialog.setInput(JavaCore.create(fWorkspaceRoot));
+ dialog.setInitialSelection(initElement);
+ dialog.setHelpAvailable(false);
+
+ if (dialog.open() == Window.OK) {
+ Object element= dialog.getFirstResult();
+ if (element instanceof IJavaProject) {
+ IJavaProject jproject= (IJavaProject)element;
+ return jproject.getPackageFragmentRoot(jproject.getProject());
+ } else if (element instanceof IPackageFragmentRoot) {
+ return (IPackageFragmentRoot)element;
+ }
+ return null;
+ }
+ return null;
+ }
+
+ private IPackageFragment choosePackage() {
+ IJavaElement[] packages= null;
+ try {
+ if (froot != null && froot.exists()) {
+ packages= froot.getChildren();
+ }
+ } catch (JavaModelException e) {
+ e.printStackTrace();
+ }
+ if (packages == null) {
+ packages= new IJavaElement[0];
+ }
+
+ ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT));
+ dialog.setIgnoreCase(false);
+ dialog.setTitle("Choose Package");
+ dialog.setMessage("Choose a Package");
+ dialog.setEmptyListMessage("You need to select a package");
+ dialog.setElements(packages);
+ dialog.setHelpAvailable(false);
+
+ IPackageFragment pack= clazz.getPackageFragment();
+ if (pack != null) {
+ dialog.setInitialSelections(new Object[] { pack });
+ }
+
+ if (dialog.open() == Window.OK) {
+ return (IPackageFragment) dialog.getFirstResult();
+ }
+ return null;
+ }
+
+ protected abstract void createFields(Composite parent, DataBindingContext dbc);
+
+ protected abstract JavaClass createInstance();
+
+ public JavaClass getClazz() {
+ return clazz;
+ }
+
+ static class ClassnameValidator implements IValidator {
+
+ public IStatus validate(Object value) {
+ String name = value.toString();
+ char[] ar = name.toCharArray();
+ for (char c : ar) {
+ if (!Character.isJavaIdentifierPart(c)) {
+ return new Status(IStatus.ERROR, "", "'" + c + "' is not allowed in a Class-Name");
+ }
+ }
+
+ if (!Character.isJavaIdentifierStart(ar[0])) {
+ return new Status(IStatus.ERROR, "", "'" + ar[0] + "' is not allowed as the first character of a Class-Name");
+ }
+
+ return Status.OK_STATUS;
+ }
+ }
+
+ static class PackageFragmentRootToStringConverter extends Converter {
+
+ public PackageFragmentRootToStringConverter() {
+ super(IPackageFragmentRoot.class, String.class);
+ }
+
+ public Object convert(Object fromObject) {
+ IPackageFragmentRoot f = (IPackageFragmentRoot) fromObject;
+ return f.getPath().makeRelative().toString();
+ }
+ }
+
+ static class PackageFragmentToStringConverter extends Converter {
+
+ public PackageFragmentToStringConverter() {
+ super(IPackageFragment.class, String.class);
+ }
+
+ public Object convert(Object fromObject) {
+ System.err.println(" =======================> Converting: " + fromObject);
+ if( fromObject == null ) {
+ return "";
+ }
+ IPackageFragment f = (IPackageFragment) fromObject;
+ return f.getElementName();
+ }
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassWizard.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassWizard.java
new file mode 100644
index 00000000..bb7178c1
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/AbstractNewClassWizard.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2010 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.e4.internal.tools.wizards.classes;
+
+import java.io.ByteArrayInputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.e4.internal.tools.wizards.classes.AbstractNewClassPage.JavaClass;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+public abstract class AbstractNewClassWizard extends Wizard implements INewWizard {
+ protected IPackageFragmentRoot root;
+ protected IFile file;
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ root = getFragmentRoot(getInitialJavaElement(selection));
+ System.err.println("Root: " + root);
+ }
+
+ protected IJavaElement getInitialJavaElement(IStructuredSelection selection) {
+ IJavaElement jelem = null;
+ if (selection != null && !selection.isEmpty()) {
+ Object selectedElement = selection.getFirstElement();
+ if (selectedElement instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable) selectedElement;
+
+ jelem = (IJavaElement) adaptable.getAdapter(IJavaElement.class);
+ if (jelem == null || !jelem.exists()) {
+ jelem = null;
+ IResource resource = (IResource) adaptable
+ .getAdapter(IResource.class);
+ if (resource != null
+ && resource.getType() != IResource.ROOT) {
+ while (jelem == null
+ && resource.getType() != IResource.PROJECT) {
+ resource = resource.getParent();
+ jelem = (IJavaElement) resource
+ .getAdapter(IJavaElement.class);
+ }
+ if (jelem == null) {
+ jelem = JavaCore.create(resource); // java project
+ }
+ }
+ }
+ }
+ }
+
+ return jelem;
+ }
+
+ protected IPackageFragmentRoot getFragmentRoot(IJavaElement elem) {
+ IPackageFragmentRoot initRoot = null;
+ if (elem != null) {
+ initRoot = (IPackageFragmentRoot) elem
+ .getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
+ try {
+ if (initRoot == null
+ || initRoot.getKind() != IPackageFragmentRoot.K_SOURCE) {
+ IJavaProject jproject = elem.getJavaProject();
+ if (jproject != null) {
+ initRoot = null;
+ if (jproject.exists()) {
+ IPackageFragmentRoot[] roots = jproject
+ .getPackageFragmentRoots();
+ for (int i = 0; i < roots.length; i++) {
+ if (roots[i].getKind() == IPackageFragmentRoot.K_SOURCE) {
+ initRoot = roots[i];
+ break;
+ }
+ }
+ }
+ if (initRoot == null) {
+ initRoot = jproject.getPackageFragmentRoot(jproject
+ .getResource());
+ }
+ }
+ }
+ } catch (JavaModelException e) {
+ // TODO
+ e.printStackTrace();
+ }
+ }
+ return initRoot;
+ }
+
+ protected abstract String getContent();
+
+ public JavaClass getDomainClass() {
+ return ((AbstractNewClassPage) getPages()[0]).getClazz();
+ }
+
+ @Override
+ public boolean performFinish() {
+ JavaClass clazz = getDomainClass();
+ String content = getContent();
+
+ IPackageFragment fragment = clazz.getPackageFragment();
+ if (fragment != null) {
+ String cuName = clazz.getName() + ".java";
+ IResource resource = fragment.getCompilationUnit(cuName)
+ .getResource();
+ file = (IFile) resource;
+ try {
+ if (!file.exists()) {
+ file.create(new ByteArrayInputStream(content.getBytes()),
+ true, null);
+ } else {
+ file.setContents(new ByteArrayInputStream(content.getBytes()),
+ IFile.FORCE | IFile.KEEP_HISTORY, null);
+ }
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ return true;
+
+ }
+
+ public IFile getFile() {
+ return file;
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewHandlerClassWizard.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewHandlerClassWizard.java
new file mode 100644
index 00000000..52009c9e
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewHandlerClassWizard.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2010 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.e4.internal.tools.wizards.classes;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.beans.BeanProperties;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.e4.internal.tools.wizards.classes.AbstractNewClassPage.JavaClass;
+import org.eclipse.e4.internal.tools.wizards.classes.templates.HandlerTemplate;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class NewHandlerClassWizard extends AbstractNewClassWizard {
+ @Override
+ protected String getContent() {
+ HandlerTemplate template = new HandlerTemplate();
+ return template.generate(getDomainClass());
+ }
+
+ @Override
+ public void addPages() {
+ addPage(new AbstractNewClassPage("Classinformation",
+ "New Handler",
+ "Create a new handler class", root, ResourcesPlugin.getWorkspace().getRoot()) {
+
+ @Override
+ protected JavaClass createInstance() {
+ return new HandlerClass(root);
+ }
+
+ @Override
+ protected void createFields(Composite parent, DataBindingContext dbc) {
+ IWidgetValueProperty textProp = WidgetProperties
+ .text(SWT.Modify);
+
+ {
+ Label l = new Label(parent, SWT.NONE);
+ l.setText("Execute Method");
+ l.setLayoutData(new GridData(GridData.END, GridData.CENTER,
+ false, false));
+
+ Text t = new Text(parent, SWT.BORDER);
+ t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ dbc.bindValue(
+ textProp.observe(t),
+ BeanProperties.value("executeMethodName").observe(
+ getClazz()));
+
+ l = new Label(parent, SWT.NONE);
+ }
+
+ {
+ Label l = new Label(parent, SWT.NONE);
+ l.setText("Can-Execute Method");
+ l.setLayoutData(new GridData(GridData.END, GridData.CENTER,
+ false, false));
+
+ Text t = new Text(parent, SWT.BORDER);
+ t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ dbc.bindValue(textProp.observe(t),
+ BeanProperties.value("canExecuteMethodName")
+ .observe(getClazz()));
+ dbc.bindValue(
+ WidgetProperties.enabled().observe(t),
+ BeanProperties.value("useCanExecute").observe(
+ getClazz()));
+
+ Button b = new Button(parent, SWT.CHECK);
+ dbc.bindValue(
+ WidgetProperties.selection().observe(b),
+ BeanProperties.value("useCanExecute").observe(
+ getClazz()));
+ }
+ }
+ });
+ }
+
+
+
+ public static class HandlerClass extends JavaClass {
+ private String executeMethodName = "execute";
+ private String canExecuteMethodName = "canExecute";
+ private boolean useCanExecute = false;
+
+ public HandlerClass(IPackageFragmentRoot root) {
+ super(root);
+ }
+
+ public String getExecuteMethodName() {
+ return executeMethodName;
+ }
+
+ public void setExecuteMethodName(String executeMethodName) {
+ support.firePropertyChange("executeMethodName",
+ this.executeMethodName,
+ this.executeMethodName = executeMethodName);
+ }
+
+ public String getCanExecuteMethodName() {
+ return canExecuteMethodName;
+ }
+
+ public void setCanExecuteMethodName(String canExecuteMethodName) {
+ support.firePropertyChange("canExecuteMethodName",
+ this.canExecuteMethodName,
+ this.canExecuteMethodName = canExecuteMethodName);
+ }
+
+ public boolean isUseCanExecute() {
+ return useCanExecute;
+ }
+
+ public void setUseCanExecute(boolean useCanExecute) {
+ support.firePropertyChange("useCanExecute", this.useCanExecute,
+ this.useCanExecute = useCanExecute);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewPartClassWizard.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewPartClassWizard.java
new file mode 100644
index 00000000..35c70947
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/NewPartClassWizard.java
@@ -0,0 +1,255 @@
+/*******************************************************************************
+ * Copyright (c) 2010 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.e4.internal.tools.wizards.classes;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.beans.BeanProperties;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.e4.internal.tools.wizards.classes.AbstractNewClassPage.JavaClass;
+import org.eclipse.e4.internal.tools.wizards.classes.templates.PartTemplate;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jface.databinding.swt.IWidgetValueProperty;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class NewPartClassWizard extends AbstractNewClassWizard {
+
+ @Override
+ public void addPages() {
+ addPage(new AbstractNewClassPage("Classinformation", "New Part",
+ "Create a new part class", root, ResourcesPlugin.getWorkspace()
+ .getRoot()) {
+
+ @Override
+ protected void createFields(Composite parent, DataBindingContext dbc) {
+ IWidgetValueProperty textProp = WidgetProperties
+ .text(SWT.Modify);
+ IWidgetValueProperty enabledProp = WidgetProperties.enabled();
+
+ {
+ Label l = new Label(parent, SWT.NONE);
+ l.setText("PostContruct Method");
+ l.setLayoutData(new GridData(GridData.END, GridData.CENTER,
+ false, false));
+
+ Text t = new Text(parent, SWT.BORDER);
+ t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ dbc.bindValue(textProp.observe(t),
+ BeanProperties.value("postConstructMethodName")
+ .observe(getClazz()));
+ dbc.bindValue(
+ enabledProp.observe(t),
+ BeanProperties.value("usePostConstruct").observe(
+ getClazz()));
+
+ Button b = new Button(parent, SWT.CHECK);
+ dbc.bindValue(
+ WidgetProperties.selection().observe(b),
+ BeanProperties.value("usePostConstruct").observe(
+ getClazz()));
+ }
+
+ {
+ Label l = new Label(parent, SWT.NONE);
+ l.setText("Predestroy Method");
+ l.setLayoutData(new GridData(GridData.END, GridData.CENTER,
+ false, false));
+
+ Text t = new Text(parent, SWT.BORDER);
+ t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ dbc.bindValue(textProp.observe(t),
+ BeanProperties.value("preDestroyMethodName")
+ .observe(getClazz()));
+ dbc.bindValue(
+ enabledProp.observe(t),
+ BeanProperties.value("usePredestroy").observe(
+ getClazz()));
+
+ Button b = new Button(parent, SWT.CHECK);
+ dbc.bindValue(
+ WidgetProperties.selection().observe(b),
+ BeanProperties.value("usePredestroy").observe(
+ getClazz()));
+ }
+
+ {
+ Label l = new Label(parent, SWT.NONE);
+ l.setText("Focus Method");
+ l.setLayoutData(new GridData(GridData.END, GridData.CENTER,
+ false, false));
+
+ Text t = new Text(parent, SWT.BORDER);
+ t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ dbc.bindValue(textProp.observe(t),
+ BeanProperties.value("focusMethodName")
+ .observe(getClazz()));
+ dbc.bindValue(
+ enabledProp.observe(t),
+ BeanProperties.value("useFocus").observe(
+ getClazz()));
+
+ Button b = new Button(parent, SWT.CHECK);
+ dbc.bindValue(
+ WidgetProperties.selection().observe(b),
+ BeanProperties.value("useFocus").observe(
+ getClazz()));
+ }
+
+ {
+ Label l = new Label(parent, SWT.NONE);
+ l.setText("Persist Method");
+ l.setLayoutData(new GridData(GridData.END, GridData.CENTER,
+ false, false));
+
+ Text t = new Text(parent, SWT.BORDER);
+ t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ dbc.bindValue(textProp.observe(t),
+ BeanProperties.value("persistMethodName")
+ .observe(getClazz()));
+ dbc.bindValue(
+ enabledProp.observe(t),
+ BeanProperties.value("usePersist").observe(
+ getClazz()));
+
+ Button b = new Button(parent, SWT.CHECK);
+ dbc.bindValue(
+ WidgetProperties.selection().observe(b),
+ BeanProperties.value("usePersist").observe(
+ getClazz()));
+ }
+ }
+
+ @Override
+ protected JavaClass createInstance() {
+ return new PartClass(root);
+ }
+
+ });
+ }
+
+ @Override
+ protected String getContent() {
+ PartTemplate template = new PartTemplate();
+ return template.generate(getDomainClass());
+ }
+
+ public static class PartClass extends JavaClass {
+ private PropertyChangeSupport support = new PropertyChangeSupport(this);
+
+ private boolean usePostConstruct;
+ private String postConstructMethodName = "postConstruct";
+
+ private boolean usePredestroy;
+ private String preDestroyMethodName = "preDestroy";
+
+ private boolean useFocus = true;
+ private String focusMethodName = "onFocus";
+
+ private boolean usePersist;
+ private String persistMethodName = "save";
+
+ public PartClass(IPackageFragmentRoot fragmentRoot) {
+ super(fragmentRoot);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ support.addPropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ support.removePropertyChangeListener(listener);
+ }
+
+ public boolean isUsePostConstruct() {
+ return usePostConstruct;
+ }
+
+ public void setUsePostConstruct(boolean usePostConstruct) {
+ support.firePropertyChange("usePostConstruct",
+ this.usePostConstruct,
+ this.usePostConstruct = usePostConstruct);
+ }
+
+ public String getPostConstructMethodName() {
+ return postConstructMethodName;
+ }
+
+ public void setPostConstructMethodName(String postConstructMethodName) {
+ support.firePropertyChange("postConstructMethodName",
+ this.postConstructMethodName,
+ this.postConstructMethodName = postConstructMethodName);
+ }
+
+ public boolean isUsePredestroy() {
+ return usePredestroy;
+ }
+
+ public void setUsePredestroy(boolean usePredestroy) {
+ support.firePropertyChange("usePredestroy", this.usePredestroy,
+ this.usePredestroy = usePredestroy);
+ }
+
+ public String getPreDestroyMethodName() {
+ return preDestroyMethodName;
+ }
+
+ public void setPreDestroyMethodName(String preDestroyMethodName) {
+ support.firePropertyChange("preDestroyMethodName",
+ this.preDestroyMethodName,
+ this.preDestroyMethodName = preDestroyMethodName);
+ }
+
+ public boolean isUseFocus() {
+ return useFocus;
+ }
+
+ public void setUseFocus(boolean useFocus) {
+ support.firePropertyChange("useFocus", this.useFocus,
+ this.useFocus = useFocus);
+ }
+
+ public String getFocusMethodName() {
+ return focusMethodName;
+ }
+
+ public void setFocusMethodName(String focusMethodName) {
+ support.firePropertyChange("focusMethodName", this.focusMethodName,
+ this.focusMethodName = focusMethodName);
+ }
+
+ public boolean isUsePersist() {
+ return usePersist;
+ }
+
+ public void setUsePersist(boolean usePersist) {
+ support.firePropertyChange("usePersist", this.usePersist,
+ this.usePersist = usePersist);
+ }
+
+ public String getPersistMethodName() {
+ return persistMethodName;
+ }
+
+ public void setPersistMethodName(String persistMethodName) {
+ support.firePropertyChange("persistMethodName",
+ this.persistMethodName,
+ this.persistMethodName = persistMethodName);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/templates/HandlerTemplate.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/templates/HandlerTemplate.java
new file mode 100644
index 00000000..ddf80d91
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/templates/HandlerTemplate.java
@@ -0,0 +1,50 @@
+package org.eclipse.e4.internal.tools.wizards.classes.templates;
+
+import org.eclipse.e4.internal.tools.wizards.classes.NewHandlerClassWizard.HandlerClass;
+
+public class HandlerTemplate
+{
+ protected static String nl;
+ public static synchronized HandlerTemplate create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ HandlerTemplate result = new HandlerTemplate();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = " " + NL + "package ";
+ protected final String TEXT_2 = ";" + NL + "" + NL + "import org.eclipse.e4.core.di.annotations.Execute;";
+ protected final String TEXT_3 = NL + "import org.eclipse.e4.core.di.annotations.CanExecute;";
+ protected final String TEXT_4 = NL + NL + "public class ";
+ protected final String TEXT_5 = " {" + NL + "\t@Execute" + NL + "\tpublic void ";
+ protected final String TEXT_6 = "() {" + NL + "\t\t//TODO Your code goes here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_7 = NL + "\t" + NL + "\t@CanExecute" + NL + "\tpublic boolean ";
+ protected final String TEXT_8 = "() {" + NL + "\t\t//TODO Your code goes here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_9 = "\t" + NL + "}";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+ HandlerClass domainClass = (HandlerClass)argument;
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( domainClass.getPackageFragment().getElementName() );
+ stringBuffer.append(TEXT_2);
+ if( domainClass.isUseCanExecute() ) {
+ stringBuffer.append(TEXT_3);
+ }
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append( domainClass.getName() );
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append( domainClass.getExecuteMethodName() );
+ stringBuffer.append(TEXT_6);
+ if( domainClass.isUseCanExecute() ) {
+ stringBuffer.append(TEXT_7);
+ stringBuffer.append( domainClass.getCanExecuteMethodName() );
+ stringBuffer.append(TEXT_8);
+ }
+ stringBuffer.append(TEXT_9);
+ return stringBuffer.toString();
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/templates/PartTemplate.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/templates/PartTemplate.java
new file mode 100644
index 00000000..7180c498
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/classes/templates/PartTemplate.java
@@ -0,0 +1,89 @@
+package org.eclipse.e4.internal.tools.wizards.classes.templates;
+
+import org.eclipse.e4.internal.tools.wizards.classes.NewPartClassWizard.PartClass;
+
+public class PartTemplate
+{
+ protected static String nl;
+ public static synchronized PartTemplate create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ PartTemplate result = new PartTemplate();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = " " + NL + "package ";
+ protected final String TEXT_2 = ";" + NL + "" + NL + "import javax.inject.Inject;";
+ protected final String TEXT_3 = NL + "import javax.annotation.PostConstruct;";
+ protected final String TEXT_4 = NL + "import javax.annotation.PreDestroy;";
+ protected final String TEXT_5 = NL + "import org.eclipse.e4.ui.di.Focus;";
+ protected final String TEXT_6 = NL + "import org.eclipse.e4.ui.di.Persist;";
+ protected final String TEXT_7 = NL + NL + "public class ";
+ protected final String TEXT_8 = " {" + NL + "\t@Inject" + NL + "\tpublic ";
+ protected final String TEXT_9 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_10 = NL + "\t@PostConstruct" + NL + "\tpublic void ";
+ protected final String TEXT_11 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_12 = NL + "\t";
+ protected final String TEXT_13 = NL + "\t@PreDestroy" + NL + "\tpublic void ";
+ protected final String TEXT_14 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_15 = NL + "\t";
+ protected final String TEXT_16 = NL + "\t@Focus" + NL + "\tpublic void ";
+ protected final String TEXT_17 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_18 = NL + "\t";
+ protected final String TEXT_19 = NL + "\t@Persist" + NL + "\tpublic void ";
+ protected final String TEXT_20 = "() {" + NL + "\t\t//TODO Your code here" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_21 = NL + "}";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+ PartClass domainClass = (PartClass)argument;
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( domainClass.getPackageFragment().getElementName() );
+ stringBuffer.append(TEXT_2);
+ if( domainClass.isUsePostConstruct() ) {
+ stringBuffer.append(TEXT_3);
+ }
+ if( domainClass.isUsePredestroy() ) {
+ stringBuffer.append(TEXT_4);
+ }
+ if( domainClass.isUseFocus() ) {
+ stringBuffer.append(TEXT_5);
+ }
+ if( domainClass.isUsePersist() ) {
+ stringBuffer.append(TEXT_6);
+ }
+ stringBuffer.append(TEXT_7);
+ stringBuffer.append( domainClass.getName() );
+ stringBuffer.append(TEXT_8);
+ stringBuffer.append( domainClass.getName() );
+ stringBuffer.append(TEXT_9);
+ if( domainClass.isUsePostConstruct() ) {
+ stringBuffer.append(TEXT_10);
+ stringBuffer.append( domainClass.getPostConstructMethodName() );
+ stringBuffer.append(TEXT_11);
+ }
+ stringBuffer.append(TEXT_12);
+ if( domainClass.isUsePredestroy() ) {
+ stringBuffer.append(TEXT_13);
+ stringBuffer.append( domainClass.getPreDestroyMethodName() );
+ stringBuffer.append(TEXT_14);
+ }
+ stringBuffer.append(TEXT_15);
+ if( domainClass.isUseFocus() ) {
+ stringBuffer.append(TEXT_16);
+ stringBuffer.append( domainClass.getFocusMethodName() );
+ stringBuffer.append(TEXT_17);
+ }
+ stringBuffer.append(TEXT_18);
+ if( domainClass.isUsePersist() ) {
+ stringBuffer.append(TEXT_19);
+ stringBuffer.append( domainClass.getPersistMethodName() );
+ stringBuffer.append(TEXT_20);
+ }
+ stringBuffer.append(TEXT_21);
+ return stringBuffer.toString();
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/BaseApplicationModelWizard.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/BaseApplicationModelWizard.java
new file mode 100644
index 00000000..0ec8559d
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/BaseApplicationModelWizard.java
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (c) 2010 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.e4.internal.tools.wizards.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.ISetSelectionTarget;
+
+public abstract class BaseApplicationModelWizard extends Wizard implements INewWizard {
+ private NewModelFilePage page;
+ private ISelection selection;
+
+ protected IWorkbench workbench;
+
+ /**
+ * Constructor for NewApplicationModelWizard.
+ */
+ public BaseApplicationModelWizard() {
+ super();
+ setNeedsProgressMonitor(true);
+ }
+
+ /**
+ * Adding the page to the wizard.
+ */
+
+ public void addPages() {
+ page = new NewModelFilePage(selection,getDefaultFileName());
+ addPage(page);
+ }
+
+ public abstract String getDefaultFileName();
+
+ @Override
+ public boolean performFinish() {
+ try {
+ // Remember the file.
+ //
+ final IFile modelFile = getModelFile();
+
+ // Do the work within an operation.
+ //
+ WorkspaceModifyOperation operation =
+ new WorkspaceModifyOperation() {
+ @Override
+ protected void execute(IProgressMonitor progressMonitor) {
+ try {
+ // Create a resource set
+ //
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ // Get the URI of the model file.
+ //
+ URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);
+
+ // Create a resource for this file.
+ //
+ Resource resource = resourceSet.createResource(fileURI);
+
+ // Add the initial model object to the contents.
+ //
+ EObject rootObject = createInitialModel();
+ if (rootObject != null) {
+ resource.getContents().add(rootObject);
+ }
+
+ // Save the contents of the resource to the file system.
+ //
+ Map<Object, Object> options = new HashMap<Object, Object>();
+ resource.save(options);
+ }
+ catch (Exception exception) {
+ throw new RuntimeException(exception);
+ }
+ finally {
+ progressMonitor.done();
+ }
+ }
+ };
+
+ getContainer().run(false, false, operation);
+
+ // Select the new file resource in the current view.
+ //
+ IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+ IWorkbenchPage page = workbenchWindow.getActivePage();
+ final IWorkbenchPart activePart = page.getActivePart();
+ if (activePart instanceof ISetSelectionTarget) {
+ final ISelection targetSelection = new StructuredSelection(modelFile);
+ getShell().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ ((ISetSelectionTarget)activePart).selectReveal(targetSelection);
+ }
+ });
+ }
+
+ // Open an editor on the new file.
+ //
+ try {
+ page.openEditor
+ (new FileEditorInput(modelFile),
+ workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId());
+ }
+ catch (PartInitException exception) {
+ MessageDialog.openError(workbenchWindow.getShell(), "Could not init editor", exception.getMessage()); //$NON-NLS-1$
+ return false;
+ }
+
+ return true;
+ }
+ catch (Exception exception) {
+ MessageDialog.openError(getShell(), "Error", exception.getMessage());
+ return false;
+ }
+ }
+
+ protected abstract EObject createInitialModel();
+
+ private IFile getModelFile() throws CoreException {
+ String containerName = page.getContainerName();
+ String fileName = page.getFileName();
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IResource resource = root.findMember(new Path(containerName));
+ if (!resource.exists() || !(resource instanceof IContainer)) {
+ throwCoreException("Container \"" + containerName
+ + "\" does not exist.");
+ }
+ IContainer container = (IContainer) resource;
+ return container.getFile(new Path(fileName));
+ }
+
+ private void throwCoreException(String message) throws CoreException {
+ IStatus status = new Status(IStatus.ERROR,
+ "org.eclipse.e4.tools.emf.editor3x", IStatus.OK, message, null);
+ throw new CoreException(status);
+ }
+
+ /**
+ * We will accept the selection in the workbench to see if we can initialize
+ * from it.
+ *
+ * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.workbench = workbench;
+ this.selection = selection;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewApplicationModelWizard.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewApplicationModelWizard.java
new file mode 100644
index 00000000..c6866256
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewApplicationModelWizard.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2010 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.e4.internal.tools.wizards.model;
+
+import org.eclipse.e4.ui.model.application.MApplicationFactory;
+import org.eclipse.emf.ecore.EObject;
+
+
+public class NewApplicationModelWizard extends BaseApplicationModelWizard {
+
+ @Override
+ public String getDefaultFileName() {
+ return "Application.e4xmi";
+ }
+
+ protected EObject createInitialModel() {
+ return (EObject) MApplicationFactory.INSTANCE.createApplication();
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewContributionModelWizard.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewContributionModelWizard.java
new file mode 100644
index 00000000..04d252f6
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewContributionModelWizard.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2010 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.e4.internal.tools.wizards.model;
+
+import org.eclipse.e4.ui.model.fragment.MFragmentFactory;
+import org.eclipse.emf.ecore.EObject;
+
+
+public class NewContributionModelWizard extends BaseApplicationModelWizard {
+
+ @Override
+ public String getDefaultFileName() {
+ return "fragment.e4xmi";
+ }
+
+ protected EObject createInitialModel() {
+ return (EObject) MFragmentFactory.INSTANCE.createModelFragments();
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewModelFilePage.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewModelFilePage.java
new file mode 100644
index 00000000..b0e8fc0c
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/model/NewModelFilePage.java
@@ -0,0 +1,199 @@
+/*******************************************************************************
+ * Copyright (c) 2010 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.e4.internal.tools.wizards.model;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+
+/**
+ * The "New" wizard page allows setting the container for the new file as well
+ * as the file name. The page will only accept file name without the extension
+ * OR with the extension that matches the expected one (e4xmi).
+ */
+
+public class NewModelFilePage extends WizardPage {
+ private Text containerText;
+
+ private Text fileText;
+
+ private ISelection selection;
+
+ private String defaultFilename;
+
+ /**
+ * Constructor for SampleNewWizardPage.
+ *
+ * @param pageName
+ */
+ public NewModelFilePage(ISelection selection, String defaultFilename) {
+ super("wizardPage");
+ setTitle("Multi-page Editor File");
+ setDescription("This wizard creates a new file with *.e4xmi extension that can be opened by a multi-page editor.");
+ this.selection = selection;
+ this.defaultFilename = defaultFilename;
+ }
+
+ /**
+ * @see IDialogPage#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 3;
+ layout.verticalSpacing = 9;
+ Label label = new Label(container, SWT.NULL);
+ label.setText("&Container:");
+
+ containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ containerText.setLayoutData(gd);
+ containerText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ dialogChanged();
+ }
+ });
+
+ Button button = new Button(container, SWT.PUSH);
+ button.setText("Browse...");
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleBrowse();
+ }
+ });
+ label = new Label(container, SWT.NULL);
+ label.setText("&File name:");
+
+ fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fileText.setLayoutData(gd);
+ fileText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ dialogChanged();
+ }
+ });
+ initialize();
+ dialogChanged();
+ setControl(container);
+ }
+
+ /**
+ * Tests if the current workbench selection is a suitable container to use.
+ */
+
+ private void initialize() {
+ if (selection != null && selection.isEmpty() == false
+ && selection instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) selection;
+ if (ssel.size() > 1)
+ return;
+ Object obj = ssel.getFirstElement();
+ if (obj instanceof IResource) {
+ IContainer container;
+ if (obj instanceof IContainer)
+ container = (IContainer) obj;
+ else
+ container = ((IResource) obj).getParent();
+ containerText.setText(container.getFullPath().toString());
+ }
+ }
+ fileText.setText(defaultFilename);
+ }
+
+ /**
+ * Uses the standard container selection dialog to choose the new value for
+ * the container field.
+ */
+
+ private void handleBrowse() {
+ ContainerSelectionDialog dialog = new ContainerSelectionDialog(
+ getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
+ "Select new file container");
+ if (dialog.open() == ContainerSelectionDialog.OK) {
+ Object[] result = dialog.getResult();
+ if (result.length == 1) {
+ containerText.setText(((Path) result[0]).toString());
+ }
+ }
+ }
+
+ /**
+ * Ensures that both text fields are set.
+ */
+
+ private void dialogChanged() {
+ IResource container = ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(new Path(getContainerName()));
+ String fileName = getFileName();
+
+ if (getContainerName().length() == 0) {
+ updateStatus("File container must be specified");
+ return;
+ }
+ if (container == null
+ || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
+ updateStatus("File container must exist");
+ return;
+ }
+ if (!container.isAccessible()) {
+ updateStatus("Project must be writable");
+ return;
+ }
+ if (fileName.length() == 0) {
+ updateStatus("File name must be specified");
+ return;
+ }
+ if (fileName.replace('\\', '/').indexOf('/', 1) > 0) {
+ updateStatus("File name must be valid");
+ return;
+ }
+ int dotLoc = fileName.lastIndexOf('.');
+ if (dotLoc != -1) {
+ String ext = fileName.substring(dotLoc + 1);
+ if (ext.equalsIgnoreCase("e4xmi") == false) {
+ updateStatus("File extension must be \"e4xmi\"");
+ return;
+ }
+ }
+ updateStatus(null);
+ }
+
+ private void updateStatus(String message) {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+
+ public String getContainerName() {
+ return containerText.getText();
+ }
+
+ public String getFileName() {
+ return fileText.getText();
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/E4NewProjectWizard.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/E4NewProjectWizard.java
new file mode 100644
index 00000000..85a29bf6
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/E4NewProjectWizard.java
@@ -0,0 +1,606 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 Soyatec(http://www.soyatec.com) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Soyatec - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.internal.tools.wizards.project;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.e4.ui.model.application.MApplication;
+import org.eclipse.e4.ui.model.application.MApplicationFactory;
+import org.eclipse.e4.ui.model.application.commands.MBindingContext;
+import org.eclipse.e4.ui.model.application.commands.MBindingTable;
+import org.eclipse.e4.ui.model.application.commands.MCommand;
+import org.eclipse.e4.ui.model.application.commands.MCommandsFactory;
+import org.eclipse.e4.ui.model.application.commands.MHandler;
+import org.eclipse.e4.ui.model.application.commands.MKeyBinding;
+import org.eclipse.e4.ui.model.application.ui.advanced.MAdvancedFactory;
+import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
+import org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack;
+import org.eclipse.e4.ui.model.application.ui.basic.MBasicFactory;
+import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer;
+import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
+import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar;
+import org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
+import org.eclipse.e4.ui.model.application.ui.menu.MToolBar;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.xmi.XMLResource;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.pde.core.plugin.IPluginBase;
+import org.eclipse.pde.core.plugin.IPluginElement;
+import org.eclipse.pde.core.plugin.IPluginExtension;
+import org.eclipse.pde.core.plugin.IPluginImport;
+import org.eclipse.pde.internal.core.ICoreConstants;
+import org.eclipse.pde.internal.core.bundle.WorkspaceBundlePluginModel;
+import org.eclipse.pde.internal.core.plugin.WorkspacePluginModelBase;
+import org.eclipse.pde.internal.ui.PDEPlugin;
+import org.eclipse.pde.internal.ui.PDEUIMessages;
+import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
+import org.eclipse.pde.internal.ui.wizards.plugin.NewPluginProjectWizard;
+import org.eclipse.pde.internal.ui.wizards.plugin.NewProjectCreationOperation;
+import org.eclipse.pde.internal.ui.wizards.plugin.PluginFieldData;
+import org.eclipse.ui.IWorkingSet;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
+
+/**
+ * @author jin.liu (jin.liu@soyatec.com)
+ */
+public class E4NewProjectWizard extends NewPluginProjectWizard {
+
+ private PluginFieldData fPluginData;
+ private NewApplicationWizardPage fApplicationPage;
+ private IProjectProvider fProjectProvider;
+ private PluginContentPage fContentPage;
+
+ public E4NewProjectWizard() {
+ fPluginData = new PluginFieldData();
+ }
+
+ public void addPages() {
+ fMainPage = new E4NewProjectWizardPage(
+ "main", fPluginData, false, getSelection()); //$NON-NLS-1$
+ fMainPage.setTitle(PDEUIMessages.NewProjectWizard_MainPage_title);
+ fMainPage.setDescription(PDEUIMessages.NewProjectWizard_MainPage_desc);
+ String pname = getDefaultValue(DEF_PROJECT_NAME);
+ if (pname != null)
+ fMainPage.setInitialProjectName(pname);
+ addPage(fMainPage);
+
+ fProjectProvider = new IProjectProvider() {
+ public String getProjectName() {
+ return fMainPage.getProjectName();
+ }
+
+ public IProject getProject() {
+ return fMainPage.getProjectHandle();
+ }
+
+ public IPath getLocationPath() {
+ return fMainPage.getLocationPath();
+ }
+ };
+
+ fContentPage = new PluginContentPage(
+ "page2", fProjectProvider, fMainPage, fPluginData); //$NON-NLS-1$
+
+ fApplicationPage = new NewApplicationWizardPage(fProjectProvider);
+
+ addPage(fContentPage);
+ addPage(fApplicationPage);
+ }
+
+ @SuppressWarnings("restriction")
+ public boolean performFinish() {
+ try {
+ fMainPage.updateData();
+ fContentPage.updateData();
+ IDialogSettings settings = getDialogSettings();
+ if (settings != null) {
+ fMainPage.saveSettings(settings);
+ fContentPage.saveSettings(settings);
+ }
+ getContainer().run(
+ false,
+ true,
+ new NewProjectCreationOperation(fPluginData,
+ fProjectProvider, null) {
+ private WorkspacePluginModelBase model;
+
+ @Override
+ protected void adjustManifests(
+ IProgressMonitor monitor, IProject project,
+ IPluginBase bundle) throws CoreException {
+ super.adjustManifests(monitor, project, bundle);
+ IPluginBase pluginBase = model.getPluginBase();
+ String[] dependencyId = new String[] {
+ "javax.inject",
+ "org.eclipse.core.resources",
+ "org.eclipse.core.runtime",
+ "org.eclipse.swt",
+ "org.eclipse.core.databinding",
+ "org.eclipse.core.databinding.beans",
+ "org.eclipse.jface",
+ "org.eclipse.jface.databinding",
+ "org.eclipse.e4.ui.services",
+ "org.eclipse.e4.ui.workbench",
+ "org.eclipse.e4.core.services",
+ "org.eclipse.e4.core.di",
+ "org.eclipse.e4.core.contexts",
+ "org.eclipse.e4.ui.workbench.swt",
+ "org.eclipse.core.databinding.property",
+ "org.eclipse.e4.ui.css.core",
+ "org.w3c.css.sac",
+ "org.eclipse.e4.core.commands",
+ "org.eclipse.e4.ui.bindings" };
+ for (String id : dependencyId) {
+ Bundle dependency = Platform.getBundle(id);
+
+ IPluginImport iimport = model
+ .getPluginFactory().createImport();
+ iimport.setId(id);
+ Version version = dependency.getVersion();
+ String versionString = version.getMajor() + "."
+ + version.getMinor() + "."
+ + version.getMicro();
+ iimport.setVersion(versionString);
+ pluginBase.add(iimport);
+ }
+ }
+
+ @Override
+ protected void setPluginLibraries(
+ WorkspacePluginModelBase model)
+ throws CoreException {
+ this.model = model;
+ super.setPluginLibraries(model);
+ }
+ });
+
+ IWorkingSet[] workingSets = fMainPage.getSelectedWorkingSets();
+ if (workingSets.length > 0)
+ getWorkbench().getWorkingSetManager().addToWorkingSets(
+ fProjectProvider.getProject(), workingSets);
+
+ this.createProductsExtension(fProjectProvider.getProject());
+
+ this.createApplicationResources(fProjectProvider.getProject(),
+ new NullProgressMonitor());
+
+ return true;
+ } catch (InvocationTargetException e) {
+ PDEPlugin.logException(e);
+ } catch (InterruptedException e) {
+ }
+ return false;
+ }
+
+ /**
+ * create products extension detail
+ *
+ * @param project
+ */
+ @SuppressWarnings("restriction")
+ public void createProductsExtension(IProject project) {
+ Map<String, String> map = fApplicationPage.getData();
+ if (map == null
+ || map.get(NewApplicationWizardPage.PRODUCT_NAME) == null)
+ return;
+
+ WorkspacePluginModelBase fmodel = new WorkspaceBundlePluginModel(
+ project.getFile(ICoreConstants.BUNDLE_FILENAME_DESCRIPTOR),
+ project.getFile(ICoreConstants.PLUGIN_FILENAME_DESCRIPTOR));
+ IPluginExtension extension = fmodel.getFactory().createExtension();
+ try {
+ String productName = map.get(NewApplicationWizardPage.PRODUCT_NAME);
+ String applicationName = map
+ .get(NewApplicationWizardPage.APPLICATION);
+
+ String xmiPath = map
+ .get(NewApplicationWizardPage.APPLICATION_XMI_PROPERTY);
+ if (xmiPath != null) {
+ xmiPath = productName + "/" + xmiPath;
+ map.put(NewApplicationWizardPage.APPLICATION_XMI_PROPERTY,
+ xmiPath);
+ }
+ String cssValue = map
+ .get(NewApplicationWizardPage.APPLICATION_CSS_PROPERTY);
+ if (cssValue != null) {
+ cssValue = "platform:/plugin/" + productName + "/" + cssValue;
+ map.put(NewApplicationWizardPage.APPLICATION_CSS_PROPERTY,
+ cssValue);
+ }
+
+ extension.setPoint("org.eclipse.core.runtime.products");
+ extension.setId("product");
+ IPluginElement productElement = fmodel.getFactory().createElement(
+ extension);
+
+ productElement.setName("product");
+ if (applicationName != null) {
+ productElement.setAttribute("application", applicationName);
+ } else {
+ productElement.setAttribute("application",
+ NewApplicationWizardPage.E4_APPLICATION);
+ }
+ productElement.setAttribute("name", productName);
+
+ Set<Entry<String, String>> set = map.entrySet();
+ if (set != null) {
+ Iterator<Entry<String, String>> it = set.iterator();
+ if (it != null) {
+ while (it.hasNext()) {
+ Entry<String, String> entry = it.next();
+ String value = entry.getValue();
+ if (value == null || value.trim().length() == 0) {
+ continue;
+ }
+
+ if (entry.getKey().equals(
+ NewApplicationWizardPage.PRODUCT_NAME)
+ || entry.getKey().equals(
+ NewApplicationWizardPage.APPLICATION)) {
+ continue;
+ }
+ IPluginElement element = fmodel.getFactory()
+ .createElement(productElement);
+ element.setName("property");
+ element.setAttribute("name", entry.getKey());
+ element.setAttribute("value", value);
+ productElement.add(element);
+ }
+ }
+ }
+ extension.add(productElement);
+ fmodel.getPluginBase().add(extension);
+ fmodel.save();
+
+ } catch (CoreException e) {
+ PDEPlugin.logException(e);
+ }
+ }
+
+ /**
+ * create products extension detail
+ *
+ * @param project
+ */
+ @SuppressWarnings("restriction")
+ public void createApplicationResources(IProject project,
+ IProgressMonitor monitor) {
+ Map<String, String> map = fApplicationPage.getData();
+ if (map == null
+ || map.get(NewApplicationWizardPage.PRODUCT_NAME) == null)
+ return;
+
+ String projectName = map.get(NewApplicationWizardPage.PRODUCT_NAME);
+ String xmiPath = map
+ .get(NewApplicationWizardPage.APPLICATION_XMI_PROPERTY);
+
+ IJavaProject javaProject = JavaCore.create(project);
+ IPackageFragment fragment = null;
+ try {
+ for (IPackageFragment element : javaProject.getPackageFragments()) {
+ if (element.getKind() == IPackageFragmentRoot.K_SOURCE) {
+ fragment = element;
+ }
+ }
+ } catch (JavaModelException e1) {
+ e1.printStackTrace();
+ }
+
+ if (xmiPath != null && xmiPath.trim().length() > 0) {
+ // Create a resource set
+ //
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ // Get the URI of the model file.
+ //
+ URI fileURI = URI.createPlatformResourceURI(project.getName() + "/"
+ + xmiPath, true);
+
+ // Create a resource for this file.
+ //
+ Resource resource = resourceSet.createResource(fileURI);
+
+ MApplication application = MApplicationFactory.INSTANCE
+ .createApplication();
+
+ application.setElementId("org.eclipse.e4.ide.application");
+
+ MBindingContext rootContext = MCommandsFactory.INSTANCE.createBindingContext();
+ rootContext.setElementId("org.eclipse.ui.contexts.dialogAndWindow");
+ rootContext.setName("In Dialog and Windows");
+
+ MBindingContext childContext = MCommandsFactory.INSTANCE.createBindingContext();
+ childContext.setElementId("org.eclipse.ui.contexts.window");
+ childContext.setName("In Windows");
+ rootContext.getChildren().add(childContext);
+
+ childContext = MCommandsFactory.INSTANCE.createBindingContext();
+ childContext.setElementId("org.eclipse.ui.contexts.dialog");
+ childContext.setName("In Dialogs");
+ rootContext.getChildren().add(childContext);
+
+ application.setRootContext(rootContext);
+ application.getBindingContexts().add("org.eclipse.ui.contexts.dialogAndWindow");
+
+ resource.getContents().add((EObject) application);
+
+ // Create Quit command
+ MCommand quitCommand = createCommand("quitCommand", "QuitHandler",
+ "Ctrl+Q", projectName, fragment, application);
+
+ MCommand openCommand = createCommand("openCommand", "OpenHandler",
+ "Ctrl+O", projectName, fragment, application);
+
+ MCommand saveCommand = createCommand("saveCommand", "SaveHandler",
+ "Ctrl+S", projectName, fragment, application);
+
+ MCommand aboutCommand = createCommand("aboutCommand",
+ "AboutHandler", "Ctrl+A", projectName, fragment,
+ application);
+
+ MTrimmedWindow mainWindow = MBasicFactory.INSTANCE.createTrimmedWindow();
+ application.getChildren().add(mainWindow);
+ {
+ mainWindow.setLabel(projectName);
+ mainWindow.setWidth(500);
+ mainWindow.setHeight(400);
+
+ // Menu
+ {
+ MMenu menu = MMenuFactory.INSTANCE.createMenu();
+ mainWindow.setMainMenu(menu);
+ menu.setElementId("menu:org.eclipse.ui.main.menu");
+
+ MMenu fileMenuItem = MMenuFactory.INSTANCE
+ .createMenu();
+ menu.getChildren().add(fileMenuItem);
+ fileMenuItem.setLabel("File");
+ {
+ MHandledMenuItem menuItemOpen = MMenuFactory.INSTANCE
+ .createHandledMenuItem();
+ fileMenuItem.getChildren().add(menuItemOpen);
+ menuItemOpen.setLabel("Open");
+ menuItemOpen.setIconURI("platform:/plugin/"
+ + project.getName() + "/icons/sample.gif");
+ menuItemOpen.setCommand(openCommand);
+
+ MHandledMenuItem menuItemSave = MMenuFactory.INSTANCE
+ .createHandledMenuItem();
+ fileMenuItem.getChildren().add(menuItemSave);
+ menuItemSave.setLabel("Save");
+ menuItemSave.setIconURI("platform:/plugin/"
+ + project.getName() + "/icons/save_edit.gif");
+ menuItemSave.setCommand(saveCommand);
+
+ MHandledMenuItem menuItemQuit = MMenuFactory.INSTANCE
+ .createHandledMenuItem();
+ fileMenuItem.getChildren().add(menuItemQuit);
+ menuItemQuit.setLabel("Quit");
+ menuItemQuit.setCommand(quitCommand);
+ }
+ MMenu helpMenuItem = MMenuFactory.INSTANCE
+ .createMenu();
+ menu.getChildren().add(helpMenuItem);
+ helpMenuItem.setLabel("Help");
+ {
+ MHandledMenuItem menuItemAbout = MMenuFactory.INSTANCE
+ .createHandledMenuItem();
+ helpMenuItem.getChildren().add(menuItemAbout);
+ menuItemAbout.setLabel("About");
+ menuItemAbout.setCommand(aboutCommand);
+ }
+ }
+
+ // PerspectiveStack
+ {
+ MPerspectiveStack perspectiveStack = MAdvancedFactory.INSTANCE
+ .createPerspectiveStack();
+ mainWindow.getChildren().add(perspectiveStack);
+
+ MPerspective perspective = MAdvancedFactory.INSTANCE
+ .createPerspective();
+ perspectiveStack.getChildren().add(perspective);
+ {
+ // Part Container
+ MPartSashContainer partSashContainer = MBasicFactory.INSTANCE
+ .createPartSashContainer();
+ perspective.getChildren().add(partSashContainer);
+
+ MPartStack partStack = MBasicFactory.INSTANCE
+ .createPartStack();
+ partSashContainer.getChildren().add(partStack);
+//
+// MPart part = MApplicationFactory.eINSTANCE.createPart();
+// partStack.getChildren().add(part);
+// part.setLabel("Main");
+ }
+
+ // WindowTrim
+ {
+ MTrimBar trimBar = MBasicFactory.INSTANCE.createTrimBar();
+ mainWindow.getTrimBars().add(trimBar);
+
+ MToolBar toolBar = MMenuFactory.INSTANCE
+ .createToolBar();
+ toolBar.setElementId("toolbar:org.eclipse.ui.main.toolbar");
+ trimBar.getChildren().add(toolBar);
+
+ MHandledToolItem toolItemOpen = MMenuFactory.INSTANCE
+ .createHandledToolItem();
+ toolBar.getChildren().add(toolItemOpen);
+ toolItemOpen.setIconURI("platform:/plugin/"
+ + project.getName() + "/icons/sample.gif");
+ toolItemOpen.setCommand(openCommand);
+
+ MHandledToolItem toolItemSave = MMenuFactory.INSTANCE
+ .createHandledToolItem();
+ toolBar.getChildren().add(toolItemSave);
+ toolItemSave.setIconURI("platform:/plugin/"
+ + project.getName() + "/icons/save_edit.gif");
+ toolItemSave.setCommand(saveCommand);
+ }
+ }
+ }
+ Map<Object, Object> options = new HashMap<Object, Object>();
+ options.put(XMLResource.OPTION_ENCODING, "UTF-8");
+ try {
+ resource.save(options);
+ } catch (IOException e) {
+ PDEPlugin.logException(e);
+ }
+ }
+
+ String cssPath = map
+ .get(NewApplicationWizardPage.APPLICATION_CSS_PROPERTY);
+ if (cssPath != null && cssPath.trim().length() > 0) {
+ IFile file = project.getFile(cssPath);
+
+ try {
+ prepareFolder(file.getParent(), monitor);
+
+ URL corePath = ResourceLocator
+ .getProjectTemplateFiles("css/default.css");
+ file.create(corePath.openStream(), true, monitor);
+ } catch (Exception e) {
+ PDEPlugin.logException(e);
+ }
+ }
+
+ // IFolder folder = project.getFolder("icons");
+ // try {
+ // folder.create(true, true, monitor);
+ // Bundle bundle = Platform
+ // .getBundle("org.eclipse.e4.tools.ui.designer");
+ //
+ // for (String fileName : new String[] { "sample.gif", "save_edit.gif"
+ // }) {
+ // URL sampleUrl = bundle.getEntry("resources/icons/" + fileName);
+ // sampleUrl = FileLocator.resolve(sampleUrl);
+ // InputStream inputStream = sampleUrl.openStream();
+ // IFile file = folder.getFile(fileName);
+ // file.create(inputStream, true, monitor);
+ // }
+ // } catch (Exception e) {
+ // PDEPlugin.logException(e);
+ // }
+
+ String template_id = "common";
+ Set<String> binaryExtentions = new HashSet<String>();
+ binaryExtentions.add(".gif");
+ binaryExtentions.add(".png");
+
+ Map<String, String> keys = new HashMap<String, String>();
+ keys.put("projectName", projectName);
+ keys.put("packageName", fragment.getElementName() + ".handlers");
+
+ try {
+ URL corePath = ResourceLocator.getProjectTemplateFiles(template_id);
+ IRunnableWithProgress op = new TemplateOperation(corePath, project,
+ keys, binaryExtentions);
+ getContainer().run(false, true, op);
+ } catch (Exception e) {
+ PDEPlugin.logException(e);
+ }
+
+ try {
+ URL corePath = ResourceLocator.getProjectTemplateFiles("src");
+ IRunnableWithProgress op = new TemplateOperation(corePath,
+ (IContainer) fragment.getResource(), keys, binaryExtentions);
+ getContainer().run(false, true, op);
+ } catch (Exception e) {
+ PDEPlugin.logException(e);
+ }
+ }
+
+ private MCommand createCommand(String name, String className,
+ String keyBinding, String projectName, IPackageFragment fragment,
+ MApplication application) {
+ MCommand command = MCommandsFactory.INSTANCE.createCommand();
+ command.setCommandName(name);
+ command.setElementId(projectName + "." + name);
+ application.getCommands().add(command);
+ {
+ // Create Quit handler for command
+ MHandler quitHandler =MCommandsFactory.INSTANCE
+ .createHandler();
+ quitHandler.setCommand(command);
+ quitHandler.setContributionURI("platform:/plugin/" + projectName + "/"
+ + fragment.getElementName() + ".handlers." + className);
+ application.getHandlers().add(quitHandler);
+
+ MKeyBinding binding = MCommandsFactory.INSTANCE
+ .createKeyBinding();
+ binding.setKeySequence(keyBinding);
+ binding.setCommand(command);
+ List<MBindingTable> tables = application.getBindingTables();
+ if (tables.size()==0) {
+ MBindingTable table = MCommandsFactory.INSTANCE.createBindingTable();
+ table.setBindingContextId("org.eclipse.ui.contexts.dialogAndWindow");
+ tables.add(table);
+ }
+ tables.get(0).getBindings().add(binding);
+ }
+ return command;
+ }
+
+ private void prepareFolder(IContainer container, IProgressMonitor monitor)
+ throws CoreException {
+ IContainer parent = container.getParent();
+ if (parent instanceof IFolder) {
+ prepareFolder((IFolder) parent, monitor);
+ }
+ if (!container.exists() && container instanceof IFolder) {
+ IFolder folder = (IFolder) container;
+ folder.create(true, true, monitor);
+ }
+ }
+
+ public String getPluginId() {
+ return fPluginData.getId();
+ }
+
+ public String getPluginVersion() {
+ return fPluginData.getVersion();
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/E4NewProjectWizardPage.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/E4NewProjectWizardPage.java
new file mode 100644
index 00000000..72ae3d44
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/E4NewProjectWizardPage.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 Soyatec(http://www.soyatec.com) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Soyatec - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.internal.tools.wizards.project;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.pde.internal.ui.wizards.plugin.AbstractFieldData;
+import org.eclipse.swt.widgets.Composite;
+
+public class E4NewProjectWizardPage extends org.eclipse.pde.internal.ui.wizards.plugin.NewProjectCreationPage {
+
+ public E4NewProjectWizardPage(String pageName, AbstractFieldData data, boolean fragment, IStructuredSelection selection) {
+ super(pageName, data, fragment, selection);
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ fOSGIButton.setSelection(true);
+ fEclipseButton.setEnabled(false);
+ fEclipseCombo.setEnabled(false);
+ }
+}
+
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/NewApplicationWizardPage.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/NewApplicationWizardPage.java
new file mode 100644
index 00000000..14bc00b9
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/NewApplicationWizardPage.java
@@ -0,0 +1,417 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 Soyatec (http://www.soyatec.com) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Soyatec - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.internal.tools.wizards.project;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.ColorDialog;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.branding.IProductConstants;
+
+/**
+ * @author jin.liu (jin.liu@soyatec.com)
+ */
+public class NewApplicationWizardPage extends WizardPage {
+ public static final String E4_APPLICATION = "org.eclipse.e4.ui.workbench.swt.E4Application";
+ public static final String APPLICATION_XMI_PROPERTY = "applicationXMI";
+ public static final String APPLICATION_CSS_PROPERTY = "applicationCSS";
+ public static final String PRODUCT_NAME = "productName";
+ public static final String APPLICATION = "application";
+
+ private final Map<String, String> data;
+
+ private IProject project;
+ private IProjectProvider projectProvider;
+ private Text proNameText;
+ private Text proApplicationText;
+ private Group propertyGroup;
+
+ private PropertyData[] PROPERTIES;
+
+ protected NewApplicationWizardPage(IProjectProvider projectProvider) {
+ super("New e4 Application Wizard Page");
+ this.projectProvider = projectProvider;
+ data = new HashMap<String, String>();
+ setTitle("e4 Application");
+ setMessage("Configure application with special values.");
+ }
+
+ public IProject getProject() {
+ if (project == null && projectProvider != null) {
+ project = projectProvider.getProject();
+ }
+ return project;
+ }
+
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
+ * .Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite control = new Composite(parent, SWT.NONE);
+ control.setLayout(new GridLayout());
+
+ Group productGroup = createProductGroup(control);
+ productGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ propertyGroup = createPropertyGroup(control);
+ propertyGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ setControl(control);
+ }
+
+ static class PropertyData {
+ private String name;
+ private String label;
+
+ private String value;
+ private Class<?> type;
+ private boolean editable;
+
+ public PropertyData(String name, String label, String value, Class<?> type,
+ boolean editable) {
+ this.name = name;
+ this.value = value;
+ this.label = label;
+ this.type = type;
+ this.editable = editable;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public Class<?> getType() {
+ return type;
+ }
+
+ public boolean isEditable() {
+ return editable;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+ }
+
+ private Group createPropertyGroup(Composite control) {
+ Group group = new Group(control, SWT.NONE);
+ group.setText("Properties");
+
+ group.setLayout(new GridLayout(3, false));
+
+ return group;
+ }
+
+ private void createPropertyItem(final Composite parent,
+ final PropertyData property) {
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(property.getLabel());
+ label.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLUE));
+ label.setToolTipText("Property \"" + property.getName() + "\"");
+
+ final Text valueText = new Text(parent, SWT.BORDER);
+ valueText.setText(property.getValue());
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ valueText.setLayoutData(gridData);
+ if (!property.isEditable()) {
+ valueText.setEditable(false);
+ }
+ valueText.addListener(SWT.Modify, new Listener() {
+ public void handleEvent(Event event) {
+ handleTextEvent(property.getName(), valueText);
+ }
+ });
+
+ if (property.getType() == Color.class
+ || property.getType() == Rectangle.class) {
+ Button button = new Button(parent, SWT.PUSH);
+ button.setText("...");
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ handleLinkEvent(property, valueText, parent.getShell());
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+ }
+ else {
+ new Label(parent, SWT.NONE);
+ }
+ data.put(property.getName(), property.getValue());
+ }
+
+ private void handleLinkEvent(PropertyData property, Text valueText,
+ Shell shell) {
+ if (property == null || valueText == null || valueText.isDisposed()) {
+ return;
+ }
+ if (property.getType() == Color.class) {
+ ColorDialog colorDialog = new ColorDialog(shell);
+ RGB selectRGB = colorDialog.open();
+ if (selectRGB != null) {
+ valueText.setText((this.hexColorConvert(Integer
+ .toHexString(selectRGB.blue))
+ + this.hexColorConvert(Integer
+ .toHexString(selectRGB.green)) + this
+ .hexColorConvert(Integer.toHexString(selectRGB.red)))
+ .toUpperCase());
+ }
+ } else if (property.getType() == Rectangle.class) {
+ this.createRectDialog(shell, valueText).open();
+ }
+ }
+
+ /**
+ * exchange the color pattern of hex numeric
+ *
+ * @param number
+ * @return
+ */
+ public String hexColorConvert(String color) {
+ if (color.length() == 1) {
+ return "0" + color;
+ }
+ return color;
+ }
+
+ /**
+ * create Rect Set dialog
+ *
+ * @param parent
+ * @param valueText
+ * @return
+ */
+ public Dialog createRectDialog(final Composite parent, final Text valueText) {
+ return new Dialog(parent.getShell()) {
+ Text xPointText, yPointText, widthText, heightText;
+
+ @Override
+ protected Button createButton(Composite parent, int id,
+ String label, boolean defaultButton) {
+ return super.createButton(parent, id, label, defaultButton);
+ }
+
+ @Override
+ protected Control createDialogArea(final Composite parent) {
+ Composite composite = (Composite) super
+ .createDialogArea(parent);
+ composite.getShell().setText("Set Rect");
+ Group group = new Group(composite, SWT.NONE);
+ group.setText("Rect");
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 4;
+ group.setLayout(gridLayout);
+
+ Label xPointLabel = new Label(group, SWT.NONE);
+ xPointLabel.setText("X:");
+ xPointText = new Text(group, SWT.BORDER);
+ VerifyListener verifyListener = createVerifyListener(parent
+ .getShell());
+ xPointText.addVerifyListener(verifyListener);
+ Label yPointLabel = new Label(group, SWT.NONE);
+ yPointLabel.setText("Y:");
+ yPointText = new Text(group, SWT.BORDER);
+ yPointText.addVerifyListener(verifyListener);
+ Label widthLabel = new Label(group, SWT.NONE);
+ widthLabel.setText("Width:");
+ widthText = new Text(group, SWT.BORDER);
+ widthText.addVerifyListener(verifyListener);
+ Label heighttLabel = new Label(group, SWT.NONE);
+ heighttLabel.setText("Height:");
+ heightText = new Text(group, SWT.BORDER);
+ heightText.addVerifyListener(verifyListener);
+
+ return composite;
+ }
+
+ @Override
+ protected void buttonPressed(int buttonId) {
+ if (IDialogConstants.OK_ID == buttonId) {
+ String xPoint = xPointText.getText();
+ String yPoint = yPointText.getText();
+ String width = widthText.getText();
+ String height = heightText.getText();
+ if (xPoint.length() == 0 || yPoint.length() == 0
+ || width.length() == 0 || height.length() == 0) {
+ MessageDialog.openWarning(parent.getShell(),
+ "Input value empty",
+ "Value shoud not be empty!");
+ } else {
+ valueText.setText(xPoint + "," + yPoint + "," + width
+ + "," + height);
+ okPressed();
+ }
+ } else if (IDialogConstants.CANCEL_ID == buttonId) {
+ cancelPressed();
+ }
+ }
+ };
+ }
+
+ /**
+ * create verify Listener
+ *
+ * @param shell
+ * @return
+ */
+ public VerifyListener createVerifyListener(final Shell shell) {
+ return new VerifyListener() {
+ public void verifyText(VerifyEvent e) {
+ char c = e.character;
+ if ("0123456789".indexOf(c) == -1) {
+ e.doit = false;
+ MessageDialog.openWarning(shell, "Input value error",
+ "Only numeric is allowed!");
+ return;
+ }
+ }
+ };
+ }
+
+ private void handleTextEvent(String property, Text valueText) {
+ if (property == null || valueText == null || valueText.isDisposed()) {
+ return;
+ }
+ String value = valueText.getText();
+ if (value.equals("")) {
+ value = null;
+ }
+ data.put(property, value);
+ }
+
+ private Group createProductGroup(Composite control) {
+ Group proGroup = new Group(control, SWT.NONE);
+ proGroup.setText("Product");
+
+ proGroup.setLayout(new GridLayout(2, false));
+
+ Label proNameLabel = new Label(proGroup, SWT.NONE);
+ proNameLabel.setText("Name:*");
+
+ proNameText = new Text(proGroup, SWT.BORDER);
+ proNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ proNameText.addListener(SWT.Modify, new Listener() {
+ public void handleEvent(Event event) {
+ handleTextEvent(PRODUCT_NAME, proNameText);
+ }
+ });
+
+ Label proApplicationLabel = new Label(proGroup, SWT.NONE);
+ proApplicationLabel.setText("Application:");
+
+ proApplicationText = new Text(proGroup, SWT.BORDER);
+ proApplicationText
+ .setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ proApplicationText.addListener(SWT.Modify, new Listener() {
+ public void handleEvent(Event event) {
+ handleTextEvent(APPLICATION, proApplicationText);
+ }
+ });
+ return proGroup;
+ }
+
+ protected PropertyData[] getPropertyData() {
+ if (PROPERTIES == null) {
+ PROPERTIES = new PropertyData[] {
+ new PropertyData(IProductConstants.APP_NAME, "Application Name:",
+ projectProvider.getProjectName(), String.class,
+ true),
+ new PropertyData(APPLICATION_XMI_PROPERTY, "Application UI:",
+ "Application.e4xmi", String.class, true),
+ new PropertyData(APPLICATION_CSS_PROPERTY, "CSS Style:",
+ "css/default.css", String.class, true),
+ new PropertyData(IProductConstants.ABOUT_TEXT, "About Message:", "",
+ String.class, true),
+ new PropertyData(
+ IProductConstants.STARTUP_FOREGROUND_COLOR, "Startup Foreground:", "",
+ Color.class, false),
+ new PropertyData(IProductConstants.STARTUP_MESSAGE_RECT, "Startup Message Region:",
+ "", Rectangle.class, false),
+ new PropertyData(IProductConstants.STARTUP_PROGRESS_RECT, "Startup Progress Region:",
+ "", Rectangle.class, false),
+ new PropertyData(
+ IProductConstants.PREFERENCE_CUSTOMIZATION, "Preference Customization:", "",
+ String.class, true) }; // plugin_customization.ini
+ }
+ return PROPERTIES;
+ }
+
+ @Override
+ public void setVisible(boolean visible) {
+ if (visible && PROPERTIES == null) {
+ proNameText.setText(projectProvider.getProjectName());
+
+ proApplicationText.setText(E4_APPLICATION);
+
+ for (PropertyData property : getPropertyData()) {
+ createPropertyItem(propertyGroup, property);
+ }
+ propertyGroup.getParent().layout();
+ }
+ super.setVisible(visible);
+ }
+
+ /**
+ * @return the data
+ */
+ public Map<String, String> getData() {
+ if (PROPERTIES == null) {
+ for (PropertyData property : getPropertyData()) {
+ data.put(property.getName(), property.getValue());
+ }
+
+ data.put(PRODUCT_NAME, projectProvider.getProjectName());
+ data.put(APPLICATION, E4_APPLICATION);
+ }
+ Map<String, String> map = new HashMap<String, String>();
+ map.putAll(data);
+ return map;
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/PluginContentPage.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/PluginContentPage.java
new file mode 100644
index 00000000..6fb9ae3f
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/PluginContentPage.java
@@ -0,0 +1,363 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Soyatec - port to e4
+ *******************************************************************************/
+package org.eclipse.e4.internal.tools.wizards.project;
+
+import java.util.Locale;
+import java.util.TreeSet;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.JavaConventions;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.pde.internal.core.util.PDEJavaHelper;
+import org.eclipse.pde.internal.core.util.VMUtil;
+import org.eclipse.pde.internal.ui.IHelpContextIds;
+import org.eclipse.pde.internal.ui.PDEUIMessages;
+import org.eclipse.pde.internal.ui.SWTFactory;
+import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
+import org.eclipse.pde.internal.ui.wizards.plugin.AbstractFieldData;
+import org.eclipse.pde.internal.ui.wizards.plugin.ContentPage;
+import org.eclipse.pde.internal.ui.wizards.plugin.NewProjectCreationPage;
+import org.eclipse.pde.internal.ui.wizards.plugin.PluginFieldData;
+import org.eclipse.pde.internal.ui.wizards.plugin.TemplateListSelectionPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+/**
+ * Content wizard page for the New Plugin Project wizard (page 2)
+ */
+public class PluginContentPage extends ContentPage {
+ private Text fClassText;
+ protected Button fGenerateActivator;
+ protected Button fUIPlugin;
+ private Label fClassLabel;
+ private Label fEELabel;
+ private Button fExeEnvButton;
+ private Combo fEEChoice;
+
+ /**
+ * Button to enable API analysis for the project during project creation
+ */
+ private Button fApiAnalysisButton;
+
+ /**
+ * Dialog settings constants
+ */
+ private final static String S_GENERATE_ACTIVATOR = "generateActivator"; //$NON-NLS-1$
+ private final static String S_UI_PLUGIN = "uiPlugin"; //$NON-NLS-1$
+ private final static String S_RCP_PLUGIN = "rcpPlugin"; //$NON-NLS-1$
+ private final static String S_API_ANALYSIS = "apiAnalysis"; //$NON-NLS-1$
+
+ protected final static int P_CLASS_GROUP = 2;
+ private final static String NO_EXECUTION_ENVIRONMENT = PDEUIMessages.PluginContentPage_noEE;
+
+ /**
+ * default tText modify listener
+ */
+ private ModifyListener classListener = new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (fInitialized)
+ fChangedGroups |= P_CLASS_GROUP;
+ validatePage();
+ }
+ };
+
+ /**
+ * Constructor
+ * @param pageName
+ * @param provider
+ * @param page
+ * @param data
+ */
+ public PluginContentPage(String pageName, IProjectProvider provider, NewProjectCreationPage page, AbstractFieldData data) {
+ super(pageName, provider, page, data);
+ setTitle(PDEUIMessages.ContentPage_title);
+ setDescription(PDEUIMessages.ContentPage_desc);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.internal.ui.wizards.plugin.ContentPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NONE);
+ container.setLayout(new GridLayout());
+
+ createPluginPropertiesGroup(container);
+ createPluginClassGroup(container);
+
+ Dialog.applyDialogFont(container);
+ setControl(container);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.NEW_PROJECT_REQUIRED_DATA);
+ }
+
+ /**
+ * Creates all of the plugin properties widgets
+ * @param container
+ */
+ private void createPluginPropertiesGroup(Composite container) {
+ Group propertiesGroup = SWTFactory.createGroup(container, PDEUIMessages.ContentPage_pGroup, 3, 1, GridData.FILL_HORIZONTAL);
+
+ Label label = new Label(propertiesGroup, SWT.NONE);
+ label.setText(PDEUIMessages.ContentPage_pid);
+ fIdText = createText(propertiesGroup, propertiesListener, 2);
+
+ label = new Label(propertiesGroup, SWT.NONE);
+ label.setText(PDEUIMessages.ContentPage_pversion);
+ fVersionText = createText(propertiesGroup, propertiesListener, 2);
+
+ label = new Label(propertiesGroup, SWT.NONE);
+ label.setText(PDEUIMessages.ContentPage_pname);
+ fNameText = createText(propertiesGroup, propertiesListener, 2);
+
+ label = new Label(propertiesGroup, SWT.NONE);
+ label.setText(PDEUIMessages.ContentPage_pprovider);
+ fProviderText = createText(propertiesGroup, propertiesListener, 2);
+
+ createExecutionEnvironmentControls(propertiesGroup);
+ }
+
+ /**
+ * Creates all of the EE widgets
+ * @param container
+ */
+ private void createExecutionEnvironmentControls(Composite container) {
+ // Create label
+ fEELabel = new Label(container, SWT.NONE);
+ fEELabel.setText(PDEUIMessages.NewProjectCreationPage_executionEnvironments_label);
+
+ // Create combo
+ fEEChoice = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
+ fEEChoice.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // Gather EEs
+ IExecutionEnvironment[] exeEnvs = VMUtil.getExecutionEnvironments();
+ TreeSet availableEEs = new TreeSet();
+ for (int i = 0; i < exeEnvs.length; i++) {
+ availableEEs.add(exeEnvs[i].getId());
+ }
+ availableEEs.add(NO_EXECUTION_ENVIRONMENT);
+
+ // Set data
+ fEEChoice.setItems((String[]) availableEEs.toArray(new String[availableEEs.size() - 1]));
+ fEEChoice.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ validatePage();
+ }
+ });
+
+ // Set default EE based on strict match to default VM
+ IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall();
+ String[] EEChoices = fEEChoice.getItems();
+ for (int i = 0; i < EEChoices.length; i++) {
+ if (!EEChoices[i].equals(NO_EXECUTION_ENVIRONMENT)) {
+ if (VMUtil.getExecutionEnvironment(EEChoices[i]).isStrictlyCompatible(defaultVM)) {
+ fEEChoice.select(i);
+ break;
+ }
+ }
+ }
+
+ // Create button
+ fExeEnvButton = new Button(container, SWT.PUSH);
+ fExeEnvButton.setLayoutData(new GridData());
+ fExeEnvButton.setText(PDEUIMessages.NewProjectCreationPage_environmentsButton);
+ fExeEnvButton.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ PreferencesUtil.createPreferenceDialogOn(getShell(), "org.eclipse.jdt.debug.ui.jreProfiles", //$NON-NLS-1$
+ new String[] {"org.eclipse.jdt.debug.ui.jreProfiles"}, null).open(); //$NON-NLS-1$
+ }
+ });
+ }
+
+ /**
+ * Creates all of the plugin options widgets
+ * @param container
+ */
+ protected void createPluginClassGroup(Composite container) {
+ Group classGroup = SWTFactory.createGroup(container, PDEUIMessages.ContentPage_pClassGroup, 2, 1, GridData.FILL_HORIZONTAL);
+
+ IDialogSettings settings = getDialogSettings();
+
+ fGenerateActivator = SWTFactory.createCheckButton(classGroup, PDEUIMessages.ContentPage_generate, null, (settings != null) ? !settings.getBoolean(S_GENERATE_ACTIVATOR) : true, 2);
+ fGenerateActivator.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ fClassLabel.setEnabled(fGenerateActivator.getSelection());
+ fClassText.setEnabled(fGenerateActivator.getSelection());
+ updateData();
+ validatePage();
+ }
+ });
+
+ fClassLabel = new Label(classGroup, SWT.NONE);
+ fClassLabel.setText(PDEUIMessages.ContentPage_classname);
+ GridData gd = new GridData();
+ gd.horizontalIndent = 20;
+ fClassLabel.setLayoutData(gd);
+ fClassText = createText(classGroup, classListener);
+
+ fUIPlugin = SWTFactory.createCheckButton(classGroup, PDEUIMessages.ContentPage_uicontribution, null, (settings != null) ? !settings.getBoolean(S_UI_PLUGIN) : true, 2);
+ fUIPlugin.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ updateData();
+ validatePage();
+ }
+ });
+
+ fApiAnalysisButton = SWTFactory.createCheckButton(classGroup, PDEUIMessages.PluginContentPage_enable_api_analysis, null, false, 2);
+ fApiAnalysisButton.setSelection((settings != null) ? settings.getBoolean(S_API_ANALYSIS) : false);
+ fApiAnalysisButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ updateData();
+ validatePage();
+ }
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.internal.ui.wizards.plugin.ContentPage#updateData()
+ */
+ public void updateData() {
+ super.updateData();
+ PluginFieldData data = (PluginFieldData) fData;
+ data.setClassname(fClassText.getText().trim());
+ data.setUIPlugin(fUIPlugin.getSelection());
+ data.setDoGenerateClass(fGenerateActivator.getSelection());
+ data.setRCPApplicationPlugin(!fData.isSimple() && !isPureOSGi());
+ data.setEnableAPITooling(fApiAnalysisButton.getSelection());
+ if (fEEChoice.isEnabled() && !fEEChoice.getText().equals(NO_EXECUTION_ENVIRONMENT)) {
+ fData.setExecutionEnvironment(fEEChoice.getText().trim());
+ } else {
+ fData.setExecutionEnvironment(null);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.internal.ui.wizards.plugin.ContentPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ if (visible) {
+ fMainPage.updateData();
+ fGenerateActivator.setSelection(!fData.isSimple());
+ fGenerateActivator.setEnabled(!fData.isSimple());
+ fClassLabel.setEnabled(!fData.isSimple() && fGenerateActivator.getSelection());
+ fClassText.setEnabled(!fData.isSimple() && fGenerateActivator.getSelection());
+ boolean wasUIPluginEnabled = fUIPlugin.isEnabled();
+ fUIPlugin.setEnabled(!fData.isSimple() && !isPureOSGi());
+ // if fUIPlugin is disabled, set selection to false
+ if (!fUIPlugin.isEnabled()) {
+ fUIPlugin.setSelection(false);
+ }
+ // if the fUIPlugin was disabled and is now enabled, then set the selection to true
+ else if (!wasUIPluginEnabled) {
+ fUIPlugin.setSelection(true);
+ }
+
+ // plugin class group
+ if (((fChangedGroups & P_CLASS_GROUP) == 0)) {
+ int oldfChanged = fChangedGroups;
+ fClassText.setText(computeId().replaceAll("-", "_").toLowerCase(Locale.ENGLISH) + ".Activator"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ fChangedGroups = oldfChanged;
+ }
+
+ boolean allowEESelection = !fData.isSimple() && fData.hasBundleStructure();
+ fEELabel.setEnabled(allowEESelection);
+ fEEChoice.setEnabled(allowEESelection);
+ fExeEnvButton.setEnabled(allowEESelection);
+ // API tooling only works for osgi bundles with java natures
+ fApiAnalysisButton.setEnabled(allowEESelection);
+ if (allowEESelection && getDialogSettings() != null) {
+ fApiAnalysisButton.setSelection(getDialogSettings().getBoolean(S_API_ANALYSIS));
+ } else {
+ fApiAnalysisButton.setSelection(false);
+ }
+ }
+ super.setVisible(visible);
+ }
+
+ /**
+ * @return if the field data is using the OSGi framework
+ */
+ private boolean isPureOSGi() {
+ return ((PluginFieldData) fData).getOSGiFramework() != null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.internal.ui.wizards.plugin.ContentPage#validatePage()
+ */
+ protected void validatePage() {
+ String errorMessage = validateProperties();
+ if (errorMessage == null && fGenerateActivator.getSelection()) {
+ IStatus status = JavaConventions.validateJavaTypeName(fClassText.getText().trim(), PDEJavaHelper.getJavaSourceLevel(null), PDEJavaHelper.getJavaComplianceLevel(null));
+ if (status.getSeverity() == IStatus.ERROR) {
+ errorMessage = status.getMessage();
+ } else if (status.getSeverity() == IStatus.WARNING) {
+ setMessage(status.getMessage(), IMessageProvider.WARNING);
+ }
+ }
+ if (errorMessage == null) {
+ String eeid = fEEChoice.getText();
+ if (fEEChoice.isEnabled()) {
+ IExecutionEnvironment ee = VMUtil.getExecutionEnvironment(eeid);
+ if (ee != null && ee.getCompatibleVMs().length == 0) {
+ errorMessage = PDEUIMessages.NewProjectCreationPage_invalidEE;
+ }
+ }
+ }
+ setErrorMessage(errorMessage);
+ setPageComplete(errorMessage == null);
+ }
+
+ /**
+ * Saves the current state of widgets of interest in the dialog settings for the wizard
+ * @param settings
+ */
+ public void saveSettings(IDialogSettings settings) {
+ settings.put(S_GENERATE_ACTIVATOR, !fGenerateActivator.getSelection());
+ if (fUIPlugin.isEnabled()) {
+ settings.put(S_UI_PLUGIN, !fUIPlugin.getSelection());
+ }
+ if (fApiAnalysisButton.isEnabled()) {
+ settings.put(S_API_ANALYSIS, fApiAnalysisButton.getSelection());
+ }
+ settings.put(S_RCP_PLUGIN, true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage()
+ */
+ public boolean canFlipToNextPage() {
+ if (getNextPage() instanceof TemplateListSelectionPage) {
+ TemplateListSelectionPage templatePage = (TemplateListSelectionPage) getNextPage();
+ return super.canFlipToNextPage() && templatePage.isAnyTemplateAvailable();
+ }
+ return super.canFlipToNextPage();
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/ResourceLocator.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/ResourceLocator.java
new file mode 100644
index 00000000..1e2c5e29
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/ResourceLocator.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 Soyatec (http://www.soyatec.com) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Soyatec - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.internal.tools.wizards.project;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.e4.internal.tools.ToolsPlugin;
+
+public class ResourceLocator {
+ private static final String TEMPLATE_FOLDER = "templates";
+
+ private static ResourceLocator instance = new ResourceLocator();
+
+ private ResourceLocator() {
+ }
+
+ public static ResourceLocator getInstance() {
+ return instance;
+ }
+
+ public static URL getProjectTemplateFiles(String folder)
+ throws IOException {
+ Plugin plugin = getResorucePlugin();
+ URL installURL = plugin.getBundle().getEntry(
+ "/" + TEMPLATE_FOLDER + "/" + folder);
+ // FileLocator.toFileURL(installURL);
+ URL corePath = FileLocator.resolve(installURL);
+ return corePath;
+ }
+
+ public static URL getFile(String relativePath) throws IOException {
+ Plugin plugin = getResorucePlugin();
+ URL installURL = plugin.getBundle().getEntry(relativePath);
+ URL corePath = FileLocator.resolve(installURL);
+ return corePath;
+ }
+
+ public static Plugin getResorucePlugin() {
+ return ToolsPlugin.getDefault();
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/TemplateOperation.java b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/TemplateOperation.java
new file mode 100644
index 00000000..3546db57
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/TemplateOperation.java
@@ -0,0 +1,401 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 Soyatec (http://www.soyatec.com) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Soyatec - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.internal.tools.wizards.project;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.e4.internal.tools.ToolsPlugin;
+import org.eclipse.pde.internal.ui.PDEUIMessages;
+import org.eclipse.pde.ui.templates.IVariableProvider;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+public class TemplateOperation extends WorkspaceModifyOperation implements
+ IVariableProvider {
+
+ private final URL templateDirectory;
+ private final IContainer target;
+ private final Map<String, String> keys;
+ private final Set<String> binaryExtentions;
+
+ public TemplateOperation(URL source, IContainer target,
+ Map<String, String> keys, Set<String> binaryExtentions) {
+ templateDirectory = source;
+ this.binaryExtentions = binaryExtentions;
+ this.target = target;
+ this.keys = keys;
+ }
+
+ @Override
+ protected void execute(IProgressMonitor monitor) throws CoreException,
+ InvocationTargetException, InterruptedException {
+ monitor.setTaskName(PDEUIMessages.AbstractTemplateSection_generating);
+
+ if ("jar".equals(templateDirectory.getProtocol())) { //$NON-NLS-1$
+ String file = templateDirectory.getFile();
+ int exclamation = file.indexOf('!');
+ if (exclamation < 0)
+ return;
+ URL fileUrl = null;
+ try {
+ fileUrl = new URL(file.substring(0, exclamation));
+ } catch (MalformedURLException mue) {
+ ToolsPlugin.logError(mue);
+ return;
+ }
+ File pluginJar = new File(fileUrl.getFile());
+ if (!pluginJar.exists())
+ return;
+ String templateDirectory = file.substring(exclamation + 1); // "/some/path/"
+ IPath path = new Path(templateDirectory);
+ ZipFile zipFile = null;
+ try {
+ zipFile = new ZipFile(pluginJar);
+ generateFiles(zipFile, path, target, monitor);
+ } catch (ZipException ze) {
+ } catch (IOException ioe) {
+ } finally {
+ if (zipFile != null) {
+ try {
+ zipFile.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ } else if ("file".equals(templateDirectory.getProtocol())) { //$NON-NLS-1$
+ File directory = new File(templateDirectory.getFile());
+ if (!directory.exists())
+ return;
+ generateFiles(directory, target, true, monitor);
+ }
+ }
+
+ private void generateFiles(File src, IContainer dst, boolean firstLevel,
+ IProgressMonitor monitor) throws CoreException {
+ File[] members = src.listFiles();
+
+ for (int i = 0; i < members.length; i++) {
+ File member = members[i];
+ String name = member.getName();
+ if (member.isDirectory()) {
+ if (".svn".equals(name) || "cvs".equalsIgnoreCase(name))
+ continue;
+ IContainer dstContainer = null;
+
+ if (dstContainer == null) {
+ String folderName = getProcessedString(name, name);
+ dstContainer = dst.getFolder(new Path(folderName));
+ }
+ if (dstContainer != null && !dstContainer.exists())
+ ((IFolder) dstContainer).create(true, true, monitor);
+ generateFiles(member, dstContainer, false, monitor);
+ } else {
+ InputStream in = null;
+ try {
+ in = new FileInputStream(member);
+ copyFile(name, in, dst, monitor);
+ } catch (IOException ioe) {
+ } finally {
+ if (in != null)
+ try {
+ in.close();
+ } catch (IOException ioe2) {
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ *
+ * @param zipFile
+ * @param path
+ * @param dst
+ * @param monitor
+ * @throws CoreException
+ */
+ private void generateFiles(ZipFile zipFile, IPath path, IContainer dst,
+ IProgressMonitor monitor) throws CoreException {
+ int pathLength = path.segmentCount();
+ // Immidiate children
+ Map childZipEntries = new HashMap(); // "dir/" or "dir/file.java"
+
+ for (Enumeration zipEntries = zipFile.entries(); zipEntries
+ .hasMoreElements();) {
+ ZipEntry zipEntry = (ZipEntry) zipEntries.nextElement();
+ IPath entryPath = new Path(zipEntry.getName());
+ if (entryPath.segmentCount() <= pathLength) {
+ // ancestor or current directory
+ continue;
+ }
+ if (!path.isPrefixOf(entryPath)) {
+ // not a descendant
+ continue;
+ }
+ if (entryPath.segmentCount() == pathLength + 1) {
+ childZipEntries.put(zipEntry.getName(), zipEntry);
+ } else {
+ String name = entryPath.uptoSegment(pathLength + 1)
+ .addTrailingSeparator().toString();
+ if (!childZipEntries.containsKey(name)) {
+ ZipEntry dirEntry = new ZipEntry(name);
+ childZipEntries.put(name, dirEntry);
+ }
+ }
+ }
+
+ for (Iterator it = childZipEntries.values().iterator(); it.hasNext();) {
+ ZipEntry zipEnry = (ZipEntry) it.next();
+ String name = new Path(zipEnry.getName()).lastSegment().toString();
+ if (zipEnry.isDirectory()) {
+ IContainer dstContainer = null;
+
+ if (dstContainer == null) {
+ String folderName = getProcessedString(name, name);
+ dstContainer = dst.getFolder(new Path(folderName));
+ }
+ if (dstContainer != null && !dstContainer.exists())
+ ((IFolder) dstContainer).create(true, true, monitor);
+ generateFiles(zipFile, path.append(name), dstContainer, monitor);
+ } else {
+ InputStream in = null;
+ try {
+ in = zipFile.getInputStream(zipEnry);
+ copyFile(name, in, dst, monitor);
+ } catch (IOException ioe) {
+ } finally {
+ if (in != null)
+ try {
+ in.close();
+ } catch (IOException ioe2) {
+ }
+ }
+ }
+ }
+ }
+
+ private void copyFile(String fileName, InputStream input, IContainer dst,
+ IProgressMonitor monitor) throws CoreException {
+ String targetFileName = getProcessedString(fileName, fileName);
+
+ monitor.subTask(targetFileName);
+ IFile dstFile = dst.getFile(new Path(targetFileName));
+
+ try {
+ InputStream stream = isBinary(fileName) ? input
+ : getProcessedStream(fileName, input);
+ if (dstFile.exists()) {
+ dstFile.setContents(stream, true, true, monitor);
+ } else {
+ dstFile.create(stream, true, monitor);
+ }
+ stream.close();
+
+ } catch (IOException e) {
+ }
+ }
+
+ protected void copyFile(String fileName, InputStream input, IContainer dst,
+ final String destPath, IProgressMonitor monitor)
+ throws CoreException {
+ String targetFileName = null;
+ if (destPath == null) {
+ targetFileName = getProcessedString(fileName, fileName);
+ } else {
+ targetFileName = destPath;
+ }
+
+ monitor.subTask(targetFileName);
+ IFile dstFile = dst.getFile(new Path(targetFileName));
+
+ try {
+ InputStream stream = isBinary(fileName) ? input
+ : getProcessedStream(fileName, input);
+ if (dstFile.exists()) {
+ dstFile.setContents(stream, true, true, monitor);
+ } else {
+ dstFile.create(stream, true, monitor);
+ }
+ stream.close();
+
+ } catch (IOException e) {
+ }
+ }
+
+ /**
+ *
+ * @param fileName
+ * @param input
+ * @param dst
+ * @param basePath
+ * @param monitor
+ * @throws CoreException
+ */
+ public void copyFile(String fileName, InputStream input, IContainer dst,
+ final String basePath, final String destName,
+ IProgressMonitor monitor) throws CoreException {
+ if (basePath == null || basePath.equals("")) {
+ copyFile(fileName, input, dst, monitor);
+ }
+
+ String targetFileName = destName == null ? getProcessedString(fileName,
+ fileName) : destName;
+
+ monitor.subTask(targetFileName);
+ IFile dstFile = dst.getFile(new Path(basePath + targetFileName));
+
+ try {
+ InputStream stream = isBinary(fileName) ? input
+ : getProcessedStream(fileName, input);
+ if (dstFile.exists()) {
+ dstFile.setContents(stream, true, true, monitor);
+ } else {
+ dstFile.create(stream, true, monitor);
+ }
+ stream.close();
+
+ } catch (IOException e) {
+ }
+ }
+
+ private boolean isBinary(String fileName) {
+ if (binaryExtentions == null) {
+ return false;
+ }
+
+ String ext = getfileExtention(fileName);
+ if (ext == null)
+ return false;
+ return binaryExtentions.contains(ext);
+ }
+
+ private String getfileExtention(String name) {
+ int indexOf = name.lastIndexOf('.');
+ if (indexOf == -1)
+ return null;
+ return name.substring(indexOf);
+ }
+
+ private InputStream getProcessedStream(String fileName, InputStream stream)
+ throws IOException, CoreException {
+ InputStreamReader reader = new InputStreamReader(stream);
+ int bufsize = 1024;
+ char[] cbuffer = new char[bufsize];
+ int read = 0;
+ StringBuffer keyBuffer = new StringBuffer();
+ StringBuffer outBuffer = new StringBuffer();
+
+ boolean replacementMode = false;
+ boolean almostReplacementMode = false;
+ boolean escape = false;
+ while (read != -1) {
+ read = reader.read(cbuffer);
+ for (int i = 0; i < read; i++) {
+ char c = cbuffer[i];
+
+ if (escape) {
+ StringBuffer buf = outBuffer;
+ buf.append(c);
+ escape = false;
+ continue;
+ }
+
+ if (c == '@') {
+ if (replacementMode && almostReplacementMode) {
+ almostReplacementMode = false;
+ } else if (replacementMode) {
+ replacementMode = false;
+ String key = keyBuffer.toString();
+ String value = key.length() == 0 ? "@@" //$NON-NLS-1$
+ : getReplacementString(key);
+ outBuffer.append(value);
+ keyBuffer.delete(0, keyBuffer.length());
+ } else if (almostReplacementMode) {
+ replacementMode = true;
+ } else {
+ almostReplacementMode = true;
+ }
+ } else {
+ if (replacementMode)
+ keyBuffer.append(c);
+ else {
+ if (almostReplacementMode)
+ outBuffer.append('@');
+ outBuffer.append(c);
+ almostReplacementMode = false;
+ }
+ }
+ }
+ }
+ return new ByteArrayInputStream(outBuffer.toString().getBytes());
+ // return new
+ // ByteArrayInputStream(outBuffer.toString().getBytes(project.
+ // getDefaultCharset()));
+ }
+
+ private String getProcessedString(String fileName, String source) {
+ if (source.indexOf('$') == -1)
+ return source;
+ int loc = -1;
+ StringBuffer buffer = new StringBuffer();
+ boolean replacementMode = false;
+ for (int i = 0; i < source.length(); i++) {
+ char c = source.charAt(i);
+ if (c == '$') {
+ if (replacementMode) {
+ String key = source.substring(loc, i);
+ String value = key.length() == 0 ? "$" : getReplacementString(key); //$NON-NLS-1$
+ buffer.append(value);
+ replacementMode = false;
+ } else {
+ replacementMode = true;
+ loc = i + 1;
+ continue;
+ }
+ } else if (!replacementMode)
+ buffer.append(c);
+ }
+ return buffer.toString();
+ }
+
+ public String getReplacementString(String key) {
+ String result = keys.get(key);
+ return result != null ? result : key;
+ }
+
+ public Object getValue(String variable) {
+ return getReplacementString(variable);
+ }
+
+}
diff --git a/bundles/org.eclipse.e4.tools/templates/common/$projectName$.product b/bundles/org.eclipse.e4.tools/templates/common/$projectName$.product
new file mode 100644
index 00000000..d91c3d09
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/templates/common/$projectName$.product
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?pde version="3.5"?>
+
+<product name="@@projectName@@" id="@@projectName@@.product" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="1.0.0.qualifier" useFeatures="false" includeLaunchers="true">
+
+ <configIni use="default">
+ </configIni>
+
+ <launcherArgs>
+ <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
+ </launcherArgs>
+
+ <windowImages/>
+
+ <plugins>
+ <plugin id="@@projectName@@"/>
+ <plugin id="com.ibm.icu"/>
+ <plugin id="javax.inject"/>
+ <plugin id="org.apache.batik.css"/>
+ <plugin id="org.apache.batik.util"/>
+ <plugin id="org.apache.batik.util.gui"/>
+ <plugin id="org.apache.commons.beanutils"/>
+ <plugin id="org.apache.commons.logging"/>
+ <plugin id="org.eclipse.core.commands"/>
+ <plugin id="org.eclipse.core.contenttype"/>
+ <plugin id="org.eclipse.core.databinding"/>
+ <plugin id="org.eclipse.core.databinding.beans"/>
+ <plugin id="org.eclipse.core.databinding.observable"/>
+ <plugin id="org.eclipse.core.databinding.property"/>
+ <plugin id="org.eclipse.core.expressions"/>
+ <plugin id="org.eclipse.core.filesystem"/>
+ <plugin id="org.eclipse.core.filesystem.win32.x86" fragment="true"/>
+ <plugin id="org.eclipse.core.jobs"/>
+ <plugin id="org.eclipse.core.resources"/>
+ <plugin id="org.eclipse.core.resources.win32.x86" fragment="true"/>
+ <plugin id="org.eclipse.core.runtime"/>
+ <plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/>
+ <plugin id="org.eclipse.e4.core.commands"/>
+ <plugin id="org.eclipse.e4.core.services"/>
+ <plugin id="org.eclipse.e4.core.services.annotations" fragment="true"/>
+ <plugin id="org.eclipse.e4.ui.bindings"/>
+ <plugin id="org.eclipse.e4.ui.css.core"/>
+ <plugin id="org.eclipse.e4.ui.css.nebula"/>
+ <plugin id="org.eclipse.e4.ui.css.swt"/>
+ <plugin id="org.eclipse.e4.ui.di"/>
+ <plugin id="org.eclipse.e4.ui.model.workbench"/>
+ <plugin id="org.eclipse.e4.ui.services"/>
+ <plugin id="org.eclipse.e4.ui.workbench"/>
+ <plugin id="org.eclipse.e4.ui.workbench.renderers.swt"/>
+ <plugin id="org.eclipse.e4.ui.workbench.swt"/>
+ <plugin id="org.eclipse.e4.ui.workbench3"/>
+ <plugin id="org.eclipse.emf.common"/>
+ <plugin id="org.eclipse.emf.databinding"/>
+ <plugin id="org.eclipse.emf.ecore"/>
+ <plugin id="org.eclipse.emf.ecore.change"/>
+ <plugin id="org.eclipse.emf.ecore.xmi"/>
+ <plugin id="org.eclipse.equinox.app"/>
+ <plugin id="org.eclipse.equinox.common"/>
+ <plugin id="org.eclipse.equinox.concurrent"/>
+ <plugin id="org.eclipse.equinox.ds"/>
+ <plugin id="org.eclipse.equinox.event"/>
+ <plugin id="org.eclipse.equinox.preferences"/>
+ <plugin id="org.eclipse.equinox.registry"/>
+ <plugin id="org.eclipse.equinox.util"/>
+ <plugin id="org.eclipse.jface"/>
+ <plugin id="org.eclipse.jface.databinding"/>
+ <plugin id="org.eclipse.nebula.widgets.gallery"/>
+ <plugin id="org.eclipse.osgi"/>
+ <plugin id="org.eclipse.osgi.services"/>
+ <plugin id="org.eclipse.swt"/>
+ <plugin id="org.eclipse.swt.win32.win32.x86" fragment="true"/>
+ <plugin id="org.pushingpixels.trident"/>
+ <plugin id="org.w3c.css.sac"/>
+ <plugin id="org.w3c.dom.smil"/>
+ <plugin id="org.w3c.dom.svg"/>
+ </plugins>
+
+
+</product>
diff --git a/bundles/org.eclipse.e4.tools/templates/common/icons/sample.gif b/bundles/org.eclipse.e4.tools/templates/common/icons/sample.gif
new file mode 100644
index 00000000..34fb3c9d
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/templates/common/icons/sample.gif
Binary files differ
diff --git a/bundles/org.eclipse.e4.tools/templates/common/icons/save_edit.gif b/bundles/org.eclipse.e4.tools/templates/common/icons/save_edit.gif
new file mode 100644
index 00000000..499dd0ca
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/templates/common/icons/save_edit.gif
Binary files differ
diff --git a/bundles/org.eclipse.e4.tools/templates/css/default.css b/bundles/org.eclipse.e4.tools/templates/css/default.css
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/templates/css/default.css
diff --git a/bundles/org.eclipse.e4.tools/templates/handler.txtjet b/bundles/org.eclipse.e4.tools/templates/handler.txtjet
new file mode 100644
index 00000000..27c7d75d
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/templates/handler.txtjet
@@ -0,0 +1,22 @@
+<%@ jet package="org.eclipse.e4.internal.tools.wizards.classes.templates" class="HandlerTemplate" imports="org.eclipse.e4.internal.tools.wizards.classes.NewHandlerClassWizard.HandlerClass" %>
+<% HandlerClass domainClass = (HandlerClass)argument; %>
+package <%= domainClass.getPackageFragment().getElementName() %>;
+
+import org.eclipse.e4.core.di.annotations.Execute;
+<% if( domainClass.isUseCanExecute() ) { %>
+import org.eclipse.e4.core.di.annotations.CanExecute;
+<% } %>
+
+public class <%= domainClass.getName() %> {
+ @Execute
+ public void <%= domainClass.getExecuteMethodName() %>() {
+ //TODO Your code goes here
+ }
+ <% if( domainClass.isUseCanExecute() ) { %>
+
+ @CanExecute
+ public boolean <%= domainClass.getCanExecuteMethodName() %>() {
+ //TODO Your code goes here
+ }
+ <% } %>
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools/templates/part.txtjet b/bundles/org.eclipse.e4.tools/templates/part.txtjet
new file mode 100644
index 00000000..03a2b1b6
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/templates/part.txtjet
@@ -0,0 +1,48 @@
+<%@ jet package="org.eclipse.e4.internal.tools.wizards.classes.templates" class="PartTemplate" imports="org.eclipse.e4.internal.tools.wizards.classes.NewPartClassWizard.PartClass" %>
+<% PartClass domainClass = (PartClass)argument; %>
+package <%= domainClass.getPackageFragment().getElementName() %>;
+
+import javax.inject.Inject;
+<% if( domainClass.isUsePostConstruct() ) { %>
+import javax.annotation.PostConstruct;
+<% } %>
+<% if( domainClass.isUsePredestroy() ) { %>
+import javax.annotation.PreDestroy;
+<% } %>
+<% if( domainClass.isUseFocus() ) { %>
+import org.eclipse.e4.ui.di.Focus;
+<% } %>
+<% if( domainClass.isUsePersist() ) { %>
+import org.eclipse.e4.ui.di.Persist;
+<% } %>
+
+public class <%= domainClass.getName() %> {
+ @Inject
+ public <%= domainClass.getName() %>() {
+ //TODO Your code here
+ }
+ <% if( domainClass.isUsePostConstruct() ) { %>
+ @PostConstruct
+ public void <%= domainClass.getPostConstructMethodName() %>() {
+ //TODO Your code here
+ }
+ <% } %>
+ <% if( domainClass.isUsePredestroy() ) { %>
+ @PreDestroy
+ public void <%= domainClass.getPreDestroyMethodName() %>() {
+ //TODO Your code here
+ }
+ <% } %>
+ <% if( domainClass.isUseFocus() ) { %>
+ @Focus
+ public void <%= domainClass.getFocusMethodName() %>() {
+ //TODO Your code here
+ }
+ <% } %>
+ <% if( domainClass.isUsePersist() ) { %>
+ @Persist
+ public void <%= domainClass.getPersistMethodName() %>() {
+ //TODO Your code here
+ }
+ <% } %>
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools/templates/src/handlers/AboutHandler.java b/bundles/org.eclipse.e4.tools/templates/src/handlers/AboutHandler.java
new file mode 100644
index 00000000..c9f6a86a
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/templates/src/handlers/AboutHandler.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package @@packageName@@;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+
+public class AboutHandler {
+ @Execute
+ public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell) {
+ MessageDialog.openInformation(shell, "About", "e4 Application example.");
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/templates/src/handlers/OpenHandler.java b/bundles/org.eclipse.e4.tools/templates/src/handlers/OpenHandler.java
new file mode 100644
index 00000000..46d423ce
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/templates/src/handlers/OpenHandler.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package @@packageName@@;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+
+public class OpenHandler {
+
+ @Execute
+ public void execute(
+ IEclipseContext context,
+ @Named(IServiceConstants.ACTIVE_SHELL) Shell shell)
+ throws InvocationTargetException, InterruptedException {
+ FileDialog dialog = new FileDialog(shell);
+ dialog.open();
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/templates/src/handlers/QuitHandler.java b/bundles/org.eclipse.e4.tools/templates/src/handlers/QuitHandler.java
new file mode 100644
index 00000000..0c1337bb
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/templates/src/handlers/QuitHandler.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package @@packageName@@;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.e4.ui.workbench.IWorkbench;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+
+public class QuitHandler {
+ @Execute
+ public void execute(IWorkbench workbench, IEclipseContext context,
+ @Named(IServiceConstants.ACTIVE_SHELL) Shell shell)
+ throws InvocationTargetException, InterruptedException {
+ if (MessageDialog.openConfirm(shell, "Confirmation",
+ "Do you want to exit?")) {
+ workbench.close();
+ }
+ }
+}
diff --git a/bundles/org.eclipse.e4.tools/templates/src/handlers/SaveHandler.java b/bundles/org.eclipse.e4.tools/templates/src/handlers/SaveHandler.java
new file mode 100644
index 00000000..c1e49cdf
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools/templates/src/handlers/SaveHandler.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package @@packageName@@;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.inject.Named;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.e4.core.contexts.ContextInjectionFactory;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.di.IDisposable;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.core.di.annotations.CanExecute;
+import org.eclipse.e4.ui.model.application.MContribution;
+import org.eclipse.e4.ui.model.application.ui.MDirtyable;
+import org.eclipse.e4.ui.services.IServiceConstants;
+//import org.eclipse.e4.ui.workbench.Persist;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.widgets.Shell;
+
+public class SaveHandler {
+ @CanExecute
+ public boolean canExecute(
+ @Named(IServiceConstants.ACTIVE_PART) MDirtyable dirtyable) {
+ if (dirtyable == null) {
+ return false;
+ }
+ return dirtyable.isDirty();
+ }
+
+ @Execute
+ public void execute(
+ IEclipseContext context,
+ @Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
+ @Named(IServiceConstants.ACTIVE_PART) final MContribution contribution)
+ throws InvocationTargetException, InterruptedException {
+ final IEclipseContext pmContext = context.createChild();
+
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
+ dialog.open();
+ dialog.run(true, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ pmContext.set(IProgressMonitor.class.getName(), monitor);
+ if (contribution != null) {
+ Object clientObject = contribution.getObject();
+// ContextInjectionFactory.invoke(clientObject, Persist.class, //$NON-NLS-1$
+// pmContext, null);
+ }
+ }
+ });
+
+ if (pmContext instanceof IDisposable) {
+ ((IDisposable) pmContext).dispose();
+ }
+ }
+}

Back to the top