Bug 185554 - [api][breaking] remove the dynamicPopupMenuExtensions extension point
Summary: [api][breaking] remove the dynamicPopupMenuExtensions extension point
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 1.0.1   Edit
Hardware: All All
: P2 enhancement (vote)
Target Milestone: 2.0   Edit
Assignee: Martin Oberhuber CLA
QA Contact: Martin Oberhuber CLA
URL: http://dsdp.eclipse.org/help/latest/t...
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2007-05-04 10:39 EDT by Martin Oberhuber CLA
Modified: 2008-08-13 13:18 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Oberhuber CLA 2007-05-04 10:39:46 EDT
The dynamicPopupMenuExtensions seems to be obsolete. It should be possible to achieve the same via
   org.eclipse.ui.popupMenus
or
   org.eclipse.ui.commands

Eclipse Platform has evolved so much that such extra handling cannot be necessary any more. We do not have any example code for dynamicPopupMenuExtensions in RSE, so it is hard to understand how this would have been used.

Anyways, migration docs should be written explaining how to migrate from dynamicPopupMenuExtensions to org.eclipse.ui.commands (best option) or org.eclpse.ui.popupMenus

See also similar bug 185552 for removing remoteSystemsViewPreferencesActions.
All the client needs to do, is contribute a handler class that opens a specific preference page. This handler class can be derived from a utility class in RSE. Because the specific preference page is likely contributed as well, so the preference page's plugin needs to be activated anyways, it is very likely that having to specify a class doesn't even activate an extra plugin.

Migration docs should be written explaining how a custom preference page can be contributed. As an Example, the existing RSE preference page show action should be contributed through one of the two methods mentioned above.

When this is done, 
* class SystemCascadingPreferencesAction will most probably be obsolete 
  (since core Eclipse cares for populating the menu already), class
* class SystemShowPreferencesPageAction will need to become API since
  clients will need to derive from it - unless we'd be able to use the commands
  extension point with command parameters to modify operation of the action,
  then it can remain internal.
Comment 1 Uwe Stieber CLA 2007-05-09 06:15:58 EDT
The are basically 2 set's of standard Eclipse extension points which can and should be used for dynamic contributions.

- Up to Eclipse 3.2.x the extension points refering to the action framework are preferable:
   - org.eclipse.ui.actionSets
   - org.eclipse.ui.editorActions
   - org.eclipse.ui.popupMenus and
   - org.eclipse.ui.viewActions

- From Eclipse 3.3, the extension points refering to the command/handler framework should be used for new contributions:
   - org.eclipse.ui.menus
   - org.eclipse.ui.handlers
   - org.eclipse.ui.bindings
   - org.eclipse.ui.commands and
   - org.eclipse.core.expressions.propertyTesters

The more powerful and flexible system is the new command/handler framework.

The direct replacements for the legacy RSE extension point "dynamicPopupMenuExtensions" will be either
   - org.eclipse.ui.popupMenus or
   - org.eclipse.ui.menus.
Both extension points are providing control over the visibility of a item within the target menu. Again, 3.3 is offering the more advanced possibilities.

Some examples for the more well-known extension point org.eclipse.ui.popupMenus. The key with that extension point is to know the id's of the groups and separators within the menu and which kind properties to test the corresponding IActionFilter implementation for the selected object type is supporting.

A simple one:

   <extension point="org.eclipse.ui.popupMenus">
      <viewerContribution targetID="org.eclipse.rse.ui.view.systemView" id="com.windriver.ide.target.ui.rse.AttachHostShell">
         <action
               class="com.windriver.ide.target.ui.actions.contrib.WRAttachHostShellAction"
               definitionId="com.windriver.ide.target.ui.actions.contrib.WRAttachHostShellAction.command"
               enablesFor="1"
               helpContextId="com.windriver.ide.target.ui.action_attach_hostshell"
               icon="icons/elcl16/attach_hostshell.gif"
               id="com.windriver.ide.target.ui.rse.actions.WRAttachHostShellAction"
               label="%WRAttachHostShellAction.label"
               menubarPath="TargetToolsMenu"
               style="push"
               tooltip="%WRAttachHostShellAction.tooltip">
         </action>
         <visibility>
            <and>
               <objectState name="isWRConnection" value="true"/>
               <objectState
                     name="adapt"
                     value="com.windriver.ide.target.model.ITargetObjectTypeNode">
               </objectState>
            </and>
         </visibility>
      </viewerContribution>
   </extension>

