Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How can I specify a position for a view ?
How can I specify a position for a view ? [message #467124] Sat, 28 April 2007 04:18 Go to next message
Eclipse UserFriend
hi, all
I separatea perspective into two parts with the code below:
------------------------------------------------------------ --
String editorArea = layout.getEditorArea();
IFolderLayout folder = layout.createFolder("left",IPageLayout.LEFT,0.6f,editorArea);
folder.addView(CustomView.ID);

IFolderLayout rightFolder = layout.createFolder("right",IPageLayout.RIGHT,0.4f,editorArea);
rightFolder.addView(ProductView.ID);
------------------------------------------------------------ --
I want to open another view that named "TaskView" in the left part, when click a button on CustomView. The code is:

------------------------------------------------------------ --
IWOrkbenchWindow window = getViewSite().getWorkbenchWindow();
window.getActivePage().showView(TaskView.ID,Integer.toString (instanceNum++),IWorkbenchPage.VIEW_ACTIVATE);
------------------------------------------------------------ --

But the "TaskView" is always opened in the right part.
Why? And how can I specify the position for a view?
Any help will be appreciated!
Re: How can I specify a position for a view ? [message #467130 is a reply to message #467124] Sat, 28 April 2007 06:37 Go to previous messageGo to next message
Eclipse UserFriend
xldelg schrieb:
> hi, all
> I separatea perspective into two parts with the code below:
> ------------------------------------------------------------ --
> String editorArea = layout.getEditorArea();
> IFolderLayout folder = layout.createFolder("left",IPageLayout.LEFT,0.6f,editorArea);
> folder.addView(CustomView.ID);
>
> IFolderLayout rightFolder = layout.createFolder("right",IPageLayout.RIGHT,0.4f,editorArea);
> rightFolder.addView(ProductView.ID);
> ------------------------------------------------------------ --
> I want to open another view that named "TaskView" in the left part, when click a button on CustomView. The code is:
>
> ------------------------------------------------------------ --
> IWOrkbenchWindow window = getViewSite().getWorkbenchWindow();
> window.getActivePage().showView(TaskView.ID,Integer.toString (instanceNum++),IWorkbenchPage.VIEW_ACTIVATE);
> ------------------------------------------------------------ --
>
> But the "TaskView" is always opened in the right part.
> Why? And how can I specify the position for a view?
> Any help will be appreciated!
hi,
you can add a placeholder for the view to the lef folder in your
perspective. Eclipse will then place the view at the position of the
placeholder.
For your example code this line may fix it.
folder.addPlaceholder(TaskView.ID);

karsten
Re: How can I specify a position for a view ? [message #467181 is a reply to message #467130] Mon, 30 April 2007 08:07 Go to previous messageGo to next message
Eclipse UserFriend
To karsten,
I tried as what you wrote, but it doesn't work, is there something wrong with the code: "
IWOrkbenchWindow window = getViewSite().getWorkbenchWindow();
window.getActivePage().showView(TaskView.ID,Integer.toString (instanceNum++),IWorkbenchPage.VIEW_ACTIVATE);
"?
Thank you all the same.
Re: How can I specify a position for a view ? [message #467217 is a reply to message #467181] Tue, 01 May 2007 07:43 Go to previous messageGo to next message
Eclipse UserFriend
xldelg schrieb:
> To karsten,
> I tried as what you wrote, but it doesn't work, is there something wrong with the code: "
> IWOrkbenchWindow window = getViewSite().getWorkbenchWindow();
> window.getActivePage().showView(TaskView.ID,Integer.toString (instanceNum++),IWorkbenchPage.VIEW_ACTIVATE);
> "?
> Thank you all the same.
In my application, I call the method showView(String ID) only. Why did
you use the other paramters? Did you reset the perspective, after adding
the placeolder? The new code is not applied to already opened perspectives.
karsten
Re: How can I specify a position for a view ? [message #467233 is a reply to message #467181] Tue, 01 May 2007 15:44 Go to previous messageGo to next message
Eclipse UserFriend
if you use a multi instance view and a secondary ID, your placeholder ID
needs to end with <your.id>:*

PW
Re: How can I specify a position for a view ? [message #467274 is a reply to message #467233] Wed, 02 May 2007 05:43 Go to previous messageGo to next message
Eclipse UserFriend
to Paul Webster :
I do as what you say, but it doesn't work.
Re: How can I specify a position for a view ? [message #467403 is a reply to message #467274] Thu, 03 May 2007 10:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: emmanuel.blonvia.vidal.fr

Hi Xldelg,
Have you found a solution to your problem ?
I'am facing the same problem. I described it in the message "[RCP] Laying
out a view in the plugin".
But my problem is a little more complicated :
I have my main RCP appli (named MainPlugin) with a Perspective class that
defines the layout of several views, for instance a view named DetailView:

IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT, 0.7f,
editorArea);
right.addPlaceholder(DetailView.ID + ":*");

With the code above, I can properly layout my DetailView view.
Now I need to add another view (named ClassView) that comes from an other
plugin (named Plugin2). Thus, my MainPlugin appli doesn't know the views
comming from the Plugin2. And that Plugin2 as no Perspective class.
Now the question is how do I layout my ClassView view ?
I tried making my ClassView inherit from DetailView but the view always set
itself in another area than the rigth one.

Can anyone help me ?
Emmanuel

"xldelg" <xldelg@sohu.com> a
Re: How can I specify a position for a view ? [message #467527 is a reply to message #467233] Sat, 05 May 2007 01:02 Go to previous messageGo to next message
Eclipse UserFriend
To Paul Webster:
Your solution is right, it solves my problem, it's my mistake. Thank you very much.
Re: How can I specify a position for a view ? [message #467529 is a reply to message #467233] Sat, 05 May 2007 01:11 Go to previous messageGo to next message
Eclipse UserFriend
To Emmanuel BLONVIA :
Paul Webster's solution solved my problem. I use the code below:

------------------------------------------------------------ ---
String editorArea = layout.getEditorArea();
IFolderLayout folder = layout.createFolder("left",IPageLayout.LEFT,0.6f,editorArea);
folder.addPlaceholder(TaskView.ID + ":*");
------------------------------------------------------------ ---
After that, when I open a instance of TaskView, it is shown in the "folder".

And your problem seems more complicated. I'm sorry that I don't konw how to solve it.
Re: How can I specify a position for a view ? [message #467715 is a reply to message #467403] Thu, 10 May 2007 08:52 Go to previous message
Eclipse UserFriend
you can use the extension org.eclipse.ui.perspectiveExtensions to extend
your main extension from your secondary plugin.

Later,
PW
Previous Topic:Dynamic menu
Next Topic:Selection problems in editors
Goto Forum:
  


Current Time: Mon May 12 15:09:05 EDT 2025

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

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

Back to the top