Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Multiple Perspectives in an RCP e4 Application
Multiple Perspectives in an RCP e4 Application [message #870268] Mon, 07 May 2012 14:22 Go to next message
Fausto Telia is currently offline Fausto Telia
Messages: 8
Registered: May 2012
Junior Member
I'm considering how to port an existing RCP 3 Appl to the new e4 application platform and I have questions related to the concept of Perspectives.

1. If I have more than one perspective, are these perspectives defined in my application model through the PerspectiveStack/Perspective entries?

2. How do I define the initial perspective? In other words, where do I implement the functions provided by the getInitialWindowPerspectiveId() method of the workbench advisor component of RCP 3.x?

Thanks
fausto
Re: Multiple Perspectives in an RCP e4 Application [message #870276 is a reply to message #870268] Mon, 07 May 2012 14:37 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5330
Registered: July 2009
Senior Member
Am 07.05.12 16:22, schrieb Fausto Telia:
> I'm considering how to port an existing RCP 3 Appl to the new e4
> application platform and I have questions related to the concept of
> Perspectives.
>
> 1. If I have more than one perspective, are these perspectives defined
> in my application model through the PerspectiveStack/Perspective entries?
>

Yes.

> 2. How do I define the initial perspective? In other words, where do I
> implement the functions provided by the getInitialWindowPerspectiveId()
> method of the workbench advisor component of RCP 3.x?
>

If you look at the PerspectiveStack you should see a "Selected Element"
attribute this is the currently active Perspective.

Tom
Re: Multiple Perspectives in an RCP e4 Application [message #870339 is a reply to message #870276] Mon, 07 May 2012 17:03 Go to previous messageGo to next message
Fausto Telia is currently offline Fausto Telia
Messages: 8
Registered: May 2012
Junior Member
Tom,
the getInitialPerspectiveId() method allows the RCP application at runtime to define which perspective should be the initial one based on some kind of application data, while the selected attribute in the Application model looks to me something to be set at definition time not at execution time.

Or is there any API that can be used when the RCP e4 appl starts in order to set the selected attribute in the application model so that the application may define the initial perspective?

fausto
Re: Multiple Perspectives in an RCP e4 Application [message #870341 is a reply to message #870339] Mon, 07 May 2012 17:09 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5330
Registered: July 2009
Senior Member
That's only true if you are not using saveAndRestore IIRC!

You can control this from the lifecycle by accessing the model before it
gets rendered and modify the selected element value to your needs.

So you'd have something like this:

class MyLifecycle {

@ProcessAdditions
void process(MApplication app) {
MPerspectiveStack stack = app.getWindows().get(0).getChildren().get(0);

stack.setSelectedElement(stack.getChildren().get(1))
}

}

This will select the 2nd perspective.

Tom

Am 07.05.12 19:03, schrieb Fausto Telia:
> Tom,
> the getInitialPerspectiveId() method allows the RCP application at
> runtime to define which perspective should be the initial one based on
> some kind of application data, while the selected attribute in the
> Application model looks to me something to be set at definition time not
> at execution time.
> Or is there any API that can be used when the RCP e4 appl starts in
> order to set the selected attribute in the application model so that the
> application may define the initial perspective?
>
> fausto
Re: Multiple Perspectives in an RCP e4 Application [message #870368 is a reply to message #870341] Mon, 07 May 2012 20:12 Go to previous messageGo to next message
Fausto Telia is currently offline Fausto Telia
Messages: 8
Registered: May 2012
Junior Member
Tom,
it works, but I had to change a little your code. This is my working sample

@ProcessAdditions
void process(MApplication app) {

MWindow l = app.getChildren().get(0);
MPerspectiveStack stack = (MPerspectiveStack) l.getChildren().get(0);

MPerspective perspectiveA = stack.getChildren().get(0);
System.out.println(perspectiveA.getLabel());

MPerspective perspectiveB = stack.getChildren().get(1);
System.out.println(perspectiveB.getLabel());

stack.setSelectedElement(perspectiveB);
}

I didn't find a getWindows() method for MApplication.

I'm using Build I20120315-1300. Do I have to download a different one?

Fausto

Re: Multiple Perspectives in an RCP e4 Application [message #870371 is a reply to message #870368] Mon, 07 May 2012 20:38 Go to previous message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5330
Registered: July 2009
Senior Member
No the code was from the top of my head - no IDE running :-)

Tom

Am 07.05.12 22:12, schrieb Fausto Telia:
> Tom,
> it works, but I had to change a little your code. This is my working sample
>
> @ProcessAdditions
> void process(MApplication app) {
>
> MWindow l = app.getChildren().get(0);
> MPerspectiveStack stack = (MPerspectiveStack)
> l.getChildren().get(0);
>
> MPerspective perspectiveA = stack.getChildren().get(0);
> System.out.println(perspectiveA.getLabel());
>
> MPerspective perspectiveB = stack.getChildren().get(1);
> System.out.println(perspectiveB.getLabel());
>
> stack.setSelectedElement(perspectiveB);
> }
>
> I didn't find a getWindows() method for MApplication.
>
> I'm using Build I20120315-1300. Do I have to download a different one?
>
> Fausto
>
>
Previous Topic:Eclipse 3.x RCP application editor
Next Topic:Can't get visible-when to work
Goto Forum:
  


Current Time: Sun Sep 21 14:14:07 GMT 2014

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

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