A more complex one:

   <extension point="org.eclipse.ui.popupMenus">
      <viewerContribution targetID="org.eclipse.rse.ui.view.systemView" id="com.windriver.ide.target.ui.rse.RefreshContrib">
         <action
               class="com.windriver.ide.target.ui.rse.internal.actions.WRRefreshAction"
               definitionId="org.eclipse.ui.file.refresh"
               helpContextId="com.windriver.ide.target.ui.action_refresh"
               icon="icons/elcl16/refresh.gif"
               id="refresh"
               label="%RefreshAction.label"
               menubarPath="group.build"
               tooltip="%RefreshAction.tooltip">
         </action>
         <visibility>
            <and>
               <not>
  	             <objectClass name="com.windriver.ide.target.ui.rse.interfaces.IWRRegistrySubSystem"/>
               </not>
               <not>
      	      <objectState
        	         name="adapt"
                     value="com.windriver.ide.target.model.ITargetManagerModel">
          	      </objectState>
               </not>
	         <or>
  	             <objectClass name="com.windriver.ide.target.ui.rse.interfaces.IWRHost"/>
    	             <objectClass name="com.windriver.ide.target.ui.rse.interfaces.IWRSubSystem"/>
      	       <objectState
        	           name="adapt"
                       value="com.windriver.ide.target.api.model.IModelNode">
          	       </objectState>
               </or>
            </and>
         </visibility>
      </viewerContribution>
   </extension>

Translating that into an example contribution for the connect/disconnect action, it would look like:

   <extension point="org.eclipse.ui.popupMenus">
      <viewerContribution targetID="org.eclipse.rse.ui.view.systemView" id="org.eclipse.rse.ui.actions.connect">
         <action
               class="org.eclipse.rse.internal.ui.actions.SystemConnectAllSubSystemsAction"
               id="connectAllSubSystemsAction"
               label="Connect"
               menubarPath="group.connection">
         </action>
         <visibility>
            <and>
               <objectClass name="org.eclipse.rse.core.model.IHost"/>
               <objectState name="connected" value="false"/>
            </and>
         </visibility>
      </viewerContribution>
       <viewerContribution targetID="org.eclipse.rse.ui.view.systemView" id="org.eclipse.rse.ui.actions.disconnect">
         <action
               class="org.eclipse.rse.internal.ui.actions.SystemDisconnectAllSubSystemsAction"
               id="disconnectAllSubSystemsAction"
               label="Disconnect"
               menubarPath="group.connection">
         </action>
         <visibility>
            <and>
               <objectClass name="org.eclipse.rse.core.model.IHost"/>
               <objectState name="connected" value="true"/>
            </and>
         </visibility>
      </viewerContribution>
  </extension>

Comment 2 Martin Oberhuber CLA 2007-05-09 06:31:14 EDT
Thanks a lot for all these examples, Uwe!

When I'm not mistaken, all of these contribute single actions only. Do you also have an example contributing a whole submenu? And do you have an idea if it is possible to suppress any existing menu items contributed by someone else in some context?

I'm not sure if these use cases are indeed in use at IBM, but I think that the dynamicPopupMenuExtensions extension point would support these.
Comment 3 Uwe Stieber CLA 2007-05-09 07:37:28 EDT
- Submenu contribution example:

   <extension point="org.eclipse.ui.popupMenus">
      <viewerContribution targetID="org.eclipse.rse.ui.view.systemView" id="com.windriver.ide.target.ui.rse.TargetToolMenuContrib.vxWorks">
         <menu label="%TargetToolsMenu.label" path="TargetToolsSubMenu" id="TargetToolsMenu">
            <separator name="TargetTools">
            </separator>
            <separator name="TargetToolsTargetConsole">
            </separator>
            <separator name="TargetToolsHostShell">
            </separator>
         </menu>
         <visibility>
            <and>
               <objectState value="true" name="isWRConnection"/>
               <objectState 
                  	  name="adapt"
                  	  value="com.windriver.ide.target.api.model.IModelNode">
               </objectState>
            </and>
         </visibility>
      </viewerContribution>
   </extension>

- Standard actions/contributions can bee suppressed within any of the several add*Actions(...) API methods. The menu manager reference is always passed to this methods. 
Comment 4 Martin Oberhuber CLA 2007-05-10 12:29:24 EDT
Work completed, checkin comment: 
[185554][api] Remove dynamicPopupMenuExtensions extension point

Removed interfaces, classes and methods:
----------------------------------------
ISystemDynamicPopupMenuExtensionManager
SystemDynamicPopupMenuExtensionManager
ISystemDynamicPopupMenuExtension
RSEUIPlugin#registerDynamicPopupMenuExtensions()

Updated ISV Docs; modified API docs in 
   AbstractSystemViewAdapter#addDynamicPopupMenuActions()
explaining that extenders can override this method in 
order to contribute dynamic popup menu extensions.

Examples for how to migrate to using the standard
Eclipse Platform extension point, as well as the 
RSE API hooks for contributing dynamic popup menu
extensions are covered in the previous comments.
Comment 5 Martin Oberhuber CLA 2008-02-05 11:14:34 EST
For adding dynamic submenus, following Wiki page should help getting started:
http://wiki.eclipse.org/Menu_Contributions/Problems_View_Example
Comment 6 Martin Oberhuber CLA 2008-02-20 11:27:02 EST
To get current context, evaluate current selection -- see
   Workbench.getSelectionService()
get current active Part in workbench
Comment 7 Martin Oberhuber CLA 2008-08-13 13:18:29 EDT
[target cleanup] 2.0 M7 was the original target milestone for this bug