Looking for a JavaEE Architect or Potential Tech Co-Founder?
Please don't hesitate to contact me.

How to show dynamic Command based on perspective in eclipse-rcp, does not work on toolbar and main menu

1.) Using the HelloWorld project template, add org.eclipse.core.expressions in your application's plugin.xml's Dependencies tab.
2.) In the extension tab do the following:
a.) add org.eclipse.core.expressions.definition, set its id to onValidationPerspective
b.) add new definition name it: onOpenPerspective
c.) right click definition and select "with", variable = activeWorkbenchWindow.activePerspective
d.) right click with and select "equals", value = perspective id
3.) Now for example you want to show a Command on your toolbar when you open a perspective x
a.) in the plugin.xml's Extension tab add org.eclipse.ui.menu
b.) select new->toolbar, set the location URI to toolbar:org.eclipse.ui.main.toolbar
c.) right click the toolbar and select new->toolbar again, id should be unique
d.) right click the second toolbar select new->command
e.) under command select visibleWhen
f.) under visibleWhen select reference and set the definitionId=onValidationPerspective
Note: onValidationPerspective is the one we have defined in the org.eclipse.core.expressions.definition

How to show dynamic Command based on perspective in eclipse-rcp, does not work on toolbar and main menu How to show dynamic Command based on perspective in eclipse-rcp, does not work on toolbar and main menu Reviewed by Edward Legaspi on Friday, February 19, 2010 Rating: 5

2 comments:

Anonymous said...

Thank you so much!!!! You're such a big help :)

Anonymous said...

Thanks!!! :D

Powered by Blogger.