Added support for provisioner extension point and deprecated extension
point

Bug 347695 - [target] [API] Extension point to contribute UI to add and
diff --git a/ui/org.eclipse.pde.ui/plugin.properties b/ui/org.eclipse.pde.ui/plugin.properties
index 2bbbc72..dc80cc2 100644
--- a/ui/org.eclipse.pde.ui/plugin.properties
+++ b/ui/org.eclipse.pde.ui/plugin.properties
@@ -214,7 +214,8 @@
 
 provisioner.file.description = This provisioner adds new plug-ins from the file system into your target platform.
 provisioner.file.name = File System
-extension-point.name.0 = Provisioners
+extension-point.name.0 = Target Provisioners
+extension-point.name.2 = Target Location Provisioners
 provisioner.p2.name = Repository or Update Site
 provisioner.p2.description = This provisioner adds new plug-ins from repositories and update sites into your target platform.
 
diff --git a/ui/org.eclipse.pde.ui/plugin.xml b/ui/org.eclipse.pde.ui/plugin.xml
index 1b0ddba..053884b 100644
--- a/ui/org.eclipse.pde.ui/plugin.xml
+++ b/ui/org.eclipse.pde.ui/plugin.xml
@@ -20,7 +20,7 @@
    <extension-point id="templates" name="%expoint.templates.name" schema="schema/templates.exsd"/>
    <extension-point id="samples" name="%expoint.samples.name" schema="schema/samples.exsd"/>
    <extension-point id="targetProvisioners" name="%extension-point.name.0" schema="schema/targetProvisioners.exsd"/>
-   <extension-point id="targetLocationProviders" name="%extension-point.name.0" schema="schema/targetLocationProviders.exsd"/>
+   <extension-point id="targetLocationProvisioners" name="%extension-point.name.2" schema="schema/targetLocationProvisioners.exsd"/>
    <extension-point id="launchShortcuts" name="%extension-point.name.1" schema="schema/launchShortcuts.exsd"/>
 
 <!-- Extensions -->
@@ -2167,19 +2167,6 @@
       </consolePageParticipant>
    </extension>
    <extension
-         point="org.eclipse.pde.ui.targetLocationProviders">
-      <locationProvider
-            icon="icons/obj16/metadata_repo_obj.gif"
-            id="org.eclipse.pde.ui.InstallableUnit"
-            name="%targetLocationProvider.IU.name"
-            type="InstallableUnit"
-            uifactory="org.eclipse.pde.internal.ui.shared.target.IUFactory">
-         <description>
-            %targetLocationProvider.IU.description
-         </description>
-      </locationProvider>
-   </extension>
-   <extension
          point="org.eclipse.core.runtime.adapters">
       <factory
             adaptableType="org.eclipse.pde.core.target.ITargetLocation"
@@ -2198,4 +2185,17 @@
          </adapter>
       </factory>
    </extension>
+   <extension
+         point="org.eclipse.pde.ui.targetLocationProvisioners">
+      <locationProvider
+            class="org.eclipse.pde.internal.ui.shared.target.InstallableUnitWizard"
+            icon="icons/obj16/metadata_repo_obj.gif"
+            id="org.eclipse.pde.ui.InstallableUnitProvisioner"
+            name="%targetLocationProvider.IU.name"
+            type="org.eclipse.pde.ui.locationProvider1">
+         <description>
+            %targetLocationProvider.IU.description
+         </description>
+      </locationProvider>
+   </extension>
 </plugin>
diff --git a/ui/org.eclipse.pde.ui/schema/targetLocationProviders.exsd b/ui/org.eclipse.pde.ui/schema/targetLocationProvisioners.exsd
similarity index 91%
rename from ui/org.eclipse.pde.ui/schema/targetLocationProviders.exsd
rename to ui/org.eclipse.pde.ui/schema/targetLocationProvisioners.exsd
index adad93a..04a5ff6 100644
--- a/ui/org.eclipse.pde.ui/schema/targetLocationProviders.exsd
+++ b/ui/org.eclipse.pde.ui/schema/targetLocationProvisioners.exsd
@@ -1,179 +1,182 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.pde.ui" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
-      <appInfo>
-         <meta.schema plugin="org.eclipse.pde.ui" id="targetLocationProviders" name="Target Location Providers"/>
-      </appInfo>
-      <documentation>
-         &lt;p&gt;
-This extension point is used to register new target plug-in location provider. Each plug-in location provider is listed when the user attempts to add plug-ins from the PDE Target Platform&apos;s Preference Page.  The selected location provider is responsible for providing the target location which contain plug-ins the user wants to add to the Target Platform.
-&lt;/p&gt;
-      </documentation>
-   </annotation>
-
-   <element name="extension">
-      <annotation>
-         <appInfo>
-            <meta.element />
-         </appInfo>
-      </annotation>
-      <complexType>
-         <sequence>
-            <element ref="locationProvider" minOccurs="1" maxOccurs="unbounded"/>
-         </sequence>
-         <attribute name="point" type="string" use="required">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="id" type="string">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="name" type="string">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-               <appInfo>
-                  <meta.attribute translatable="true"/>
-               </appInfo>
-            </annotation>
-         </attribute>
-      </complexType>
-   </element>
-
-   <element name="locationProvider">
-      <annotation>
-         <appInfo>
-            <meta.element labelAttribute="name" icon="icon"/>
-         </appInfo>
-      </annotation>
-      <complexType>
-         <sequence>
-            <element ref="description" minOccurs="0" maxOccurs="1"/>
-         </sequence>
-         <attribute name="id" type="string" use="required">
-            <annotation>
-               <documentation>
-                  a unique identifier of the provisioner
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="name" type="string" use="required">
-            <annotation>
-               <documentation>
-                  human readable name of the provisioner
-               </documentation>
-               <appInfo>
-                  <meta.attribute translatable="true"/>
-               </appInfo>
-            </annotation>
-         </attribute>
-         <attribute name="icon" type="string">
-            <annotation>
-               <documentation>
-                  a relative path of an icon that will be used to visually 
-represent the provisioner.
-               </documentation>
-               <appInfo>
-                  <meta.attribute kind="resource"/>
-               </appInfo>
-            </annotation>
-         </attribute>
-         <attribute name="type" type="string" use="required">
-            <annotation>
-               <documentation>
-                  The Target Location type provided by the wizard
-               </documentation>
-            </annotation>
-         </attribute>
-      </complexType>
-   </element>
-
-   <element name="description" type="string">
-      <annotation>
-         <appInfo>
-            <meta.element translatable="true"/>
-         </appInfo>
-         <documentation>
-            human-readable description of the provisioner
-         </documentation>
-      </annotation>
-   </element>
-
-   <annotation>
-      <appInfo>
-         <meta.section type="since"/>
-      </appInfo>
-      <documentation>
-         3.8
-      </documentation>
-   </annotation>
-
-   <annotation>
-      <appInfo>
-         <meta.section type="examples"/>
-      </appInfo>
-      <documentation>
-         &lt;p&gt;
-The following is an example of the extension point:
-&lt;pre&gt;
-   &lt;extension
-         point=&quot;org.eclipse.pde.ui.targetLocationProviders&quot;&gt;
-      &lt;locationProvider
-            icon=&quot;icons/obj16/metadata_repo_obj.gif&quot;
-            id=&quot;org.eclipse.pde.ui.InstallableUnit&quot;
-            name=&quot;%targetLocationProvider.IU.name&quot;
-            type=&quot;InstallableUnit&quot;
-            uifactory=&quot;org.eclipse.pde.internal.ui.shared.target.IUFactory&quot;&gt;
-         &lt;description&gt;
-            %targetLocationProvider.IU.description
-         &lt;/description&gt;
-      &lt;/locationProvider&gt;
-   &lt;/extension&gt;
-&lt;/pre&gt;
-      </documentation>
-   </annotation>
-
-   <annotation>
-      <appInfo>
-         <meta.section type="implementation"/>
-      </appInfo>
-      <documentation>
-         &lt;p&gt;
-PDE supplies an update site location provider to add plug-ins from repositories.
-&lt;/p&gt;
-      </documentation>
-   </annotation>
-
-   <annotation>
-      <appInfo>
-         <meta.section type="copyright"/>
-      </appInfo>
-      <documentation>
-         Copyright (c) 2011 IBM Corporation and others.
-&lt;br&gt;
-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 
-&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;.
-      </documentation>
-   </annotation>
-
-   <annotation>
-      <appInfo>
-         <meta.section type="apiInfo"/>
-      </appInfo>
-      <documentation>
-         Each template mut provide an adapter factory to provide labels and contents for the target location. It may optionally implement &lt;code&gt;org.eclipse.pde.ui.ILocationUIFactory&lt;/code&gt; interface if it needs to be seeded with the target definition.
-      </documentation>
-   </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?>

+<!-- Schema file written by PDE -->

+<schema targetNamespace="org.eclipse.pde.ui" xmlns="http://www.w3.org/2001/XMLSchema">

+<annotation>

+      <appInfo>

+         <meta.schema plugin="org.eclipse.pde.ui" id="targetLocationProvisioners" name="Target Location Provisioners"/>

+      </appInfo>

+      <documentation>

+         &lt;p&gt;

+This extension point is used to register new target plug-in location provider. Each plug-in location provider is listed when the user attempts to add plug-ins from the PDE Target Platform&apos;s Preference Page.  The selected location provider is responsible for providing the target location which contain plug-ins the user wants to add to the Target Platform.

+&lt;/p&gt;

+      </documentation>

+   </annotation>

+

+   <element name="extension">

+      <annotation>

+         <appInfo>

+            <meta.element />

+         </appInfo>

+      </annotation>

+      <complexType>

+         <sequence>

+            <element ref="locationProvider" minOccurs="1" maxOccurs="unbounded"/>

+         </sequence>

+         <attribute name="point" type="string" use="required">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+            </annotation>

+         </attribute>

+         <attribute name="id" type="string">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+            </annotation>

+         </attribute>

+         <attribute name="name" type="string">

+            <annotation>

+               <documentation>

+                  

+               </documentation>

+               <appInfo>

+                  <meta.attribute translatable="true"/>

+               </appInfo>

+            </annotation>

+         </attribute>

+      </complexType>

+   </element>

+

+   <element name="locationProvider">

+      <annotation>

+         <appInfo>

+            <meta.element labelAttribute="name" icon="icon"/>

+         </appInfo>

+      </annotation>

+      <complexType>

+         <sequence>

+            <element ref="description" minOccurs="0" maxOccurs="1"/>

+         </sequence>

+         <attribute name="id" type="string" use="required">

+            <annotation>

+               <documentation>

+                  a unique identifier of the provisioner

+               </documentation>

+            </annotation>

+         </attribute>

+         <attribute name="name" type="string" use="required">

+            <annotation>

+               <documentation>

+                  human readable name of the provisioner

+               </documentation>

+               <appInfo>

+                  <meta.attribute translatable="true"/>

+               </appInfo>

+            </annotation>

+         </attribute>

+         <attribute name="icon" type="string">

+            <annotation>

+               <documentation>

+                  a relative path of an icon that will be used to visually 

+represent the provisioner.

+               </documentation>

+               <appInfo>

+                  <meta.attribute kind="resource"/>

+               </appInfo>

+            </annotation>

+         </attribute>

+         <attribute name="class" type="string" use="required">

+            <annotation>

+               <documentation>

+                  a class that provides a wizard for the user to add content to the target.  The value of this attribute is the fully qualified name of the Java class that implements &lt;code&gt;org.eclipse.pde.ui.target.ITargetLocationWizard&lt;/code&gt;.

+               </documentation>

+               <appInfo>

+                  <meta.attribute kind="java" basedOn=":org.eclipse.pde.ui.target.ITargetLocationWizard"/>

+               </appInfo>

+            </annotation>

+         </attribute>

+      </complexType>

+   </element>

+

+   <element name="description" type="string">

+      <annotation>

+         <appInfo>

+            <meta.element translatable="true"/>

+         </appInfo>

+         <documentation>

