dsto.dfc.swing.list
Class AbstractAddRowCommand

java.lang.Object
  extended by dsto.dfc.swing.commands.AbstractCommand
      extended by dsto.dfc.swing.commands.BasicAddEntryCommand
          extended by dsto.dfc.swing.list.AbstractAddRowCommand
All Implemented Interfaces:
Command, Iconic, Copyable, ActionListener, Cloneable, EventListener

public abstract class AbstractAddRowCommand
extends BasicAddEntryCommand

Base class for "Add New Row"-type commands. Subclasses must implement createNewEntry() and may choose to override addEntry () and getIndexForNewEntry ().

Version:
$Revision$
Author:
Matthew Phillips

Field Summary
protected  DfcList list
           
 
Fields inherited from class dsto.dfc.swing.commands.AbstractCommand
displayName, icon
 
Fields inherited from interface dsto.dfc.swing.icons.Iconic
NULL_ICON
 
Constructor Summary
AbstractAddRowCommand(DfcList list)
           
 
Method Summary
protected  boolean addEntry(DfcListModel model, Object entry, int index)
          Subclasses may override this to change the way the entry is added to a model.
protected abstract  Object createNewEntry()
          Subclasses must override this to create a new entry for the list eg via showing a dialog.
 void execute()
          Executes command by calling createNewEntry (), and then adding the entry at the index specified by getIndexForNewEntry () by calling addEntry ().
protected  int getIndexForNewEntry(Object newEntry)
          Get the index for an entry to the list - subclasses may choose to override this.
 
Methods inherited from class dsto.dfc.swing.commands.BasicAddEntryCommand
getAccelerator, getDescription, getGroupInView, getIcon, getMnemonic, getName, isInteractive
 
Methods inherited from class dsto.dfc.swing.commands.AbstractCommand
actionPerformed, canReplace, clone, getDefaultDisplayName, getDisplayName, getLargeIcon, getLogString, isEnabled, setDisplayName, setIcon
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

list

protected DfcList list
Constructor Detail

AbstractAddRowCommand

public AbstractAddRowCommand(DfcList list)
Method Detail

execute

public void execute()
Executes command by calling createNewEntry (), and then adding the entry at the index specified by getIndexForNewEntry () by calling addEntry ().

Specified by:
execute in interface Command
Overrides:
execute in class BasicAddEntryCommand

addEntry

protected boolean addEntry(DfcListModel model,
                           Object entry,
                           int index)
Subclasses may override this to change the way the entry is added to a model.

Returns:
True if the entry was added.

createNewEntry

protected abstract Object createNewEntry()
Subclasses must override this to create a new entry for the list eg via showing a dialog.

Returns:
A new entry to be added to the list, or null if no entry should be added.

getIndexForNewEntry

protected int getIndexForNewEntry(Object newEntry)
Get the index for an entry to the list - subclasses may choose to override this. Default is to return the end of the list.



Copyright © 2008 Commonwealth of Australia