summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaarten Meijer2013-01-08 17:34:12 (EST)
committer Curtis Windatt2013-01-08 17:34:12 (EST)
commit3bd94f514dc85a3744abc69f06580f820dbc3e7b (patch)
treeaa540026aacee0ad93bbd21310ea69008bf7c7d8
parentc604df7186ef2b0654770b83599a4acc749774ce (diff)
downloadeclipse.pde.ui-3bd94f514dc85a3744abc69f06580f820dbc3e7b.zip
eclipse.pde.ui-3bd94f514dc85a3744abc69f06580f820dbc3e7b.tar.gz
eclipse.pde.ui-3bd94f514dc85a3744abc69f06580f820dbc3e7b.tar.bz2
Bug 395795 - [patch] Template with Incremental Project Builder generatesv20130108-223412
IObjectActionDelegate instead of handler
-rw-r--r--ui/org.eclipse.pde.ui.templates/plugin.properties17
-rw-r--r--ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/PDETemplateMessages.java7
-rw-r--r--ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/ide/BuilderTemplate.java191
-rw-r--r--ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/pderesources.properties17
-rw-r--r--ui/org.eclipse.pde.ui.templates/templates_3.0/builder/java/AddRemove$natureClassName$Handler.java77
5 files changed, 242 insertions, 67 deletions
diff --git a/ui/org.eclipse.pde.ui.templates/plugin.properties b/ui/org.eclipse.pde.ui.templates/plugin.properties
index 4ddf287..dc1ce0e 100644
--- a/ui/org.eclipse.pde.ui.templates/plugin.properties
+++ b/ui/org.eclipse.pde.ui.templates/plugin.properties
@@ -1,10 +1,10 @@
###############################################################################
-# Copyright (c) 2006, 2009 IBM Corporation and others.
+# Copyright (c) 2006, 2013 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
###############################################################################
@@ -92,13 +92,14 @@ and adds a problem marker to not well formed files.</li>\
<li><b>Sample Project Nature</b>. This nature owns the builder. Builder runs for projects \
of this nature.</li>\
<li><b>Sample Problem Marker</b>. The builder uses this sub-type of a problem marker to mark errors.</li>\
-<li><b>Sample Popup Menu Action</b>. An action in a project context menu allows adding or removing \
+<li><b>Sample Commands and Handlers</b>. A menu contribution in the "Configure" section in a project context menu allows adding or removing \
the sample nature to or from a workspace project.</li>\
<p><b>Extensions Used</b></p>\
<li>org.eclipse.core.resources.builders</li>\
<li>org.eclipse.core.resources.markers</li>\
<li>org.eclipse.core.resources.natures</li>\
-<li>org.eclipse.ui.popupMenus</li>
+<li>org.eclipse.ui.commands</li>\
+<li>org.eclipse.ui.menus</li>
pluginContent.mail.name = RCP Mail Template
pluginContent.mail.description=\
@@ -209,8 +210,8 @@ newExtension.templates.builder.name = Project Builder and Nature
newExtension.templates.builder.desc = This template creates an incremental \
project builder and a project nature. The sample builder checks XML files in the project \
and adds a problem marker to not well formed files. The builder runs for projects \
-of the sample nature. Select "Add|Remove Sample" Nature action from \
-a project context menu, to toggle the nature on a project.
+of the sample nature. Select "Enable Sample Buider" or "Disable Sample Builder" command from \
+the "Configure" section of a project context menu, to toggle the nature on a project.
newExtension.templates.decorator.name = Icon Decorator
newExtension.templates.decorator.desc = <p>%template.decorator.desc%</p>
@@ -305,7 +306,7 @@ template.help.name = Help Table of Contents
template.help.desc = This template creates a Help table of contents. \
If this table is set to primary, it can be standalone, or integrated \
into pre-set categories. If the table is not set to primary, it can \
-optionally be integrated into a primary table of contents for testing.
+optionally be integrated into a primary table of contents for testing.
template.decorator.name = Icon Decorator
@@ -327,7 +328,7 @@ template.perspective.name = Release Engineering Perspective
template.perspective.desc = This template creates a release engineering themed perspective. \
While most users will not be doing any release engineering, the theme allows for a very logical \
layout of the perspective elements and demonstrates how to access the various team and CVS \
-components from within a perspective.
+components from within a perspective.
bundleVendor = Eclipse.org
bundleName = PDE Templates
diff --git a/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/PDETemplateMessages.java b/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/PDETemplateMessages.java
index 10cb59c..261ad0b 100644
--- a/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/PDETemplateMessages.java
+++ b/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/PDETemplateMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 IBM Corporation and others.
+ * Copyright (c) 2006, 2013 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
@@ -190,7 +190,10 @@ public class PDETemplateMessages extends NLS {
public static String BuilderTemplate_defaultBuilderName;
public static String BuilderTemplate_defaultNatureName;
public static String BuilderTemplate_markerName;
- public static String BuilderTemplate_generateAction;
+ public static String BuilderTemplate_generateCommand;
+ public static String BuilderTemplate_enableLabel;
+ public static String BuilderTemplate_disableLabel;
+ public static String BuilderTemplate_commandName;
public static String DecoratorTemplate_title;
public static String DecoratorTemplate_desc;
diff --git a/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/ide/BuilderTemplate.java b/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/ide/BuilderTemplate.java
index 91af7ea..8414c24 100644
--- a/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/ide/BuilderTemplate.java
+++ b/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/ide/BuilderTemplate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 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
@@ -12,24 +12,14 @@ package org.eclipse.pde.internal.ui.templates.ide;
import java.io.File;
import java.util.ArrayList;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardPage;
-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.IPluginModelBase;
-import org.eclipse.pde.core.plugin.IPluginModelFactory;
-import org.eclipse.pde.core.plugin.IPluginReference;
-import org.eclipse.pde.internal.ui.templates.IHelpContextIds;
-import org.eclipse.pde.internal.ui.templates.PDETemplateMessages;
-import org.eclipse.pde.internal.ui.templates.PDETemplateSection;
+import org.eclipse.pde.core.plugin.*;
+import org.eclipse.pde.internal.ui.templates.*;
import org.eclipse.pde.ui.IFieldData;
-import org.eclipse.pde.ui.templates.AbstractTemplateSection;
-import org.eclipse.pde.ui.templates.BooleanOption;
-import org.eclipse.pde.ui.templates.PluginReference;
+import org.eclipse.pde.ui.templates.*;
public class BuilderTemplate extends PDETemplateSection {
@@ -59,7 +49,7 @@ public class BuilderTemplate extends PDETemplateSection {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.pde.ui.templates.OptionTemplateSection#getSectionId()
*/
public String getSectionId() {
@@ -84,7 +74,7 @@ public class BuilderTemplate extends PDETemplateSection {
addOption(KEY_NATURE_ID, PDETemplateMessages.BuilderTemplate_natureId, "sampleNature", 0); //$NON-NLS-1$
addOption(KEY_NATURE_NAME, PDETemplateMessages.BuilderTemplate_natureName, PDETemplateMessages.BuilderTemplate_defaultNatureName, 0);
- actionOption = (BooleanOption) addOption(KEY_GEN_ACTION, PDETemplateMessages.BuilderTemplate_generateAction, true, 0);
+ actionOption = (BooleanOption) addOption(KEY_GEN_ACTION, PDETemplateMessages.BuilderTemplate_generateCommand, true, 0);
}
public void addPages(Wizard wizard) {
@@ -115,7 +105,7 @@ public class BuilderTemplate extends PDETemplateSection {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.pde.ui.templates.ITemplateSection#getUsedExtensionPoint()
*/
public String getUsedExtensionPoint() {
@@ -171,55 +161,153 @@ public class BuilderTemplate extends PDETemplateSection {
// Popup Action
if (actionOption.isSelected()) {
- IPluginExtension extension3 = createExtension("org.eclipse.ui.popupMenus", true); //$NON-NLS-1$
- IPluginElement objectContribution = factory.createElement(extension3);
- objectContribution.setName("objectContribution"); //$NON-NLS-1$
- objectContribution.setAttribute("objectClass", //$NON-NLS-1$
- "org.eclipse.core.resources.IProject"); //$NON-NLS-1$
- objectContribution.setAttribute("adaptable", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- objectContribution.setAttribute("nameFilter", "*"); //$NON-NLS-1$ //$NON-NLS-2$
- objectContribution.setAttribute("id", model.getPluginBase().getId() //$NON-NLS-1$
- + ".contribution1"); //$NON-NLS-1$
- extension3.add(objectContribution);
-
- IPluginElement action = factory.createElement(objectContribution);
- action.setName("action"); //$NON-NLS-1$
- action.setAttribute("label", PDETemplateMessages.BuilderTemplate_actionLabel); //$NON-NLS-1$
- action.setAttribute("class", getStringOption(KEY_PACKAGE_NAME) //$NON-NLS-1$
- + ".ToggleNatureAction"); //$NON-NLS-1$
- action.setAttribute("menubarPath", "additions"); //$NON-NLS-1$ //$NON-NLS-2$
- action.setAttribute("enablesFor", "+"); //$NON-NLS-1$ //$NON-NLS-2$
- action.setAttribute("id", model.getPluginBase().getId() //$NON-NLS-1$
- + ".addRemoveNatureAction"); //$NON-NLS-1$
- objectContribution.add(action);
+ IPluginExtension extension3 = createExtension("org.eclipse.ui.commands", true); //$NON-NLS-1$
+
+ IPluginElement category = factory.createElement(extension3);
+ category.setName("category"); //$NON-NLS-1$
+ category.setAttribute("id", model.getPluginBase().getId() //$NON-NLS-1$
+ + "." + getStringOption(KEY_NATURE_ID) + ".category"); //$NON-NLS-1$ //$NON-NLS-2$
+ category.setAttribute("name", getStringOption(KEY_NATURE_NAME) + " commands"); //$NON-NLS-1$ //$NON-NLS-2$
+ extension3.add(category);
+
+ IPluginElement command = factory.createElement(extension3);
+ command.setName("command"); //$NON-NLS-1$
+ command.setAttribute("categoryId", model.getPluginBase().getId() //$NON-NLS-1$
+ + "." + getStringOption(KEY_NATURE_ID) + ".category"); //$NON-NLS-1$ //$NON-NLS-2$
+ command.setAttribute("defaultHandler", getStringOption(KEY_PACKAGE_NAME) //$NON-NLS-1$
+ + ".AddRemove" + getStringOption(KEY_NATURE_CLASS_NAME) + "Handler"); //$NON-NLS-1$ //$NON-NLS-2$
+ command.setAttribute("id", model.getPluginBase().getId() //$NON-NLS-1$
+ + ".addRemove" + getStringOption(KEY_NATURE_CLASS_NAME)); //$NON-NLS-1$
+ command.setAttribute("name", PDETemplateMessages.BuilderTemplate_commandName + getStringOption(KEY_NATURE_NAME)); //$NON-NLS-1$
+ extension3.add(command);
if (!extension3.isInTheModel())
plugin.add(extension3);
+
+ IPluginExtension extension4 = createExtension("org.eclipse.ui.menus", true); //$NON-NLS-1$
+ IPluginElement menuContribution = factory.createElement(extension4);
+ menuContribution.setName("menuContribution"); //$NON-NLS-1$
+ menuContribution.setAttribute("locationURI", //$NON-NLS-1$
+ "popup:org.eclipse.ui.projectConfigure?after=additions"); //$NON-NLS-1$
+ extension4.add(menuContribution);
+
+ IPluginElement disableCommand = factory.createElement(menuContribution);
+ disableCommand.setName("command"); //$NON-NLS-1$
+ disableCommand.setAttribute("label", PDETemplateMessages.BuilderTemplate_disableLabel); //$NON-NLS-1$
+ disableCommand.setAttribute("commandId", model.getPluginBase().getId() //$NON-NLS-1$
+ + ".addRemove" + getStringOption(KEY_NATURE_CLASS_NAME)); //$NON-NLS-1$
+ disableCommand.setAttribute("style", "push"); //$NON-NLS-1$ //$NON-NLS-2$
+ menuContribution.add(disableCommand);
+
+ IPluginElement visibleWhen = factory.createElement(disableCommand);
+ visibleWhen.setName("visibleWhen"); //$NON-NLS-1$
+ visibleWhen.setAttribute("checkEnabled", "false"); //$NON-NLS-1$ //$NON-NLS-2$
+ disableCommand.add(visibleWhen);
+
+ IPluginElement with = factory.createElement(visibleWhen);
+ with.setName("with"); //$NON-NLS-1$
+ with.setAttribute("variable", "selection"); //$NON-NLS-1$ //$NON-NLS-2$
+ visibleWhen.add(with);
+
+ IPluginElement count = factory.createElement(with);
+ count.setName("count"); //$NON-NLS-1$
+ count.setAttribute("value", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+ with.add(count);
+
+ IPluginElement iterate = factory.createElement(with);
+ iterate.setName("iterate"); //$NON-NLS-1$
+ with.add(iterate);
+
+ IPluginElement and = factory.createElement(iterate);
+ and.setName("and"); //$NON-NLS-1$
+ iterate.add(and);
+
+ IPluginElement instanceof1 = factory.createElement(and);
+ instanceof1.setName("instanceof"); //$NON-NLS-1$
+ instanceof1.setAttribute("value", "org.eclipse.core.resources.IProject"); //$NON-NLS-1$ //$NON-NLS-2$
+ and.add(instanceof1);
+
+ IPluginElement test = factory.createElement(and);
+ test.setName("test"); //$NON-NLS-1$
+ test.setAttribute("property", "org.eclipse.core.resources.projectNature"); //$NON-NLS-1$ //$NON-NLS-2$
+ test.setAttribute("value", model.getPluginBase().getId() //$NON-NLS-1$
+ + "." + getStringOption(KEY_NATURE_ID)); //$NON-NLS-1$
+ and.add(test);
+
+ IPluginElement enableCommand = factory.createElement(menuContribution);
+ enableCommand.setName("command"); //$NON-NLS-1$
+ enableCommand.setAttribute("label", PDETemplateMessages.BuilderTemplate_enableLabel); //$NON-NLS-1$
+ enableCommand.setAttribute("commandId", model.getPluginBase().getId() //$NON-NLS-1$
+ + ".addRemove" + getStringOption(KEY_NATURE_CLASS_NAME)); //$NON-NLS-1$
+ enableCommand.setAttribute("style", "push"); //$NON-NLS-1$ //$NON-NLS-2$
+ menuContribution.add(enableCommand);
+
+ IPluginElement visibleWhen2 = factory.createElement(enableCommand);
+ visibleWhen2.setName("visibleWhen"); //$NON-NLS-1$
+ visibleWhen2.setAttribute("checkEnabled", "false"); //$NON-NLS-1$ //$NON-NLS-2$
+ enableCommand.add(visibleWhen2);
+
+ IPluginElement with2 = factory.createElement(visibleWhen2);
+ with2.setName("with"); //$NON-NLS-1$
+ with2.setAttribute("variable", "selection"); //$NON-NLS-1$ //$NON-NLS-2$
+ visibleWhen2.add(with2);
+
+ IPluginElement count2 = factory.createElement(with2);
+ count2.setName("count"); //$NON-NLS-1$
+ count2.setAttribute("value", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+ with2.add(count2);
+
+ IPluginElement iterate2 = factory.createElement(with2);
+ iterate2.setName("iterate"); //$NON-NLS-1$
+ with2.add(iterate2);
+
+ IPluginElement and2 = factory.createElement(iterate2);
+ and2.setName("and"); //$NON-NLS-1$
+ iterate2.add(and2);
+
+ IPluginElement instanceof2 = factory.createElement(and2);
+ instanceof2.setName("instanceof"); //$NON-NLS-1$
+ instanceof2.setAttribute("value", "org.eclipse.core.resources.IProject"); //$NON-NLS-1$ //$NON-NLS-2$
+ and2.add(instanceof2);
+
+ IPluginElement not = factory.createElement(and2);
+ not.setName("not"); //$NON-NLS-1$
+ and2.add(not);
+
+ IPluginElement test2 = factory.createElement(not);
+ test2.setName("test"); //$NON-NLS-1$
+ test2.setAttribute("property", "org.eclipse.core.resources.projectNature"); //$NON-NLS-1$ //$NON-NLS-2$
+ test2.setAttribute("value", model.getPluginBase().getId() //$NON-NLS-1$
+ + "." + getStringOption(KEY_NATURE_ID)); //$NON-NLS-1$
+ not.add(test2);
+
+ if (!extension4.isInTheModel())
+ plugin.add(extension4);
}
// Marker
- IPluginExtension extension4 = createExtension("org.eclipse.core.resources.markers", false); //$NON-NLS-1$
- extension4.setId("xmlProblem"); //$NON-NLS-1$
- extension4.setName(PDETemplateMessages.BuilderTemplate_markerName);
+ IPluginExtension extension8 = createExtension("org.eclipse.core.resources.markers", false); //$NON-NLS-1$
+ extension8.setId("xmlProblem"); //$NON-NLS-1$
+ extension8.setName(PDETemplateMessages.BuilderTemplate_markerName);
- IPluginElement superElement = factory.createElement(extension4);
+ IPluginElement superElement = factory.createElement(extension8);
superElement.setName("super"); //$NON-NLS-1$
superElement.setAttribute("type", //$NON-NLS-1$
"org.eclipse.core.resources.problemmarker"); //$NON-NLS-1$
- extension4.add(superElement);
+ extension8.add(superElement);
- IPluginElement persistent = factory.createElement(extension4);
+ IPluginElement persistent = factory.createElement(extension8);
persistent.setName("persistent"); //$NON-NLS-1$
persistent.setAttribute("value", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- extension4.add(persistent);
+ extension8.add(persistent);
- if (!extension4.isInTheModel())
- plugin.add(extension4);
+ if (!extension8.isInTheModel())
+ plugin.add(extension8);
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.pde.ui.templates.AbstractTemplateSection#getDependencies(java.lang.String)
*/
public IPluginReference[] getDependencies(String schemaVersion) {
@@ -236,7 +324,7 @@ public class BuilderTemplate extends PDETemplateSection {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.pde.internal.ui.wizards.templates.PDETemplateSection#formatPackageName(java.lang.String)
*/
protected String getFormattedPackageName(String id) {
@@ -251,9 +339,12 @@ public class BuilderTemplate extends PDETemplateSection {
*/
protected boolean isOkToCreateFile(File sourceFile) {
String fileName = sourceFile.getName();
- if (fileName.equals("ToggleNatureAction.java")) { //$NON-NLS-1$
+ if (fileName.equals("AddRemove$natureClassName$Handler.java")) { //$NON-NLS-1$
return actionOption.isSelected();
}
+ if (fileName.equals("ToggleNatureAction.java")) { //$NON-NLS-1$
+ return false;
+ }
return true;
}
diff --git a/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/pderesources.properties b/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/pderesources.properties
index b358b0e..614a65a 100644
--- a/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/pderesources.properties
+++ b/ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/pderesources.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2006, 2010 IBM Corporation and others.
+# Copyright (c) 2006, 2013 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
@@ -51,9 +51,9 @@ HelloOSGiTemplate_stopMessage=Stop Message:
HelloWorldTemplate_sampleAction = &Sample Action
HelloOSGiServiceTemplate_greeting=&Language:
-HelloOSGiServiceTemplate_word1=Word 1:
-HelloOSGiServiceTemplate_word2=Word 2:
-HelloOSGiServiceTemplate_word3=Word 3:
+HelloOSGiServiceTemplate_word1=Word 1:
+HelloOSGiServiceTemplate_word2=Word 2:
+HelloOSGiServiceTemplate_word3=Word 3:
HelloOSGiServiceTemplate_howdy=en_US
HelloOSGiServiceTemplate_pageDescription=This template creates a OSGi service that acts as a dictionary.
HelloOSGiServiceTemplate_pageTitle=Dictionary OSGi Service
@@ -176,7 +176,10 @@ BuilderTemplate_actionLabel = Add/Remove Sample Nature
BuilderTemplate_defaultBuilderName = Sample Project Builder
BuilderTemplate_defaultNatureName = Sample Project Nature
BuilderTemplate_markerName = XML Problem
-BuilderTemplate_generateAction = Generate a popup menu &action to toggle project nature
+BuilderTemplate_generateCommand = Generate a popup menu &command and handler to toggle project nature
+BuilderTemplate_enableLabel = Enable Sample builder
+BuilderTemplate_disableLabel = Disable Sample builder
+BuilderTemplate_commandName = Add/Remove
DecoratorTemplate_title = Decorator Options
DecoratorTemplate_desc = Choose the options to control which decorator should be created and where it should be displayed.
@@ -203,7 +206,7 @@ ImportWizardTemplate_wizardDefaultName = Import File
ImportWizardTemplate_filters = Select File Type Filter:
ImportWizardTemplate_filterChoices = All,Show All File Types (*.*),Images,Show Image File Types (*.jpg;*.gif;*.bmp),Docs,Show Document File Types (*.doc;*.txt;*.pdf),Archives,Show Archive File Types (*.zip;*.tar;*.jar)
ImportWizardTemplate_wizardDescription = Import a file from the local file system into the workspace.
-
+
MailTemplate_title=RCP Mail Template
MailNewWizard_title=New plug-in project with an RCP mail template
@@ -235,7 +238,7 @@ PerspectiveTemplate_perspectiveName = Release Engineering
PerspectiveTemplate_perspectiveShortcuts = Add &Related Perspective Shortcuts
PerspectiveTemplate_showViewShortcuts = Add Show View &Shortcuts
PerspectiveTemplate_newWizardShortcuts = Add New &Wizard Shortcuts
-PerspectiveTemplate_actionSets = Add &Menu and Toolbar Contributions (Action Sets)
+PerspectiveTemplate_actionSets = Add &Menu and Toolbar Contributions (Action Sets)
#Preferences Service Example
OSGiPreferencesServiceNewWizard_title = OSGi Preferences Service Example Wizard
diff --git a/ui/org.eclipse.pde.ui.templates/templates_3.0/builder/java/AddRemove$natureClassName$Handler.java b/ui/org.eclipse.pde.ui.templates/templates_3.0/builder/java/AddRemove$natureClassName$Handler.java
new file mode 100644
index 0000000..51a8de4
--- /dev/null
+++ b/ui/org.eclipse.pde.ui.templates/templates_3.0/builder/java/AddRemove$natureClassName$Handler.java
@@ -0,0 +1,77 @@
+package $packageName$;
+
+import java.util.Iterator;
+import org.eclipse.core.commands.*;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class AddRemove$natureClassName$Handler extends AbstractHandler {
+
+ private ISelection selection;
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ // TODO Auto-generated method stub
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ //
+ if (selection instanceof IStructuredSelection) {
+ for (Iterator<?> it = ((IStructuredSelection) selection).iterator(); it
+ .hasNext();) {
+ Object element = it.next();
+ IProject project = null;
+ if (element instanceof IProject) {
+ project = (IProject) element;
+ } else if (element instanceof IAdaptable) {
+ project = (IProject) ((IAdaptable) element)
+ .getAdapter(IProject.class);
+ }
+ if (project != null) {
+ try {
+ toggleNature(project);
+ } catch (CoreException e) {
+ //TODO log something
+ throw new ExecutionException("Failed to toggle nature",
+ e);
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Toggles sample nature on a project
+ *
+ * @param project
+ * to have sample nature added or removed
+ */
+ private void toggleNature(IProject project) throws CoreException {
+ IProjectDescription description = project.getDescription();
+ String[] natures = description.getNatureIds();
+
+ for (int i = 0; i < natures.length; ++i) {
+ if ($natureClassName$.NATURE_ID.equals(natures[i])) {
+ // Remove the nature
+ String[] newNatures = new String[natures.length - 1];
+ System.arraycopy(natures, 0, newNatures, 0, i);
+ System.arraycopy(natures, i + 1, newNatures, i, natures.length - i - 1);
+ description.setNatureIds(newNatures);
+ project.setDescription(description, null);
+ return;
+ }
+ }
+
+ // Add the nature
+ String[] newNatures = new String[natures.length + 1];
+ System.arraycopy(natures, 0, newNatures, 0, natures.length);
+ newNatures[natures.length] = $natureClassName$.NATURE_ID;
+ description.setNatureIds(newNatures);
+ project.setDescription(description, null);
+ }
+
+} \ No newline at end of file