Learn Dynamic Command in Eclipse Rcp 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

2 Comments

Post a Comment

Post a Comment

Previous Post Next Post
NERV Open Source

Building production Spring Boot systems?

Explore NERV — open-source Java libraries for audit trails, persistence, exception handling, and reliable event-driven architecture.

Explore NERV on GitHub →