+            human-readable description of the provisioner

+         </documentation>

+      </annotation>

+   </element>

+

+   <annotation>

+      <appInfo>

+         <meta.section type="since"/>

+      </appInfo>

+      <documentation>

+         3.8

+      </documentation>

+   </annotation>

+

+   <annotation>

+      <appInfo>

+         <meta.section type="examples"/>

+      </appInfo>

+      <documentation>

+         &lt;p&gt;

+The following is an example of the extension point:

+&lt;pre&gt;

+   &lt;extension

+         point=&quot;org.eclipse.pde.ui.targetLocationProviders&quot;&gt;

+      &lt;locationProvider

+            icon=&quot;icons/obj16/metadata_repo_obj.gif&quot;

+            id=&quot;org.eclipse.pde.ui.InstallableUnit&quot;

+            name=&quot;%targetLocationProvider.IU.name&quot;

+            type=&quot;InstallableUnit&quot;

+            uifactory=&quot;org.eclipse.pde.internal.ui.shared.target.IUFactory&quot;&gt;

+         &lt;description&gt;

+            %targetLocationProvider.IU.description

+         &lt;/description&gt;

+      &lt;/locationProvider&gt;

+   &lt;/extension&gt;

+&lt;/pre&gt;

+      </documentation>

+   </annotation>

+

+   <annotation>

+      <appInfo>

+         <meta.section type="implementation"/>

+      </appInfo>

+      <documentation>

+         &lt;p&gt;

+PDE supplies an update site location provider to add plug-ins from repositories.

+&lt;/p&gt;

+      </documentation>

+   </annotation>

+

+   <annotation>

+      <appInfo>

+         <meta.section type="copyright"/>

+      </appInfo>

+      <documentation>

+         Copyright (c) 2011 IBM Corporation and others.

+&lt;br&gt;

+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 

+&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;.

+      </documentation>

+   </annotation>

+

+   <annotation>

+      <appInfo>

+         <meta.section type="apiInfo"/>

+      </appInfo>

+      <documentation>

+         Each template mut provide an adapter factory to provide labels and contents for the target location. It may optionally implement &lt;code&gt;org.eclipse.pde.ui.ILocationUIFactory&lt;/code&gt; interface if it needs to be seeded with the target definition.

+      </documentation>

+   </annotation>

+

+</schema>

diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/AddBundleContainerSelectionPage.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/AddBundleContainerSelectionPage.java
index ea93c7d..d7accf6 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/AddBundleContainerSelectionPage.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/AddBundleContainerSelectionPage.java
@@ -10,17 +10,19 @@
  *******************************************************************************/
 package org.eclipse.pde.internal.ui.shared.target;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 import org.eclipse.core.runtime.*;
 import org.eclipse.jface.dialogs.*;
 import org.eclipse.jface.viewers.*;
 import org.eclipse.jface.wizard.*;
-import org.eclipse.pde.core.target.ITargetDefinition;
-import org.eclipse.pde.core.target.ITargetLocation;
+import org.eclipse.pde.core.target.*;
+import org.eclipse.pde.internal.core.PDECore;
 import org.eclipse.pde.internal.ui.*;
 import org.eclipse.pde.internal.ui.wizards.WizardElement;
-import org.eclipse.pde.ui.target.ILocationWizard;
+import org.eclipse.pde.ui.IProvisionerWizard;
+import org.eclipse.pde.ui.target.ITargetLocationWizard;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.SashForm;
 import org.eclipse.swt.graphics.Image;
@@ -42,7 +44,12 @@
 	/**
 	 * Extension point that provides target provisioner wizard
 	 */
-	private static final String TARGETLOCATION_PROVIDER_POINT = "targetLocationProviders"; //$NON-NLS-1$
+	private static final String TARGET_LOCATION_PROVISIONER_POINT = "targetLocationProvisioners"; //$NON-NLS-1$
+
+	/**
+	 * Deprecated extension point providing target provisioner wizards
+	 */
+	private static final String TARGET_PROVISIONER_POINT = "targetProvisioners"; //$NON-NLS-1$
 
 	/**
 	 * Section in the dialog settings for this wizard and the wizards created with selection
@@ -50,6 +57,7 @@
 	 */
 	static final String SETTINGS_SECTION = "editBundleContainerWizard"; //$NON-NLS-1$
 
