Package org.eclipse.gef.ui.properties

# Class SetPropertyValueCommand

java.lang.Object
org.eclipse.gef.commands.Command
org.eclipse.gef.ui.properties.SetPropertyValueCommand

public class SetPropertyValueCommand extends Command
A command used to set or reset the value of a property.

Since:
  3.7

## Field Summary

Fields
Modifier and Type
Field
Description
`protected static final Object`
`DEFAULT_VALUE`
Value constant to indicate that the property is to be reset to its default value during execute/redo and undo.

## Constructor Summary

Constructors
Constructor
Description
`SetPropertyValueCommand(String propertyLabel, IPropertySource propertySource, Object propertyId, Object newValue)`
Constructs a new `SetPropertyValueCommand`.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`canExecute()`
`void`
`execute()`
Executes the Command.
`protected Object`
`getNewValue()`
Returns the new value to be set for the property when executing or redoing.
`protected 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 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()`.

### Methods inherited from class org.eclipse.gef.commands.Command

`canRedo, canUndo, chain, dispose, getDebugLabel, getLabel, setDebugLabel, setLabel`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### DEFAULT_VALUE

protected static final Object DEFAULT_VALUE
Value constant to indicate that the property is to be reset to its default value during execute/redo and undo.

## Constructor Details

### SetPropertyValueCommand

public SetPropertyValueCommand(String propertyLabel, IPropertySource propertySource, Object propertyId, Object newValue)
Constructs a new `SetPropertyValueCommand`.

Parameters:
  `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.
Since:
  3.7

## Method Details

### canExecute

public boolean canExecute()

Overrides:
  `canExecute` in class `Command`
Returns:
  `true` if the command can be executed
See Also:
  - `Command.canExecute()`

### execute

public void execute()
Description copied from class: `Command`
Executes the Command. This method should not be called if the Command is not executable.

Overrides:
  `execute` in class `Command`
See Also:
  - `Command.execute()`

### getNewValue

protected Object getNewValue()
Returns the new value to be set for the property when executing or redoing.

Returns:
  the new value or `DEFAULT_VALUE` to indicate that the default value should be set as the new value.
Since:
  3.7

### getOldValue

protected 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.

Returns:
  the old value of the property or `DEFAULT_VALUE`.
Since:
  3.7

### getPropertyId

protected Object getPropertyId()
Returns the id by which to identify the property whose value is to be set.

Returns:
  the id of the property whose value is to be set.
Since:
  3.7

### getPropertySource

protected IPropertySource getPropertySource()
Returns the `IPropertySource` which provides the property, whose value is to be set.

Returns:
  the `IPropertySource` which provides the property.
Since:
  3.7

### redo

public void redo()
Description copied from class: `Command`
Re-executes the Command. This method should only be called after `undo()` has been called.

Overrides:
  `redo` in class `Command`
See Also:
  - `Command.redo()`

### undo

public void undo()
Description copied from class: `Command`
Undoes the changes performed during `execute()`. This method should only be called after `execute` has been called, and only when `canUndo()` returns `true`.

Overrides:
  `undo` in class `Command`
See Also:
  - `Command.undo()`