no

How to Open a View Using Command in Eclipse Rcp

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 t...

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();
}

Related

java-eclipse-rcp 4119257421947031396

Post a Comment Default Comments

2 comments

Samuel Kroslak said...

great, that helped, thanks!

Anonymous said...

The brown Text is difficult to spot on the brown background :P

Outsourcing

Are you looking for freelancers in the Philippines? Get in touch.

Donations

If you like what I do, you can support this channel by buying me a coffee. I would be grateful for your contribution! Your donations will help me create more FREE online courses and learning materials for programmers and remote workers.

item