Runtime

## org.eclipse.gmf.runtime.common.core.command
Class OneTimeCommand

    java.lang.Object
      org.eclipse.core.commands.operations.AbstractOperation
          org.eclipse.gmf.runtime.common.core.command.AbstractCommand
              org.eclipse.gmf.runtime.common.core.command.OneTimeCommand

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

public abstract class OneTimeCommand
extends AbstractCommand

A command does its work once, and can never be undone or redone. It does not do any work that invalidates the undo history in a linear undo model.

By default, it is assigned the `NULL_CONTEXT` when it is constructed, and no other contexts can be added to it or removed from it.

This class is meant to be subclassed by clients who have work to do in a command that should have no effect on the operation history.

Field Summary
`protected static IUndoContext` `NULL_CONTEXT` The null undo context.

Constructor Summary
`OneTimeCommand(java.lang.String label)` Initializes me with a label.
`OneTimeCommand(java.lang.String label, java.util.List affectedFiles)` Initializes me with a label and a list of `IFile`s that anticipate modifying when I am executed.

Method Summary
`void` `addContext(IUndoContext context)` Does nothing.
`boolean` `canRedo()` Not redoable.
`boolean` `canUndo()` Not undoable.
`protected CommandResult` `doRedoWithResult(IProgressMonitor progressMonitor, IAdaptable info)` Not redoable.
`protected CommandResult` `doUndoWithResult(IProgressMonitor progressMonitor, IAdaptable info)` Not undoable.
`void` `removeContext(IUndoContext context)` Does nothing.

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

Methods inherited from class org.eclipse.core.commands.operations.AbstractOperation
`canExecute, getContexts, getLabel, hasContext, 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
`canExecute, getContexts, getLabel, hasContext`

Field Detail

### NULL_CONTEXT

    protected static final IUndoContext NULL_CONTEXT

  The null undo context.

Constructor Detail

### OneTimeCommand

    public OneTimeCommand(java.lang.String label)

  Initializes me with a label.

Parameters:
  `label` - the operation label

### OneTimeCommand

    public OneTimeCommand(java.lang.String label,
                          java.util.List affectedFiles)

  Initializes me with a label and a list of `IFile`s that anticipate modifying when I am executed.

Parameters:
  `label` - the operation label
  `affectedFiles` - the list of affected `IFile`s; may be `null`

Method Detail

### addContext

    public final void addContext(IUndoContext context)

  Does nothing. The context will not be added to the operation.

### removeContext

    public final void removeContext(IUndoContext context)

  Does nothing. The context will not be removed from the operation.

### canUndo

    public final boolean canUndo()

  Not undoable. Returns `false`.

### canRedo

    public final boolean canRedo()

  Not redoable. Returns `false`.

### doUndoWithResult

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

  Not undoable. Throws an ExecutionException.

  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

### doRedoWithResult

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

  Not redoable. Throws an ExecutionException.

  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

Runtime

Guidelines for using Eclipse APIs.

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