Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2012-01-10 13:41:41 +0000
committerUwe Stieber2012-01-10 13:41:41 +0000
commit6a935544e30ad0dc59353e1271bfd85bc7e96d24 (patch)
tree1affaa20aa4a04ac6787fe7cca63645451359106
parent83f22a95bcf8a2d940c2c14182b2b4622c52259d (diff)
downloadorg.eclipse.tcf-6a935544e30ad0dc59353e1271bfd85bc7e96d24.tar.gz
org.eclipse.tcf-6a935544e30ad0dc59353e1271bfd85bc7e96d24.tar.xz
org.eclipse.tcf-6a935544e30ad0dc59353e1271bfd85bc7e96d24.zip
Target Explorer: Bug 368243 - [UI] Allow dynamic new wizard contributions
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/actions/NewActionProvider.java15
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.properties9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.xml5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/schema/newWizards.exsd8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/schema/wizardProviders.exsd109
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.properties6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/interfaces/INewWizardProvider.java32
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardCategory.java259
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardContentProvider.java107
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardDescriptor.java235
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardRegistry.java109
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardSelectionPage.java46
13 files changed, 910 insertions, 34 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties
index a6c0ba09e..6da4f4a5c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties
@@ -47,6 +47,8 @@ Command.open.name=Open
PropertiesAction.label=P&roperties
PropertiesAction.tooltip=Show Properties of Selection
+
menu.showIn.label = Show In
menu.properties.label = Properties
-command.showInProperties.label = Show In Properties \ No newline at end of file
+
+command.showInProperties.label = Show In Properties
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/actions/NewActionProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/actions/NewActionProvider.java
index 4d72d9a71..6a080fd95 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/actions/NewActionProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/actions/NewActionProvider.java
@@ -6,26 +6,30 @@
*
* Contributors:
* Wind River Systems - initial API and implementation
+ * Tobias Schwarz (Wind River) - [368243] [UI] Allow dynamic new wizard contributions
*******************************************************************************/
package org.eclipse.tcf.te.ui.views.actions;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
-import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
-import org.eclipse.tcf.te.ui.views.nls.Messages;
import org.eclipse.tcf.te.ui.interfaces.IContextHelpIds;
import org.eclipse.tcf.te.ui.interfaces.ImageConsts;
+import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.tcf.te.ui.views.nls.Messages;
import org.eclipse.tcf.te.ui.wizards.newWizard.NewWizardRegistry;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.internal.actions.CommandAction;
+import org.eclipse.ui.internal.navigator.wizards.WizardShortcutAction;
import org.eclipse.ui.navigator.CommonActionProvider;
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
import org.eclipse.ui.navigator.ICommonMenuConstants;
import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
import org.eclipse.ui.navigator.WizardActionGroup;
+import org.eclipse.ui.wizards.IWizardDescriptor;
/**
* Action provider implementation providing the "New >" content menu
@@ -109,6 +113,13 @@ public class NewActionProvider extends CommonActionProvider {
newWizardActionGroup.fillContextMenu(newMenu);
}
+
+ IWorkbenchWindow window = ((ICommonViewerWorkbenchSite)getActionSite().getViewSite()).getWorkbenchWindow();
+ for (IWizardDescriptor wizard : NewWizardRegistry.getInstance().getCommonWizards(getContext().getSelection())) {
+ IAction action = new WizardShortcutAction(window, wizard);
+ newMenu.add(action);
+ }
+
// Add the standard additions marker
newMenu.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS));
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.properties
index 4619f9908..5227c4252 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.properties
@@ -11,6 +11,12 @@
pluginName = Target Explorer, Common UI and Helper
providerName = Eclipse.org
+# ***** Extension Points *****
+
+extension-point.newWizards.name = New Wizards
+extension-point.wizardProviders.name=New Wizard Providers
+extension-point.viewers.name = Tree Viewer Extension
+
# ***** Wizards *****
NewWizards.category.name=General
@@ -34,9 +40,6 @@ DefaultStatusHandler.label=Default Status Handler
SWTDisplayExecutorUtilDelegate.label=SWT Display Executor Utility Delegate
-extension-point.newtarget.name = New Target Wizards
-extension-point.treeviewer.name = Tree Viewer Extension
-
# ***** Preference Pages *****
preference.page.name=Target Explorer
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.xml
index ff900d88e..6df902d2f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.xml
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
- <extension-point id="newWizards" name="%extension-point.newtarget.name" schema="schema/newWizards.exsd"/>
- <extension-point id="viewers" name="%extension-point.treeviewer.name" schema="schema/viewers.exsd"/>
+ <extension-point id="newWizards" name="%extension-point.newWizards.name" schema="schema/newWizards.exsd"/>
+ <extension-point id="wizardProviders" name="%extension-point.wizardProviders.name" schema="schema/wizardProviders.exsd"/>
+ <extension-point id="viewers" name="%extension-point.viewers.name" schema="schema/viewers.exsd"/>
<extension-point id="cellEditors" name="%ExtensionPoint.cellEditors.name" schema="schema/cellEditors.exsd"/>
<!-- New target wizard contributions -->
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/schema/newWizards.exsd b/target_explorer/plugins/org.eclipse.tcf.te.ui/schema/newWizards.exsd
index ddd391869..ea02f9c37 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/schema/newWizards.exsd
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/schema/newWizards.exsd
@@ -3,12 +3,12 @@
<schema targetNamespace="org.eclipse.tcf.te.ui" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
- <meta.schema plugin="org.eclipse.tcf.te.ui" id="newWizards" name="New Target Wizards"/>
+ <meta.schema plugin="org.eclipse.tcf.te.ui" id="newWizards" name="New Wizards"/>
</appinfo>
<documentation>
- This extension point is used to register target creation wizard extensions. Target creation wizards appear as choices within the &quot;New Target&quot; dialog, and are used to create target definitions. Target creation wizards can be organized in categories. Uncategorized wizards or wizards with invalid category paths will be sorted in as non-categorized root element.
+ This extension point is used to register element creation wizard extensions. Element creation wizards appear as choices within the &quot;New&quot; dialog. The new element creation wizards can be organized in categories. Uncategorized wizards or wizards with invalid category paths will be sorted in as non-categorized root element.
&lt;p&gt;
-Target creation wizards may optionally specify a description subelement whose body should contain short text about the wizard.
+New element creation wizards may optionally specify a description subelement whose body should contain short text about the wizard.
</documentation>
</annotation>
@@ -200,7 +200,7 @@ Target creation wizards may optionally specify a description subelement whose bo
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
- The provider of a new target creation wizard must implement &lt;samp&gt;org.eclipse.ui.IWorkbenchWizard&lt;/samp&gt;.
+ The provider of a new element creation wizard must implement &lt;samp&gt;org.eclipse.ui.IWorkbenchWizard&lt;/samp&gt;.
</documentation>
</annotation>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/schema/wizardProviders.exsd b/target_explorer/plugins/org.eclipse.tcf.te.ui/schema/wizardProviders.exsd
new file mode 100644
index 000000000..c65cf8778
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/schema/wizardProviders.exsd
@@ -0,0 +1,109 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.tcf.te.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.tcf.te.ui" id="wizardProvider" name="New Wizard Providers"/>
+ </appinfo>
+ <documentation>
+ This extension point is used to contribute new wizard providers. New wizard providers allow a more dynamic contribution than via the &quot;org.eclipse.tcf.te.ui.newWizards&quot; extension point.
+ </documentation>
+ </annotation>
+
+ <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="wizardProvider" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="wizardProvider">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.tcf.te.ui.wizards.interfaces.INewWizardProvider"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ Target Explorer 1.0.0
+ </documentation>
+ </annotation>
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ The provider of a new wizard provider must implement &lt;samp&gt;org.eclipse.tcf.te.ui.wizards.interfaces.INewWizardProvider&lt;/samp&gt;.
+ </documentation>
+ </annotation>
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2012 Wind River Systems, Inc. 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.
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.properties
index 71c638598..e537e0780 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/nls/Messages.properties
@@ -9,10 +9,10 @@ ConfigFilterAction_TooltipText=Configure Viewer Filters
# ***** Wizards *****
ConfigFilterAction_PromptMessage=Select the filters to apply (matching items will be hidden):
-NewWizard_dialog_title=New Target
+NewWizard_dialog_title=New
-NewWizardSelectionPage_title=Select a target wizard
-NewWizardSelectionPage_description=Please select the target creation wizard matching the target to connect to.
+NewWizardSelectionPage_title=Select a wizard
+NewWizardSelectionPage_description=Please select the wizard which will create the desired object.
NewWizardSelectionPage_wizards=Wizards:
NewWizardSelectionPage_createWizardFailed=The selected wizard could not be started.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/interfaces/INewWizardProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/interfaces/INewWizardProvider.java
new file mode 100644
index 000000000..a29fb55a9
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/interfaces/INewWizardProvider.java
@@ -0,0 +1,32 @@
+/*
+ * INewWizardProvider.java
+ * Created on 14.12.2011
+ *
+ * Copyright 2011 Wind River Systems Inc. All rights reserved.
+ */
+package org.eclipse.tcf.te.ui.wizards.interfaces;
+
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.wizards.IWizardCategory;
+import org.eclipse.ui.wizards.IWizardDescriptor;
+
+/**
+ * INewWizardProvider
+ * @author tobias.schwarz@windriver.com
+ */
+public interface INewWizardProvider extends IExecutableExtension {
+
+ /**
+ * Get the dynamic list of new wizard categories including the wizards.
+ * @return The list of new wizard categories.
+ */
+ public IWizardCategory[] getCategories();
+
+ /**
+ * Get the list if common wizards for the given selection.
+ * @param selection The current selection.
+ * @return A list of wizards or <code>null</code>.
+ */
+ public IWizardDescriptor[] getCommonWizards(ISelection selection);
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardCategory.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardCategory.java
new file mode 100644
index 000000000..a3974f6e1
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardCategory.java
@@ -0,0 +1,259 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.wizards.newWizard;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.internal.WorkbenchImages;
+import org.eclipse.ui.internal.dialogs.WizardCollectionElement;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.wizards.IWizardCategory;
+import org.eclipse.ui.wizards.IWizardDescriptor;
+
+/**
+ * New wizard category node implementation.
+ */
+@SuppressWarnings("restriction")
+public class NewWizardCategory implements IWizardCategory, IWorkbenchAdapter {
+
+ private String id;
+ private String label;
+ private IWizardCategory parent;
+
+ private List<IWizardCategory> categories = new ArrayList<IWizardCategory>();
+ private List<IWizardDescriptor> wizards = new ArrayList<IWizardDescriptor>();
+
+ /**
+ * Constructor.
+ */
+ public NewWizardCategory(String id, String label) {
+ this.id = id;
+ this.label = label;
+ }
+
+ /**
+ * Constructor.
+ */
+ public NewWizardCategory(IWizardCategory baseCategory) {
+ id = baseCategory.getId();
+ label = baseCategory.getLabel();
+ parent = baseCategory.getParent();
+
+ IWizardCategory[] baseCategories = baseCategory.getCategories();
+ if (baseCategories != null && baseCategories.length > 0) {
+ categories = new ArrayList<IWizardCategory>(Arrays.asList(baseCategories));
+ }
+
+ IWizardDescriptor[] baseWizards = baseCategory.getWizards();
+ if (baseWizards != null && baseWizards.length > 0) {
+ wizards = new ArrayList<IWizardDescriptor>(Arrays.asList(baseWizards));
+ }
+ }
+
+ /**
+ * Clear the list of wizards and sub categories.
+ */
+ public void clear() {
+ categories.clear();
+ wizards.clear();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (other instanceof IWizardCategory) {
+ ((IWizardCategory)other).getId().equals(getId());
+ }
+ return super.equals(other);
+ }
+
+ /**
+ * Set the parent wizard category.
+ *
+ * @param parent The parent wizard category or <code>null</code>.
+ */
+ public void setParent(IWizardCategory parent) {
+ this.parent = parent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.wizards.IWizardCategory#findCategory(org.eclipse.core.runtime.IPath)
+ */
+ @Override
+ public IWizardCategory findCategory(IPath path) {
+ String searchString = path.segment(0);
+ for (IWizardCategory category : getCategories()) {
+ if (category.getId().equals(searchString)) {
+ if (path.segmentCount() == 1) {
+ return category;
+ }
+
+ return category.findCategory(path.removeFirstSegments(1));
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Find a category with the given id.
+ *
+ * @param id The category id.
+ * @return The category or <code>null</code>.
+ */
+ public IWizardCategory findCategory(String id) {
+ for (IWizardCategory category : getCategories()) {
+ if (id.equals(category.getId())) {
+ return category;
+ }
+ }
+ for (IWizardCategory category : getCategories()) {
+ IWizardCategory found = null;
+ if (category instanceof NewWizardCategory) {
+ found = ((NewWizardCategory)category).findCategory(id);
+ }
+ if (category instanceof WizardCollectionElement) {
+ found = ((WizardCollectionElement)category).findCategory(id);
+ }
+ if (found != null) {
+ return found;
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.wizards.IWizardCategory#findWizard(java.lang.String)
+ */
+ @Override
+ public IWizardDescriptor findWizard(String id) {
+ for (IWizardDescriptor wizard : getWizards()) {
+ if (wizard.getId().equals(id)) {
+ return wizard;
+ }
+ }
+ for (IWizardCategory category : getCategories()) {
+ IWizardDescriptor wizard = category.findWizard(id);
+ if (wizard != null) {
+ return wizard;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a sub category.
+ * @param category The category.
+ */
+ public void addCategory(IWizardCategory category) {
+ categories.add(category);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.wizards.IWizardCategory#getCategories()
+ */
+ @Override
+ public IWizardCategory[] getCategories() {
+ return categories.toArray(new IWizardCategory[categories.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.wizards.IWizardCategory#getId()
+ */
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.wizards.IWizardCategory#getLabel()
+ */
+ @Override
+ public String getLabel() {
+ return label;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.wizards.IWizardCategory#getParent()
+ */
+ @Override
+ public IWizardCategory getParent() {
+ return parent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.wizards.IWizardCategory#getPath()
+ */
+ @Override
+ public IPath getPath() {
+ return getParent() != null ? getParent().getPath().append(getId()) : new Path(getId());
+ }
+
+ /**
+ * Add a wizard.
+ * @param wizard The wizard.
+ */
+ public void addWizard(IWizardDescriptor wizard) {
+ wizards.add(wizard);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.wizards.IWizardCategory#getWizards()
+ */
+ @Override
+ public IWizardDescriptor[] getWizards() {
+ return wizards.toArray(new IWizardDescriptor[wizards.size()]);
+ }
+
+ @Override
+ public Object[] getChildren(Object o) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
+ */
+ @Override
+ public ImageDescriptor getImageDescriptor(Object object) {
+ return WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
+ */
+ @Override
+ public String getLabel(Object o) {
+ return getLabel();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
+ */
+ @Override
+ public Object getParent(Object o) {
+ return getParent();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardContentProvider.java
new file mode 100644
index 000000000..96ec94a44
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardContentProvider.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.wizards.newWizard;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.ui.wizards.IWizardCategory;
+import org.eclipse.ui.wizards.IWizardDescriptor;
+import org.eclipse.ui.wizards.IWizardRegistry;
+
+/**
+ * New wizard content provider implementation.
+ */
+public class NewWizardContentProvider implements ITreeContentProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)
+ */
+ @Override
+ public Object[] getElements(Object inputElement) {
+ List<Object> children = new ArrayList<Object>();
+ if (inputElement instanceof IWizardRegistry) {
+ IWizardRegistry registry = (IWizardRegistry)inputElement;
+ IWizardDescriptor[] primary = registry.getPrimaryWizards();
+ if (primary != null && primary.length > 0) {
+ children.addAll(Arrays.asList(primary));
+ }
+ children.addAll(Arrays.asList(getChildren(registry.getRootCategory())));
+
+ if (children.size() == 1 && children.get(0) instanceof IWizardCategory) {
+ IWizardCategory category = (IWizardCategory)children.get(0);
+ children.clear();
+ children.addAll(Arrays.asList(getChildren(category)));
+ }
+ }
+
+ return children.toArray();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+ */
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ List<Object> children = new ArrayList<Object>();
+ if (parentElement instanceof IWizardCategory) {
+ for (IWizardCategory category : ((IWizardCategory)parentElement).getCategories()) {
+ if ((category.getCategories() != null && category.getCategories().length > 0) ||
+ (category.getWizards() != null && category.getWizards().length > 0)) {
+ children.add(category);
+ }
+ }
+ children.addAll(Arrays.asList(((IWizardCategory)parentElement).getWizards()));
+
+ return children.toArray();
+ }
+ return new Object[0];
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+ */
+ @Override
+ public Object getParent(Object element) {
+ if (element instanceof IWizardCategory) {
+ return ((IWizardCategory)element).getParent();
+ }
+ else if (element instanceof IWizardDescriptor) {
+ return ((IWizardDescriptor)element).getCategory();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+ */
+ @Override
+ public boolean hasChildren(Object element) {
+ return getChildren(element).length > 0;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardDescriptor.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardDescriptor.java
new file mode 100644
index 000000000..25a573c86
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardDescriptor.java
@@ -0,0 +1,235 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.wizards.newWizard;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.wizards.IWizardCategory;
+import org.eclipse.ui.wizards.IWizardDescriptor;
+
+/**
+ * New wizard descriptor implementation.
+ */
+public class NewWizardDescriptor implements IWizardDescriptor, IWorkbenchAdapter {
+
+ private String id;
+ private String label;
+ private String description;
+ private String helpRef;
+ private ImageDescriptor imageDescriptor;
+ private IWizardCategory category;
+ private IWorkbenchWizard wizard;
+ private String[] tags;
+ private boolean canFinishEarly = false;
+ private boolean hasPages = true;
+
+ /**
+ * Constructor.
+ */
+ public NewWizardDescriptor(IWizardCategory category, String id, String label, String description, String helpRef, ImageDescriptor imageDescriptor) {
+ this.category = category;
+ this.id = id;
+ this.label = label;
+ this.description = description;
+ this.helpRef = helpRef;
+ this.imageDescriptor = imageDescriptor;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (other instanceof IWizardDescriptor) {
+ ((IWizardDescriptor)other).getId().equals(getId());
+ }
+ return super.equals(other);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPartDescriptor#getId()
+ */
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPartDescriptor#getImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return imageDescriptor;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPartDescriptor#getLabel()
+ */
+ @Override
+ public String getLabel() {
+ return label;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ @Override
+ public Object getAdapter(Class adapter) {
+ return Platform.getAdapterManager().getAdapter(this, adapter);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.wizards.IWizardDescriptor#adaptedSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ @Override
+ public IStructuredSelection adaptedSelection(IStructuredSelection selection) {
+ return selection;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.wizards.IWizardDescriptor#getDescription()
+ */
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Set tags for this wizard.
+ * @param tags The tags.
+ */
+ public void setTags(String[] tags) {
+ this.tags = tags;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.wizards.IWizardDescriptor#getTags()
+ */
+ @Override
+ public String[] getTags() {
+ return tags;
+ }
+
+ /**
+ * Set the wizard.
+ * @param wizard The wizard.
+ */
+ public void setWizard(IWorkbenchWizard wizard) {
+ this.wizard = wizard;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.wizards.IWizardDescriptor#createWizard()
+ */
+ @Override
+ public IWorkbenchWizard createWizard() throws CoreException {
+ return wizard;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.wizards.IWizardDescriptor#getDescriptionImage()
+ */
+ @Override
+ public ImageDescriptor getDescriptionImage() {
+ return imageDescriptor;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.wizards.IWizardDescriptor#getHelpHref()
+ */
+ @Override
+ public String getHelpHref() {
+ return helpRef;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.wizards.IWizardDescriptor#getCategory()
+ */
+ @Override
+ public IWizardCategory getCategory() {
+ return category;
+ }
+
+ /**
+ * Set the canFinishEarly flag.
+ * @param canFinishEarly
+ */
+ public void setCanFinishEarly(boolean canFinishEarly) {
+ this.canFinishEarly = canFinishEarly;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.wizards.IWizardDescriptor#canFinishEarly()
+ */
+ @Override
+ public boolean canFinishEarly() {
+ return canFinishEarly;
+ }
+
+ /**
+ * Set the hasPages flag.
+ * @param hasPages
+ */
+ public void setHasPages(boolean hasPages) {
+ this.hasPages = hasPages;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.wizards.IWizardDescriptor#hasPages()
+ */
+ @Override
+ public boolean hasPages() {
+ return hasPages;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
+ */
+ @Override
+ public Object[] getChildren(Object o) {
+ return new Object[0];
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
+ */
+ @Override
+ public ImageDescriptor getImageDescriptor(Object object) {
+ return getImageDescriptor();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
+ */
+ @Override
+ public String getLabel(Object o) {
+ return getLabel();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
+ */
+ @Override
+ public Object getParent(Object o) {
+ return getCategory();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardRegistry.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardRegistry.java
index 0b297ad3e..fd2e56fea 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardRegistry.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardRegistry.java
@@ -1,26 +1,42 @@
/*******************************************************************************
- * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. 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:
* Wind River Systems - initial API and implementation
+ * Tobias Schwarz (Wind River) - [368243] [UI] Allow dynamic new wizard contributions
*******************************************************************************/
package org.eclipse.tcf.te.ui.wizards.newWizard;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.tcf.te.ui.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.wizards.interfaces.INewWizardProvider;
+import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
import org.eclipse.ui.internal.wizards.AbstractExtensionWizardRegistry;
+import org.eclipse.ui.wizards.IWizardCategory;
+import org.eclipse.ui.wizards.IWizardDescriptor;
/**
- * New target wizard registry.
+ * New wizard registry.
*
* @see org.eclipse.ui.internal.wizards.NewWizardRegistry
*/
@SuppressWarnings("restriction")
public final class NewWizardRegistry extends AbstractExtensionWizardRegistry {
+ private List<INewWizardProvider> newWizardProvider = new ArrayList<INewWizardProvider>();
+
/*
* Thread save singleton instance creation.
*/
@@ -42,13 +58,32 @@ public final class NewWizardRegistry extends AbstractExtensionWizardRegistry {
return LazyInstance.instance;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.internal.wizards.AbstractExtensionWizardRegistry#doInitialize()
+ */
+ @Override
+ protected void doInitialize() {
+ super.doInitialize();
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(getPlugin(), "wizardProviders"); //$NON-NLS-1$
+ for (IConfigurationElement element : point.getConfigurationElements()) {
+ if (element.getName().equals("wizardProvider")) { //$NON-NLS-1$
+ try {
+ INewWizardProvider provider = (INewWizardProvider)element.createExecutableExtension("class"); //$NON-NLS-1$
+ newWizardProvider.add(provider);
+ }
+ catch (CoreException e) {
+ }
+ }
+ }
+
+ }
/* (non-Javadoc)
* @see org.eclipse.ui.internal.wizards.AbstractExtensionWizardRegistry#getExtensionPoint()
*/
@Override
protected String getExtensionPoint() {
- return "newWizards"; //$NON-NLS-1$
+ return IWorkbenchRegistryConstants.PL_NEW;
}
/* (non-Javadoc)
@@ -59,4 +94,72 @@ public final class NewWizardRegistry extends AbstractExtensionWizardRegistry {
return UIPlugin.getUniqueIdentifier();
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.internal.wizards.AbstractWizardRegistry#findWizard(java.lang.String)
+ */
+ @Override
+ public IWizardDescriptor findWizard(String id) {
+ return getRootCategory().findWizard(id);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.internal.wizards.AbstractWizardRegistry#getPrimaryWizards()
+ */
+ @Override
+ public IWizardDescriptor [] getPrimaryWizards() {
+ return super.getPrimaryWizards();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.internal.wizards.AbstractWizardRegistry#findCategory(java.lang.String)
+ */
+ @Override
+ public IWizardCategory findCategory(String id) {
+ IWizardCategory root = getRootCategory();
+ if (root instanceof NewWizardCategory) {
+ ((NewWizardCategory)root).findCategory(id);
+ }
+ return super.findCategory(id);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.internal.wizards.AbstractWizardRegistry#getRootCategory()
+ */
+ @Override
+ public IWizardCategory getRootCategory() {
+ initialize();
+ if (!newWizardProvider.isEmpty()) {
+ NewWizardCategory root = new NewWizardCategory(super.getRootCategory());
+
+ for (INewWizardProvider provider : newWizardProvider) {
+ for (IWizardCategory category : provider.getCategories()) {
+ root.addCategory(category);
+ }
+ }
+
+ return root;
+ }
+
+ return super.getRootCategory();
+ }
+
+ /**
+ * Get the list of common wizards for the given selection.
+ *
+ * @param selection The current selection.
+ * @return The list of common wizards.
+ */
+ public IWizardDescriptor[] getCommonWizards(ISelection selection) {
+ initialize();
+ List<IWizardDescriptor> allWizards = new ArrayList<IWizardDescriptor>();
+
+ for (INewWizardProvider provider : newWizardProvider) {
+ IWizardDescriptor[] wizards = provider.getCommonWizards(selection);
+ if (wizards != null && wizards.length > 0) {
+ allWizards.addAll(Arrays.asList(wizards));
+ }
+ }
+
+ return allWizards.toArray(new IWizardDescriptor[allWizards.size()]);
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardSelectionPage.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardSelectionPage.java
index 2f43218ff..402b4f263 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardSelectionPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardSelectionPage.java
@@ -1,11 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. 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:
* Wind River Systems - initial API and implementation
+ * Tobias Schwarz (Wind River) - [368243] [UI] Allow dynamic new wizard contributions
*******************************************************************************/
package org.eclipse.tcf.te.ui.wizards.newWizard;
@@ -60,7 +61,6 @@ import org.eclipse.ui.activities.WorkbenchActivityHelper;
import org.eclipse.ui.dialogs.FilteredTree;
import org.eclipse.ui.dialogs.PatternFilter;
import org.eclipse.ui.internal.activities.ws.WorkbenchTriggerPoints;
-import org.eclipse.ui.internal.dialogs.WizardContentProvider;
import org.eclipse.ui.internal.dialogs.WizardPatternFilter;
import org.eclipse.ui.internal.dialogs.WorkbenchWizardElement;
import org.eclipse.ui.model.WorkbenchLabelProvider;
@@ -212,7 +212,7 @@ public class NewWizardSelectionPage extends WizardPage {
filteredTree.setLayoutData(layoutData);
final TreeViewer treeViewer = filteredTree.getViewer();
- treeViewer.setContentProvider(new WizardContentProvider());
+ treeViewer.setContentProvider(new NewWizardContentProvider());
treeViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
treeViewer.setComparator(new NewWizardViewerComparator());
@@ -234,7 +234,9 @@ public class NewWizardSelectionPage extends WizardPage {
Object element = selection.getFirstElement();
if (element instanceof IWizardDescriptor) {
// Double-click on a connection type is triggering the sub wizard
- if (canFlipToNextPage()) getWizard().getContainer().showPage(getNextPage());
+ if (canFlipToNextPage()) {
+ getWizard().getContainer().showPage(getNextPage());
+ }
} else if (event.getViewer() instanceof TreeViewer) {
TreeViewer viewer = (TreeViewer)event.getViewer();
if (viewer.isExpandable(element)) {
@@ -245,7 +247,7 @@ public class NewWizardSelectionPage extends WizardPage {
}
});
- treeViewer.setInput(wizardRegistry.getRootCategory());
+ treeViewer.setInput(wizardRegistry);
// apply the standard dialog font
Dialog.applyDialogFont(composite);
@@ -303,7 +305,9 @@ public class NewWizardSelectionPage extends WizardPage {
if (selectedWizardDescriptor.getDescription() != null && !"".equals(selectedWizardDescriptor.getDescription())) { //$NON-NLS-1$
setDescription(selectedWizardDescriptor.getDescription());
} else {
- if (!getDefaultDescription().equals(getDescription())) setDescription(getDefaultDescription());
+ if (!getDefaultDescription().equals(getDescription())) {
+ setDescription(getDefaultDescription());
+ }
}
} else {
selectedWizardDescriptor = null;
@@ -341,7 +345,9 @@ public class NewWizardSelectionPage extends WizardPage {
if (wizard != null) {
// If the wizard got created by the call to getWizard(),
// then allow the wizard to create its pages
- if (!isCreated) wizard.addPages();
+ if (!isCreated) {
+ wizard.addPages();
+ }
// Return the starting page of the wizard
return wizard.getStartingPage();
}
@@ -393,9 +399,13 @@ public class NewWizardSelectionPage extends WizardPage {
IDialogSettings settings = super.getDialogSettings();
// If the dialog settings could not set from the wizard, fallback to the plugin's
// dialog settings store.
- if (settings == null) settings = UIPlugin.getDefault().getDialogSettings();
+ if (settings == null) {
+ settings = UIPlugin.getDefault().getDialogSettings();
+ }
String sectionName = this.getClass().getName();
- if (settings.getSection(sectionName) == null) settings.addNewSection(sectionName);
+ if (settings.getSection(sectionName) == null) {
+ settings.addNewSection(sectionName);
+ }
settings = settings.getSection(sectionName);
return settings;
@@ -409,11 +419,13 @@ public class NewWizardSelectionPage extends WizardPage {
if (settings != null) {
String[] expandedCategories = settings.getArray(EXPANDED_CATEGORIES_SETTINGS_ID);
// by default we expand always the "General" category.
- if (expandedCategories == null) expandedCategories = DEFAULT_EXPANDED_CATEGORY_IDS;
+ if (expandedCategories == null) {
+ expandedCategories = DEFAULT_EXPANDED_CATEGORY_IDS;
+ }
if (expandedCategories != null) {
List<IWizardCategory> expanded = new ArrayList<IWizardCategory>();
- for (int i = 0; i < expandedCategories.length; i++) {
- String categoryId = expandedCategories[i];
+ for (String expandedCategorie : expandedCategories) {
+ String categoryId = expandedCategorie;
if (categoryId != null && !"".equals(categoryId.trim())) { //$NON-NLS-1$
IWizardCategory category = wizardRegistry.findCategory(categoryId);
if (category != null && !expanded.contains(category)) {
@@ -422,7 +434,9 @@ public class NewWizardSelectionPage extends WizardPage {
}
}
- if (expanded.size() > 0) filteredTree.getViewer().setExpandedElements(expanded.toArray());
+ if (expanded.size() > 0) {
+ filteredTree.getViewer().setExpandedElements(expanded.toArray());
+ }
}
String selectedWizardDescriptorId = settings.get(SELECTED_WIZARD_DESCRIPTOR_SETTINGS_ID);
@@ -443,9 +457,9 @@ public class NewWizardSelectionPage extends WizardPage {
if (settings != null) {
List<String> expandedCategories = new ArrayList<String>();
Object[] expanded = filteredTree.getViewer().getVisibleExpandedElements();
- for (int i = 0; i < expanded.length; i++) {
- if (expanded[i] instanceof IWizardCategory) {
- expandedCategories.add(((IWizardCategory)expanded[i]).getId());
+ for (Object element : expanded) {
+ if (element instanceof IWizardCategory) {
+ expandedCategories.add(((IWizardCategory)element).getId());
}
}
settings.put(EXPANDED_CATEGORIES_SETTINGS_ID, expandedCategories.toArray(new String[expandedCategories.size()]));

Back to the top