Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Anticipating a workbench view
Anticipating a workbench view [message #520338] Fri, 12 March 2010 00:38 Go to next message
Marian Schedenig is currently offline Marian SchedenigFriend
Messages: 25
Registered: July 2009
Junior Member
Hi!

I'm using this code to find the console view in my plug-in's workbench:

IWorkbenchWindow activeWorkbenchWindow =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
IConsoleView consoleView = (IConsoleView)
activePage.findView(IConsoleConstants.ID_CONSOLE_VIEW);

Right now I'm using this to modify an action contributed via an extension
when my plug-in is activated (since what I'm doing isn't possible
declaratively). I'd prefer to do this before the user executes my action,
i.e. before lazy activation initialises my plug-in.

Which leads me to my question: Is there a way to register some kind of
listener that is notified when a specific view is opened? I can have my
plug-in initialise during Eclipse startup using the startup extension, but
at this point the workbench doesn't seem to be sufficiently initialised to
do my thing (and also I'm not sure how much I can generally rely on the
overall initialisation progress I see in my debugger).

My idea would be to register a listener somewhere on the workbench which is
notified when the console view first opens, so that it can immediately
modify (or, in this case, simply create) my desired action.

Thx,
Marian.
Re: Anticipating a workbench view [message #520369 is a reply to message #520338] Fri, 12 March 2010 06:34 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
On 12/03/10 6:08 AM, Marian Schedenig wrote:
> My idea would be to register a listener somewhere on the workbench which is
> notified when the console view first opens, so that it can immediately
> modify (or, in this case, simply create) my desired action.

Check IPerspectiveListener.perspectiveChanged()

- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: Anticipating a workbench view [message #520588 is a reply to message #520369] Fri, 12 March 2010 23:07 Go to previous messageGo to next message
Marian Schedenig is currently offline Marian SchedenigFriend
Messages: 25
Registered: July 2009
Junior Member
Prakash G.R. wrote:

> On 12/03/10 6:08 AM, Marian Schedenig wrote:
>> My idea would be to register a listener somewhere on the workbench which
>> is notified when the console view first opens, so that it can immediately
>> modify (or, in this case, simply create) my desired action.
>
> Check IPerspectiveListener.perspectiveChanged()

Thanks.

I just tried it, looking through the various versions of
IPerspectiveListener. It doesn't seem to help my problem, though: I can use
the IStartup interface and extension to fetch the workbench window when it's
created and attach a perspective listener. I then get events in the listener
whenever the *user* changes the perspective, e.g. by switching between
views.

However, more often than not, the view I'm interested in is already shown
when the workbench starts. And I don't seem to get any events for the
initial views shown after the workbench has opened.

Cheers,
Marian.
Re: Anticipating a workbench view [message #520595 is a reply to message #520588] Sat, 13 March 2010 01:08 Go to previous message
Marian Schedenig is currently offline Marian SchedenigFriend
Messages: 25
Registered: July 2009
Junior Member
Marian Schedenig wrote:

> However, more often than not, the view I'm interested in is already shown
> when the workbench starts. And I don't seem to get any events for the
> initial views shown after the workbench has opened.

Never mind. When the view is visible in the workbench's startup
configuration, I can find it via the workbench window in my early startup
method. If it's not there, I register the IPerspectiveListener and check for
it on perspective activations/changes. Once I find it, I do my thing and
unregister the listener.

Seems to work like a charm.

Cheers,
Marian.
Previous Topic:Jobs, UIJobs and Threads oh my!
Next Topic:Working efficiently with Bookmarks
Goto Forum:
  


Current Time: Wed Nov 26 00:45:37 GMT 2014

Powered by FUDForum. Page generated in 0.10550 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software