Runtime

## org.eclipse.gmf.runtime.diagram.ui.commands
Class PopupMenuCommand

    java.lang.Object
      org.eclipse.core.commands.operations.AbstractOperation
          org.eclipse.gmf.runtime.common.core.command.AbstractCommand
              org.eclipse.gmf.runtime.diagram.ui.commands.PopupMenuCommand

All Implemented Interfaces:
  ICommand, org.eclipse.gmf.runtime.common.core.internal.command.ICommandWithSettableResult, IUndoableOperation

Direct Known Subclasses:
  CreateOrSelectElementCommand, PromptForConnectionAndEndCommand

public class PopupMenuCommand
extends AbstractCommand

A command that pops up a `PopupMenu` or a `PopupDialog` when it executes. The result from the `PopupMenu` or `PopupDialog` is retrieved via `getCommandResult().getReturnValue()`.

Field Summary
`static int` `POPUP_DIALOG` The popup dialog style for this command.
`static int` `POPUP_MENU` The popup menu style for this command.

Constructor Summary
`PopupMenuCommand(java.lang.String label, Shell parentShell)` Creates a new `PopupMenuCommand`.
`PopupMenuCommand(java.lang.String label, Shell parentShell, PopupMenu popupMenu)` Creates a new `PopupMenuCommand`.

Method Summary
`boolean` `canRedo()`
`boolean` `canUndo()`
`protected CommandResult` `doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info)` Performs the actual work of executing this command.
`protected CommandResult` `doRedoWithResult(IProgressMonitor progressMonitor, IAdaptable info)` Performs the actual work of redoing this command.
`protected CommandResult` `doUndoWithResult(IProgressMonitor progressMonitor, IAdaptable info)` Performs the actual work of undoing this command.
`protected Shell` `getParentShell()` Gets the parentShell.
`protected PopupDialog` `getPopupDialog()` Gets the popupDialog.
`protected PopupMenu` `getPopupMenu()` Gets the popupMenu.
`void` `setParentShell(Shell parentShell)` Sets the parentShell.
`void` `setPopupDialog(PopupDialog popupDialog)` Sets the popupDialog.
`void` `setPopupMenu(PopupMenu popupMenu)` Sets the popupMenu.

Methods inherited from class org.eclipse.gmf.runtime.common.core.command.AbstractCommand
`compose, dispose, execute, getAffectedFiles, getCommandResult, internalSetResult, redo, reduce, setResult, undo`

Methods inherited from class org.eclipse.core.commands.operations.AbstractOperation
`addContext, canExecute, getContexts, getLabel, hasContext, removeContext, setLabel, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.eclipse.core.commands.operations.IUndoableOperation
`addContext, canExecute, getContexts, getLabel, hasContext, removeContext`

Field Detail

### POPUP_MENU

    public static final int POPUP_MENU

  The popup menu style for this command.

  See Also:
    Constant Field Values

### POPUP_DIALOG

    public static final int POPUP_DIALOG

  The popup dialog style for this command.

  See Also:
    Constant Field Values

Constructor Detail

### PopupMenuCommand

    public PopupMenuCommand(java.lang.String label,
                            Shell parentShell)

  Creates a new `PopupMenuCommand`.

Parameters:
  `label` - the command label
  `parentShell` - the parent shell

### PopupMenuCommand

    public PopupMenuCommand(java.lang.String label,
                            Shell parentShell,
                            PopupMenu popupMenu)

  Creates a new `PopupMenuCommand`.

Parameters:
  `label` - the command label
  `parentShell` - the parent shell
  `popupMenu` - the popup menu

Method Detail

### doExecuteWithResult

    protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor,
                                                IAdaptable info)
                                         throws ExecutionException

  Description copied from class: `AbstractCommand`
  Performs the actual work of executing this command. Subclasses must implement this method to perform some operation.

  Specified by:
    `doExecuteWithResult` in class `AbstractCommand`
  Parameters:
    `progressMonitor` - the progress monitor provided by the operation history. Must never be `null`.
    `info` - the IAdaptable (or `null`) provided by the caller in order to supply UI information for prompting the user if necessary. When this parameter is not `null`, it should minimally contain an adapter for the org.eclipse.swt.widgets.Shell.class.
  Returns:
    The result of executing this command. May be `null` if the execution status is OK, but there is no meaningful result to be returned.
  Throws:
    `ExecutionException` - if, for some reason, I fail to complete the operation

### doRedoWithResult

    protected CommandResult doRedoWithResult(IProgressMonitor progressMonitor,
                                             IAdaptable info)
                                      throws ExecutionException

  Description copied from class: `AbstractCommand`
  Performs the actual work of redoing this command. Subclasses must implement this method to perform the redo.

  Specified by:
    `doRedoWithResult` in class `AbstractCommand`
  Parameters:
    `progressMonitor` - the progress monitor provided by the operation history. Must never be `null`.
    `info` - the IAdaptable (or `null`) provided by the caller in order to supply UI information for prompting the user if necessary. When this parameter is not `null`, it should minimally contain an adapter for the org.eclipse.swt.widgets.Shell.class.
  Returns:
    The result of redoing this command. May be `null` if the execution status is OK, but there is no meaningful result to be returned.
  Throws:
    `ExecutionException` - on failure to redo

### doUndoWithResult

    protected CommandResult doUndoWithResult(IProgressMonitor progressMonitor,
                                             IAdaptable info)
                                      throws ExecutionException

  Description copied from class: `AbstractCommand`
  Performs the actual work of undoing this command. Subclasses must implement this method to perform the undo.

  Specified by:
    `doUndoWithResult` in class `AbstractCommand`
  Parameters:
    `progressMonitor` - the progress monitor provided by the operation history. Must never be `null`.
    `info` - the IAdaptable (or `null`) provided by the caller in order to supply UI information for prompting the user if necessary. When this parameter is not `null`, it should minimally contain an adapter for the org.eclipse.swt.widgets.Shell.class.
  Returns:
    The result of undoing this command. May be `null` if the execution status is OK, but there is no meaningful result to be returned.
  Throws:
    `ExecutionException` - on failure to undo

### canRedo

    public boolean canRedo()

### canUndo

    public boolean canUndo()

### getParentShell

    protected Shell getParentShell()

  Gets the parentShell.

  Returns:
    Returns the parentShell.

### setParentShell

    public void setParentShell(Shell parentShell)

  Sets the parentShell.

  Parameters:
    `parentShell` - The parentShell to set.

### getPopupMenu

    protected PopupMenu getPopupMenu()

  Gets the popupMenu.

  Returns:
    Returns the popupMenu.

### setPopupMenu

    public void setPopupMenu(PopupMenu popupMenu)

  Sets the popupMenu. Sets the popup dialog to null.

  Parameters:
    `popupMenu` - The popupMenu to set.

### getPopupDialog

    protected PopupDialog getPopupDialog()

  Gets the popupDialog.

  Returns:
    Returns the popupDialog.

### setPopupDialog

    public void setPopupDialog(PopupDialog popupDialog)

  Sets the popupDialog. Sets the popup menu to null.

  Parameters:
    `popupDialog` - The popupDialog to set.

Runtime

Guidelines for using Eclipse APIs.

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