diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java index 8d9ecab68..9c4b4a6a1 100644 --- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java +++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java @@ -30,6 +30,7 @@ import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.internal.events.*; import org.eclipse.core.internal.localstore.FileSystemResourceManager; +import org.eclipse.core.internal.preferences.PreferencesService; import org.eclipse.core.internal.properties.IPropertyManager; import org.eclipse.core.internal.properties.PropertyManager2; import org.eclipse.core.internal.refresh.RefreshManager; @@ -1848,6 +1849,20 @@ protected void initializeMoveDeleteHook() { } } + /* + * Add the project scope to the preference service's default look-up order so + * people get it for free + */ + private void initializePreferenceLookupOrder() { + PreferencesService service = PreferencesService.getDefault(); + String[] original = service.getDefaultDefaultLookupOrder(); + List newOrder = new ArrayList<>(); + // put the project scope first on the list + newOrder.add(ProjectScope.SCOPE); + newOrder.addAll(Arrays.asList(original)); + service.setDefaultDefaultLookupOrder(newOrder.toArray(new String[newOrder.size()])); + } + /** * A team hook hasn't been initialized. Check the extension point and * try to create a new hook if a user has one defined as an extension. @@ -2186,6 +2201,12 @@ protected long nextNodeId() { * @see ResourcesPlugin#getWorkspace() */ public IStatus open(IProgressMonitor monitor) throws CoreException { + if (!localMetaArea.hasSavedWorkspace()) { + localMetaArea.createMetaArea(); + } + PlatformURLResourceConnection.startup(getRoot().getLocation()); + initializePreferenceLookupOrder(); + // This method is not inside an operation because it is the one responsible for // creating the WorkManager object (who takes care of operations). String message = Messages.resources_workspaceOpen; diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/ResourcesPlugin.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/ResourcesPlugin.java index 636b3a8c8..0b06c2fa7 100644 --- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/ResourcesPlugin.java +++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/ResourcesPlugin.java @@ -18,9 +18,9 @@ *******************************************************************************/ package org.eclipse.core.resources; -import java.util.*; -import org.eclipse.core.internal.preferences.PreferencesService; -import org.eclipse.core.internal.resources.*; +import java.util.Hashtable; +import org.eclipse.core.internal.resources.CheckMissingNaturesListener; +import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.internal.utils.Policy; import org.eclipse.core.runtime.*; @@ -372,24 +372,6 @@ public ResourcesPlugin() { plugin = this; } - /** - * Constructs a brand new workspace structure at the location in the local file system - * identified by the given path and returns a new workspace object. - * - * @exception CoreException if the workspace structure could not be constructed. - * Reasons include: - * - */ - private static void constructWorkspace() throws CoreException { - new LocalMetaArea().createMetaArea(); - } - /** * Returns the encoding to use when reading text files in the workspace. * This is the value of the PREF_ENCODING preference, or the @@ -477,15 +459,9 @@ public void start(BundleContext context) throws Exception { Hashtable properties = new Hashtable<>(2); properties.put(DebugOptions.LISTENER_SYMBOLICNAME, PI_RESOURCES); debugRegistration = context.registerService(DebugOptionsListener.class, Policy.RESOURCES_DEBUG_OPTIONS_LISTENER, properties); - - if (!new LocalMetaArea().hasSavedWorkspace()) { - constructWorkspace(); - } // Remember workspace before opening, to // make it easier to debug cases where open() is failing. workspace = new Workspace(); - PlatformURLResourceConnection.startup(workspace.getRoot().getLocation()); - initializePreferenceLookupOrder(); IStatus result = workspace.open(null); if (!result.isOK()) getLog().log(result); @@ -495,17 +471,4 @@ public void start(BundleContext context) throws Exception { InstanceScope.INSTANCE.getNode(PI_RESOURCES).addPreferenceChangeListener(checkMissingNaturesListener); } - /* - * Add the project scope to the preference service's default look-up order so - * people get it for free - */ - private void initializePreferenceLookupOrder() { - PreferencesService service = PreferencesService.getDefault(); - String[] original = service.getDefaultDefaultLookupOrder(); - List newOrder = new ArrayList<>(); - // put the project scope first on the list - newOrder.add(ProjectScope.SCOPE); - newOrder.addAll(Arrays.asList(original)); - service.setDefaultDefaultLookupOrder(newOrder.toArray(new String[newOrder.size()])); - } }