views:

494

answers:

2

"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 advance, Abhinav"

A: 

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

derBiggi
Dear Andreas,Thank you for your reply. The method suggested by you seems working. As now I am able to get the view shortcut entry inside Window->Show VIew->Other...->General category. Earlier it was coming in Window->Show View->Other...->Others category. But I want these shortcuts of General category directly under Window->Show View menu and not under Other..->General submenu. I think this might be need to set under preferences somewhere but I am not able to find this. Could you please suggest what I am actually missing here.Anyways thanks a lot again for your reply.
Abhinav Mishra
Ok, i asked my coworker who did this in our project:In your plugin.xml, add an extension from "org.eclipse.ui.perspectiveExtensions". In there, you can add a "perspectiveExtension", for your new perspective or for the standard one, and inside that, add a "viewShortcut". That one needs the ID of the view.I think that's it.
derBiggi
A: 

You can also read the "Perspective Article" on eclipse:

In the example below you can see how createInitialLayout is implemented in the TestPerspective class. For clarity the algorithm has been split into two parts which define the actions and layout: defineActions and defineLayout.

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 the File > New, Show View, or Perspective > Open menus of the window.
You can also add complete action sets to the menu or toolbar of the window. In this example a few File > New and Show View items are added.

public void defineActions(IPageLayout layout) {

    // Add "show views".
    layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
    ...
}
VonC
Dear VonC,Thank you for your quick reply.This method seems to be the same as described in above reply. As you can see my comment above, this is working but I am facing a little problem which described above. Also, the link to article you have send is also useful.Thanks again
Abhinav Mishra