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
Answertopia.com

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

  




 

 


org.eclipse.emf.transaction
Class RecordingCommand


java.lang.Object
  extended by 

org.eclipse.emf.common.command.AbstractCommand
      extended by 
org.eclipse.emf.transaction.RecordingCommand
All Implemented Interfaces:
Command, ConditionalRedoCommand

public abstract class RecordingCommand
extends AbstractCommand
implements ConditionalRedoCommand

A partial Command implementation that records the changes made by a subclass's direct manipulation of objects via the metamodel's API. This simplifies the programming model for complex commands (not requiring composition of set/add/remove commands) while still providing automatic undo/redo support.

Subclasses are simply required to implement the doExecute() method to make the desired changes to the model. Note that, because changes are recorded for automatic undo/redo, the concrete command must not make any changes that cannot be recorded by EMF (unless it does not matter that they will not be undone).


Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.emf.common.command. AbstractCommand
AbstractCommand.NonDirtying
 
Nested classes/interfaces inherited from interface org.eclipse.emf.transaction.util. ConditionalRedoCommand
ConditionalRedoCommand.Compound
 
Field Summary
 
Fields inherited from class org.eclipse.emf.common.command. AbstractCommand
description, isExecutable, isPrepared, label
 
Constructor Summary
RecordingCommand ( TransactionalEditingDomain domain)
          Initializes me with the editing domain in which I am to be executed.
RecordingCommand ( TransactionalEditingDomain domain, String label)
          Initializes me with my editing domain and a human-readable label.
RecordingCommand ( TransactionalEditingDomain domain, String label, String description)
          Initializes me with my editing domain, label, and more expansive description.
 
Method Summary
 boolean canRedo ()
          I can be redone if I successfully recorded the changes that I executed.
 boolean canUndo ()
          I can be undone if I successfully recorded the changes that I executed.
  Command chain ( Command command)
           
 void dispose ()
          Extends the inherited implementation by disposing my change description, if any.
protected abstract  void doExecute ()
          Implemented by subclasses to perform the necessary changes in the model.
 void execute ()
          Implements the execution with automatic recording of undo information.
protected  boolean prepare ()
          Subclasses should override this if they have more preparation to do.
 void redo ()
          Redoes the changes that I recorded.
 void undo ()
          Undoes the changes that I recorded.
 
Methods inherited from class org.eclipse.emf.common.command. AbstractCommand
canExecute, getAffectedObjects, getDescription, getLabel, getResult, setDescription, 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.emf.common.command. Command
canExecute, getAffectedObjects, getDescription, getLabel, getResult
 

Constructor Detail

RecordingCommand

public RecordingCommand(
TransactionalEditingDomain domain)
Initializes me with the editing domain in which I am to be executed.

Parameters:
domain - my domain

RecordingCommand

public RecordingCommand(
TransactionalEditingDomain domain,
                        
String label)
Initializes me with my editing domain and a human-readable label.

Parameters:
domain - my domain
label - my user-friendly label

RecordingCommand

public RecordingCommand(
TransactionalEditingDomain domain,
                        
String label,
                        
String description)
Initializes me with my editing domain, label, and more expansive description.

Parameters:
domain - my domain
label - my label
description - my long description
Method Detail

prepare

protected boolean prepare()
Subclasses should override this if they have more preparation to do. By default, the result is just true.

Overrides:
prepare in class AbstractCommand

execute

public final void execute()
Implements the execution with automatic recording of undo information. Delegates the actual model changes to the subclass's implementation of the doExecute() method.

Specified by:
execute in interface Command
See Also:
doExecute()

canUndo

public boolean canUndo()
I can be undone if I successfully recorded the changes that I executed. Subclasses would not normally need to override this method.

Specified by:
canUndo in interface Command
Overrides:
canUndo in class AbstractCommand

canRedo

public boolean canRedo()
I can be redone if I successfully recorded the changes that I executed. Subclasses would not normally need to override this method.

Specified by:
canRedo in interface ConditionalRedoCommand
Returns:
true if I can be redone; false, otherwise

undo

public final void undo()
Undoes the changes that I recorded. Subclasses would not normally need to override this method.

Specified by:
undo in interface Command
Overrides:
undo in class AbstractCommand
Throws:
IllegalStateException - if I am not undoable
See Also:
canUndo()

redo

public final void redo()
Redoes the changes that I recorded. Subclasses would not normally need to override this method.

Specified by:
redo in interface Command
Throws:
IllegalStateException - if I am not redoable
See Also:
canRedo()

doExecute

protected abstract void doExecute()
Implemented by subclasses to perform the necessary changes in the model. These changes are applied by direct manipulation of the model objects, not by executing commands.


chain

public 
Command chain(
Command command)
Specified by:
chain in interface Command
Overrides:
chain in class AbstractCommand

dispose

public void dispose()
Extends the inherited implementation by disposing my change description, if any.

Specified by:
dispose in interface Command
Overrides:
dispose in class AbstractCommand

Copyright 2002, 2007 IBM Corporation and others.
All Rights Reserved.


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