I want my RCP
app to always prompt the user for the workspace location. I can specify a default location either with the -data
arg in eclipse.ini
or the osgi.instance.area.default
property in configuration/config.ini
. But I don't want the user to have to know about and edit either of these files to change the workspace location.
Setting the preference Prompt for workspace on startup
has no effect. I launch the app in a clean workspace, with no -data
arg or osgi.instance.area.default
property set, and it creates a workspace
folder in the current directory, and does not prompt to select a location.
I use a copy of the IDEApplication
class for my application. I see that in line 188 which is one of the first lines run after start()
, the platform location is already set, and this prevents the dialog from showing. I don't know why it's already set before even trying to launch the UI, and setting the preference has no effect. (I verified in configuration/.settings/org.eclipse.ui.ide.prefs
that SHOW_WORKSPACE_SELECTION_DIALOG=true
).
I tried re-setting the location by adding
instanceLoc = instanceLoc.createLocation(instanceLoc, null, false);
at the beginning of checkInstanceLocation()
. This enables the workspace chooser dialog to come up, but setting the location this way has no effect on what the app actually uses for its instance area when it launches.
I thought that maybe some earlyStartup
code in my app may be interfering, as I read that if you access the preferences too soon you can prevent the workspace chooser from opening. So I commented out the few earlyStartup
declarations I had, and still I can't get the workspace chooser dialog to show.
The problem turned out to be that some classes loaded as dependencies of my OSGI service were accessing the class ResourcesPlugin
, which causes the workspace location to be set immediately. Since this was happening before the workspace chooser dialog was launched, the location used was the value of the -data arg if specified, otherwise $(pwd)/workspace
.
I tried resolving the issue by adjusting the start level of my service plug-in. With a start level of 7 or higher, the workspace chooser dialog was no longer pre-empted. However, the service did not work properly then. After numerous unsuccessful attempts to make the service work properly with a custom start level, I abandoned that approach and re-worked my code so the reference to ResourcesPlugin
occurs later in the application startup process. Specifically, I moved it to the postWindowOpen
method of my custom WorkbenchWindowAdvisor
implementation.