Runtime

org.eclipse.gmf.runtime.common.ui.action
Class ActionMenuManager

java.lang.Object
  extended byorg.eclipse.jface.action.ContributionManager
      extended byorg.eclipse.jface.action.MenuManager
          extended byorg.eclipse.gmf.runtime.common.ui.action.ActionMenuManager
All Implemented Interfaces:
IContributionItem, IContributionManager, IMenuManager

public class ActionMenuManager
extends MenuManager

An implementation of an IMenuManager that inherits its UI (text + icon + hints) from a given action. When filled in a toolbar, the menu is rendered as a tool item with two parts: a button, whose icon comes from the supplied action handler, and a drop-down menu arrow. When the arrow is pressed, the drop-down menu is shown. When the button is pressed, the associated action is executed. The manager can have an optional style to retarget the last executed action. In this case the tool item UI reflects the last executed sub-action from the menu. When filled in a menu, this menu shows up as a normal cascading menu with its GUI inherited from the supplied action.


Nested Class Summary
 class ActionMenuManager.MenuCreatorAction
          An action that provides a menu and fills it from the contribution items of the enclosing menu manager.
 
Field Summary
protected  ActionMenuManager.MenuCreatorAction action
          the associated menu action
protected  IAction defaultAction
          the associated menu action
 
Constructor Summary
ActionMenuManager(java.lang.String id, IAction actionHandler)
          Creates a new instance of ActionMenuManager with a given action handler.
ActionMenuManager(java.lang.String id, IAction actionHandler, boolean retargetLastAction)
          Creates a new instance of ActionMenuManager with a given action handler and an option to retarget the last executed menu action.
 
Method Summary
 void dispose()
           
 void fill(Composite parent)
           
 void fill(Menu parent, int index)
           
 void fill(ToolBar parent, int index)
           
 IAction getDefaultAction()
           
protected  IContributionItem[] getRealItems()
          Returns the contribution items of this manager.
 boolean isDirty()
           
 boolean isDynamic()
           
 boolean isEnabled()
           
 boolean isGroupMarker()
           
protected  boolean isRetargetLastAction()
          Returns whether the option to retarget last action was requested
 boolean isSeparator()
           
 boolean isVisible()
           
protected  void itemAdded(IContributionItem item)
           
protected  void itemRemoved(IContributionItem item)
           
protected  void setDefaultAction(IAction defaultAction)
           
 void setParent(IContributionManager parent)
           
 void setVisible(boolean visible)
           
protected  void subActionSelected(IAction subActionHandler)
          Handle subaction selection
 void update()
           
 void update(boolean force)
           
 void update(java.lang.String id)
           
 void updateAll(boolean force)
           
 
Methods inherited from class org.eclipse.jface.action.MenuManager
addMenuListener, createContextMenu, createMenuBar, createMenuBar, fill, findMenuUsingPath, findUsingPath, getId, getMenu, getMenuText, getOverrides, getParent, getRemoveAllWhenShown, isSubstituteFor, markDirty, removeMenuListener, saveWidgetState, setOverrides, setRemoveAllWhenShown, update
 
Methods inherited from class org.eclipse.jface.action.ContributionManager
add, add, allowItem, appendToGroup, appendToGroup, dumpStatistics, find, getItems, hasDynamicItems, indexOf, indexOf, insert, insertAfter, insertAfter, insertBefore, insertBefore, internalSetItems, isEmpty, prependToGroup, prependToGroup, remove, remove, removeAll, replaceItem, setDirty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.jface.action.IContributionManager
add, add, appendToGroup, appendToGroup, find, getItems, insertAfter, insertAfter, insertBefore, insertBefore, isEmpty, prependToGroup, prependToGroup, remove, remove, removeAll
 

Field Detail

action

protected final ActionMenuManager.MenuCreatorAction action
the associated menu action


defaultAction

protected IAction defaultAction
the associated menu action

Constructor Detail

ActionMenuManager

public ActionMenuManager(java.lang.String id,
                         IAction actionHandler)
Creates a new instance of ActionMenuManager with a given action handler. The manager does not retarget the last selected action from the menu

Parameters:
id - The menu manager id
actionHandler - the menu associated action handler

ActionMenuManager

public ActionMenuManager(java.lang.String id,
                         IAction actionHandler,
                         boolean retargetLastAction)
Creates a new instance of ActionMenuManager with a given action handler and an option to retarget the last executed menu action.

Parameters:
id - The menu manager id
actionHandler - the menu associated action handler
retargetLastAction - whether to retarget the last action or not
Method Detail

isRetargetLastAction

protected boolean isRetargetLastAction()
Returns whether the option to retarget last action was requested

Returns:
true if retargetLastAction is enabled, false otherwise

subActionSelected

protected void subActionSelected(IAction subActionHandler)
Handle subaction selection

Parameters:
subActionHandler - The selected sub action handler

fill

public void fill(Composite parent)

fill

public void fill(Menu parent,
                 int index)

fill

public void fill(ToolBar parent,
                 int index)

dispose

public void dispose()

isEnabled

public boolean isEnabled()

isDirty

public boolean isDirty()

isDynamic

public boolean isDynamic()

isGroupMarker

public boolean isGroupMarker()

isSeparator

public boolean isSeparator()

isVisible

public boolean isVisible()

setParent

public void setParent(IContributionManager parent)

setVisible

public void setVisible(boolean visible)

update

public void update()

update

public void update(java.lang.String id)

updateAll

public void updateAll(boolean force)

update

public void update(boolean force)

itemAdded

protected void itemAdded(IContributionItem item)

itemRemoved

protected void itemRemoved(IContributionItem item)

getRealItems

protected IContributionItem[] getRealItems()
Returns the contribution items of this manager. If an item is wrapper in a SubContributionItem instance it extracts the real item instance

Returns:
An array of real items of this contribution manager

getDefaultAction

public IAction getDefaultAction()

setDefaultAction

protected void setDefaultAction(IAction defaultAction)

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.