it.amattioli.applicate.commands
Class AbstractCommand

Show UML class diagram
java.lang.Object
  extended by it.amattioli.applicate.commands.AbstractCommand
All Implemented Interfaces:
Command, ValuesLister, it.amattioli.dominate.util.PropertyChangeEmitter
Direct Known Subclasses:
NullCommand, TreeEditorCommand, UndoAvailableCommand, UndoCommand

public abstract class AbstractCommand
extends Object
implements Command, it.amattioli.dominate.util.PropertyChangeEmitter, ValuesLister

This class is a base implementation of the Command interface. It implements the two addCommandListener methods and fires a CommandEvent when doCommand() and cancelCommand() are called with CommandResult.SUCCESSFUL and CommandResult.CANCELLED respectively. This class implements PropertyChangeEmitter too, so extenders can fire PropertyChangeEvent when a command property changes.

Author:
andrea

Constructor Summary
AbstractCommand()
           
 
Method Summary
 void addCommandListener(CommandListener listener)
          Add a listener for this command events.
 void addCommandListener(CommandListener listener, CommandResult... results)
          Add a listener for this command events.
 void addPropertyChangeListener(PropertyChangeListener listener)
           
 void cancelCommand()
           
 void doCommand()
          Execute this command.
protected  void firePropertyChange(String propertyName, Object oldValue, Object newValue)
           
 Collection<?> getPropertyValues(String propertyName)
           
 void removePropertyChangeListener(PropertyChangeListener listener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCommand

public AbstractCommand()
Method Detail

doCommand

public void doCommand()
               throws ApplicationException
Description copied from interface: Command
Execute this command.

Specified by:
doCommand in interface Command
Throws:
ApplicationException

cancelCommand

public void cancelCommand()
Specified by:
cancelCommand in interface Command

addCommandListener

public void addCommandListener(CommandListener listener)
Description copied from interface: Command
Add a listener for this command events. Every time this command fires a CommandEvent the CommandListener.commandDone(CommandEvent) method will be called on all the added listeners.

Specified by:
addCommandListener in interface Command
Parameters:
listener - the listener to be added

addCommandListener

public void addCommandListener(CommandListener listener,
                               CommandResult... results)
Description copied from interface: Command
Add a listener for this command events. Every time this command fires a CommandEvent the CommandListener.commandDone(CommandEvent) method will be called on all the added listeners with result equals to one of the specified results.

Specified by:
addCommandListener in interface Command
Parameters:
listener - the listener to be added

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  Object oldValue,
                                  Object newValue)

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Specified by:
addPropertyChangeListener in interface it.amattioli.dominate.util.PropertyChangeEmitter

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Specified by:
removePropertyChangeListener in interface it.amattioli.dominate.util.PropertyChangeEmitter

getPropertyValues

public Collection<?> getPropertyValues(String propertyName)
Specified by:
getPropertyValues in interface ValuesLister


Copyright © 2011. All Rights Reserved.