+	private static ITargetPlatformService fTargetService;
 	private Text fDescription;
 	private ITargetDefinition fTarget;
 
@@ -61,6 +69,21 @@
 		fTarget = target;
 	}
 
+	/**
+	 * Gets the target platform service provided by PDE Core
+	 * @return the target platform service
+	 * @throws CoreException if unable to acquire the service
+	 */
+	private static ITargetPlatformService getTargetPlatformService() throws CoreException {
+		if (fTargetService == null) {
+			fTargetService = (ITargetPlatformService) PDECore.getDefault().acquireService(ITargetPlatformService.class.getName());
+			if (fTargetService == null) {
+				throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, Messages.AddDirectoryContainerPage_9));
+			}
+		}
+		return fTargetService;
+	}
+
 	/* (non-Javadoc)
 	 * @see org.eclipse.jface.wizard.WizardSelectionPage#dispose()
 	 */
@@ -139,7 +162,8 @@
 	private void initViewerContents(TableViewer wizardSelectionViewer) {
 		List choices = new ArrayList();
 		choices.addAll(getStandardChoices());
-		choices.addAll(getLocationExtensionChoices());
+		choices.addAll(getTargetLocationProvisionerChoices()); // Extension point contributions
+		choices.addAll(getTargetProvisionerChoices()); // Deprecated extension point contributions
 		wizardSelectionViewer.setInput(choices.toArray(new IWizardNode[choices.size()]));
 	}
 
@@ -275,10 +299,10 @@
 	 * The extension point was deprecated in 3.5 but we need to retain some compatibility.
 	 * @return list of wizard nodes
 	 */
