Looking for hook to run in main UI thread after init is complete [message #816267] |
Thu, 08 March 2012 16:21 |
Bob Beetcher Messages: 2 Registered: July 2009 |
Junior Member |
|
|
Because I'm not very well traveled in Eclipse java RCP development, please excuse any confusing concepts or terminology I may include with this post.
As I see it, I'm looking for help with how to ensure a particular code sequence of mine always gets run under the application's main UI thread after initialization is complete.
The code sequence I want to be run looks like this:
final IWorkbenchPage activePage =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
viewStartup(activePage);
}
where the viewStartup method contains:
activePage.showView("com.my.particular.view.id", null, IWorkbenchPage.VIEW_CREATE);
The point of the whole sequence is to trigger asynchronous loading of the view, which normally takes around 30 seconds. Currently, the view loading isn't triggered until a user selects the view which is very frustrating for them. Because the users are usually involved with other application operations for significant periods of time, loading the view in the background would be a big help. Then, when they select the view it will open immediately.
I have verified the code sequence works as desired if run under the main UI thread after initialization completes by hooking it into a couple of our application's menu options. Because there are numerous options the user might first access after initialization, it's not a robust solution to instrument this view loading through such touch points.
What would work best is to implement some hook, listener, or whatever that didn't require user action and always was run under the main UI thread after initialization was sufficiently complete to allow the code sequence of interest to run OK.
For background, here are some things I've tried that didn't work to run the code sequence.
1) Plug-in start() method: Null pointer exception. Believe this is because initialization hasn't proceeded far enough.
2) Plug-in earlyStart() method: Null pointer exception. Believe exception arises because it's not running in the main UI thread.
3) Hooking into project builder: That only runs in response to workspace changes and anyway incurs null pointer exception. Believe this is because it's not running in the main UI thread.
Our RCP is an XML authoring IDE for which user actions are usually initiated by making selections in the Navigator view. Perhaps there's a way to add a listener to that view which could be triggered off the first mouse click in the view. My lack of experience has prevented me from experimenting with something like that.
Thanks ahead of time for any suggestions you folks may be able to provide.
|
|
|
|
Re: Looking for hook to run in main UI thread after init is complete [message #820220 is a reply to message #820199] |
Tue, 13 March 2012 21:37 |
Eclipse User |
|
|
|
Hi,
This may be OK in your particular case. But remember that using the
IStartup extension point means that your plugin will be started always
on every start up even if the user has none of your views open or even
if he doesn't care about your views at all but just simply has your
plugins installed. It also slows down start up because there are so many
plugins that think they need to be activated at start up even though
they may never be used.
--
Thanks,
Rich Kulp
|
|
|
Powered by
FUDForum. Page generated in 0.01676 seconds