Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Associate Editor with Perspective
Associate Editor with Perspective [message #484190] Fri, 04 September 2009 14:22 Go to next message
Dave is currently offline DaveFriend
Messages: 28
Registered: July 2009
Junior Member
I am developing an Eclipse application that contains multiple
perspectives. I want to associate an editor with the perspective in which
it was opened, so that it is only displayed when the perspective is
active. For example, if the user opens editor A in perspective A, I don't
want editor A to be displayed when the user switches to perspective B. If
the user subsequently opens editor B in perspective B, and then switches
back to perspective A, I want editor A to be redisplayed, and not editor B.

Is there a way to do this? Even if there is not a simple way to do it, I
am willing to consider more complicated ways. Any suggestions?
Re: Associate Editor with Perspective [message #484198 is a reply to message #484190] Fri, 04 September 2009 14:53 Go to previous messageGo to next message
Remy Suen is currently offline Remy SuenFriend
Messages: 462
Registered: July 2009
Senior Member
On Fri, 04 Sep 2009 14:22:34 +0000, Dave wrote:
> Is there a way to do this? Even if there is not a simple way to do it,
> I am willing to consider more complicated ways. Any suggestions?

We added new API in 3.5 which should help with this. Please see bug 11001.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=11001

http://help.eclipse.org/stable/nftopic/org.eclipse.platform. doc.isv/
reference/api/org/eclipse/ui/IWorkbenchPage.html#showEditor%
28org.eclipse.ui.IEditorReference%29

http://help.eclipse.org/stable/nftopic/org.eclipse.platform. doc.isv/
reference/api/org/eclipse/ui/IWorkbenchPage.html#hideEditor%
28org.eclipse.ui.IEditorReference%29

As the API is new, there may be some problems with it. Please report bugs
if you spot any problems. Thank you.

Regards,
Remy
Re: Associate Editor with Perspective [message #484222 is a reply to message #484198] Fri, 04 September 2009 16:06 Go to previous messageGo to next message
Dave is currently offline DaveFriend
Messages: 28
Registered: July 2009
Junior Member
Remy Suen wrote:

> On Fri, 04 Sep 2009 14:22:34 +0000, Dave wrote:
>> Is there a way to do this? Even if there is not a simple way to do it,
>> I am willing to consider more complicated ways. Any suggestions?

> We added new API in 3.5 which should help with this. Please see bug 11001.
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=11001

> http://help.eclipse.org/stable/nftopic/org.eclipse.platform. doc.isv/
> reference/api/org/eclipse/ui/IWorkbenchPage.html#showEditor%
> 28org.eclipse.ui.IEditorReference%29

> http://help.eclipse.org/stable/nftopic/org.eclipse.platform. doc.isv/
> reference/api/org/eclipse/ui/IWorkbenchPage.html#hideEditor%
> 28org.eclipse.ui.IEditorReference%29

> As the API is new, there may be some problems with it. Please report bugs
> if you spot any problems. Thank you.

> Regards,
> Remy

Thanks for the information. The new API looks like the kind of thing I'm
looking for. But I'm still a little confused as to how to use it to
achieve what I want. Is there a recommendation as to where/when (i.e.,
class/method, listener event, etc.) to hide the editors, and where/when to
re-show them? The API documentation says that getEditorReferences() does
not return hidden editors. So how do I get the list of hidden editors
that I want to re-show when a perspective is being re-shown? Note that I
don't necessarily want to re-show all hidden editors, as there may be some
hidden editors associated with perspectives that are not being re-shown.
Any advice would be appreciated!
Re: Associate Editor with Perspective [message #484230 is a reply to message #484222] Fri, 04 September 2009 16:33 Go to previous messageGo to next message
Remy Suen is currently offline Remy SuenFriend
Messages: 462
Registered: July 2009
Senior Member
On Fri, 04 Sep 2009 16:06:30 +0000, Dave wrote:
> Is there a recommendation as to where/when (i.e.,
> class/method, listener event, etc.) to hide the editors, and where/when
> to re-show them?

The simplest thing to do would be to just react to perspective events and
show/hide your editors.

> So how do I get the list of hidden
> editors that I want to re-show when a perspective is being re-shown?

You need to keep track of what you've shown/hidden yourself and what you
want to show/hide the next time the perspective changes. This is up to
the client to decide.

Regards,
Remy
Re: Associate Editor with Perspective [message #484247 is a reply to message #484230] Fri, 04 September 2009 18:17 Go to previous messageGo to next message
Dave is currently offline DaveFriend
Messages: 28
Registered: July 2009
Junior Member
Remy Suen wrote:

> On Fri, 04 Sep 2009 16:06:30 +0000, Dave wrote:
>> Is there a recommendation as to where/when (i.e.,
>> class/method, listener event, etc.) to hide the editors, and where/when
>> to re-show them?

> The simplest thing to do would be to just react to perspective events and
> show/hide your editors.

>> So how do I get the list of hidden
>> editors that I want to re-show when a perspective is being re-shown?

> You need to keep track of what you've shown/hidden yourself and what you
> want to show/hide the next time the perspective changes. This is up to
> the client to decide.

> Regards,
> Remy

Thanks for your help. I'm a novice when it comes to Eclipse RCP
development, so I was wondering if you could point me in the right
direction. What is the recommended way for me to set it up so that I can
react to perspective events? In other words, do I add a listener to
something? If so, what type of listener, what would I be adding it to,
and when would I add it? (i.e., during workbench initialization?
workbench page initialization? what classes/methods represent those
actions in the workbench lifecycle anyway?)

Also, is there a method I can call that will return all of the open
editors, including hidden ones?

Thanks again for being patient with me!

Regards,
Dave
Re: Associate Editor with Perspective [message #484337 is a reply to message #484247] Sun, 06 September 2009 22:00 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 423
Registered: July 2009
Senior Member
Hi Dave,

Try these as a starting point:


PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPers pectiveListener(listener);
PlatformUI.getWorkbench()..getEditorRegistry()

Best regards,

Wim Jongman

> Remy Suen wrote:
>
>> On Fri, 04 Sep 2009 16:06:30 +0000, Dave wrote:
>>> Is there a recommendation as to where/when (i.e.,
>>> class/method, listener event, etc.) to hide the editors, and where/when
>>> to re-show them?
>
>> The simplest thing to do would be to just react to perspective events and
>> show/hide your editors.
>
>>> So how do I get the list of hidden
>>> editors that I want to re-show when a perspective is being re-shown?
>
>> You need to keep track of what you've shown/hidden yourself and what you
>> want to show/hide the next time the perspective changes. This is up to
>> the client to decide.
>
>> Regards,
>> Remy
>
> Thanks for your help. I'm a novice when it comes to Eclipse RCP
> development, so I was wondering if you could point me in the right
> direction. What is the recommended way for me to set it up so that I can
> react to perspective events? In other words, do I add a listener to
> something? If so, what type of listener, what would I be adding it to,
> and when would I add it? (i.e., during workbench initialization?
> workbench page initialization? what classes/methods represent those
> actions in the workbench lifecycle anyway?)
>
> Also, is there a method I can call that will return all of the open
> editors, including hidden ones?
>
> Thanks again for being patient with me!
>
> Regards,
> Dave
Re: Associate Editor with Perspective [message #484687 is a reply to message #484247] Tue, 08 September 2009 18:14 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Dave wrote on Fri, 04 September 2009 14:17

Thanks for your help. I'm a novice when it comes to Eclipse RCP
development, so I was wondering if you could point me in the right
direction. What is the recommended way for me to set it up so that I can
react to perspective events? In other words, do I add a listener to
something? If so, what type of listener, what would I be adding it to,
and when would I add it? (i.e., during workbench initialization?
workbench page initialization? what classes/methods represent those
actions in the workbench lifecycle anyway?)

Also, is there a method I can call that will return all of the open
editors, including hidden ones?

Thanks again for being patient with me!

Regards,
Dave


This API was added for the most hard-core of hard-core RCP developers. It is not how we recommend using editors and the editor areas (the questions you've posted are just the beginning, believe me Smile

That being said, I would consider writing your editor+perspective management code in its own plugin. Try and limit what else it does, and then to get the behaviour your want (in a RCP app) you would look at starting up your management functionality in your workbench advisor (it has post startup methods).

You need to listen to callbacks in the IPerspectiveListener* methods, and you might even need an IPartlListener2 listener in order to tell when editors are opened/closed.


PW


Previous Topic:Licence question
Next Topic:Setting editor tab dirty in EMF generated Editor
Goto Forum:
  


Current Time: Thu Apr 25 11:22:12 GMT 2024

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

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

Back to the top