Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » E4 Switch Views
E4 Switch Views [message #898878] Sat, 28 July 2012 18:50 Go to next message
Alex W is currently offline Alex WFriend
Messages: 3
Registered: July 2012
Junior Member
Hi

i'm new to RCP so it will be a little bit hard to descripe my problem. Very Happy
Well i would like to switch view by pressing buttons. Each Button must show a specified View.

Actual i have in one Perspective two Views. (Hope its spelled correct. In Application.e4xmi its called "Part")
The application has two sections. The left side will show buttons as menu and the rigth side different views but only one is active an will be shown to the user. By pressing one button the corresponding view should appear in the rigth side. So the button event has to decide which view will be shown.

Hopefully i explaned it understandable.
Oh yes i will create a E4 RCP Application!

Can anyone help me?

Codesnippets or complete Projectexample will be accepted. Laughing

Kind Regards
Alex
Re: E4 Switch Views [message #898879 is a reply to message #898878] Sat, 28 July 2012 19:04 Go to previous messageGo to next message
Eclipse UserFriend
Yes in fact, they are called parts. All (most) of things in e4 are done through services and also what you want to do is done through the EPartService. To obtain the EPS you have to inject in the class which holds the buttons like this :
@Inject
privat EPartService partService;

then in your button's listener you can show (or hide) a part like this:
partService.showPart(chosenPart,PartState.VISIBLE);

to find the chosenPart you have to search it like this:
partService.findPart("this.is.the.part.id");

So pretty much all you need is the EPartService.
Re: E4 Switch Views [message #898885 is a reply to message #898879] Sat, 28 July 2012 19:40 Go to previous messageGo to next message
Alex W is currently offline Alex WFriend
Messages: 3
Registered: July 2012
Junior Member
Sadly it works not very well.

Case 1) the rigth parts is invisible. If i use showPart then it will not correctly shown. Only the Tabname is shown but the content is missing. Do i click on Tabname i get this exception: java.lang.IllegalArgumentException: Widget has the wrong parent

Case 2) in the right section is one part visible. after pressing button this part disapear completly and the left part occupies the complete window. Never again will a second part be shown.

Do you have any idears?

Maybe the order of the parts is wrong?

Edit: I have some strange warnings: Discouraged access: The method showPart(String, EPartService.PartState) from the type EPartService is not accessible due to restriction on required library ...eclipse\plugins\org.eclipse.e4.ui.workbench_0.10.2.v20120531-1742.jar
Could this be the problem?

[Updated on: Sat, 28 July 2012 19:45]

Report message to a moderator

Re: E4 Switch Views [message #898890 is a reply to message #898885] Sat, 28 July 2012 20:25 Go to previous messageGo to next message
Alex W is currently offline Alex WFriend
Messages: 3
Registered: July 2012
Junior Member
Ok i have a solution. Every Part need to be visible at start of application. Then use following order: set one part to visible and second set all other parts to hide.

Its strange why it only works in this order but it works.

Now i have a question for refactoring. I would like to put this logic to one location. I tried doing it on a "Common" class. But it doesn't work. Is this even possible or do i need to write this code to every mouse-event method?

And can i hide the tab-title bar in each part? Google doesn't show some solution after searching 1 hour. Of course not for e4. Crying or Very Sad
Re: E4 Switch Views [message #898895 is a reply to message #898890] Sat, 28 July 2012 21:34 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

If the tab name is shown and the content is missing the problem has nothing to do with the handler but with how you implement your part's composite content. Make sure you put a method with the @Focus annotation in your part class and delegate the focus to the right control. This will save you some strange behavior.

For the refactoring thing I'm not sure what you mean but you can use handlers and commands if you want to encapsulate commanding code.

I am not aware of a way to hide the tab title (other than leaving an empty label).

You can find other resources on e4 app development here: http://www.vogella.com/eclipse.html
Re: E4 Switch Views [message #899089 is a reply to message #898890] Mon, 30 July 2012 14:18 Go to previous messageGo to next message
Joseph Carroll is currently offline Joseph CarrollFriend
Messages: 174
Registered: May 2012
Location: Milwaukee, WI
Senior Member

Have you looked into PartSashContainer's and PartStack's? You shouldn't need to have anything visible (or not) at runtime. IIRC, you are able to control the sizing of each element by setting the "Container Data" attribute for the individual part.

JD
Re: E4 Switch Views [message #899488 is a reply to message #899089] Wed, 01 August 2012 07:16 Go to previous message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1098
Registered: July 2009
Senior Member

You might have been hit by Bug 372211. If a part is initial not visible you also need to use the model service to set it to visible. Please feel free to complain in the bug, I think the current behavior is not as expected by most users.
Previous Topic:CNF adding Undo and Redo actions
Next Topic:Platform.getExtensionRegistry() returns null !!
Goto Forum:
  


Current Time: Fri Oct 04 22:08:30 GMT 2024

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

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

Back to the top