Showing a view in Eclipse
I'm developing a plug-in in Eclipse and I want to show a view. I'm using this:
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().sho开发者_运维问答wView("org.eclipse.ui.articles.MyView");
however it's being added on the right not at the set of views where I want it to be displayed.
How can I specify the location?
Ok found out how.
This gave me the idea of what I should do: http://www.eclipse.org/articles/viewArticle/ViewArticle2.html in the View Position paragraph under the Step 3 section.
When declaring the perspective, I added a placeholder to contain the view. It is shown in the following code:
public void defineLayout(IPageLayout layout) {
String editorArea = layout.getEditorArea();
IFolderLayout bottom =
layout.createFolder("bottom", IPageLayout.BOTTOM, (float) 0.75f, editorArea);
bottom.addPlaceholder("org.eclipse.ui.articles.MyView");
}
Later on, I use:
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("org.eclipse.ui.articles.MyView")
to show the view and it appears where I had declared in the Perspective and not at the default right-hand side.
Hope it could help someone else.
Thanks and regards,
Krt_Malta
精彩评论