Home » Eclipse Projects » Eclipse Platform » Plugin start and Application start
Plugin start and Application start [message #1476732] |
Mon, 17 November 2014 09:54 |
|
I recently met a problem, the eclipse does not launch the last-used
workspace for me, but always launch the default
workspace(user.home/workspace).
I checked the configuration/.settings/org.eclipse.ui.ide.pref config
file, and it's fine, in the file there are recently used five workspace
location, and even if I remove this file, eclipse won't show the prompt
for workspace dialog.
So i finally looked into the source code, and after hours of work, I
finally find out the problem:
1. For some reason, a plugin(org.apache.directory.studio.ldapbrowser.ui)
was started before the IDEApplication.start()
2. This plugin (...ldapbrowser.ui) in some way lead to a call to the
Plugin#getStateLocation(), and the following:
InternalPlatform#getStateLocation() -->
DataArea#getStateLocation() -->
DataArea#assertLocationInitialized() -->
BaseLocation#getURL() -->
BaseLocation#setURL()...
That's the problem here, the method getURL() calls the method setURL(),
and that caused the member "location" be set to the default value
(user.home/workspace).
3. And when IDEApplication starts,
Location instanceLoc = Platform.getInstanceLocation();
if (instanceLoc.isSet()) {
...
}
the instanceLoc.isSet() will be a "true", so the default location is
used, and the code after this will never reached.
There is something I don't understand here:
1. Is it a problem that plugin(ldapbrowser.ui) starts before
IDEApplication starts? (I think this would be a "NO" here, because I
find that many other plugins start before that.)
2. Is it a problem that getURL() calls setURL(), because that looks
strange...
3. If it's OK for #2, should plugin be forbiden to call
Plugin#getStateLocation() before application starts?
or is there any other workaround to avoid this problem for plugins
developers?
Dollyn
|
|
|
Re: Plugin start and Application start [message #1476830 is a reply to message #1476732] |
Mon, 17 November 2014 11:36 |
Ed Merks Messages: 33264 Registered: July 2009 |
Senior Member |
|
|
Dollyn
I wonder if something has affected the
Window->Preferences->General->Startup and Shutdown->Workspaces->Prompt
for workspace on startup preference? If that's enabled, it should
always prompt on startup. Note that you can use -data ... to specify the
workspace on the command line...
On 17/11/2014 10:54 AM, dollyn wrote:
> I recently met a problem, the eclipse does not launch the last-used
> workspace for me, but always launch the default
> workspace(user.home/workspace).
>
> I checked the configuration/.settings/org.eclipse.ui.ide.pref config
> file, and it's fine, in the file there are recently used five
> workspace location, and even if I remove this file, eclipse won't show
> the prompt for workspace dialog.
>
> So i finally looked into the source code, and after hours of work, I
> finally find out the problem:
>
> 1. For some reason, a
> plugin(org.apache.directory.studio.ldapbrowser.ui) was started before
> the IDEApplication.start()
>
> 2. This plugin (...ldapbrowser.ui) in some way lead to a call to the
> Plugin#getStateLocation(), and the following:
>
> InternalPlatform#getStateLocation() -->
> DataArea#getStateLocation() -->
> DataArea#assertLocationInitialized() -->
> BaseLocation#getURL() -->
> BaseLocation#setURL()...
>
> That's the problem here, the method getURL() calls the method
> setURL(), and that caused the member "location" be set to the default
> value (user.home/workspace).
>
> 3. And when IDEApplication starts,
> Location instanceLoc = Platform.getInstanceLocation();
> if (instanceLoc.isSet()) {
> ...
> }
>
> the instanceLoc.isSet() will be a "true", so the default location is
> used, and the code after this will never reached.
>
>
> There is something I don't understand here:
> 1. Is it a problem that plugin(ldapbrowser.ui) starts before
> IDEApplication starts? (I think this would be a "NO" here, because I
> find that many other plugins start before that.)
>
> 2. Is it a problem that getURL() calls setURL(), because that looks
> strange...
>
> 3. If it's OK for #2, should plugin be forbiden to call
> Plugin#getStateLocation() before application starts?
>
> or is there any other workaround to avoid this problem for plugins
> developers?
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Plugin start and Application start [message #1477470 is a reply to message #1476830] |
Mon, 17 November 2014 23:16 |
|
Yes, the preferences "Prompt for workspace on startup preference?" is enabled. But look at the IDEApplication#start():
// -data @none was specified but an ide requires workspace
Location instanceLoc = Platform.getInstanceLocation();
if (instanceLoc == null) {
MessageDialog
.openError(
shell,
IDEWorkbenchMessages.IDEApplication_workspaceMandatoryTitle,
IDEWorkbenchMessages.IDEApplication_workspaceMandatoryMessage);
return EXIT_OK;
}
// -data "/valid/path", workspace already set
if (instanceLoc.isSet()) {
// make sure the meta data version is compatible (or the user has
// chosen to overwrite it).
if (!checkValidWorkspace(shell, instanceLoc.getURL())) {
return EXIT_OK;
}
// at this point its valid, so try to lock it and update the
// metadata version information if successful
try {
if (instanceLoc.lock()) {
writeWorkspaceVersion();
return null;
}
......
}
// -data @noDefault or -data not specified, prompt and set
ChooseWorkspaceData launchData = new ChooseWorkspaceData(instanceLoc
.getDefault());
....
if "instanceLoc.isSet() " is true, the prompt dialog will never shown, just like -data is provided. But I did not provide -data. The call to getStateLocation() caused "instanceLoc.isSet()" return true.
-data is ok, but I still think that there is something wrong here, something caused the preferences settings is ignored.
Dollyn
|
|
|
Re: Plugin start and Application start [message #1477529 is a reply to message #1477470] |
Tue, 18 November 2014 00:27 |
|
And after I uninstall the "apache directory studio LDAP browser" plugin,
everything works fine now.
The problem is that in some day, maybe another plugin will lead to the
same problem agin, should we do something to avoid this ?
Dollyn
|
|
|
Goto Forum:
Current Time: Fri Jan 24 06:36:49 GMT 2025
Powered by FUDForum. Page generated in 0.04194 seconds
|