Adding team actions

The team UI plug-in defines a popup menu extension in order to consolidate all team-related actions in one place.  The team menu includes many subgroup slots so that team provider plug-ins can contribute actions and have some amount of control over the order of items in the menu.  The following markup is from the team UI's plug-in manifest:

<extension
     point="org.eclipse.ui.popupMenus">
	<objectContribution
       	   id="org.eclipse.team.ui.ResourceContributions"
           objectClass="org.eclipse.core.resources.IResource" adaptable="true">
		<menu
			id="team.main"
			path="additions"
			label="%TeamGroupMenu.label">
			<separator name="group1"/>
			<separator name="group2"/>
			<separator name="group3"/>
			<separator name="group4"/>
			<separator name="group5"/>
			<separator name="group6"/>
			<separator name="group7"/>
			<separator name="group8"/>
			<separator name="group9"/>
			<separator name="group10"/>
			<separator name="targetGroup"/>
			<separator name="projectGroup"/>
		</menu>
	... 
</extension>

A team menu is added to the popup menu of all views that show resources (or objects that adapt to resources.)  Your plug-in can use the id of this menu and the separator groups in order to add your own menu items.  There is nothing to keep you from defining your own popup menus, action sets, or view and editor actions.  However, adding your actions to the predefined team menu makes it easier for the end user to find your actions.

Let's look at a CVS action that demonstrates some interesting points:

<extension
    point="org.eclipse.ui.popupMenus">
     <objectContribution
           objectClass="org.eclipse.core.resources.IFile"
           adaptable="true"
           id="org.eclipse.team.ccvs.ui.IFileContributions">
        <filter
              name="projectPersistentProperty"
              value="org.eclipse.team.core.repository=org.eclipse.team.cvs.core.cvsnature">
        </filter>
        <action
              label="%IgnoreAction.label"
              tooltip="%IgnoreAction.tooltip"
              class="org.eclipse.team.internal.ccvs.ui.actions.IgnoreAction"
              menubarPath="team.main/group3"
              helpContextId="org.eclipse.team.cvs.ui.team_ignore_action_context"
              id="org.eclipse.team.ccvs.ui.ignore">
        </action>
	...

Note that the action is contributed using the org.eclipse.ui.popupMenus workbench extension point.  Here are some team-specific things happening in the markup:

The implementation of an action is largely dependent on your specific provider.

Commands can be contributed in a similar way:

   <extension point="org.eclipse.core.expressions.definitions">
      <definition id="org.eclipse.ui.example.ccvs.ui.IFileContributions">
         <iterate ifEmpty="false">
            <adapt type="org.eclipse.core.resources.IFile">
               <test property="org.eclipse.core.resources.projectPersistentProperty"
                     value="org.eclipse.team.core.repository=org.eclipse.team.cvs.core.cvsnature"/>
            </adapt>
         </iterate>
      </definition>
   </extension>
   <extension point="org.eclipse.ui.menus">
      <menuContribution locationURI="popup:team.main?after=group3">
         <command commandId="org.eclipse.team.ccvs.ui.ignore"
               id="org.eclipse.ui.example.ccvs.ui.ignore"
               style="push">
            <visibleWhen checkEnabled="false">
               <or>
                  <with variable="activeMenuSelection">
                     <reference definitionId="org.eclipse.ui.example.ccvs.ui.IFileContributions"/>
                  </with>
                  <with variable="activeMenuEditorInput">
                     <reference definitionId="org.eclipse.ui.example.ccvs.ui.IFileContributions"/>
                  </with>
               </or>
            </visibleWhen>
         </command>
      </menuContribution>
   </extension>