public class SetPropertyValueCommand extends Command
Modifier and Type | Field and Description |
---|---|
protected static java.lang.Object |
DEFAULT_VALUE
Value constant to indicate that the property is to be reset to its
default value during execute/redo and undo.
|
Constructor and Description |
---|
SetPropertyValueCommand(java.lang.String propertyLabel,
IPropertySource propertySource,
java.lang.Object propertyId,
java.lang.Object newValue)
Constructs a new
SetPropertyValueCommand . |
Modifier and Type | Method and Description |
---|---|
boolean |
canExecute() |
void |
execute()
Executes the Command.
|
protected java.lang.Object |
getNewValue()
Returns the new value to be set for the property when executing or
redoing.
|
protected java.lang.Object |
getOldValue()
After the command has been executed or redone, returns the old value of
the property or
DEFAULT_VALUE if the property did not have a
value before. |
protected java.lang.Object |
getPropertyId()
Returns the id by which to identify the property whose value is to be
set.
|
protected IPropertySource |
getPropertySource()
Returns the
IPropertySource which provides the property, whose
value is to be set. |
void |
redo()
Re-executes the Command.
|
void |
undo()
Undoes the changes performed during
execute() . |
canRedo, canUndo, chain, dispose, getDebugLabel, getLabel, setDebugLabel, setLabel
protected static final java.lang.Object DEFAULT_VALUE
public SetPropertyValueCommand(java.lang.String propertyLabel, IPropertySource propertySource, java.lang.Object propertyId, java.lang.Object newValue)
SetPropertyValueCommand
.propertyLabel
- A label to identify the property whose value is set by this
command.propertySource
- The property source which provides the property, whose value
is to be set.propertyId
- The id of the property whose value is to be set.newValue
- The new value to set for the property or
DEFAULT_VALUE
to indicate that the property should be
reset.public boolean canExecute()
canExecute
in class Command
true
if the command can be executedCommand.canExecute()
public void execute()
Command
execute
in class Command
Command.execute()
protected java.lang.Object getNewValue()
DEFAULT_VALUE
to indicate that the
default value should be set as the new value.protected java.lang.Object getOldValue()
DEFAULT_VALUE
if the property did not have a
value before.DEFAULT_VALUE
.protected java.lang.Object getPropertyId()
protected IPropertySource getPropertySource()
IPropertySource
which provides the property, whose
value is to be set.IPropertySource
which provides the property.public void redo()
Command
undo()
has been called.redo
in class Command
Command.redo()
public void undo()
Command
execute()
. This method
should only be called after execute
has been called, and
only when canUndo()
returns true
.undo
in class Command
Command.undo()
Copyright (c) IBM Corp. and others 2000, 2011. All Rights Reserved.