Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to tell if a view is visible/hidden or not?
How to tell if a view is visible/hidden or not? [message #511223] Sun, 31 January 2010 13:24 Go to next message
Catalin Gerea is currently offline Catalin Gerea
Messages: 89
Registered: July 2009
Location: Bucharest, Romania
Member

I have two views ViewA and ViewB that are in a stack relation (ViewB is displayed in the right side of ViewA). Obviously only one of these two views is visible and the other one is hidden.

I want to know which view is hidden so that I can make it visible by programatically calling the showView(view_descriptor.getId()) on the active IWorkbenchPage page.

So far I was able to do this: in ViewB I registered a IPartListener2 and keep a boolean about the visibility of the view but I do not know how to make this info available in my ViewSwitcherMenu class that extends ContributionItem (I am trying to used a dynamic menu).

Is there another simpler way to find out if a view is visible or not?
From the active page I can get the array of the available view references (IViewReference[]) and isolate the view I am interested in but I do not know if it is hidden or not.

Any help would be greatly appreciated.


Time is what you make of it.
Re: How to tell if a view is visible/hidden or not? [message #511426 is a reply to message #511223] Mon, 01 February 2010 10:24 Go to previous messageGo to next message
Wim Jongman is currently offline Wim Jongman
Messages: 418
Registered: July 2009
Senior Member
Hi Catalin,

I hope somebody has some better ideas but this is what I can think off:

can't you just call showview and be done with it?

If not then you can store the result of your partlistener in a global thing
like the dialog settings or a static variable (e.g.
UTIL.get/setVisibleViewList()). You can also let your view implement an
interface and set a listener on one of your view controls in
createpartcontrol that will provide the value through the interface method.

Here is an article about providing state to the workbench with an
isourceprovider


http://blog.eclipse-tips.com/2009/02/commands-part-5-authent ication-in-rcp.html

--

Best Regards,
Wim Jongman
-- Enter any 11-digit prime number to continue...
(Eclipse Old Skool Quote Service)

> I have two views ViewA and ViewB that are in a stack relation (ViewB is
displayed in the right side of ViewA). Obviously only one of these two views
is visible and the other one is hidden.
>
> I want to know which view is hidden so that I can make it visible by
programatically calling the showView(view_descriptor.getId()) on the active
IWorkbenchPage page.
>
> So far I was able to do this: in ViewB I registered a IPartListener2 and
keep a boolean about the visibility of the view but I do not know how to make
this info available in my ViewSwitcherMenu class that extends
ContributionItem (I am trying to used a dynamic menu).
>
> Is there another simpler way to find out if a view is visible or not?
> From the active page I can get the array of the available view references
(IViewReference[]) and isolate the view I am interested in but I do not know
if it is hidden or not.
>
> Any help would be greatly appreciated.
> --
> Time is what you make of it.
Re: How to tell if a view is visible/hidden or not? [message #511529 is a reply to message #511426] Mon, 01 February 2010 22:11 Go to previous messageGo to next message
Catalin Gerea is currently offline Catalin Gerea
Messages: 89
Registered: July 2009
Location: Bucharest, Romania
Member

Hello Wim

I found what I was looking for but I do not like it because it uses org.eclipse.ui.internal class.

For any view I can get the IViewReference. If you cast it to WorkbenchPartReference then you will be able to use the getVisible() method that will tell if the view is visible or not.

In my particular case the layout of my perspectives is fixed and the views have no minimize / maximize or close buttons.

I started with this example http://eclipsesource.com/blogs/2009/03/31/replacing-the-pers pective-switcher-in-rcp-apps/ and I wanted to modify it for stacked views also.


Time is what you make of it.
Re: How to tell if a view is visible/hidden or not? [message #511635 is a reply to message #511223] Tue, 02 February 2010 11:04 Go to previous messageGo to next message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
Catalin Gerea wrote:
> I have two views ViewA and ViewB that are in a stack relation (ViewB
> is displayed in the right side of ViewA). Obviously only one of these
> two views is visible and the other one is hidden.
Did you try org.eclipse.ui.IWorkbenchPage.isPartVisible(IWorkbenchPart)?

Dani
>
> I want to know which view is hidden so that I can make it visible by
> programatically calling the showView(view_descriptor.getId()) on the
> active IWorkbenchPage page.
>
> So far I was able to do this: in ViewB I registered a IPartListener2
> and keep a boolean about the visibility of the view but I do not know
> how to make this info available in my ViewSwitcherMenu class that
> extends ContributionItem (I am trying to used a dynamic menu).
>
> Is there another simpler way to find out if a view is visible or not?
> From the active page I can get the array of the available view
> references (IViewReference[]) and isolate the view I am interested in
> but I do not know if it is hidden or not.
>
> Any help would be greatly appreciated.
Re: How to tell if a view is visible/hidden or not? [message #511783 is a reply to message #511635] Tue, 02 February 2010 20:14 Go to previous message
Catalin Gerea is currently offline Catalin Gerea
Messages: 89
Registered: July 2009
Location: Bucharest, Romania
Member

Hello Dani

Thanks for the correct info.


Time is what you make of it.
Previous Topic:Project Navigator View
Next Topic:how to implement IF/ENDIF matching in TextEditor extension
Goto Forum:
  


Current Time: Fri Sep 19 12:11:41 GMT 2014

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

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