Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Runtime

org.eclipse.gmf.runtime.common.core.command
Class AbstractCommand

java.lang.Object
  extended by 

org.eclipse.core.commands.operations.AbstractOperation
      extended by 
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 IUndoableOperations that do not modify EMF model resources.

The operation provides a list of IFiles 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 IFiles 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 IFiles 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 org.eclipse.core.commands.operations. AbstractOperation
addContext, canExecute, canRedo, canUndo, 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.gmf.runtime.common.core.command. ICommand
setLabel
 
Methods inherited from interface org.eclipse.core.commands.operations. IUndoableOperation
addContext, canExecute, canRedo, canUndo, getContexts, getLabel, hasContext, removeContext
 

Constructor Detail

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 IFiles that anticipate modifying when I am executed, undone or redone.

Parameters:
label - the operation label, should never be null.
affectedFiles - the list of affected IFiles; may be null
Method Detail

getAffectedFiles

public java.util.List getAffectedFiles()
Returns the IFiles that may be modified when the operation is executed, undone or redone.

Specified by:
getAffectedFiles in interface ICommand
Returns:
the list of IFiles 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

Runtime

Guidelines for using Eclipse APIs.

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


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire