Rebase to master, work on dev platform resolve, add in additional managers
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/core/target/ITargetDefinition.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/core/target/ITargetDefinition.java
index 901b973..0c1237f 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/core/target/ITargetDefinition.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/core/target/ITargetDefinition.java
@@ -80,6 +80,17 @@
 	public TargetBundle[] getAllBundles();

 

 	/**

+	 * Returns all features included in this target definition or <code>null</code>

+	 * if this container is not resolved. Takes all the features available from the

+	 * set target locations (returned by {@link #getAllFeatures()} and applies

+	 * any feature filters (returned by {@link #getIncluded()}) to determine the 

+	 * final list of features in this target. Any bundle filters will be ignored.

+	 * 

+	 * @return resolved features or <code>null</code>

+	 */

+	public TargetFeature[] getFeatures();

+

+	/**

 	 * Returns the list of feature models available in this target or <code>null</code> if

 	 * this target has not been resolved.

 	 * 

diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/core/target/LoadTargetDefinitionJob.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/core/target/LoadTargetDefinitionJob.java
index 0dfa866..26a76e6 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/core/target/LoadTargetDefinitionJob.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/core/target/LoadTargetDefinitionJob.java
@@ -32,6 +32,8 @@
 /**

  * Sets the current target platform based on a target definition.

  * 

+ * TODO 159072 Delete? Move to part of the service?

+ * 

  * @since 3.8

  */

 public class LoadTargetDefinitionJob extends WorkspaceJob {

diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/FeatureModelManager.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/FeatureModelManager.java
index 1f9b3bb..1d73db4 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/FeatureModelManager.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/FeatureModelManager.java
@@ -55,7 +55,7 @@
 		fListeners = new ArrayList();
 	}
 
-	public synchronized void shutdown() {
+	public synchronized void dispose() {
 		if (fWorkspaceManager != null)
 			fWorkspaceManager.removeModelProviderListener(fProviderListener);
 		if (fExternalManager != null) {
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ICoreConstants.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ICoreConstants.java
index 760ccdd..ed01a46 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ICoreConstants.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ICoreConstants.java
@@ -14,30 +14,69 @@
 import java.util.Locale;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.pde.internal.core.platform.DevelopmentPlatform;
 import org.osgi.framework.Constants;
 
 public interface ICoreConstants {
 
-	// Target Platform
+	/**
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
+	 */
 	String PLATFORM_PATH = "platform_path"; //$NON-NLS-1$
-	String SAVED_PLATFORM = "saved_platform"; //$NON-NLS-1$
+	/**
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
+	 */
 	String TARGET_MODE = "target_mode"; //$NON-NLS-1$
+	/**
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
+	 */
 	String VALUE_USE_THIS = "useThis"; //$NON-NLS-1$
+	/**
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
+	 */
 	String VALUE_USE_OTHER = "useOther"; //$NON-NLS-1$
+	/**
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
+	 */
 	String CHECKED_PLUGINS = "checkedPlugins"; //$NON-NLS-1$
+	/**
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
+	 */
 	String VALUE_SAVED_NONE = "[savedNone]"; //$NON-NLS-1$
+	/**
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
+	 */
 	String VALUE_SAVED_ALL = "[savedAll]"; //$NON-NLS-1$
+	/**
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
+	 */
 	String VALUE_SAVED_SOME = "savedSome"; //$NON-NLS-1$
+	/**
+	 * Internal preference allowing additional source locations to be added to the source location manager
+	 */
 	String P_SOURCE_LOCATIONS = "source_locations"; //$NON-NLS-1$
-	String P_EXT_LOCATIONS = "ext_locations"; //$NON-NLS-1$
+	/**
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
+	 */
 	String PROGRAM_ARGS = "program_args"; //$NON-NLS-1$
+	/**
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
+	 */
 	String VM_ARGS = "vm_args"; //$NON-NLS-1$
+	/**
+	 * @deprecated Outdated preference that when set, would add vm arguments from eclipse.ini to the target platform. This
+	 * is now handled directly on the preference page/editor, allowing the user to select a subset of arguments.
+	 */
 	String VM_LAUNCHER_INI = "vm_launcher_ini"; //$NON-NLS-1$
+	/**
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
+	 */
 	String IMPLICIT_DEPENDENCIES = "implicit_dependencies"; //$NON-NLS-1$
-	String GROUP_PLUGINS_VIEW = "group_plugins"; //$NON-NLS-1$
+	/**
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
+	 */
 	String ADDITIONAL_LOCATIONS = "additional_locations"; //$NON-NLS-1$
 	String TARGET_PLATFORM_REALIZATION = "target_platform_realization"; //$NON-NLS-1$
-
 	/**
 	 * This preference was only used during 3.5, it has been replaced in 3.6
 	 * with POOLED_URLS.
@@ -48,6 +87,7 @@
 	/**
 	 * Comma separated list of bundle URLs used from the bundle pool.
 	 * @since 3.6
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
 	 */
 	String POOLED_URLS = "pooled_urls"; //$NON-NLS-1$
 	/**
@@ -55,27 +95,50 @@
 	 * are comma separated, with each entry taking the form of [id]@[version]
 	 * 
 	 * @since 3.6
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
 	 */
 	String EXTERNAL_FEATURES = "external_features"; //$NON-NLS-1$
 	/**
 	 * @since 3.6 - Bug 282708: [target] issues with two versions of the same bundle 
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
 	 */
 	String CHECKED_VERSION_PLUGINS = "checkedVersionPlugins"; //$NON-NLS-1$
 
 	// Target Environment
+	/**
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
+	 */
 	String OS = "org.eclipse.pde.ui.os"; //$NON-NLS-1$
+	/**
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
+	 */
 	String WS = "org.eclipse.pde.ui.ws"; //$NON-NLS-1$
+	/**
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
+	 */
 	String NL = "org.eclipse.pde.ui.nl"; //$NON-NLS-1$
+	/**
+	 * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}
+	 */
 	String ARCH = "org.eclipse.pde.ui.arch"; //$NON-NLS-1$
 
+	/**
+	 * Internal preference that can be used to provide additional OS choices when editing a target platform
+	 */
 	String OS_EXTRA = "org.eclipse.pde.os.extra"; //$NON-NLS-1$
+	/**
+	 * Internal preference that can be used to provide additional WS choices when editing a target platform
+	 */
 	String WS_EXTRA = "org.eclipse.pde.ws.extra"; //$NON-NLS-1$
+	/**
+	 * Internal preference that can be used to provide additional NL choices when editing a target platform
+	 */
 	String NL_EXTRA = "org.eclipse.pde.nl.extra"; //$NON-NLS-1$
+	/**
+	 * Internal preference that can be used to provide additional ARCH choices when editing a target platform
+	 */
 	String ARCH_EXTRA = "org.eclipse.pde.arch.extra"; //$NON-NLS-1$
 
-	// Target JRE
-	String TARGET_JRE = "targetJRE"; //$NON-NLS-1$
-
 	/** Constant for the string <code>extension</code> */
 	public final static String EXTENSION_NAME = "extension"; //$NON-NLS-1$	
 
@@ -120,7 +183,6 @@
 	public static final String EQUINOX_PROPERTY = "pluginProject.equinox"; //$NON-NLS-1$
 	public static final String EXTENSIONS_PROPERTY = "pluginProject.extensions"; //$NON-NLS-1$
 	public static final String RESOLVE_WITH_REQUIRE_BUNDLE = "resolve.requirebundle"; //$NON-NLS-1$
-	public static final String TARGET_PROFILE = "target.profile"; //$NON-NLS-1$
 	/**
 	 * Configures launch shortcuts visible in the manifest editor for a project.
 	 * Value is a comma separated list of <code>org.eclipse.pde.ui.launchShortcuts</code>
@@ -229,7 +291,7 @@
 	public static final String WORKSPACE_TARGET_HANDLE = "workspace_target_handle"; //$NON-NLS-1$
 
 	/**
-	 * Explicit setting when the user chooses no target for the workspace.
+	 * Explicit setting when the user chooses no target for the workspace.  Value is set on {@link #WORKSPACE_TARGET_HANDLE} preference.
 	 */
 	public static final String NO_TARGET = "NO_TARGET"; //$NON-NLS-1$
 
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/JavadocLocationManager.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/JavadocLocationManager.java
index d8266bf..95e38be 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/JavadocLocationManager.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/JavadocLocationManager.java
@@ -19,6 +19,7 @@
 import org.eclipse.osgi.service.resolver.HostSpecification;
 import org.eclipse.pde.core.plugin.IPluginModelBase;
 import org.eclipse.pde.core.plugin.PluginRegistry;
+import org.eclipse.pde.internal.core.platform.IDevelopmentPlatform;
 import org.eclipse.pde.internal.core.util.CoreUtility;
 
 public class JavadocLocationManager {
@@ -27,6 +28,21 @@
 
 	private HashMap fLocations;
 
+	/**
+	 * Development platform to initialize javadoc locations from
+	 */
+	private IDevelopmentPlatform fDevelopmentPlatform;
+
+	/**
+	 * Constructor for a javadoc location manager.  Requires a development platform to collect
+	 * extension entries. The entries are not initialized until required to lookup javadoc.
+	 * 
+	 * @param developmentPlatform development platform to access extensions from
+	 */
+	public JavadocLocationManager(IDevelopmentPlatform developmentPlatform) {
+		fDevelopmentPlatform = developmentPlatform;
+	}
+
 	public String getJavadocLocation(IPluginModelBase model) {
 		try {
 			File file = new File(model.getInstallLocation());
@@ -67,14 +83,15 @@
 		if (fLocations != null)
 			return;
 		fLocations = new HashMap();
-
-		IExtension[] extensions = PDECore.getDefault().getExtensionsRegistry().findExtensions(JAVADOC_ID, false);
-		for (int i = 0; i < extensions.length; i++) {
-			IPluginModelBase base = PluginRegistry.findModel(extensions[i].getContributor().getName());
-			// only search external models
-			if (base == null || base.getUnderlyingResource() != null)
-				continue;
-			processExtension(extensions[i], base);
+		if (fDevelopmentPlatform != null && fDevelopmentPlatform.isInitialized()) {
+			IExtension[] extensions = fDevelopmentPlatform.getExtensionRegistry().findExtensions(JAVADOC_ID, false);
+			for (int i = 0; i < extensions.length; i++) {
+				IPluginModelBase base = PluginRegistry.findModel(extensions[i].getContributor().getName());
+				// only search external models
+				if (base == null || base.getUnderlyingResource() != null)
+					continue;
+				processExtension(extensions[i], base);
+			}
 		}
 	}
 
@@ -136,8 +153,4 @@
 		}
 	}
 
-	public synchronized void reset() {
-		fLocations = null;
-	}
-
 }
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEExtensionRegistry.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEExtensionRegistry.java
index d9538eb..5848c11 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEExtensionRegistry.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEExtensionRegistry.java
@@ -42,15 +42,6 @@
 		}
 	}
 
-	public PDEExtensionRegistry(IPluginModelBase[] models) {
-		fModels = models;
-		if (fStrategy == null) {
-			File extensionsDir = new File(PDECore.getDefault().getStateLocation().toFile(), EXTENSION_DIR);
-			// Use TargetPDERegistryStrategy so we don't connect listeners to PluginModelManager.  This is used only in target so we don't need change events.
-			fStrategy = new TargetPDERegistryStrategy(new File[] {extensionsDir}, new boolean[] {false}, fMasterKey, this);
-		}
-	}
-
 	// Methods used to control information/status of Extension Registry
 
 	protected IPluginModelBase[] getModels() {
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/SourceLocationManager.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/SourceLocationManager.java
index 040e955..02f4361 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/SourceLocationManager.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/SourceLocationManager.java
@@ -18,6 +18,7 @@
 import org.eclipse.core.runtime.spi.RegistryContributor;
 import org.eclipse.osgi.service.resolver.BundleDescription;
 import org.eclipse.pde.core.plugin.*;
+import org.eclipse.pde.internal.core.platform.IDevelopmentPlatform;
 import org.osgi.framework.Version;
 
 /**
@@ -29,12 +30,28 @@
 	/**
 	 * List of source locations that have been discovered using extension points
 	 */
-	private List fExtensionLocations = null;
+	private List fExtensionLocations;
 
 	/**
 	 * Manages locations of individual source bundles
 	 */
-	private BundleManifestSourceLocationManager fBundleManifestLocator = null;
+	private BundleManifestSourceLocationManager fBundleManifestLocator;
+
+	/**
+	 * Development platform to initialize source locations from
+	 */
+	private IDevelopmentPlatform fDevelopmentPlatform;
+
+	/**
+	 * Constructor for a source location manager.  Requires a development platform to collect
+	 * source bundles and extension source entries. The entries are not initialized until required
+	 * to lookup source.
+	 * 
+	 * @param developmentPlatform development platform to access source from
+	 */
+	public SourceLocationManager(IDevelopmentPlatform developmentPlatform) {
+		fDevelopmentPlatform = developmentPlatform;
+	}
 
 	/**
 	 * Searches source locations for one that provides source for the given pluginBase.
@@ -165,14 +182,6 @@
 	}
 
 	/**
-	 * Clears the cache of all known extension and bundle manifest locations.
-	 */
-	public void reset() {
-		fExtensionLocations = null;
-		fBundleManifestLocator = null;
-	}
-
-	/**
 	 * @return array of source locations that have been specified by the user
 	 */
 	public List getUserLocations() {
@@ -189,7 +198,7 @@
 	 */
 	public List getExtensionLocations() {
 		if (fExtensionLocations == null) {
-			fExtensionLocations = processExtensions();
+			fExtensionLocations = initializeExtensionLocations();
 		}
 		return fExtensionLocations;
 	}
@@ -337,38 +346,45 @@
 	/**
 	 * @return array of source locations that were added via extension point
 	 */
-	private static List processExtensions() {
+	private List initializeExtensionLocations() {
 		ArrayList result = new ArrayList();
-		IExtension[] extensions = PDECore.getDefault().getExtensionsRegistry().findExtensions(PDECore.PLUGIN_ID + ".source", false); //$NON-NLS-1$
-		for (int i = 0; i < extensions.length; i++) {
-			IConfigurationElement[] children = extensions[i].getConfigurationElements();
-			RegistryContributor contributor = (RegistryContributor) extensions[i].getContributor();
-			long bundleId = Long.parseLong(contributor.getActualId());
-			BundleDescription desc = PDECore.getDefault().getModelManager().getState().getState().getBundle(Long.parseLong(contributor.getActualId()));
-			IPluginModelBase base = null;
-			if (desc != null)
-				base = PluginRegistry.findModel(desc);
-			// desc might be null if the workspace contains a plug-in with the same Bundle-SymbolicName
-			else {
-				ModelEntry entry = PluginRegistry.findEntry(contributor.getActualName());
-				IPluginModelBase externalModels[] = entry.getExternalModels();
-				for (int j = 0; j < externalModels.length; j++) {
-					BundleDescription extDesc = externalModels[j].getBundleDescription();
-					if (extDesc != null && extDesc.getBundleId() == bundleId)
-						base = externalModels[j];
+		if (fDevelopmentPlatform != null && fDevelopmentPlatform.isInitialized()) {
+			IExtension[] extensions = fDevelopmentPlatform.getExtensionRegistry().findExtensions(PDECore.PLUGIN_ID + ".source", false); //$NON-NLS-1$
+			for (int i = 0; i < extensions.length; i++) {
+				IConfigurationElement[] children = extensions[i].getConfigurationElements();
+				RegistryContributor contributor = (RegistryContributor) extensions[i].getContributor();
+				long bundleId = Long.parseLong(contributor.getActualId());
+				BundleDescription desc = fDevelopmentPlatform.getState().getState().getBundle(Long.parseLong(contributor.getActualId()));
+				IPluginModelBase base = null;
+				
+				// TODO Need the development platform specific plugin registry
+				fDevelopmentPlatform.getPluginModelManager().
+				
+				
+				if (desc != null)
+					base = PluginRegistry.findModel(desc);
+				// desc might be null if the workspace contains a plug-in with the same Bundle-SymbolicName
+				else {
+					ModelEntry entry = PluginRegistry.findEntry(contributor.getActualName());
+					IPluginModelBase externalModels[] = entry.getExternalModels();
+					for (int j = 0; j < externalModels.length; j++) {
+						BundleDescription extDesc = externalModels[j].getBundleDescription();
+						if (extDesc != null && extDesc.getBundleId() == bundleId)
+							base = externalModels[j];
+					}
 				}
-			}
-			if (base == null)
-				continue;
-			for (int j = 0; j < children.length; j++) {
-				if (children[j].getName().equals("location")) { //$NON-NLS-1$
-					String pathValue = children[j].getAttribute("path"); //$NON-NLS-1$
-					IPath path = new Path(base.getInstallLocation()).append(pathValue);
-					if (path.toFile().exists()) {
-						SourceLocation location = new SourceLocation(path);
-						location.setUserDefined(false);
-						if (!result.contains(location))
-							result.add(location);
+				if (base == null)
+					continue;
+				for (int j = 0; j < children.length; j++) {
+					if (children[j].getName().equals("location")) { //$NON-NLS-1$
+						String pathValue = children[j].getAttribute("path"); //$NON-NLS-1$
+						IPath path = new Path(base.getInstallLocation()).append(pathValue);
+						if (path.toFile().exists()) {
+							SourceLocation location = new SourceLocation(path);
+							location.setUserDefined(false);
+							if (!result.contains(location))
+								result.add(location);
+						}
 					}
 				}
 			}
@@ -381,9 +397,11 @@
 	 * platform.
 	 * @return bundle manifest source location manager
 	 */
-	protected BundleManifestSourceLocationManager initializeBundleManifestLocations() {
+	private BundleManifestSourceLocationManager initializeBundleManifestLocations() {
 		BundleManifestSourceLocationManager manager = new BundleManifestSourceLocationManager();
-		manager.setPlugins(PDECore.getDefault().getModelManager().getExternalModels());
+		if (fDevelopmentPlatform != null && fDevelopmentPlatform.isInitialized()) {
+			manager.setPlugins(fDevelopmentPlatform.getPluginModelManager().getExternalModels());
+		}
 		return manager;
 	}
 
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/TargetPlatformResetJob.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/TargetPlatformResetJob.java
index 9337e91..2e07509 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/TargetPlatformResetJob.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/TargetPlatformResetJob.java
@@ -17,6 +17,10 @@
 import org.eclipse.pde.core.plugin.IPluginModelBase;
 import org.eclipse.pde.internal.core.platform.ExternalLibraryCache;
 
+/**
+ * TODO 159072 Delete?
+ *
+ */
 public class TargetPlatformResetJob extends Job {
 
 	private PDEState fState;
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/TargetPreferenceModifyListener.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/TargetPreferenceModifyListener.java
index 5212dff..185a137 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/TargetPreferenceModifyListener.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/TargetPreferenceModifyListener.java
@@ -11,13 +11,17 @@
 package org.eclipse.pde.internal.core;
 
 import org.eclipse.core.runtime.preferences.*;
+import org.eclipse.pde.internal.core.platform.DevelopmentPlatform;
 import org.osgi.service.prefs.BackingStoreException;
 
 /**
  * Disallows importing of target platform preferences. Target platform should not
  * be modified by preference import.
  * 
+ * TODO 159072 Delete?
+ * 
  * @since 3.5
+ * @deprecated Target platform data must be accessed through the {@link DevelopmentPlatform}, not preferences anymore
  */
 public class TargetPreferenceModifyListener extends PreferenceModifyListener {
 
@@ -40,15 +44,8 @@
 				node.remove(ICoreConstants.POOLED_URLS);
 				node.remove(ICoreConstants.PROGRAM_ARGS);
 				node.remove(ICoreConstants.OS);
-				for (int i = 0; i < 4; i++) {
-					StringBuffer key = new StringBuffer();
-					key.append(ICoreConstants.SAVED_PLATFORM);
-					key.append(i);
-					node.remove(key.toString());
-				}
 				node.remove(ICoreConstants.TARGET_MODE);
 				node.remove(ICoreConstants.TARGET_PLATFORM_REALIZATION);
-				node.remove(ICoreConstants.TARGET_PROFILE);
 				node.remove(ICoreConstants.VM_ARGS);
 				node.remove(ICoreConstants.WORKSPACE_TARGET_HANDLE);
 				node.remove(ICoreConstants.WS);
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/platform/DevelopmentPlatform.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/platform/DevelopmentPlatform.java
index 52b791b..6464ec9 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/platform/DevelopmentPlatform.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/platform/DevelopmentPlatform.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * 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.internal.core.platform;
 
 import java.io.File;
@@ -8,118 +18,39 @@
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.*;
 import org.eclipse.equinox.frameworkadmin.BundleInfo;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
 import org.eclipse.osgi.util.NLS;
+import org.eclipse.pde.core.target.ITargetDefinition;
+import org.eclipse.pde.core.target.TargetBundle;
 import org.eclipse.pde.internal.core.*;
-import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
-import org.eclipse.pde.internal.core.target.TargetPlatformService;
-import org.eclipse.pde.internal.core.target.provisional.*;
+import org.eclipse.pde.internal.core.schema.SchemaRegistry;
 
 public class DevelopmentPlatform implements IDevelopmentPlatform {
 
 	private PDEState fState;
 	private PluginModelManager fPluginModelManager;
 	private FeatureModelManager fFeatureModelManager;
+	private SourceLocationManager fSourceLocationManager;
+	private JavadocLocationManager fJavadocLocationManager;
+	private TracingOptionsManager fTracingOptionsManager;
+	private PDEExtensionRegistry fExtensionRegistry;
+	private SchemaRegistry fSchemaRegistry;
 	private ITargetDefinition fTargetDefinition;
 
 	public DevelopmentPlatform(ITargetDefinition targetDefinition) {
 		fTargetDefinition = targetDefinition;
 	}
 
-	public void resolve(IProgressMonitor monitor) throws CoreException {
-		// TODO Should we return a multi status instead of handling it ourselves
-		// TODO Support tracing statements here
-		SubMonitor subMon = SubMonitor.convert(monitor, "Resolving development platform", 1000);
-
-		// Create the state
-		fState = null;
-
-		// If using the default target, load a target definition
-		if (fTargetDefinition == null) {
-			ITargetPlatformService targetService = (ITargetPlatformService) PDECore.getDefault().acquireService(ITargetPlatformService.class.getName());
-			if (targetService == null) {
-				throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, "Unable to acquire target platform service"));
-			}
-			fTargetDefinition = ((TargetPlatformService) targetService).newDefaultTargetDefinition();
-		}
-
-		if (subMon.isCanceled()) {
-			return;
-		}
-
-		// Resolve the target bundles
-		List targetURLs = new ArrayList();
-		subMon.subTask("Resolving target definition");
-		IStatus status = null;
-		if (!fTargetDefinition.isResolved()) {
-			status = fTargetDefinition.resolve(subMon.newChild(100));
-		}
-		subMon.setWorkRemaining(900);
-
-		if (status != null && status.getSeverity() == IStatus.ERROR) {
-			// Log the status and assume there are no target bundles
-			PDECore.log(status);
-		} else {
-			// Add target bundles to the state
-			IResolvedBundle[] targetBundles = fTargetDefinition.getBundles();
-			for (int i = 0; i < targetBundles.length; i++) {
-				BundleInfo currentBundle = targetBundles[i].getBundleInfo();
-				File bundleLocation = org.eclipse.core.runtime.URIUtil.toFile(currentBundle.getLocation());
-				if (bundleLocation == null) {
-					PDECore.log(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, NLS.bind("Could not open plug-in at: {0}", currentBundle.getLocation())));
-				} else {
-					targetURLs.add(bundleLocation);
-				}
-//			try {
-//				Dictionary currentManifest = ManifestHelper.loadManifest(bundleLocation);
-//				TargetWeaver.weaveManifest(currentManifest);
-//				BundleDescription newBundle = stateFactory.createBundleDescription(state, currentManifest, bundleLocation.getAbsolutePath(), getNextId());
-//				state.addBundle(newBundle);
-//			} catch (IOException e) {
-//				PDECore.log(e);
-//			} catch (BundleException e) {
-//				PDECore.log(e);
-//			}
-			}
-		}
-
-		// Resolve workspace bundles
-		ArrayList workspaceURLs = new ArrayList();
-		IProject[] projects = PDECore.getWorkspace().getRoot().getProjects();
-		for (int i = 0; i < projects.length; i++) {
-			if (WorkspaceModelManager.isPluginProject(projects[i])) {
-				try {
-					IPath path = projects[i].getLocation();
-					if (path != null) {
-						workspaceURLs.add(path.toFile().toURL());
-					}
-				} catch (MalformedURLException e) {
-				}
-			}
-		}
-
-		// Resolve the state
-		// Create a state that contains all bundles from the target and workspace
-		// If a workspace bundle has the same symbolic name as a target bundle,
-		// the target counterpart is subsequently removed from the state.
-
-		fState = new PDEState(getPluginPaths(), (URL[]) targetURLs.toArray(new URL[targetURLs.size()]), subMon.newChild(100));
-
-		// Create plug-in models
-
-		// Handle feature models
-		IFeatureModel[] targetFeatures = fTargetDefinition.getAllFeatures();
+	/* (non-Javadoc)
+	 * @see org.eclipse.pde.internal.core.platform.IDevelopmentPlatform#isInitialized()
+	 */
+	public boolean isInitialized() {
+		// The state is initialized last
+		return fState != null;
 
 	}
 
-	/**
-	 * Returns the next available bundle id for bundles being added to a state.
-	 * 
-	 * @return next available bundle id
-	 */
-//	private long getNextId() {
-//		return ++fBundleId;
-//	}
-
 	/* (non-Javadoc)
 	 * @see org.eclipse.pde.internal.core.platform.IDevelopmentPlatform#getTargetDefinition()
 	 */
@@ -134,6 +65,241 @@
 		return fState;
 	}
 
+	/* (non-Javadoc)
+	 * @see org.eclipse.pde.internal.core.platform.IDevelopmentPlatform#getPluginModelManager()
+	 */
+	public PluginModelManager getPluginModelManager() {
+		return fPluginModelManager;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.pde.internal.core.platform.IDevelopmentPlatform#getFeatureModelManager()
+	 */
+	public FeatureModelManager getFeatureModelManager() {
+		return fFeatureModelManager;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.pde.internal.core.platform.IDevelopmentPlatform#getExtensionRegistry()
+	 */
+	public PDEExtensionRegistry getExtensionRegistry() {
+		return fExtensionRegistry;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.pde.internal.core.platform.IDevelopmentPlatform#getJavadocLocationManager()
+	 */
+	public JavadocLocationManager getJavadocLocationManager() {
+		return fJavadocLocationManager;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.pde.internal.core.platform.IDevelopmentPlatform#getSourceLocationManager()
+	 */
+	public SourceLocationManager getSourceLocationManager() {
+		return fSourceLocationManager;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.pde.internal.core.platform.IDevelopmentPlatform#getSchemaRegistry()
+	 */
+	public SchemaRegistry getSchemaRegistry() {
+		return fSchemaRegistry;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.pde.internal.core.platform.IDevelopmentPlatform#getTracingOptionsManager()
+	 */
+	public TracingOptionsManager getTracingOptionsManager() {
+		return fTracingOptionsManager;
+	}
+
+	public void resolve(IProgressMonitor monitor) throws CoreException {
+		// TODO Should we return a multi status instead of handling it ourselves
+		// TODO Support tracing statements here
+		// TODO Remember to clean up strings
+		// TODO handleReload used to remove duplicates, is this broken now?
+		// TODO Someone has to save the workspace target handle preference
+		SubMonitor subMon = SubMonitor.convert(monitor, "Resolving development platform", 1000);
+		try {
+			// Reset any managers and clear listener lists
+			clearManagers();
+
+			// TODO If using the default target, load a target definition?
+//			if (fTargetDefinition == null) {
+//				ITargetPlatformService targetService = (ITargetPlatformService) PDECore.getDefault().acquireService(ITargetPlatformService.class.getName());
+//				if (targetService == null) {
+//					throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, "Unable to acquire target platform service"));
+//				}
+//				fTargetDefinition = targetService.newDefaultTarget();
+//			}
+//			if (subMon.isCanceled()) {
+//				return;
+//			}
+
+			// Resolve the target definition
+			subMon.subTask("Resolving target definition");
+			IStatus status = null;
+			if (!fTargetDefinition.isResolved()) {
+				status = fTargetDefinition.resolve(subMon.newChild(200));
+			}
+			subMon.setWorkRemaining(800);
+			if (subMon.isCanceled()) {
+				return;
+			}
+
+			// Collect bundles from the target
+			List targetURLs = new ArrayList();
+			if (status != null && status.getSeverity() == IStatus.ERROR) {
+				// Log the status and assume there are no target bundles
+				PDECore.log(status);
+			} else {
+				TargetBundle[] targetBundles = fTargetDefinition.getBundles();
+				for (int i = 0; i < targetBundles.length; i++) {
+					BundleInfo currentBundle = targetBundles[i].getBundleInfo();
+					File bundleLocation = org.eclipse.core.runtime.URIUtil.toFile(currentBundle.getLocation());
+					if (bundleLocation == null) {
+						PDECore.log(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, NLS.bind("Could not open plug-in at: {0}", currentBundle.getLocation())));
+					} else {
+						targetURLs.add(bundleLocation);
+					}
+				}
+			}
+			subMon.setWorkRemaining(750);
+			if (subMon.isCanceled()) {
+				return;
+			}
+
+			// Collect bundles from the workspace
+			ArrayList workspaceURLs = new ArrayList();
+			IProject[] projects = PDECore.getWorkspace().getRoot().getProjects();
+			for (int i = 0; i < projects.length; i++) {
+				if (WorkspaceModelManager.isPluginProject(projects[i])) {
+					try {
+						IPath path = projects[i].getLocation();
+						if (path != null) {
+							workspaceURLs.add(path.toFile().toURL());
+						}
+					} catch (MalformedURLException e) {
+					}
+				}
+			}
+			subMon.setWorkRemaining(700);
+			if (subMon.isCanceled()) {
+				return;
+			}
+
+			// Create the state
+			subMon.subTask("Create plug-in models and OSGi state");
+			PDEState state = new PDEState(getPluginPaths(), (URL[]) targetURLs.toArray(new URL[targetURLs.size()]), subMon.newChild(300));
+			subMon.setWorkRemaining(400);
+			if (subMon.isCanceled()) {
+				return;
+			}
+
+			// TODO Create plug-in model manager
+			PluginModelManager pluginManager = new org.eclipse.pde.internal.core.platform.PluginModelManager();
+			pluginManager.initialize(subMon.newChild(50));
+			subMon.setWorkRemaining(350);
+			if (subMon.isCanceled()) {
+				return;
+			}
+
+			// TODO Create feature model manager
+			// TODO Filter features by included
+			subMon.subTask("Create feature models");
+			FeatureModelManager featureManager = new FeatureModelManager();
+			featureManager.initialize(subMon.newChild(100));
+			subMon.setWorkRemaining(250);
+			if (subMon.isCanceled()) {
+				return;
+			}
+
+			// Create managers and final cleanup
+			subMon.subTask("Create additional managers");
+			loadJRE(fTargetDefinition);
+
+			// TODO We can't use the preferences anymore
+			EclipseHomeInitializer.resetEclipseHomeVariable();
+
+			// TODO Clean extracted libraries
+			// TODO Look at better ways of clearning the extracted libs, this was part of external model manager
+			ExternalLibraryCache.getInstance().cleanExtractedLibraries(pluginManager.getExternalModels());
+
+			fState = state;
+			fPluginModelManager = pluginManager;
+			fFeatureModelManager = featureManager;
+			createManagers();
+
+		} finally {
+			subMon.done();
+			if (monitor != null) {
+				monitor.done();
+			}
+		}
+	}
+
+	private void clearManagers() {
+		// TODO Do we need to dispose the state?
+		fState = null;
+		if (fPluginModelManager != null) {
+			fPluginModelManager.dispose();
+			fPluginModelManager = null;
+		}
+		if (fFeatureModelManager != null) {
+			fFeatureModelManager.dispose();
+			fFeatureModelManager = null;
+		}
+		// TODO Still accessing static managers
+		if (fExtensionRegistry != null) {
+			fExtensionRegistry.stop();
+			fExtensionRegistry = null;
+		}
+		// TODO Still accessing static managers
+		fSchemaRegistry = null;
+		// TODO Still accessing static managers
+		fTracingOptionsManager = null;
+
+		fSourceLocationManager = null;
+		fJavadocLocationManager = null;
+	}
+
+	/**
+	 * Sets the workspace default JRE based on the target's JRE container.
+	 *
+	 * @param definition target to get jre from
+	 */
+	private void loadJRE(ITargetDefinition definition) {
+		if (definition != null) {
+			IPath container = definition.getJREContainer();
+			if (container != null) {
+				IVMInstall jre = JavaRuntime.getVMInstall(container);
+				if (jre != null) {
+					IVMInstall def = JavaRuntime.getDefaultVMInstall();
+					if (!jre.equals(def)) {
+						try {
+							JavaRuntime.setDefaultVMInstall(jre, null);
+						} catch (CoreException e) {
+							PDECore.log(e);
+						}
+					}
+				}
+			}
+		}
+	}
+
+	/**
+	 * Creates the additional managers that will not finish initializing until they
+	 * are first called.
+	 */
+	private void createManagers() {
+		fSourceLocationManager = new SourceLocationManager(this);
+		fJavadocLocationManager = new JavadocLocationManager(this);
+		fTracingOptionsManager = new TracingOptionsManager();
+		fSchemaRegistry = new SchemaRegistry();
+		fExtensionRegistry = new PDEExtensionRegistry();
+	}
+
 	/**
 	 * Return URLs to projects in the workspace that have a manifest file (MANIFEST.MF
 	 * or plugin.xml)
@@ -157,17 +323,28 @@
 		return (URL[]) list.toArray(new URL[list.size()]);
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.pde.internal.core.platform.IDevelopmentPlatform#getPluginModelManager()
+	/**
+	 * Sets the TARGET_PROFILE preference which stores the ID of the target profile used 
+	 * (if based on an target extension) or the workspace location of the file that
+	 * was used. For now we just clear it.
+	 * <p>
+	 * Sets the WORKSPACE_TARGET_HANDLE.
+	 * </p>
+	 * @param pref
 	 */
-	public PluginModelManager getPluginModelManager() {
-		return fPluginModelManager;
-	}
+//	private void loadAdditionalPreferences(PDEPreferencesManager pref) throws CoreException {
+//		pref.setValue(ICoreConstants.TARGET_PROFILE, ""); //$NON-NLS-1$
+//		String memento = fTarget.getHandle().getMemento();
+//		if (fNone) {
+//			memento = ICoreConstants.NO_TARGET;
+//		}
+//		pref.setValue(ICoreConstants.WORKSPACE_TARGET_HANDLE, memento);
+//		ITargetLocation[] containers = fTarget.getTargetLocations();
+//		boolean profile = false;
+//		if (containers != null && containers.length > 0) {
+//			profile = containers[0] instanceof ProfileBundleContainer;
+//		}
+//		pref.setValue(ICoreConstants.TARGET_PLATFORM_REALIZATION, profile);
+//	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.pde.internal.core.platform.IDevelopmentPlatform#getFeatureModelManager()
-	 */
-	public FeatureModelManager getFeatureModelManager() {
-		return fFeatureModelManager;
-	}
 }
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/platform/IDevelopmentPlatform.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/platform/IDevelopmentPlatform.java
index e4a3208..7b9ab51 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/platform/IDevelopmentPlatform.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/platform/IDevelopmentPlatform.java
@@ -10,11 +10,9 @@
  *******************************************************************************/
 package org.eclipse.pde.internal.core.platform;
 
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.pde.internal.core.FeatureModelManager;
-import org.eclipse.pde.internal.core.PDEState;
-import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
+import org.eclipse.pde.core.target.ITargetDefinition;
+import org.eclipse.pde.internal.core.*;
+import org.eclipse.pde.internal.core.schema.SchemaRegistry;
 
 /**
  * Central location for all bundles, features and models required to develop, build 
@@ -23,14 +21,24 @@
  */
 public interface IDevelopmentPlatform {
 
-	public void resolve(IProgressMonitor monitor) throws CoreException;
+	public SourceLocationManager getSourceLocationManager();
 
-	public ITargetDefinition getTargetDefinition();
+	public JavadocLocationManager getJavadocLocationManager();
 
-	public PDEState getState();
+	public TracingOptionsManager getTracingOptionsManager();
+
+	public PDEExtensionRegistry getExtensionRegistry();
+
+	public SchemaRegistry getSchemaRegistry();
 
 	public PluginModelManager getPluginModelManager();
 
 	public FeatureModelManager getFeatureModelManager();
 
+	public PDEState getState();
+
+	public ITargetDefinition getTargetDefinition();
+
+	public boolean isInitialized();
+
 }
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/platform/PluginModelManager.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/platform/PluginModelManager.java
index 0503066..26bb5e3 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/platform/PluginModelManager.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/platform/PluginModelManager.java
@@ -70,7 +70,7 @@
 	/**
 	 * Perform cleanup upon shutting down
 	 */
-	public void shutdown() {
+	public void dispose() {
 		if (fListeners != null) {
 			fListeners.clear();
 			fListeners = null;
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/ExternalPluginModelBase.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/ExternalPluginModelBase.java
index d6accd0..7001ff0 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/ExternalPluginModelBase.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/ExternalPluginModelBase.java
@@ -18,7 +18,6 @@
 import org.eclipse.osgi.service.resolver.BundleDescription;
 import org.eclipse.pde.core.build.IBuildModel;
 import org.eclipse.pde.internal.core.*;
-import org.eclipse.pde.internal.core.platform.PDEStateStandin;
 
 public abstract class ExternalPluginModelBase extends AbstractPluginModelBase {
 
@@ -64,7 +63,7 @@
 	public void load() {
 	}
 
-	public void load(BundleDescription description, PDEStateStandin state) {
+	public void load(BundleDescription description, PDEState state) {
 		IPath path = new Path(description.getLocation());
 		String device = path.getDevice();
 		if (device != null)
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetDefinition.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetDefinition.java
index d46558c..7cb9212 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetDefinition.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetDefinition.java
@@ -866,6 +866,60 @@
 	}
 
 	/* (non-Javadoc)
+	 * @see org.eclipse.pde.core.target.ITargetDefinition#getFeatures()
+	 */
+	public TargetFeature[] getFeatures() {
+		TargetFeature[] allFeatures = getAllFeatures();
+		List included = new ArrayList();
+
+		// If the target has includes, but only plug-ins are specified, just include all features
+		// If the target has feature includes, only add features that are included (bug 308693)
+		NameVersionDescriptor[] includes = getIncluded();
+		boolean featuresFound = false; // If only plug-ins are specified, include all features
+		if (includes != null) {
+			for (int i = 0; i < includes.length; i++) {
+				if (includes[i].getType() == NameVersionDescriptor.TYPE_FEATURE) {
+					featuresFound = true;
+					TargetFeature bestMatch = null;
+					for (int j = 0; j < allFeatures.length; j++) {
+						TargetFeature feature = allFeatures[j];
+						if (feature.getId().equals(includes[i].getId())) {
+							if (includes[i].getVersion() != null) {
+								// Try to find an exact feature match
+								if (includes[i].getVersion().equals(feature.getVersion())) {
+									// Exact match
+									bestMatch = feature;
+									break;
+								}
+							} else if (bestMatch != null) {
+								// If no version specified take the highest version
+								Version v1 = Version.parseVersion(feature.getVersion());
+								Version v2 = Version.parseVersion(feature.getVersion());
+								if (v1.compareTo(v2) > 0) {
+									bestMatch = feature;
+								}
+							}
+
+							if (bestMatch == null) {
+								// If we can't find a version match, just take any name match
+								bestMatch = feature;
+							}
+						}
+					}
+					if (bestMatch != null) {
+						included.add(bestMatch);
+					}
+				}
+			}
+		}
+
+		if (includes == null || !featuresFound) {
+			return allFeatures;
+		}
+		return (TargetFeature[]) included.toArray(new TargetFeature[included.size()]);
+	}
+
+	/* (non-Javadoc)
 	 * @see org.eclipse.pde.core.target.ITargetDefinition#getAllFeatures()
 	 */
 	public TargetFeature[] getAllFeatures() {