Execute an eclipse-rcp command and open an eclipse-rcp view in code
Tech-Today

Execute an eclipse-rcp command and open an eclipse-rcp view in code


Objective:
1.) To execute an eclipse rcp command in code
2.) To open an eclipse rcp view in command

Most of the time you will just use the extension tab in the plugin.xml but for those who chose to implement in code here's how they're done:

Solution:
1.) By consulting the eclipse-rcp documentation, this is how I done it:
//execute command
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IViewPart view = window.getActivePage().findView("your.view.class.id");
IHandlerService service = (IHandlerService) view.getSite().getService(IHandlerService.class);
service.executeCommand("your.application.command.id", null);
Please take note of the findView and executeCommand parameters, which are IDs.

2.) Opening an eclipse-rcp view in code:
//open view
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
try {
//any view in your application
window.getActivePage().showView(you.view.class.id);
} catch (PartInitException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}




- Add Eclipse-rcp's Views Short List, Perspective Short List In The Org.eclipse.ui.menus Plugin Via Dynamic Compoundcontributionitem Class
Recently, I've encountered a problem wherein I wanted to display the eclipse-rcp's list of view, perspective etc using the extension org.eclipse.ui.menus. The problem can easily solved by the ApplicationActionBarAdvisor, see the code below: private...

- How To Open A View Using The Eclipse-rcp's Plugin.xml's Extension Tab. Passing The View Id As A Command Parameter.
1.) Create a new HelloWorld RCP project 2.) Open the plugin.xml file and click the Extension tab 3.) Add the extension org.eclipse.ui.commands a.) right click and select New->command b.) set the command's id to command.showView c.) set the defaultHandler...

- Open A View In The Eclipse-rcp's Extension Tab Using The Showviewhandler Class
Let's do this quick. 1.) Create a new HelloWorld Plug-in Project and name it CommandParameter. 2.) Open the plugin.xml and click the Extensions tab. 3.) In the All Extensions tab click the Add button and under the Extension Point Filter: search "view"....

- Create A New Eclipse-rcp Preference Page By Code When A Listener Is Invoked
Objective: -To create an eclipse-rcp preference page without using the preference extension, all is done in code. This is done by creating a customized button with a SelectionListener, and eventually that action will call a customized preference page....

- Updating The Status Message Dynamically Of An Eclipse Rcp Application By Using A Worker Thread
Objective: -To create an eclipse application that will dynamically update the action bar's status message from a worker thread. Updating a part of the screen in another thread is a good practice, since it will not make your screen blink, also the...



Tech-Today








.