dsto.dfc.swing.tree
Class CmdAddEntry

java.lang.Object
  extended by dsto.dfc.swing.commands.AbstractCommand
      extended by dsto.dfc.swing.commands.AbstractMutableCommand
          extended by dsto.dfc.swing.commands.AbstractSelectionBasedCommand
              extended by dsto.dfc.swing.tree.CmdAddEntry
All Implemented Interfaces:
Command, SelectionListener, Iconic, Copyable, Disposable, PropertyEventSource, ActionListener, Cloneable, EventListener

public class CmdAddEntry
extends AbstractSelectionBasedCommand

Add a new entry as a child of the currently selected entry.

Version:
$Revision$

Field Summary
 
Fields inherited from class dsto.dfc.swing.commands.AbstractSelectionBasedCommand
source
 
Fields inherited from class dsto.dfc.swing.commands.AbstractMutableCommand
listeners
 
Fields inherited from class dsto.dfc.swing.commands.AbstractCommand
displayName, icon
 
Fields inherited from interface dsto.dfc.swing.icons.Iconic
NULL_ICON
 
Constructor Summary
protected CmdAddEntry()
           
  CmdAddEntry(DfcTree tree)
           
  CmdAddEntry(DfcTree tree, Cloneable entryTemplate)
           
 
Method Summary
protected  Object createNewEntry(Object selectedEntry, int selectedIndex)
          Create a new entry to be added to the tree.
protected  boolean entryAdded(TreePath newEntryPath)
          Called after a new entry has been added to the model.
 void execute()
          Execute the command.
 KeyStroke getAccelerator()
          Get a keyboard accelerator for the command.
 String getDescription()
          A short description of the command, suitable for a tooltip or use in a status panel.
 String getGroupInView(String viewName)
          Get the preferred group that this command should appear in for a given view.
 Icon getIcon()
          The small (16x16) icon for the object.
 char getMnemonic()
          Get a character shortcut for the command (eg for use on a menu).
 String getName()
          The formal identifying name for this command (eg edit.Copy, file.Open).
 boolean isEditAfterAdd()
           
 boolean isInteractive()
          True if this command will interact with the user when execute() is called.
 void selectionChanged(SelectionEvent e)
          SelectionListener interface implementation: does nothing.
 void setEditAfterAdd(boolean newValue)
          Set whether cell editor is invoked on a new entry.
protected  boolean updateEnabled()
          Return true if the command should be enabled in the current tree context.
 
Methods inherited from class dsto.dfc.swing.commands.AbstractSelectionBasedCommand
dispose
 
Methods inherited from class dsto.dfc.swing.commands.AbstractMutableCommand
addPropertyChangeListener, clone, isEnabled, removePropertyChangeListener, setEnabled, setIcon
 
Methods inherited from class dsto.dfc.swing.commands.AbstractCommand
actionPerformed, canReplace, getDefaultDisplayName, getDisplayName, getLargeIcon, getLogString, setDisplayName
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmdAddEntry

public CmdAddEntry(DfcTree tree)

CmdAddEntry

public CmdAddEntry(DfcTree tree,
                   Cloneable entryTemplate)

CmdAddEntry

protected CmdAddEntry()
Method Detail

setEditAfterAdd

public void setEditAfterAdd(boolean newValue)
Set whether cell editor is invoked on a new entry.


isEditAfterAdd

public boolean isEditAfterAdd()

execute

public void execute()
Description copied from interface: Command
Execute the command.

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

getName

public String getName()
Description copied from interface: Command
The formal identifying name for this command (eg edit.Copy, file.Open). This must not change during the lifetime of a command instance.

Specified by:
getName in interface Command
Specified by:
getName in interface Iconic
Specified by:
getName in class AbstractCommand

getIcon

public Icon getIcon()
Description copied from interface: Iconic
The small (16x16) icon for the object. May be null if no small icon is available.

Specified by:
getIcon in interface Iconic
Overrides:
getIcon in class AbstractCommand

getDescription

public String getDescription()
Description copied from interface: Command
A short description of the command, suitable for a tooltip or use in a status panel.

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

isInteractive

public boolean isInteractive()
Description copied from interface: Command
True if this command will interact with the user when execute() is called.

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

getGroupInView

public String getGroupInView(String viewName)
Description copied from interface: Command
Get the preferred group that this command should appear in for a given view. This may be overridden by a setting in the CommandRegistry.

If the command changes its group in any view it should generate a groupInView property change event with the old value set to the old group and the new value set to the new group.

Specified by:
getGroupInView in interface Command
Specified by:
getGroupInView in class AbstractCommand
Parameters:
viewName - The name of the view.
Returns:
The group in the view, or null if this command does not appear in the given view.

getMnemonic

public char getMnemonic()
Description copied from interface: Command
Get a character shortcut for the command (eg for use on a menu). May return 0 for no mnemonic.

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

getAccelerator

public KeyStroke getAccelerator()
Description copied from interface: Command
Get a keyboard accelerator for the command. May return null for no accelerator.

Specified by:
getAccelerator in interface Command
Overrides:
getAccelerator in class AbstractCommand

selectionChanged

public void selectionChanged(SelectionEvent e)
Description copied from class: AbstractSelectionBasedCommand
SelectionListener interface implementation: does nothing.

Specified by:
selectionChanged in interface SelectionListener
Overrides:
selectionChanged in class AbstractSelectionBasedCommand

createNewEntry

protected Object createNewEntry(Object selectedEntry,
                                int selectedIndex)
                         throws CloneNotSupportedException
Create a new entry to be added to the tree. The default implementation is to return a clone of entryTemplate, but subclasses may choose to override this.

Parameters:
selectedEntry - The currently selected model entry.
selectedIndex - The index of the selected entry.
Returns:
A new value to be added to the tree model.
Throws:
CloneNotSupportedException - if a new value could not be created.

entryAdded

protected boolean entryAdded(TreePath newEntryPath)
Called after a new entry has been added to the model. Can be used to perform post-add customisation of entry (eg popup a customisation dialog).

Parameters:
newEntryPath - The path to the new entry.
Returns:
True if entry should be added, false if add operation should be cancelled.

updateEnabled

protected boolean updateEnabled()
Return true if the command should be enabled in the current tree context. By default this is called by selectionChanged () and the result used in a call to setEnabled (). Superclasses may choose to override this, especially if they define createNewEntry() also.

Returns:
True if the command should be enabled.


Copyright © 2008 Commonwealth of Australia