dsto.dfc.swing.commands
Class AbstractCompositeCommand

java.lang.Object
  extended by dsto.dfc.swing.commands.AbstractCommand
      extended by dsto.dfc.swing.commands.AbstractMutableCommand
          extended by dsto.dfc.swing.commands.AbstractCompositeCommand
All Implemented Interfaces:
Command, CompositeCommand, CustomMenuProvider, Iconic, Copyable, PropertyEventSource, ActionListener, Cloneable, EventListener

public abstract class AbstractCompositeCommand
extends AbstractMutableCommand
implements CompositeCommand, CustomMenuProvider

The AbstractCompositeCommand should be used when you want to have a list of commands that are in some way linked together.

Author:
Mofeed

Field Summary
 
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
AbstractCompositeCommand()
          Default constructor creates a menu provider.
 
Method Summary
 void addChangeListener(ChangeListener l)
          Custom menu providers should fire change events when the menu UI needs to be updated.
 boolean canReplace(Command command)
          Returns false;
 List createMenuItems()
          Create the menu items that represent the UI for the command.
 void destroyMenuItems(List menuItems)
          Destroy menu items created by createMenuItems ().
abstract  void execute()
          Execute the command.
 KeyStroke getAccelerator()
          Get a keyboard accelerator for the command.
abstract  Command[] getCommands()
          Returns the complete list of defined 'selectable' commands.
abstract  String getDescription()
          A short description of the command, suitable for a tooltip or use in a status panel.
abstract  String getGroupInView(String viewName)
          Get the preferred group that this command should appear in for a given view.
abstract  Icon getIcon()
          The small (16x16) icon for the object.
 Icon getLargeIcon()
          The large (32x32) icon.
 String getLogString()
          Returns the command name followed by empty brackets.
abstract  int getMaxSelectedCommands()
          Get the maximum number of commands that may be selected at any one time.
abstract  char getMnemonic()
          Get a character shortcut for the command (eg for use on a menu).
abstract  String getName()
          The formal identifying name for this command (eg edit.Copy, file.Open).
abstract  Command[] getSelectedCommands()
          Gets the currently selected command/s.
abstract  boolean isInteractive()
          True if this command will interact with the user when execute() is called.
 boolean isSelected(Command cmdChild)
           
 void removeChangeListener(ChangeListener l)
           
 
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, getDefaultDisplayName, getDisplayName, setDisplayName
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface dsto.dfc.swing.commands.Command
getDisplayName, isEnabled
 
Methods inherited from interface dsto.dfc.util.PropertyEventSource
addPropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

AbstractCompositeCommand

public AbstractCompositeCommand()
Default constructor creates a menu provider.

Method Detail

getSelectedCommands

public abstract Command[] getSelectedCommands()
Description copied from interface: CompositeCommand
Gets the currently selected command/s. If these values change, the composite command should fire a property change event. If maxSelectedCommands = 0, this should return an empty array.

Specified by:
getSelectedCommands in interface CompositeCommand

getMaxSelectedCommands

public abstract int getMaxSelectedCommands()
Description copied from interface: CompositeCommand
Get the maximum number of commands that may be selected at any one time. eg this may affect the way the menu items are rendered for the command: if max selected values is 0, the normal JMenuItems are used for each value, if 1, then JRadioButtonMenuItems are used and if > 1 then JCheckBoxMenuItems are used.

Specified by:
getMaxSelectedCommands in interface CompositeCommand

getCommands

public abstract Command[] getCommands()
Description copied from interface: CompositeCommand
Returns the complete list of defined 'selectable' commands.

Specified by:
getCommands in interface CompositeCommand

execute

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

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

getName

public abstract 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

getDescription

public abstract 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 abstract 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 abstract 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 abstract 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

getIcon

public abstract 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

getLogString

public String getLogString()
Description copied from class: AbstractCommand
Returns the command name followed by empty brackets.

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

canReplace

public boolean canReplace(Command command)
Description copied from class: AbstractCommand
Returns false;

Specified by:
canReplace in interface Command
Overrides:
canReplace 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

getLargeIcon

public Icon getLargeIcon()
Description copied from interface: Iconic
The large (32x32) icon.

Specified by:
getLargeIcon in interface Iconic
Overrides:
getLargeIcon in class AbstractCommand
Returns:
The large icon, or null if no large icon is available.

isSelected

public boolean isSelected(Command cmdChild)

createMenuItems

public List createMenuItems()
Description copied from interface: CustomMenuProvider
Create the menu items that represent the UI for the command.

Specified by:
createMenuItems in interface CustomMenuProvider
Returns:
A new list of JComponent's to be added to the menu for the command.

destroyMenuItems

public void destroyMenuItems(List menuItems)
Description copied from interface: CustomMenuProvider
Destroy menu items created by createMenuItems ().

Specified by:
destroyMenuItems in interface CustomMenuProvider

removeChangeListener

public void removeChangeListener(ChangeListener l)
Specified by:
removeChangeListener in interface CustomMenuProvider

addChangeListener

public void addChangeListener(ChangeListener l)
Description copied from interface: CustomMenuProvider
Custom menu providers should fire change events when the menu UI needs to be updated. This event will trigger any interested listeners to destroy old menu items (destroyMenuItems ()) and create new ones (createMenuItems ()).

Specified by:
addChangeListener in interface CustomMenuProvider


Copyright © 2008 Commonwealth of Australia