public class CopyCommand extends StrictCompoundCommand
EditingDomain.createCommand
.
The copy implementation is, at each level, delegated to CreateCopyCommand
and
InitializeCopyCommand
which can be overridden to control the copy's object creation
and initialization respectively.
Modifier and Type | Class and Description |
---|---|
static class |
CopyCommand.Helper
This helper class is used to keep track of copied objects and their associated copies.
|
AbstractCommand.NonDirtying
Modifier and Type | Field and Description |
---|---|
protected CopyCommand.Helper |
copyHelper
This is a map of objects to their copies
|
protected static java.lang.String |
DESCRIPTION
This caches the description.
|
protected EditingDomain |
domain
This keeps track of the domain in which this command is created.
|
protected static java.lang.String |
LABEL
This caches the label.
|
protected boolean |
optimize
This controls whether or not to optimize the canExecute (prepare)
|
protected EObject |
owner
This keeps track of the owner in the command parameter from the constructor.
|
isPessimistic, isUndoable, rightMostExecutedCommandIndex
commandList, LAST_COMMAND_ALL, MERGE_COMMAND_ALL, resultIndex
description, isExecutable, isPrepared, label
Constructor and Description |
---|
CopyCommand(EditingDomain domain,
EObject owner,
CopyCommand.Helper copyHelper)
This creates and instance in the given domain and for the given owner
|
CopyCommand(EditingDomain domain,
EObject owner,
CopyCommand.Helper copyHelper,
boolean optimize)
This creates and instance in the given domain and for the given owner
|
Modifier and Type | Method and Description |
---|---|
protected void |
addCreateCopyCommands(CompoundCommand compoundCommand,
EObject object) |
boolean |
canExecute()
Calls
AbstractCommand.prepare() ,
caches the result in AbstractCommand.isExecutable ,
and sets AbstractCommand.isPrepared to true ;
from then on, it will yield the value of isExecutable. |
static Command |
create(EditingDomain domain,
java.util.Collection<?> collection)
This creates a command that copies the given collection of objects.
|
static Command |
create(EditingDomain domain,
java.lang.Object owner)
This creates a command that copies the given object.
|
void |
execute()
Calls
Command.execute() for each command in the list,
but makes sure to call redo for any commands that were previously executed to compute canExecute. |
protected boolean |
prepare()
Returns
false if any command on the list returns false for Command.canExecute() ,
or if some command before the last one can't be undone and hence we can't test all the commands for executability. |
java.lang.String |
toString()
This gives an abbreviated name using this object's own class' name, without package qualification,
followed by a space separated list of field:value pairs.
|
appendAndExecute, redo, undo
append, appendIfCanExecute, canUndo, dispose, getAffectedObjects, getCommandList, getDescription, getLabel, getMergedAffectedObjectsCollection, getMergedResultCollection, getResult, getResultIndex, isEmpty, unwrap
chain, setDescription, setLabel
protected static final java.lang.String LABEL
protected static final java.lang.String DESCRIPTION
protected EditingDomain domain
protected EObject owner
protected CopyCommand.Helper copyHelper
protected boolean optimize
public CopyCommand(EditingDomain domain, EObject owner, CopyCommand.Helper copyHelper)
public CopyCommand(EditingDomain domain, EObject owner, CopyCommand.Helper copyHelper, boolean optimize)
public static Command create(EditingDomain domain, java.lang.Object owner)
public static Command create(EditingDomain domain, java.util.Collection<?> collection)
protected boolean prepare()
StrictCompoundCommand
false
if any command on the list returns false
for Command.canExecute()
,
or if some command before the last one can't be undone and hence we can't test all the commands for executability.prepare
in class StrictCompoundCommand
public boolean canExecute()
AbstractCommand
AbstractCommand.prepare()
,
caches the result in AbstractCommand.isExecutable
,
and sets AbstractCommand.isPrepared
to true
;
from then on, it will yield the value of isExecutable.canExecute
in interface Command
canExecute
in class AbstractCommand
public void execute()
StrictCompoundCommand
Command.execute()
for each command in the list,
but makes sure to call redo for any commands that were previously executed to compute canExecute.
In the case that StrictCompoundCommand.isPessimistic
is false, only the last command will be executed
since the others will have been executed but not undone during StrictCompoundCommand.prepare()
.execute
in interface Command
execute
in class StrictCompoundCommand
protected void addCreateCopyCommands(CompoundCommand compoundCommand, EObject object)
public java.lang.String toString()
toString
in class StrictCompoundCommand