Community
Participate
Working Groups
I'm working on moving the workspace selection data from a private file to some config area preferences. I test this in the runtime workbench by putting a value of @noDefault into the Workspace Data, Location field. Since IDEApplication will not run without a workspace, this will cause the IDEApplication to open the workspace selection dialog. The problem I have is when I try to access a preference that does not exist yet. My code is something like this: IPreferenceStore store = new ScopedPreferenceStore( new ConfigurationScope(), PlatformUI.PLUGIN_ID); showDialog = store.getBoolean("SHOW_WORKSPACE_SELECTION_DIALOG"); When the value is looked up inside of #getBoolean, its not found in the config area (this is the first run) so the default area is examined. It seems to be during this part that there's an attempt to access the instance area, which doesn't exist yet, which raises the following exception. Perhaps there could be a setting on ScopedPreferenceStore to avoid looking in the default area? Or perhaps there's a difference store that I should be using? ------------------------------------------ java.lang.IllegalStateException: The instance data location has not been specified yet. at org.eclipse.core.internal.runtime.DataArea. assertLocationInitialized(DataArea.java:42) at org.eclipse.core.internal.runtime.DataArea.getStateLocation(DataArea. java:81) at org.eclipse.core.internal.preferences.InstancePreferences. getBaseLocation(InstancePreferences.java:41) at org.eclipse.core.internal.preferences.InstancePreferences. initializeChildren(InstancePreferences.java:187) at org.eclipse.core.internal.preferences.InstancePreferences. <init>(InstancePreferences.java:55) at org.eclipse.core.internal.preferences.InstancePreferences. internalCreate(InstancePreferences.java:197) at org.eclipse.core.internal.preferences.EclipsePreferences. create(EclipsePreferences.java:272) at org.eclipse.core.internal.preferences.EclipsePreferences. create(EclipsePreferences.java:268) at org.eclipse.core.internal.preferences.PreferencesService. createNode(PreferencesService.java:352) at org.eclipse.core.internal.preferences.RootPreferences. getChild(RootPreferences.java:63) at org.eclipse.core.internal.preferences.RootPreferences. node(RootPreferences.java:90) at org.eclipse.core.internal.preferences.AbstractScope. getNode(AbstractScope.java:39) at org.eclipse.ui.preferences.ScopedPreferenceStore. getStorePreferences(ScopedPreferenceStore.java:183) at org.eclipse.ui.preferences.ScopedPreferenceStore. <init>(ScopedPreferenceStore.java:119) at org.eclipse.ui.plugin.AbstractUIPlugin. getPreferenceStore(AbstractUIPlugin.java:279) at org.eclipse.ui.internal.UIPreferenceInitializer. initializeDefaultPreferences(UIPreferenceInitializer.java:28) at org.eclipse.core.internal.preferences.DefaultPreferences. runInitializer(DefaultPreferences.java:157) at org.eclipse.core.internal.preferences.DefaultPreferences. applyRuntimeDefaults(DefaultPreferences.java:189) at org.eclipse.core.internal.preferences.DefaultPreferences. loadDefaults(DefaultPreferences.java:321) at org.eclipse.core.internal.preferences.DefaultPreferences. load(DefaultPreferences.java:317) at org.eclipse.core.internal.preferences.EclipsePreferences. create(EclipsePreferences.java:292) at org.eclipse.core.internal.preferences.EclipsePreferences. getChild(EclipsePreferences.java:381) at org.eclipse.core.internal.preferences.EclipsePreferences. internalNode(EclipsePreferences.java:518) at org.eclipse.core.internal.preferences.EclipsePreferences. node(EclipsePreferences.java:650) at org.eclipse.core.internal.preferences.AbstractScope. getNode(AbstractScope.java:39) at org.eclipse.ui.preferences.ScopedPreferenceStore. getPreferenceNodes(ScopedPreferenceStore.java:221) at org.eclipse.ui.preferences.ScopedPreferenceStore. internalGet(ScopedPreferenceStore.java:373) at org.eclipse.ui.preferences.ScopedPreferenceStore. getBoolean(ScopedPreferenceStore.java:305) at org.eclipse.ui.internal.ide.ChooseWorkspaceData. readPersistedData_pref(ChooseWorkspaceData.java:325)
The problem isn't where I described before. The class mentioned there is provided by UI to manage our own preference lookup. I've changed my code so that it doesn't use that class and fixed the problem. For future reference... 1. The prefs FAQ is at http://dev.eclipse.org/viewcvs/index. cgi/~checkout~/platform-core-home/documents/user_settings/faq.html 2. My code looks like: String qualifier = PlatformUI.PLUGIN_ID; Preferences node = Platform.getPreferencesService().getRootNode().node( ConfigurationScope.SCOPE).node(qualifier); node.getBoolean( IWorkbenchPreferenceConstants.SHOW_WORKSPACE_SELECTION_DIALOG, true);
Here's the stack trace for the code that seems to prevent me from getting a default configuration preference.
Fixed when fixing bug 75209. Old code used to call Platform#getLocation and use the fact that it was null to indicate whether or not the instance area had been set. This is not good enough so we have changed the code to check for null and to call Location#isSet on the returned non-null location object.