HOW TO USE THE CLASS OF "openPerspectiveMenu" IN A CLASS? - eclipse

I want to develope plug-ins in eclipse,the function of the plug-ins is when right-click menu the button opens a perspective.I find the class which is "openPerspectiveMenu" has not been used,please tell me the alternative.
thank you!

The way to open a perspective programmatically is to call:
IWorkbench.showPerspective(String perspectiveId,
IWorkbenchWindow window)
throws WorkbenchException
Javadoc here.
See http://wiki.eclipse.org/FAQ_How_do_I_show_a_given_perspective%3F for details.

Related

In Eclipse, how can I view which ui class is active?

I know that there is a feature in Eclipse that shows the class name of the active element of the eclipse interface (for example, the class of the element selected with mouse). It is used to debug client plugin extensions, but I don't remember how to call it..
How can I get this feature? Which key combination I can use?
Thanks,
Michele.
You are probably thinking of the Plug-in Spy plug-in. Press Alt+Shift+F1 to see to details about the current selection. Alt+Shift+F2 lets to find out information about menu items.

How do I show all perspectives in my rcp project eclipse perspective bar (coolbar) upon startup?

Upon startup I only have the Open Perspective button and the default perspective that I set in method getInitialWindowPerspectiveId on its right. I want to show all my other perspectives on that coolbar.
Until now i tried:
config.ini file with org.eclipse.ui/PERSPECTIVE_BAR_EXTRAS=id1,id2,id3
plugin_customization.ini with org.eclipse.ui/PERSPECTIVE_BAR_EXTRAS=id1,id2,id3
in class ApplicationWorkbenchAdvisor in the initialize method someone said to do this:
PlatformUI.getPreferenceStore().setDefault(IWorkbenchPreferenceConstants.PERSPECTIVE_BAR_EXTRAS,"id1,id2,id3");
PlatformUI.getPreferenceStore().setValue(IWorkbenchPreferenceConstants.PERSPECTIVE_BAR_EXTRAS,"id1,id2,id3");
Nothing worked.
However i found a workaround:
in class ApplicationWorkbenchWindowAdvisor in the postWindowOpen i manually show all my perspectives. This leaves them opened in the coolbar. However this is not the optimum way and maybe someone knows the proper way to show all my perspective shortcuts on the coolbar.
PlatformUI.getWorkbench().showPerspective("id1", getWindowConfigurer().getWindow());
PlatformUI.getWorkbench().showPerspective("id2", getWindowConfigurer().getWindow());
PlatformUI.getWorkbench().showPerspective("id3", getWindowConfigurer().getWindow());
Thanks
The 'plugin_customization.ini' method should work
The 'plugin_customization.ini' file must be in your RCP plugin
The 'plugin_customization.ini' must be included in the build in the 'build.properties' file.

How to get resource object in RCP App

I use CNF to make a view like Project Explorer in my RCP app. I'm done showing new menu and its submenu when user right clicks on a project in the view.
But when user click on a submenu (for this case, a method library going to be created), I need to know which project object that user has right-clicked on.
My question is how can I do that? Please help me.
Thank you all,
Nautilus
I think the wiki page E4/EAS/Selection should provide a way to query the right selection.
In Eclipse 3.x, the org.eclipse.ui.ISelectionService allows workbench parts to query the active selection in addition to attaching listeners for monitoring selection changes.
(see this example)
In the e4 world, selection is propagated with the ESelectionService.
Thank VonC,
Now I got the resource object that user has right-clicked on by doing this:
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
CommonNavigator view = (CommonNavigator)page.findView("spe.ui.navigator.view");
selection = (IStructuredSelection) view.getSite().getSelectionProvider().getSelection();
But I'm really not happy completely with the solution. Note that I open a INewWizard after the action. In the INewWizard we have public void init(IWorkbench workbench, IStructuredSelection selection). I really want to use this method but I don't how to make it work.
Please, someone help me.
Thanks

Eclipse Plugine Development for Popup menu

How can i add the my menu item inside the Run as menu item in pop up menu.
Thanks and Regards
Rahul Nakate
Mainly you have to extend the extension point org.eclipse.debug.core.launchConfigurationTypes and implement org.eclipse.debug.core.ILaunchConfigurationDelegate.
How to implement your own run configuration is a big topic. I would suggest to read the following: http://www.eclipse.org/articles/Article-Launch-Framework/launch.html

How to get from an EditPart to its Editor in Eclipse? (Eclipse plug-in development)

I am writing an eclipse plug-in that extends editor. Inside the editor I put some EditParts. From some of these edit parts I need a reference to their encapsulating editor (so that for example, when clicking an instance of MyEditPart, I want to programmatically close the editor).
Please advise on the API to get from an EditPart instance to the Editor it is in.
Thanks.
You can try:
IEditorPart editor = ((DefaultEditDomain) getViewer().getEditDomain()).getEditorPart();
from the EditPart.