-	private List getLocationExtensionChoices() {
+	private List getTargetLocationProvisionerChoices() {
 		List list = new ArrayList();
 		IExtensionRegistry registry = Platform.getExtensionRegistry();
-		IExtensionPoint point = registry.getExtensionPoint(PDEPlugin.getPluginId(), TARGETLOCATION_PROVIDER_POINT);
+		IExtensionPoint point = registry.getExtensionPoint(PDEPlugin.getPluginId(), TARGET_LOCATION_PROVISIONER_POINT);
 		if (point == null)
 			return list;
 		IExtension[] extensions = point.getExtensions();
@@ -299,7 +323,44 @@
 						}
 					};
 					if (!WorkbenchActivityHelper.filterItem(pc)) {
-						list.add(createExtensionNode(element, elements[j].getAttribute("type")));
+						list.add(createTargetLocationProvisionerNode(element));
+					}
+				}
+			}
+		}
+		return list;
+	}
+
+	/**
+	 * Returns a list of choices created from the ITargetProvisioner extension
+	 * The extension point was deprecated in 3.5 but we need to retain some compatibility.
+	 * @return list of wizard nodes
+	 */
+	private List getTargetProvisionerChoices() {
+		List list = new ArrayList();
+		IExtensionRegistry registry = Platform.getExtensionRegistry();
+		IExtensionPoint point = registry.getExtensionPoint(PDEPlugin.getPluginId(), TARGET_PROVISIONER_POINT);
+		if (point == null)
+			return list;
+		IExtension[] extensions = point.getExtensions();
+		for (int i = 0; i < extensions.length; i++) {
+			IConfigurationElement[] elements = extensions[i].getConfigurationElements();
+			for (int j = 0; j < elements.length; j++) {
+				WizardElement element = createWizardElement(elements[j]);
+				if (element != null) {
+					final String pluginId = element.getPluginId();
+					final String contributionId = element.getID();
+					IPluginContribution pc = new IPluginContribution() {
+						public String getLocalId() {
+							return contributionId;
+						}
+
+						public String getPluginId() {
+							return pluginId;
+						}
+					};
+					if (!WorkbenchActivityHelper.filterItem(pc)) {
+						list.add(createDeprecatedExtensionNode(element));
 					}
 				}
 			}
@@ -334,45 +395,107 @@
 	 * @param element wizard element representing the extension
 	 * @return wizard node
 	 */
-	private AbstractBundleContainerNode createExtensionNode(final WizardElement element, final String type) {
+	private AbstractBundleContainerNode createTargetLocationProvisionerNode(final WizardElement element) {
 		return new AbstractBundleContainerNode(element.getLabel(), element.getDescription(), element.getImage()) {
 			public IWizard createWizard() {
 				Wizard wizard = new Wizard() {
-					private ILocationWizard addWizard;
+					private ITargetLocationWizard fWizard;
 
 					public void addPages() {
-						addWizard = LocationProviderManager.getInstance(fTarget).getAddWizard(type);
-						if (addWizard == null) {
+						try {
+							fWizard = (ITargetLocationWizard) element.createExecutableExtension();
+						} catch (CoreException e) {
+							PDEPlugin.log(e);
 							MessageDialog.openError(getContainer().getShell(), Messages.Errors_CreationError, Messages.Errors_CreationError_NoWizard);
-							return;
 						}
-						addWizard.setContainer(getContainer());
-						addWizard.addPages();
-						IWizardPage[] pages = addWizard.getPages();
+						fWizard.setTarget(fTarget);
+						fWizard.setContainer(getContainer());
+						fWizard.addPages();
+						IWizardPage[] pages = fWizard.getPages();
 						for (int i = 0; i < pages.length; i++)
 							addPage(pages[i]);
 					}
 
 					public boolean performFinish() {
-						if (addWizard != null) {
-							if (!addWizard.performFinish()) {
+						if (fWizard != null) {
+							if (!fWizard.performFinish()) {
 								return false;
 							}
-							ITargetLocation[] locations = addWizard.getLocations();
-							for (int i = 0; i < locations.length; i++) {
-								if (locations[i] == null) {
+							ITargetLocation[] locations = fWizard.getLocations();
+							if (locations != null) {
+								ITargetLocation[] oldContainers = fTarget.getTargetLocations();
+								if (oldContainers == null) {
+									fTarget.setTargetLocations(locations);
+								} else {
+									ITargetLocation[] newContainers = new ITargetLocation[oldContainers.length + locations.length];
+									System.arraycopy(oldContainers, 0, newContainers, 0, oldContainers.length);
+									System.arraycopy(locations, 0, newContainers, oldContainers.length, locations.length);
+									fTarget.setTargetLocations(newContainers);
+								}
+							}
+						}
+						return true;
+					}
+				};
+				wizard.setContainer(getContainer());
+				wizard.setWindowTitle(Messages.AddBundleContainerSelectionPage_1);
+				return wizard;
+			}
+		};
+	}
+
+	/**
+	 * Creates a wizard node that will get the pages from the contributed wizard and create a directory bundle container from the result
+	 * @param element wizard element representing the extension
+	 * @return wizard node
+	 */
+	private AbstractBundleContainerNode createDeprecatedExtensionNode(final WizardElement element) {
+		return new AbstractBundleContainerNode(element.getLabel(), element.getDescription(), element.getImage()) {
+			public IWizard createWizard() {
+				Wizard wizard = new Wizard() {
+					private IProvisionerWizard fWizard;
+
+					public void addPages() {
+						try {
+							fWizard = (IProvisionerWizard) element.createExecutableExtension();
+						} catch (CoreException e) {
+							PDEPlugin.log(e);
+							MessageDialog.openError(getContainer().getShell(), Messages.Errors_CreationError, Messages.Errors_CreationError_NoWizard);
+						}
+						fWizard.setContainer(getContainer());
+						fWizard.addPages();
+						IWizardPage[] pages = fWizard.getPages();
+						for (int i = 0; i < pages.length; i++)
+							addPage(pages[i]);
+					}
+
+					public boolean performFinish() {
+						if (fWizard != null) {
+							if (!fWizard.performFinish()) {
+								return false;
+							}
+							File[] dirs = fWizard.getLocations();
+							for (int i = 0; i < dirs.length; i++) {
+								if (dirs[i] == null || !dirs[i].isDirectory()) {
 									ErrorDialog.openError(getShell(), Messages.AddBundleContainerSelectionPage_0, Messages.AddBundleContainerSelectionPage_5, new Status(IStatus.ERROR, PDEPlugin.getPluginId(), Messages.AddDirectoryContainerPage_6));
 									return false;
 								}
-							}
-							ITargetLocation[] oldContainers = fTarget.getTargetLocations();
-							if (oldContainers == null || oldContainers.length == 0) {
-								fTarget.setTargetLocations(locations);
-							} else {
-								ITargetLocation[] newContainers = new ITargetLocation[oldContainers.length + locations.length];
-								System.arraycopy(oldContainers, 0, newContainers, 0, oldContainers.length);
-								System.arraycopy(locations, 0, newContainers, oldContainers.length, locations.length);
-								fTarget.setTargetLocations(newContainers);
+								try {
+									// First try the specified dir, then try the plugins dir
+									ITargetLocation container = getTargetPlatformService().newDirectoryLocation(dirs[i].getPath());
+									ITargetLocation[] oldContainers = fTarget.getTargetLocations();
+									if (oldContainers == null) {
+										fTarget.setTargetLocations(new ITargetLocation[] {container});
+									} else {
+										ITargetLocation[] newContainers = new ITargetLocation[oldContainers.length + 1];
+										System.arraycopy(oldContainers, 0, newContainers, 0, oldContainers.length);
+										newContainers[oldContainers.length] = container;
+										fTarget.setTargetLocations(newContainers);
+									}
+								} catch (CoreException ex) {
+									ErrorDialog.openError(getShell(), Messages.AddBundleContainerSelectionPage_0, Messages.AddBundleContainerSelectionPage_5, ex.getStatus());
+									return false;
+								}
 							}
 						}
 						return true;
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/InstallableUnitWizard.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/InstallableUnitWizard.java
index a44df77..5bb99f1 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/InstallableUnitWizard.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/InstallableUnitWizard.java
@@ -10,13 +10,12 @@
  *******************************************************************************/

 package org.eclipse.pde.internal.ui.shared.target;

 

-import org.eclipse.pde.ui.target.ILocationWizard;

-

 import org.eclipse.jface.dialogs.IDialogSettings;

 import org.eclipse.jface.wizard.Wizard;

 import org.eclipse.pde.core.target.ITargetDefinition;

 import org.eclipse.pde.core.target.ITargetLocation;

 import org.eclipse.pde.internal.ui.PDEPlugin;

+import org.eclipse.pde.ui.target.ITargetLocationWizard;

 

 /**

  * Wizard for selecting Installable Units. 

@@ -25,7 +24,7 @@
  * org.eclipse.pde.ui.targetProvisioner 

  *

  */

-public class InstallableUnitWizard extends Wizard implements ILocationWizard {

+public class InstallableUnitWizard extends Wizard implements ITargetLocationWizard {

 

 	private ITargetDefinition fTarget;

 

@@ -37,8 +36,14 @@
 	 */

 	static final String SETTINGS_SECTION = "editBundleContainerWizard"; //$NON-NLS-1$

 

-	public InstallableUnitWizard(ITargetDefinition target) {

+	public InstallableUnitWizard() {

 		setWindowTitle(Messages.AddBundleContainerSelectionPage_1);

+	}

+

+	/* (non-Javadoc)

+	 * @see org.eclipse.pde.ui.target.ITargetLocationWizard#setTarget(org.eclipse.pde.core.target.ITargetDefinition)

+	 */

+	public void setTarget(ITargetDefinition target) {

 		fTarget = target;

 	}

 

@@ -58,7 +63,7 @@
 	 * @see org.eclipse.jface.wizard.Wizard#performFinish()

 	 */

 	public boolean performFinish() {

-		fLocation = ((EditIUContainerPage) getPages()[0]).getTargetLocation();

+		fLocation = ((EditIUContainerPage) getPages()[0]).getBundleContainer();

 		return true;

 	}

 

diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java
index 9096b8c..8396831 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java
@@ -314,6 +314,7 @@
 								fTreeViewer.setSelection(new StructuredSelection(location), true);
 							}
 						}
+						break; //Only open for one selected item
 					}
 				} else if (location instanceof AbstractBundleContainer) {
 					// TODO Custom code for locations that don't use adapaters yet
@@ -327,6 +328,7 @@
 						// TODO We can't restore selection if they replace the location
 						fTreeViewer.setSelection(new StructuredSelection(location), true);
 					}
+					break; //Only open for one selected item
 				}
 			} else if (currentSelection instanceof IUWrapper) {
 				// TODO Custom code to allow editing of individual IUs
@@ -343,6 +345,7 @@
 					// TODO We can't restore selection if they replace the location
 					fTreeViewer.setSelection(new StructuredSelection(wrapper.getParent()), true);
 				}
+				break; //Only open for one selected item
 			}
 		}
 	}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/IProvisionerWizard.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/IProvisionerWizard.java
index aa274fb..24f75e2 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/IProvisionerWizard.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/IProvisionerWizard.java
@@ -11,7 +11,7 @@
 package org.eclipse.pde.ui;
 
 import java.io.File;
-import org.eclipse.pde.ui.target.ILocationWizard;
+import org.eclipse.pde.ui.target.ITargetLocationWizard;
 
 /**
  * This interface represents a wizard which will be used to add plug-ins to 
@@ -20,7 +20,7 @@
  * cases it may not contribute any wizard pages.
  * 
  * @noextend This interface is not intended to be extended by clients.
- * @deprecated Use org.eclipse.pde.ui.targetLocationProviders extension with {@link ILocationWizard} instead
+ * @deprecated Use org.eclipse.pde.ui.targetLocationProviders extension with {@link ITargetLocationWizard} instead
  * @since 3.3
  */
 
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/target/ILocationWizard.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/target/ILocationWizard.java
deleted file mode 100644
index 5ebb9a1..0000000
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/target/ILocationWizard.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.ui.target;
-
-import org.eclipse.pde.ui.IBasePluginWizard;
-
-import org.eclipse.pde.core.target.ITargetLocation;
-
-/**
- * This interface represents a wizard which will be used to add plug-ins to 
- * the Target Platform.  Typically, it maps to one wizard page, but more
- * complex sections may span several pages. Also note that in the very simple
- * cases it may not contribute any wizard pages.
- * 
- * @noextend This interface is not intended to be extended by clients.
- * @since 3.7
- */
-
-public interface ILocationWizard extends IBasePluginWizard {
-
-	/**
-	 * Returns an array of target locations which contain plug-ins to be added to
-	 * the Target Platform.
-	 * 
-	 * @return an array that represent the locations that will provide new plug-ins.
-	 */
-	public ITargetLocation[] getLocations();
-
-}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/target/ITargetLocationWizard.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/target/ITargetLocationWizard.java
new file mode 100644
index 0000000..9c4c226
--- /dev/null
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/target/ITargetLocationWizard.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.ui.target;
+
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.pde.core.target.ITargetDefinition;
+import org.eclipse.pde.core.target.ITargetLocation;
+
+/**
+ * This interface represents a wizard which will be used to add plug-ins to 
+ * the Target Platform.  Implementors must have a default constructor (zero
+ * arguments) for the class to be created from the extension.
+ * 
+ * @noextend This interface is not intended to be extended by clients.
+ * @since 3.7
+ */
+
+public interface ITargetLocationWizard extends IWizard {
+
+	/**
+	 * After this wizard is created, this method will be called, providing this wizard with information
+	 * from the target definition the new location(s) will be added to.  It is not recommended that 
+	 * implementors modify the target as UI behaviour is not API (it may change between releases).
+	 * 
+	 * @param target the target definition this location is being added to
+	 */
+	public void setTarget(ITargetDefinition target);
+
+	/**
+	 * Returns an array of target locations which contain plug-ins to be added to
+	 * the Target Platform.
+	 * 
+	 * @return an array that represent the locations that will provide new plug-ins.
+	 */
+	public ITargetLocation[] getLocations();
+
+}