Wednesday, March 21, 2012

How to hide or show action set in eclipse workbench when eclipse related part (like: Editor, View etc.) will be (de)activated



Extension Point: org.eclipse.ui.actionSetPartAssociations

Using this extension point, we can hide or show related action set in eclipse workbench when specific eclipse part like: Editor or View will be deactivated or activated.
Now I'm implementing it with our existing Show View actionSet (id: SampleCode.showView.actionSet) and existing Sample View (id: SampleCode.view). After implementation, if the Sample view is active/highlighted then only the Show View action set will be visible otherwise this action set will be hidden. To implement in this way, follow the below mentioned steps:

Make sure that, the "visible" property of the selected action set should be default value, like below screenshot:


Action Set "visible" property is set to default value


1. Add the extension point in "Extensions" tab like below screenshot.

Adding "actionSetPartAssociations" extension point
2. After adding this extension, add new actionSetPartAssociation and provide the targetID* as SampleCode.showView.actionSet which is our existing action set id.


Property of "actionSetPartAssociation" extension point
3. After that, R-click on "actionSetPartAssociation" -> New -> part. Provide the Sample View id i.e. SampleCode.view

Property of "part"
4. Run the project. When the Sample View is active, then action button and also menu item is shown like below screenshot:

Output window when Sample View is activated
And, when Sample View is inactive, then action button and menu item is hide from eclipse toolbar as well as menu bar like below screenshot:

Output window when Sample View is inactive
Attachment: To Download this project click here.

No comments:

Post a Comment