## Action set part associations

Once your plug-in defines an action set, it can use the org.eclipse.ui.actionSetPartAssociations extension point to specify that an action set should be made visible when a particular view or editor is active.

Ultimately, the user controls the appearance of action sets using Window->Customize Perspectives... in the workbench menu. If the user marks an action set visible, it will always be visible when the perspective is active, regardless of the active view or editor. Likewise, if the user marks the action set as hidden, it will always be hidden when the perspective is active. If the user does not change the state of an action set in this dialog, then the action set part associations are used to determine the visibility of the action set.

The markup for an action set part association is straightforward. The following example comes from the Java development tools (JDT) UI plug-in.

       <extension point="org.eclipse.ui.actionSetPartAssociations">
    	<actionSetPartAssociation
    		targetID="org.eclipse.jdt.ui.CodingActionSet">
    		<part id="org.eclipse.jdt.ui.PackageExplorer"/>
    		<part id="org.eclipse.jdt.ui.TypeHierarchy" />
    		<part id="org.eclipse.jdt.ui.CompilationUnitEditor"/>
    		<part id="org.eclipse.jdt.ui.ClassFileEditor"/>
    		<part id="org.eclipse.jdt.ui.ProjectsView"/>
    		<part id="org.eclipse.jdt.ui.PackagesView"/>
    		<part id="org.eclipse.jdt.ui.TypesView"/>
    		<part id="org.eclipse.jdt.ui.MembersView"/>
    	</actionSetPartAssociation>
    </extension>

The targetID specifies the action set. (The CodingActionSet was previously defined in the JDT plug-in manifest.) One or more part attributes can be specified to indicate which views and editors will cause the action set to become visible in the menus and toolbar. The effect of this extension contribution is that the actions associated with writing Java code will only be visible when one of the specified views is active.