Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Spungin2014-08-06 00:32:29 +0000
committerSteven Spungin2014-08-06 07:58:03 +0000
commit3f4e765c597ea8720f3e510fbb88f3d3edd38bf2 (patch)
treed08c001589091c9bbdfd62265197cb38ec013002
parent524f4fc3c336b68531f70ab481ff4aed906f33b6 (diff)
downloadorg.eclipse.e4.tools-3f4e765c597ea8720f3e510fbb88f3d3edd38bf2.tar.gz
org.eclipse.e4.tools-3f4e765c597ea8720f3e510fbb88f3d3edd38bf2.tar.xz
org.eclipse.e4.tools-3f4e765c597ea8720f3e510fbb88f3d3edd38bf2.zip
Bug 438591 - [tooling] Add option to generate lifecycle class whenI20140807-2200I20140806-2200I20140806-0900
creating application Change-Id: Ib84106a2777bbd422acc197057b5573ffbd0404c Signed-off-by: Steven Spungin <steven@spungin.tv>
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/E4NewProjectWizard.java38
-rw-r--r--bundles/org.eclipse.e4.tools/src/org/eclipse/e4/internal/tools/wizards/project/NewApplicationWizardPage.java61
2 files changed, 76 insertions, 23 deletions
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
index 256a3da6..355302a0 100644
--- 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
@@ -293,13 +293,15 @@ public class E4NewProjectWizard extends NewPluginProjectWizard {
cssValue);
}
- String lifeCycleValue = map
- .get(NewApplicationWizardPage.APPLICATION_LIFECYCLE_PROPERTY);
- if (lifeCycleValue != null) {
- lifeCycleValue = "bundleclass://" + fPluginData.getId() + "/"
- + fPluginData.getId().toLowerCase() + "." + lifeCycleValue;
- map.put(NewApplicationWizardPage.APPLICATION_LIFECYCLE_PROPERTY,
- lifeCycleValue);
+ if ("TRUE".equals(map.get(NewApplicationWizardPage.generateLifecycle))){
+ String lifeCycleValue = map
+ .get(NewApplicationWizardPage.generateLifecycleName);
+ if (lifeCycleValue != null && lifeCycleValue.isEmpty() == false) {
+ lifeCycleValue = "bundleclass://" + fPluginData.getId() + "/"
+ + fPluginData.getId().toLowerCase() + "." + lifeCycleValue;
+ map.put(NewApplicationWizardPage.LIFECYCLE_URI_PROPERTY,
+ lifeCycleValue);
+ }
}
extension.setPoint("org.eclipse.core.runtime.products");
@@ -333,6 +335,10 @@ public class E4NewProjectWizard extends NewPluginProjectWizard {
NewApplicationWizardPage.APPLICATION)
|| entry.getKey().equals(
NewApplicationWizardPage.richSample)
+ || entry.getKey().equals(
+ NewApplicationWizardPage.generateLifecycle)
+ || entry.getKey().equals(
+ NewApplicationWizardPage.generateLifecycleName)
|| entry.getKey()
.equals(NewApplicationWizardPage.CLEAR_PERSISTED_STATE)) {
continue;
@@ -374,15 +380,17 @@ public class E4NewProjectWizard extends NewPluginProjectWizard {
// them with underscores, product name does the same
String pluginName = fPluginData.getId();
- // BEGIN Generate E4Lifecycle class with annotations
- String classname = fPluginData.getId() + "." + map.get(NewApplicationWizardPage.APPLICATION_LIFECYCLE_PROPERTY);
- LifeCycleClassCodeGenerator fGenerator = new LifeCycleClassCodeGenerator(project, classname, fPluginData, false, getContainer());
- try {
- fGenerator.generate(new NullProgressMonitor());
- } catch (CoreException e2) {
- e2.printStackTrace();
+ // BEGIN Generate E4Lifecycle class with annotations
+ boolean lifeCycleCreated = "TRUE".equals(map.get(NewApplicationWizardPage.generateLifecycle));
+ if (lifeCycleCreated){
+ String classname = fPluginData.getId() + "." + map.get(NewApplicationWizardPage.generateLifecycleName);
+ LifeCycleClassCodeGenerator fGenerator = new LifeCycleClassCodeGenerator(project, classname, fPluginData, false, getContainer());
+ try {
+ fGenerator.generate(new NullProgressMonitor());
+ } catch (CoreException e2) {
+ e2.printStackTrace();
+ }
}
- boolean lifeCycleCreated = true;
// END Generate E4Lifecycle class with annotations
// If there's no Activator or LifeCycle created we create default package
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
index 1faac656..d52b3535 100644
--- 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
@@ -10,6 +10,7 @@
* IBM Corporation - ongoing enhancements
* Lars Vogel, vogella GmbH - ongoing enhancements
* Sopot Cela - ongoing enhancements
+ * Steven Spungin - ongoing enhancements, Bug 438591
*******************************************************************************/
package org.eclipse.e4.internal.tools.wizards.project;
@@ -24,8 +25,11 @@ import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
import org.eclipse.pde.internal.ui.wizards.plugin.AbstractFieldData;
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.events.SelectionListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.graphics.Color;
@@ -51,12 +55,15 @@ import org.eclipse.ui.branding.IProductConstants;
public class NewApplicationWizardPage extends WizardPage {
public static final String E4_APPLICATION = "org.eclipse.e4.ui.workbench.swt.E4Application";
public static final String APPLICATION_CSS_PROPERTY = "applicationCSS";
- public static final String APPLICATION_LIFECYCLE_PROPERTY = "lifeCycleURI";
+ public static final String LIFECYCLE_URI_PROPERTY = "lifeCycleURI";
public static final String PRODUCT_NAME = "productName";
public static final String APPLICATION = "application";
public static final String CLEAR_PERSISTED_STATE = "clearPersistedState";
public static final String EOL = System.getProperty("line.separator");
public static final String richSample = "RICH_SAMPLE";
+ public static final String generateLifecycle = "GENERATE_LIFECYCLE";
+ public static final String generateLifecycleName = "GENERATE_LIFECYCLE_NAME";
+
private final Map<String, String> data;
private IProject project;
@@ -67,6 +74,8 @@ public class NewApplicationWizardPage extends WizardPage {
private PropertyData[] PROPERTIES;
private Button richSampleCheckbox;
+ protected Button generateLifecycleClassCheckbox;
+ protected Text lifeCycleName;
protected NewApplicationWizardPage(IProjectProvider projectProvider,
AbstractFieldData pluginData) {
@@ -114,22 +123,60 @@ public class NewApplicationWizardPage extends WizardPage {
private Group createTemplateGroup(Composite parent) {
Group group = new Group(parent, SWT.NONE);
- group.setLayout(new GridLayout(1, false));
+ group.setLayout(new GridLayout(3, false));
group.setText("Template option");
-
+
richSampleCheckbox = new Button(group, SWT.CHECK);
-
+
richSampleCheckbox.setSelection(false);
richSampleCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- data.put(richSample, richSampleCheckbox.getSelection() ? "TRUE"
- : "FALSE");
+ data.put(richSample, richSampleCheckbox.getSelection() ? "TRUE" : "FALSE");
}
});
richSampleCheckbox.setText("Create sample content (parts, menu etc.)");
+ richSampleCheckbox.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, false, false, 2, 1));
+
+ {
+ SelectionListener listener= new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ lifeCycleName.setEnabled(generateLifecycleClassCheckbox.getSelection());
+ data.put(generateLifecycle, generateLifecycleClassCheckbox.getSelection() ? "TRUE" : "FALSE");
+ }
+ };
+
+ generateLifecycleClassCheckbox = new Button(group, SWT.CHECK);
+ generateLifecycleClassCheckbox.setSelection(false);
+
+ generateLifecycleClassCheckbox.setText("Create an e4 lifecycle annotated class");
+ generateLifecycleClassCheckbox.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, false, false, 2, 1));
+ generateLifecycleClassCheckbox.addSelectionListener(listener);
+
+ new Label(group, SWT.NONE);
+ Label lbl = new Label(group, SWT.NONE);
+ lbl.setText("LifeCycle class name:");
+ GridData gd = new GridData();
+ gd.horizontalIndent = 20;
+ lbl.setLayoutData(gd);
+
+ lifeCycleName = new Text(group, SWT.BORDER);
+ lifeCycleName.setText("E4LifeCycle");
+ lifeCycleName.setEnabled(false);
+ lifeCycleName.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ lifeCycleName.addModifyListener(new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ data.put(generateLifecycleName, lifeCycleName.getText());
+ }
+ });
+ data.put(generateLifecycleName, lifeCycleName.getText());
+ }
return group;
}
+
static class PropertyData {
private String name;
@@ -425,8 +472,6 @@ public class NewApplicationWizardPage extends WizardPage {
PROPERTIES = new PropertyData[] {
new PropertyData(APPLICATION_CSS_PROPERTY, "CSS Style:",
"css/default.css", String.class, true),
- new PropertyData(APPLICATION_LIFECYCLE_PROPERTY, "LifeCycle Class Name:",
- "E4LifeCycle", String.class, true),
new PropertyData(
IProductConstants.PREFERENCE_CUSTOMIZATION,
"Preference Customization:", "", String.class, true),

Back to the top