|
|
|
|
org.eclipse.gmf.runtime.common.core.command
Class AbstractCommand
java.lang.Object
org.eclipse.core.commands.operations.AbstractOperation
org.eclipse.gmf.runtime.common.core.command.AbstractCommand
-
All Implemented Interfaces:
-
IUndoableOperation,
ICommand, org.eclipse.gmf.runtime.common.core.internal.command.ICommandWithSettableResult
-
Direct Known Subclasses:
-
CompositeCommand,
IdentityCommand,
OneTimeCommand,
UnexecutableCommand
-
public abstract class AbstractCommand
- extends
AbstractOperation
- implements
ICommand, org.eclipse.gmf.runtime.common.core.internal.command.ICommandWithSettableResult
An abstract superclass for GMF
IUndoableOperation s that do not
modify EMF model resources.
The operation provides a list of
IFile s that are expected to be modified when
the operation is executed, undone or redone. An
IOperationApprover is
registered with the
OperationHistoryFactory.getOperationHistory() to
validate the modification to these resources.
This class is meant to be extended by clients.
-
See Also:
-
ICommand
Constructor Summary
|
AbstractCommand
(java.lang.String label)
Initializes me with a label. |
AbstractCommand
(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, undone or redone. |
Method Summary
|
ICommand
|
compose
(
IUndoableOperation operation)
Returns a new command object that represents a composition of this
command with the specified command parameter. |
void
|
dispose
()
|
protected abstract
CommandResult
|
doExecuteWithResult
(
IProgressMonitor progressMonitor,
IAdaptable info)
Performs the actual work of executing this command. |
protected abstract
CommandResult
|
doRedoWithResult
(
IProgressMonitor progressMonitor,
IAdaptable info)
Performs the actual work of redoing this command. |
protected abstract
CommandResult
|
doUndoWithResult
(
IProgressMonitor progressMonitor,
IAdaptable info)
Performs the actual work of undoing this command. |
IStatus
|
execute
(
IProgressMonitor progressMonitor,
IAdaptable info)
Delegates to
doExecuteWithResult(IProgressMonitor, IAdaptable) and sets
the command result. |
java.util.List
|
getAffectedFiles
()
Returns the
IFile s that may be modified when the operation is
executed, undone or redone. |
CommandResult
|
getCommandResult
()
Retrieves the result of executing, undoing, or redoing this command,
depending on which of these operations was last performed. |
void
|
internalSetResult
(
CommandResult result)
Deprecated. internal API
|
IStatus
|
redo
(
IProgressMonitor progressMonitor,
IAdaptable info)
Delegates to
doRedoWithResult(IProgressMonitor, IAdaptable) and sets the
command result. |
ICommand
|
reduce
()
Returns the simplest form of this command that is equivalent. |
protected void
|
setResult
(
CommandResult result)
Sets the command result. |
IStatus
|
undo
(
IProgressMonitor progressMonitor,
IAdaptable info)
Delegates to
doUndoWithResult(IProgressMonitor, IAdaptable) and sets the
command result. |
Methods inherited from class java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
|
Methods inherited from interface org.eclipse.gmf.runtime.common.core.command.
ICommand
|
setLabel
|
AbstractCommand
public AbstractCommand(java.lang.String label)
- Initializes me with a label.
-
Parameters:
-
label - the operation label, should never be null .
AbstractCommand
public AbstractCommand(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, undone or redone.
-
Parameters:
-
label - the operation label, should never be null . -
affectedFiles - the list of affected
IFile s; may be null
getAffectedFiles
public java.util.List getAffectedFiles()
- Returns the
IFile s that may be modified when the operation is
executed, undone or redone.
-
-
Specified by:
-
getAffectedFiles
in interface
ICommand
-
-
Returns:
- the list of
IFile s that will be modified
getCommandResult
public
CommandResult getCommandResult()
-
Description copied from interface:
ICommand
- Retrieves the result of executing, undoing, or redoing this command,
depending on which of these operations was last performed. This value can
be
null if the operation has no meaningful result.
The value of this result is undefined if the command has not yet been
executed, undone or redone.
-
-
Specified by:
-
getCommandResult
in interface
ICommand
-
-
Returns:
- The result of executing, undoing or redoing this command.
setResult
protected final void setResult(
CommandResult result)
- Sets the command result.
-
-
-
Parameters:
-
result - the new result for this command.
compose
public
ICommand compose(
IUndoableOperation operation)
-
Description copied from interface:
ICommand
- Returns a new command object that represents a composition of this
command with the specified
command parameter.
-
-
Specified by:
-
compose
in interface
ICommand
-
-
Parameters:
-
operation - The operation that is to be composed with this command.
-
Returns:
- A command that represents a composition of this command with the
specified command.
reduce
public
ICommand reduce()
-
Description copied from interface:
ICommand
- Returns the simplest form of this command that is equivalent. Use this
method to remove unnecessary nesting of commands.
-
-
Specified by:
-
reduce
in interface
ICommand
-
-
Returns:
- the simplest form of this command that is equivalent
execute
public
IStatus execute(
IProgressMonitor progressMonitor,
IAdaptable info)
throws
ExecutionException
- Delegates to
doExecuteWithResult(IProgressMonitor, IAdaptable) and sets
the command result.
-
-
Specified by:
-
execute
in interface
IUndoableOperation
-
Specified by:
-
execute
in class
AbstractOperation
-
-
Throws:
-
ExecutionException
doExecuteWithResult
protected abstract
CommandResult doExecuteWithResult(
IProgressMonitor progressMonitor,
IAdaptable info)
throws
ExecutionException
- Performs the actual work of executing this command. Subclasses must
implement this method to perform some operation.
-
-
-
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
redo
public
IStatus redo(
IProgressMonitor progressMonitor,
IAdaptable info)
throws
ExecutionException
- Delegates to
doRedoWithResult(IProgressMonitor, IAdaptable) and sets the
command result.
-
-
Specified by:
-
redo
in interface
IUndoableOperation
-
Specified by:
-
redo
in class
AbstractOperation
-
-
Throws:
-
ExecutionException
doRedoWithResult
protected abstract
CommandResult doRedoWithResult(
IProgressMonitor progressMonitor,
IAdaptable info)
throws
ExecutionException
- Performs the actual work of redoing this command. Subclasses must
implement this method to perform the redo.
-
-
-
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
undo
public
IStatus undo(
IProgressMonitor progressMonitor,
IAdaptable info)
throws
ExecutionException
- Delegates to
doUndoWithResult(IProgressMonitor, IAdaptable) and sets the
command result.
-
-
Specified by:
-
undo
in interface
IUndoableOperation
-
Specified by:
-
undo
in class
AbstractOperation
-
-
Throws:
-
ExecutionException
doUndoWithResult
protected abstract
CommandResult doUndoWithResult(
IProgressMonitor progressMonitor,
IAdaptable info)
throws
ExecutionException
- Performs the actual work of undoing this command. Subclasses must
implement this method to perform the undo.
-
-
-
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
dispose
public void dispose()
-
-
Specified by:
-
dispose
in interface
IUndoableOperation
-
Overrides:
-
dispose
in class
AbstractOperation
-
internalSetResult
public void internalSetResult(
CommandResult result)
-
Deprecated. internal API
- Internal method to set the command result.
-
-
Specified by:
-
internalSetResult in interface org.eclipse.gmf.runtime.common.core.internal.command.ICommandWithSettableResult
-
-
Parameters:
-
result - CommandResult to set
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.
|
|
|