Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Switching between activated views
Switching between activated views [message #665192] Wed, 13 April 2011 15:25 Go to next message
Eclipse UserFriend
Originally posted by: rth_morpheus.web.de

Hi there,

I'm working on a small RCP-Application. This application consists of a
tree view containing three different types of data, and a stack of three
views, each one linked to one of these data types. The views in the
stack implement the SelectionListener, so each time an item from the
tree is selected, the corresponding view loads its information. What I
now would like to do, is switching the view corresponding to the data
type when I select an item in the tree. I tried doing so by using

getSite().getPage().showView(viewId);

using the ids of the views, but, besides getting an Exception, it
doesn't seem to work as I hoped.
Does anyone know of a better approach?

Thanks

Robert
Re: Switching between activated views [message #665227 is a reply to message #665192] Wed, 13 April 2011 18:17 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 04/13/2011 11:25 AM, Robert Hälke wrote:
>
> getSite().getPage().showView(viewId);

This is the correct API. What exception are you getting?

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: Switching between activated views [message #665264 is a reply to message #665227] Wed, 13 April 2011 22:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rth_morpheus.web.de

Am 13.04.2011 20:17, schrieb Paul Webster:
> On 04/13/2011 11:25 AM, Robert Hälke wrote:
>>
>> getSite().getPage().showView(viewId);
>
> This is the correct API. What exception are you getting?
>
> PW
>
>

I get a RuntimeException:

java.lang.RuntimeException: WARNING: Prevented recursive attempt to
activate part de.unirostock.bives.gui.views.versionDetailsView while
still in the middle of activating part
de.unirostock.bives.gui.views.modelTreeView
at
org.eclipse.ui.internal.WorkbenchPage.setActivePart(Workbenc hPage.java:3487)
at
org.eclipse.ui.internal.WorkbenchPage.internalActivate(Workb enchPage.java:617)
at org.eclipse.ui.internal.WorkbenchPage.activate(WorkbenchPage .java:589)
at
org.eclipse.ui.internal.WorkbenchPage.busyShowView(Workbench Page.java:1096)
at
org.eclipse.ui.internal.WorkbenchPage.busyShowView(Workbench Page.java:1066)
at org.eclipse.ui.internal.WorkbenchPage$20.run(WorkbenchPage.j ava:3822)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:70)
at org.eclipse.ui.internal.WorkbenchPage.showView(WorkbenchPage .java:3819)
at org.eclipse.ui.internal.WorkbenchPage.showView(WorkbenchPage .java:3795)
[...]

The problem appears to be connected to the tree view, from which I
select the different data types. The selectionChanged method I have
implemented in all three views appears to be called twice each time I
select a different data type, once from the old view currently active,
and once from the new view.

Robert
Re: Switching between activated views [message #665353 is a reply to message #665264] Thu, 14 April 2011 12:14 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 04/13/2011 06:29 PM, Robert Hälke wrote:
> I get a RuntimeException:
>
> java.lang.RuntimeException: WARNING: Prevented recursive attempt to
> activate part de.unirostock.bives.gui.views.versionDetailsView while
> still in the middle of activating part
> de.unirostock.bives.gui.views.modelTreeView

Does the secondary view have to be activated, or just brought to the
top? You could just make it visible in the other stack and have the
user click on it if they want to interact with it.

ex: you could use page.showView("id", null, IWorkbenchPage.VIEW_VISIBLE);

The other alternative is to restrict those calls to something like a
"double-click", or if you notice a change in selection, schedule a UIJob
(on step up from an asyncExec) to make the showView(*) call in the next
display loop.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: Switching between activated views [message #665429 is a reply to message #665353] Thu, 14 April 2011 15:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rth_morpheus.web.de

Am 14.04.2011 14:14, schrieb Paul Webster:
> On 04/13/2011 06:29 PM, Robert Hälke wrote:
>> I get a RuntimeException:
>>
>> java.lang.RuntimeException: WARNING: Prevented recursive attempt to
>> activate part de.unirostock.bives.gui.views.versionDetailsView while
>> still in the middle of activating part
>> de.unirostock.bives.gui.views.modelTreeView
>
> Does the secondary view have to be activated, or just brought to the
> top? You could just make it visible in the other stack and have the user
> click on it if they want to interact with it.

All views are activated, I just want to switch the visibility.

> ex: you could use page.showView("id", null, IWorkbenchPage.VIEW_VISIBLE);

That did the trick, the views are now switching as intende.

> The other alternative is to restrict those calls to something like a
> "double-click", or if you notice a change in selection, schedule a UIJob
> (on step up from an asyncExec) to make the showView(*) call in the next
> display loop.
>
> PW
>
>

Thanks a lot for your help, Paul!

Regards

Robert
Re: Switching between activated views [message #665488 is a reply to message #665429] Thu, 14 April 2011 18:51 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 04/14/2011 11:19 AM, Robert Hälke wrote:
>> All views are activated, I just want to switch the visibility.

Just FYI, there's only one activated part (view or editor) in a given
workbench window. The one that actually has the focus.

But I'm glad my trick worked.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Previous Topic:Issue print command
Next Topic:Change text in a view (Simple help needed!)
Goto Forum:
  


Current Time: Fri Apr 19 09:26:49 GMT 2024

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

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

Back to the top