"I have created an Eclipse plugin which creates a view in Eclipse. Currently it is displayed in the Eclipse menu as : 'Window->Show View->Others'.
I want to show it in 'Window -> Show View' and not under the submenu 'Others'.
I have tried it giving the 'Category' of the view in the plugin.xml file as 'org.eclipse.ui' but it is still showing the view in 'Others' submenu.
Is there any other way to do so? Any suggestions are helpful in this regard.
Thanks in ad开发者_开发知识库vance, Abhinav"
I think you can do that with a customized perspective.
In your plugin.xml, add an extension point for "org.eclipse.ui.perspectives", and create a new class implementing IPerspectiveFactory.
This class has a method "createInitialLayout( IPageLayout layout )", and on that layout you can call "layout.addShowViewShortcut( < ID of your view > )"
You can also add shortcuts for wizards etc. there.
Hope that helps, Andreas
You can also read the "Perspective Article" on eclipse:
In the example below you can see how
createInitialLayout
is implemented in theTestPerspective
class. For clarity the algorithm has been split into two parts which define the actions and layout:defineActions
anddefineLayout
.
public void createInitialLayout(IPageLayout layout) {
defineActions(layout);
defineLayout(layout);
}
In
defineActions
a number of items and action sets are added to the window. A perspective may add items to theFile > New
,Show View
, orPerspective > Open
menus of the window.
You can also add complete action sets to the menu or toolbar of the window. In this example a fewFile > New
andShow View
items are added.
public void defineActions(IPageLayout layout) {
// Add "show views".
layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
...
}
When shortcuts of such kind shall be added to an existing perspective, the plugin providing views, new file wizards, or perspectives may declare an extension to org.eclipse.ui.perspectiveExtensions
. Perspectives such as org.eclipse.jdt.ui.JavaPerspective
, org.eclipse.emf.ecoretools.perspective
, or org.eclipse.ui.resourcePerspective
can be extended to provide new-wizard, view, perspective shortcuts and more.
精彩评论