Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Prouvost2015-05-19 17:53:23 +0000
committerVikas Chandra2015-05-20 13:56:17 +0000
commitec9e7488d467797447f77273a775dade71b8fa17 (patch)
treebc1a7c3b2634b2e1f20ed54786bbc1c87bdb973e
parent2b41b30d45937de0dff7056779996d68eba255c8 (diff)
downloadeclipse.pde.ui-ec9e7488d467797447f77273a775dade71b8fa17.tar.gz
eclipse.pde.ui-ec9e7488d467797447f77273a775dade71b8fa17.tar.xz
eclipse.pde.ui-ec9e7488d467797447f77273a775dade71b8fa17.zip
Change-Id: Ic9890cc498d33a651fccf9cf46100d459bf35ae2 Signed-off-by: Olivier Prouvost <olivier.prouvost@opcoach.com> Also-by: Noopur Gupta <noopur_gupta@in.ibm.com> Also-by: Vikas Chandra <Vikas.Chandra@in.ibm.com>
-rw-r--r--ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ApplicationNewWizard.java49
-rw-r--r--ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ApplicationTemplate.java25
-rw-r--r--ui/org.eclipse.pde.ui.templates/templates_3.5/E4Application/java/$activator$.java30
-rw-r--r--ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF2
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/plugin/PluginClassCodeGenerator.java5
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/plugin/PluginFieldData.java12
6 files changed, 38 insertions, 85 deletions
diff --git a/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ApplicationNewWizard.java b/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ApplicationNewWizard.java
index 257c500c12..8a37b38d9b 100644
--- a/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ApplicationNewWizard.java
+++ b/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ApplicationNewWizard.java
@@ -1,19 +1,22 @@
/*******************************************************************************
- * Copyright (c) 2015 OPCoach.
+ * Copyright (c) 2015 OPCoach
* 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:
- * Olivier Prouvost <olivier.prouvost@opcoach.com> - initial API and implementation (bug #441331)
+ * Olivier Prouvost <olivier.prouvost@opcoach.com> - initial API and implementation (bug #441331, 466269, 466680)
*******************************************************************************/
package org.eclipse.pde.internal.ui.templates.e4;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.pde.core.plugin.*;
import org.eclipse.pde.internal.ui.templates.PDETemplateMessages;
+import org.eclipse.pde.internal.ui.wizards.plugin.PluginFieldData;
import org.eclipse.pde.ui.IFieldData;
import org.eclipse.pde.ui.templates.*;
import org.eclipse.ui.*;
@@ -30,6 +33,7 @@ public class E4ApplicationNewWizard extends NewPluginTemplateWizard {
public void init(IFieldData data) {
super.init(data);
setWindowTitle(PDETemplateMessages.E4ApplicationNewWizard_title);
+ setE4Plugin(true); // Fix 466680
}
@Override
@@ -43,9 +47,6 @@ public class E4ApplicationNewWizard extends NewPluginTemplateWizard {
// Must do like ancestor
boolean result = super.performFinish(project, model, monitor);
- // Remove the internal generated Activator
- removeActivatorIfPackageChanged(project);
-
// but must then remove the "org.eclipse.ui" dependency which has been generated !
// and core.runtime without any version (must remove it and readd it with good version) !
IPluginBase pb = model.getPluginBase();
@@ -96,29 +97,6 @@ public class E4ApplicationNewWizard extends NewPluginTemplateWizard {
return result;
}
- /**
- * With the wizard management, a default Activator is generated by ancestor pages
- * For E4 project, this activator is not compliant (because it extends AbstractUIPlugin),
- * and by default it is overriden by this file :
- * org.eclipse.pde.ui.templates/templates_3.5/E4Application/java/$activator$.java
- * unless we changed the package name...
- *
- * So this method remove the default generated file if the package name has changed in the last page.
- * This is a mess, but there is no other way :( !!
- */
- private void removeActivatorIfPackageChanged(IProject project) {
-
- String finalPackage = (String) appTemplate.getValue(AbstractTemplateSection.KEY_PACKAGE_NAME);
- if (!appTemplate.initialPackage.equals(finalPackage)) {
- IFolder f = project.getFolder(new Path("src/" + appTemplate.initialPackage)); //$NON-NLS-1$
- try {
- if (f.exists())
- f.delete(true, new NullProgressMonitor());
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
- }
/**
* Opens the model editor after the project was created.
@@ -131,8 +109,17 @@ public class E4ApplicationNewWizard extends NewPluginTemplateWizard {
final FileEditorInput input = new FileEditorInput(file);
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
final IWorkbenchPage page = window.getActivePage();
- page.openEditor(input, MODEL_EDITOR_ID);
+ if (page != null)
+ page.openEditor(input, MODEL_EDITOR_ID);
}
}
+ /** The template must generate an E4 compliant plugin */
+ private void setE4Plugin(boolean e4Mode) {
+ IFieldData data = getData();
+ if (data instanceof PluginFieldData) {
+ PluginFieldData pfd = (PluginFieldData) data;
+ pfd.setE4Plugin(e4Mode);
+ }
+ }
}
diff --git a/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ApplicationTemplate.java b/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ApplicationTemplate.java
index bb9e002ebe..737e75c656 100644
--- a/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ApplicationTemplate.java
+++ b/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ApplicationTemplate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 OPCoach.
+ * Copyright (c) 2015 OPCoach
* 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
@@ -7,7 +7,7 @@
*
* Contributors:
* Olivier Prouvost <olivier.prouvost@opcoach.com> - initial API and implementation (bug #441331)
- * Olivier Prouvost <olivier.prouvost@opcoach.com> - Bug 463821
+ * Olivier Prouvost <olivier.prouvost@opcoach.com> - Bug 463821, 466269, 466680
* Lars Vogel <Lars.Vogel@vogella.com> - Bug 463821
*******************************************************************************/
package org.eclipse.pde.internal.ui.templates.e4;
@@ -21,7 +21,6 @@ import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.pde.core.plugin.*;
import org.eclipse.pde.internal.ui.templates.*;
import org.eclipse.pde.ui.IFieldData;
-import org.eclipse.pde.ui.IPluginFieldData;
import org.eclipse.pde.ui.templates.PluginReference;
import org.eclipse.pde.ui.templates.TemplateOption;
@@ -35,7 +34,6 @@ public class E4ApplicationTemplate extends PDETemplateSection {
// Set the names of the two template files to be tested in isOkToCreateFile method
// Those files are stored in the org.eclipse.pde.ui.templates/templates_3.5/E4Application/java folder
- private static final String TEMPLATE_ACTIVATOR_FILENAME = "$activator$.java"; //$NON-NLS-1$
private static final String TEMPLATE_LIFECYCLE_FILENAME = "$lifeCycleClassName$.java"; //$NON-NLS-1$
// name of the non empty application model file stored in the org.eclipse.pde.ui.templates/templates_3.5/E4Application folder
@@ -45,10 +43,6 @@ public class E4ApplicationTemplate extends PDETemplateSection {
private TemplateOption lifeCycleClassnameOption;
- private boolean mustGenerateActivator;
-
- String initialPackage = null; // Name of package set in the activator class name (get from previous page).
-
public E4ApplicationTemplate() {
setPageCount(1);
createOptions();
@@ -146,9 +140,6 @@ public class E4ApplicationTemplate extends PDETemplateSection {
// If file is the lifeCycleClassname (with a $ at the end) we keep it only if life cycle must be created.
String fname = sourceFile.getName();
- // Fix bug #463821 : Check activator using the options saved in the overridden initializeFields method
- if (fname.equals(TEMPLATE_ACTIVATOR_FILENAME))
- return mustGenerateActivator;
if (fname.equals(TEMPLATE_LIFECYCLE_FILENAME))
return getBooleanOption(KEY_CREATE_LIFE_CYCLE);
@@ -187,20 +178,14 @@ public class E4ApplicationTemplate extends PDETemplateSection {
protected void initializeFields(IFieldData data) {
// This is called because isDependentOnParentWizard returns true
// We can get values entered in previous pages and put them in the local options.
- // At this point, we need to remember if we have to generate the activator or not.
- if (data instanceof IPluginFieldData) {
- mustGenerateActivator = ((IPluginFieldData) data).doGenerateClass();
- }
-
- // In a new project wizard, we don't know this yet - the
- // model has not been created
- initialPackage = getFormattedPackageName(data.getId());
+ // At this point, we need to get package name for this plugin
+ String initialPackage = getFormattedPackageName(data.getId());
initializeOption(KEY_PACKAGE_NAME, initialPackage);
}
@Override
public void initializeFields(IPluginModelBase model) {
- initialPackage = getFormattedPackageName(model.getPluginBase().getId());
+ String initialPackage = getFormattedPackageName(model.getPluginBase().getId());
initializeOption(KEY_PACKAGE_NAME, initialPackage);
}
diff --git a/ui/org.eclipse.pde.ui.templates/templates_3.5/E4Application/java/$activator$.java b/ui/org.eclipse.pde.ui.templates/templates_3.5/E4Application/java/$activator$.java
deleted file mode 100644
index 88259693a2..0000000000
--- a/ui/org.eclipse.pde.ui.templates/templates_3.5/E4Application/java/$activator$.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package $packageName$;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class $activator$ implements BundleActivator {
-
- private static BundleContext context;
-
- static BundleContext getContext() {
- return context;
- }
-
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext bundleContext) throws Exception {
- $activator$.context = bundleContext;
- }
-
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext bundleContext) throws Exception {
- $activator$.context = null;
- }
-
-}
diff --git a/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF
index 3bdd7100b0..24940d0232 100644
--- a/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF
+++ b/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF
@@ -57,7 +57,7 @@ Export-Package:
org.eclipse.pde.internal.ui.wizards.extension;x-internal:=true,
org.eclipse.pde.internal.ui.wizards.feature;x-internal:=true,
org.eclipse.pde.internal.ui.wizards.imports;x-internal:=true,
- org.eclipse.pde.internal.ui.wizards.plugin;x-internal:=true,
+ org.eclipse.pde.internal.ui.wizards.plugin;x-friends:="org.eclipse.pde.ui.templates",
org.eclipse.pde.internal.ui.wizards.product;x-friends:="org.eclipse.pde.ui.templates",
org.eclipse.pde.internal.ui.wizards.site;x-internal:=true,
org.eclipse.pde.internal.ui.wizards.target;x-internal:=true,
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/plugin/PluginClassCodeGenerator.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/plugin/PluginClassCodeGenerator.java
index e81debdbbb..c73dd1cb89 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/plugin/PluginClassCodeGenerator.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/plugin/PluginClassCodeGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Peter Friese <peter.friese@itemis.de> - bug 241074
+ * Olivier Prouvost <olivier.prouvost@opcoach.com> - bug 466680
*******************************************************************************/
package org.eclipse.pde.internal.ui.wizards.plugin;
@@ -49,7 +50,7 @@ public class PluginClassCodeGenerator {
StringWriter swriter = new StringWriter();
PrintWriter writer = new PrintWriter(swriter);
// only generate/extend plug-in classes if it's a IU plug-in
- if (fPluginData.getOSGiFramework() != null || !fPluginData.isUIPlugin()) {
+ if (fPluginData.getOSGiFramework() != null || !fPluginData.isUIPlugin() || fPluginData.isE4Plugin()) {
generateActivatorClass(packageName, className, writer);
} else {
generatePluginClass(packageName, className, writer);
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/plugin/PluginFieldData.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/plugin/PluginFieldData.java
index 7ffb9d9a85..08f0db30a0 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/plugin/PluginFieldData.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/plugin/PluginFieldData.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Olivier Prouvost <olivier.prouvost@opcoach.com> - bug 466680
*******************************************************************************/
package org.eclipse.pde.internal.ui.wizards.plugin;
@@ -21,6 +22,7 @@ public class PluginFieldData extends AbstractFieldData implements IPluginFieldDa
private boolean fDoGenerateClass = true;
private boolean fRCPAppPlugin = false;
private boolean fSetupAPITooling = false;
+ private boolean fE4Plugin = false;
private ArrayList<ITemplateSection> templates = new ArrayList<ITemplateSection>();
/* (non-Javadoc)
@@ -88,4 +90,12 @@ public class PluginFieldData extends AbstractFieldData implements IPluginFieldDa
fSetupAPITooling = enable;
}
+ public boolean isE4Plugin() {
+ return fE4Plugin;
+ }
+
+ public void setE4Plugin(boolean e4Plugin) {
+ this.fE4Plugin = e4Plugin;
+ }
+
}

Back to the top