Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display view in Eclipse menu Window-> Show View

"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"

like image 584
javdev Avatar asked Nov 06 '09 11:11

javdev


People also ask

What are Eclipse views?

Eclipse views allow users to see a graphical representation of project metadata. For example the project navigator view presents a graphical representation of the folders and files associated with a project and properties view presents a graphical representation of an element selected in another view or editor.

How do I show project Window in Eclipse?

To view the project explorer, click on Window menu then, click on Show View and select Project Explorer. There is simpler way to open project explorer, when you are in the editor press alt + shift + w and select project explorer.

Where is the menu in Eclipse?

The menu items related to building a project can be found on the Project menu. The menu items on the Run menu allow you to start a program in the run mode or debug mode.

What is Window in Eclipse?

Parts of an Eclipse Window An eclipse window can have multiple perspectives open in it but only one perspective can be active at any point of time. A user can switch between open perspectives or open a new perspective. A perspective controls what appears in some menus and tool bars.


2 Answers

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

like image 174
derBiggi Avatar answered Oct 08 '22 06:10

derBiggi


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);
    ...
}
like image 39
VonC Avatar answered Oct 08 '22 06:10

VonC