0

Is it possible to add the Team options for SVN repository access to a custom context menu on a custom view? If so, how?

I have tried

<menuContribution locationURI="popup:my.view.ID#PopupMenu">
    <menu id="team.main" label="Team">
        <separator name="group1" visible="false"/>
        <separator name="group2" visible="false"/>
        <separator name="group3" visible="false"/>
    </menu>

in my plugin.xml, but only an EGit menu popped up once with grayed items when the mouse hovered over them.

Cornflake
  • 63
  • 5

1 Answers1

0

You can look at the org.eclipse.team.svn.ui plugin to see how the actions are defined. This uses the old style org.eclipse.ui.popupMenus extension point with objectContribution entries. For most entries on single files the object contribution is defined as:

<objectContribution
        adaptable="true"
        objectClass="org.eclipse.core.resources.mapping.ResourceMapping"
        id="org.eclipse.team.svn.ui.ResourceContributions">

     <enablement>
       <adapt type="org.eclipse.core.resources.mapping.ResourceMapping">
          <test property="org.eclipse.core.resources.projectPersistentProperty" args="org.eclipse.team.core.repository,org.eclipse.team.svn.core.svnnature" />
       </adapt>
     </enablement>

Which means the actions will only show for objects which adapt to ResourceMapping and are in a project with the SVN nature and a repository. IFile objects normally adapt to ResourceMapping but if you are using some other object you will have to set this up yourself.

greg-449
  • 109,219
  • 232
  • 102
  • 145
  • Thank you for the hint. If I implement IProject / IFile for the objects in my custom view and provide the menu groups group.new / group.open / ... / svn.main for the popup menu it works. – Cornflake Nov 15 '13 at 06:50
  • Another important thing are the adapters for the view's content objects. E.g. for the team menu the adapter org.eclipse.core.resources.mapping.ResourceMapping needs to be checked in getAdapter(). – Cornflake Nov 18 '13 at 14:06