dsto.dfc.swt.commands
Class CmdChangeDataObjectProperty

java.lang.Object
  extended by dsto.dfc.util.BasicPropertyEventSource
      extended by dsto.dfc.swt.commands.AbstractCommand
          extended by dsto.dfc.swt.commands.CmdChangeDataObjectProperty
All Implemented Interfaces:
PropertyListener, Command, Copyable, Disposable, JavaBean, PropertyEventSource, Serializable, Cloneable, EventListener

public class CmdChangeDataObjectProperty
extends AbstractCommand
implements Command, PropertyListener, Disposable

Command to change a property of one or more target data objects. It becomes enabled only when one or more target bjects have property values different from the target value.

NOTE: this command must be disposed after use since it adds listeners to the target targetObjects.

Author:
Matthew Phillips
See Also:
Serialized Form

Field Summary
protected  UIPropertyListener listener
           
protected  ListDataObject objectList
           
protected  Object property
           
protected  IDataObject[] targetObjects
           
protected  Object value
           
 
Fields inherited from class dsto.dfc.swt.commands.AbstractCommand
NO_ICON
 
Constructor Summary
CmdChangeDataObjectProperty(String name, Object property, Object value, String group, String description, Icon icon)
          Create a new instance.
CmdChangeDataObjectProperty(String name, Object property, Object value, String group, String description, String iconName)
          Create a new instance.
 
Method Summary
 void dispose()
          Dispose of the object (unregister listeners, close open resources etc).
 void execute()
          Execute the command.
 IDataObject[] getTargetObjects()
           
protected  boolean hasDifferentValue()
           
 void propertyValueChanged(PropertyEvent e)
           
 void setTargetObjects(IDataObject[] targetObjects)
          Set the target objects to be changed.
protected  Object targetValue(int n)
          Get the value from the n'th target object.
protected  boolean testShouldEnable()
          Called when target property changes to see if the command should be enabled.
 
Methods inherited from class dsto.dfc.swt.commands.AbstractCommand
addCommandListener, clone, createDefaultDisplayName, fireCommandExecuted, fireCommandExecuted, getAccelerator, getContextMenuGroup, getDescription, getDisplayName, getGroupInView, getIcon, getLogString, getMainMenuGroup, getMnemonic, getName, getToolbarGroup, isEnabled, isInteractive, removeCommandListener, setAccelerator, setContextMenuGroup, setDescription, setDisplayName, setEnabled, setIcon, setInteractive, setMainMenuGroup, setMnemonic, setName, setToolbarGroup
 
Methods inherited from class dsto.dfc.util.BasicPropertyEventSource
addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeSource, removePropertyChangeListener, setPropertyChangeSource
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface dsto.dfc.swt.commands.Command
addCommandListener, getAccelerator, getDescription, getDisplayName, getGroupInView, getIcon, getLogString, getMnemonic, getName, isEnabled, isInteractive, removeCommandListener, setAccelerator, setContextMenuGroup, setDescription, setDisplayName, setEnabled, setIcon, setMainMenuGroup, setMnemonic, setToolbarGroup
 
Methods inherited from interface dsto.dfc.util.PropertyEventSource
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

targetObjects

protected IDataObject[] targetObjects

property

protected Object property

value

protected Object value

objectList

protected ListDataObject objectList

listener

protected UIPropertyListener listener
Constructor Detail

CmdChangeDataObjectProperty

public CmdChangeDataObjectProperty(String name,
                                   Object property,
                                   Object value,
                                   String group,
                                   String description,
                                   String iconName)
Create a new instance.

Parameters:
name - The command name.
property - The property to set on the target objects.
value - The vaue to set.
group - The command group.
description - The command description.
iconName - The command icon resource name.

CmdChangeDataObjectProperty

public CmdChangeDataObjectProperty(String name,
                                   Object property,
                                   Object value,
                                   String group,
                                   String description,
                                   Icon icon)
Create a new instance.

Parameters:
name - The command name.
property - The property to set on the target objects.
value - The vaue to set.
group - The command group.
description - The command description.
icon - The command icon.
Method Detail

dispose

public void dispose()
Description copied from interface: Disposable
Dispose of the object (unregister listeners, close open resources etc). It should be safe to call this method more than once. Note for beans that support client event listeners: if there are listeners registered when this is called, this method should do nothing.

Specified by:
dispose in interface Disposable

setTargetObjects

public void setTargetObjects(IDataObject[] targetObjects)
Set the target objects to be changed. May be null.


getTargetObjects

public IDataObject[] getTargetObjects()

testShouldEnable

protected boolean testShouldEnable()
Called when target property changes to see if the command should be enabled. Default is to disable when all targets have command's target value. Subclasses may override.


hasDifferentValue

protected boolean hasDifferentValue()

targetValue

protected Object targetValue(int n)
Get the value from the n'th target object.


execute

public void execute()
Description copied from interface: Command
Execute the command. Commands should fire CommandListener.commandExecuted(CommandEvent) when executed.

Specified by:
execute in interface Command
Specified by:
execute in class AbstractCommand

propertyValueChanged

public void propertyValueChanged(PropertyEvent e)
Specified by:
propertyValueChanged in interface PropertyListener


Copyright © 2008 Commonwealth of Australia