Bug 222023 - [Workbench] Provide startup parameter API for PlatformUI.getWorkbench().restart()
Summary: [Workbench] Provide startup parameter API for PlatformUI.getWorkbench().resta...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: All All
: P3 enhancement with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-10 06:34 EDT by Kai Toedter CLA
Modified: 2014-09-04 16:58 EDT (History)
20 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kai Toedter CLA 2008-03-10 06:34:50 EDT
Build ID:  I20080207-1530

It is currently not possible to pass startup parameters when restarting the workbench via PlatformUI.getWorkbench().restart(). This would be very helpful if you want to change the language of an RCP application at runtime but also for a lot of other use cases.

The current workaround is to manually modify the <product>.ini file, but this works only when the application is deployed and not when launched from the Eclipse IDE.
Comment 1 Thomas Watson CLA 2008-03-10 09:26:02 EDT
The property eclipse.exitdata may be able to be used as a work around.  I think
this property is used by the workbench to restart with a different workspace by
specifying another -data parameter.  You could set this property before calling
the restart() method.
Comment 2 Kai Toedter CLA 2008-03-10 10:05:31 EDT
(In reply to comment #1)
> The property eclipse.exitdata may be able to be used as a work around.  I think
> this property is used by the workbench to restart with a different workspace by
> specifying another -data parameter.  You could set this property before calling
> the restart() method.
> 
Thanks Thomas, but for some unknown reason returning IApplication.EXIT_RELAUNCH in my application does actually not relaunch the application. Only EXIT_RESTART works fine, but eclipse.exitdata is only supposed to work with EXIT_RELAUNCH. Any hints?

Comment 3 Kim Horne CLA 2008-03-11 14:09:39 EDT
Tom: in light of the last comment does this belong back in the Equinox bucket?
Comment 4 Thomas Watson CLA 2008-03-11 15:46:30 EDT
The EXIT_RELAUNCH return code works for me if I am not self-hosting from Eclipse (i.e. I deploy the application jar to an installation of eclipse and launch from there).  If I launch from PDE this does not work.  I suspect because PDE does not understand the relaunch exit code.

See org.eclipse.ui.internal.ide.actions.OpenWorkspaceAction.  This is how the workbench sets the eclipse.exitdata to relaunch with 
Comment 5 Andrew Niefer CLA 2008-03-11 16:18:34 EDT
By definition, EXIT_RESTART uses the same command line again.
So I expect what this bug is really asking for is a IWorkbench.relaunch() (EXIT_RELAUNCH) method.

The reason the relaunch does not work when self-hosting with PDE is that PDE has no way to get the value of the eclipse.exitdata property.  
Comment 6 dev2null CLA 2008-03-12 03:35:50 EDT
Changing language should not require a restart of the application in the first place. Is there already a bug for dynamically switching Locale? I've searched bugzilla but could not find any.
Comment 7 Kai Toedter CLA 2008-03-13 04:36:26 EDT
(In reply to comment #5)
> By definition, EXIT_RESTART uses the same command line again.
> So I expect what this bug is really asking for is a IWorkbench.relaunch()
> (EXIT_RELAUNCH) method.
> 
> The reason the relaunch does not work when self-hosting with PDE is that PDE
> has no way to get the value of the eclipse.exitdata property.  
> 
But even in a deployed application EXIT_RELAUNCH with the "eclipse.exitdata" property set to "-nl <locale>" has no effect on both the splash screen and the application's locale after relaunch. But probably I did something wrong...  

Handler code:
// locale is "de" or "en"
System.getProperties().setProperty("eclipse.exitdata", "-nl " + locale);
PlatformUI.getWorkbench().restart();

In my application:
int returnCode = PlatformUI.createAndRunWorkbench(display,
   new ApplicationWorkbenchAdvisor());
      if (returnCode == PlatformUI.RETURN_RESTART) {
         return IApplication.EXIT_RELAUNCH;
      }
....
Comment 8 Andrew Niefer CLA 2008-03-13 13:39:02 EDT
Look at OpenWorkspaceAction.buildCommandLine which builds the eclipse.exitdata for switch workspace.

Arguments are separated by '\n'.  Generally, the format for the exitdata should be:
${eclipse.vm}\n
${eclipse.vmargs}\n
${eclipse.commands}

Those system properties contain the values for the currently running eclipse, I would suggest that you get eclipse.commands and modify it as appropriate

As well, OpenWorkspaceAction.restart suggests a relaunch can be achieved with Workbench.restart by setting eclipse.exitcode to 24, this is dependent on the behaviour in IDEApplication.start
Comment 9 dev2null CLA 2008-03-14 03:27:07 EDT
I've added bug 222706 for "dynamic change of locale" support. Has this already been considered for eclipse 4.0?

Anyway, I'm adding language selection to a rcp application. The language selection will be added to a login dialog that is displayed before the workbench is started. 

Is it possible to avoid a restart in this scenario, e.g. by changing the osgi.nl or osgi.nl.user properties?
Comment 10 chaitanya tangudu CLA 2008-10-01 15:39:49 EDT
Even if we osgi.nl user properties as the required language, it doesn't effect on the workbench locale. So is there any current work around to set locale to workbench at runtime before this bug is fixed?
Comment 11 Paul Webster CLA 2008-10-02 08:19:12 EDT
(In reply to comment #10)
> Even if we osgi.nl user properties as the required language, it doesn't effect
> on the workbench locale. So is there any current work around to set locale to
> workbench at runtime before this bug is fixed?


Are you restarting eclipse (that's the only work around AFAIK).  Also, vote for bug 75320

PW