Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to open an editor in createInitialLayout
How to open an editor in createInitialLayout [message #447557] Mon, 10 April 2006 23:21 Go to next message
Ravi is currently offline RaviFriend
Messages: 16
Registered: July 2009
Junior Member
Hi,

I am developing a RCP with a view and a editor as the initial perspective.

I add a view to the initial perspective in the createInitialLayout method:
------------------------------------------------------------ ------------------
IFolderLayout tl = layout.createFolder("tl", IPageLayout.LEFT, 0.28f,
editorArea);
tl.addView("views");
------------------------------------------------------------ ------------------

I add an editor in the createInitialLayout method using the following-
------------------------------------------------------------ ------------------
IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
page.openEditor(input, "Editor");
------------------------------------------------------------ ------------------

The problem that I am facing is the "page is null" when I run this as an
RCP.
As expected, this works when I run as part of the Eclipse workbench and
not as a product. How do I get around this issue?

Thanks in advance.

Regards,
Ravi
Re: How to open an editor in createInitialLayout [message #447558 is a reply to message #447557] Mon, 10 April 2006 23:38 Go to previous messageGo to next message
Ravi is currently offline RaviFriend
Messages: 16
Registered: July 2009
Junior Member
Hi,

The article "Inside the Workbench, A guide to the workbench internals"
quotes the following -
"The page owns a set of perspectives. Perspectives contain a layout and
information about what action sets to enable. Although perspectives appear
to contain views and the editor area, they only own a layout."

Shouldn't the page be created before the createInitialLayout method of the
Perspective class?

Regards,
Ravi
Re: How to open an editor in createInitialLayout [message #447593 is a reply to message #447558] Tue, 11 April 2006 13:02 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Ravi wrote:
> Hi,
>
> The article "Inside the Workbench, A guide to the workbench internals"
> quotes the following -
> "The page owns a set of perspectives. Perspectives contain a layout and
> information about what action sets to enable. Although perspectives
> appear to contain views and the editor area, they only own a layout."
>
> Shouldn't the page be created before the createInitialLayout method of
> the Perspective class?

Actually it's the opposite, createInitialLayout() is filling in layout
data. That's not tied to a page, but must be used by the perspective in
a page to create the page layout.

createInitialLayout() will almost always be called before page creation
on startup.

Layout is responsible for where the editor area shows up, not what
editors are open.

What about attaching a perspective listener to the workbench window.
Check when your perspective is opened, and open the editor then.

Later,
PW


Re: How to open an editor in createInitialLayout [message #447613 is a reply to message #447593] Wed, 12 April 2006 02:31 Go to previous messageGo to next message
Ravi is currently offline RaviFriend
Messages: 16
Registered: July 2009
Junior Member
Hi Paul,

Thanks for the reply.
I tried attaching a perspective listener to the workbench window. The
addPerspectiveListener method doesn't have a return value. I cannot check
if my perspective is opened and hence cannot open the editor. Any
suggestions?

When does the page get created? I understand that createInitialLayout
defines the layout of a perspective. To display a perspective you need a
page. Any ideas what is the sequence?

Regards,
Ravi
Re: How to open an editor in createInitialLayout [message #447674 is a reply to message #447613] Wed, 12 April 2006 11:55 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Ravi wrote:
> Hi Paul,
>
> Thanks for the reply.
> I tried attaching a perspective listener to the workbench window. The
> addPerspectiveListener method doesn't have a return value. I cannot
> check if my perspective is opened and hence cannot open the editor. Any
> suggestions?

Sorry, why didn't you just listen for the perspectiveOpened() event?
Check out IPerspectiveListener/2/3/4

> When does the page get created? I understand that createInitialLayout
> defines the layout of a perspective. To display a perspective you need a
> page. Any ideas what is the sequence?

The page gets created and then the perspective gets created in the page.
The createInitialLayout() can happen any time before the perspective
gets created. Some of them never get called, since they only get
instantiated when someone tries to open their perspective.

Later,
PW


Re: How to open an editor in createInitialLayout [message #448358 is a reply to message #447674] Fri, 21 April 2006 21:26 Go to previous message
Ravi is currently offline RaviFriend
Messages: 16
Registered: July 2009
Junior Member
Hi Paul,

Many thanks for your prompt response.

I have resolved this issue by opening the editor in the postWindowOpen
method. The page would have got created by the time this method gets
called.

Regards,
Ravi

Paul Webster wrote:

> Ravi wrote:
>> Hi Paul,
>>
>> Thanks for the reply.
>> I tried attaching a perspective listener to the workbench window. The
>> addPerspectiveListener method doesn't have a return value. I cannot
>> check if my perspective is opened and hence cannot open the editor. Any
>> suggestions?

> Sorry, why didn't you just listen for the perspectiveOpened() event?
> Check out IPerspectiveListener/2/3/4

>> When does the page get created? I understand that createInitialLayout
>> defines the layout of a perspective. To display a perspective you need a
>> page. Any ideas what is the sequence?

> The page gets created and then the perspective gets created in the page.
> The createInitialLayout() can happen any time before the perspective
> gets created. Some of them never get called, since they only get
> instantiated when someone tries to open their perspective.

> Later,
> PW
Previous Topic:Hyperlinks to open a view
Next Topic:Activation and deactivation of editors
Goto Forum:
  


Current Time: Mon Dec 02 11:16:12 GMT 2024

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

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

Back to the top