org.esa.beam.framework.ui.command
Class Command

java.lang.Object
  extended by org.esa.beam.framework.ui.command.Command
All Implemented Interfaces:
com.bc.ceres.core.runtime.ConfigurableExtension
Direct Known Subclasses:
CommandGroup, SelectableCommand

public abstract class Command
extends Object
implements com.bc.ceres.core.runtime.ConfigurableExtension

The Command is a ...

Version:
$Revision$ $Date$
Author:
Norman Fomferra, Sabine Embacher

Field Summary
static String ACTION_KEY_CONTEXT
           
static String ACTION_KEY_LARGE_ICON
          The key used for storing a large icon for the action, used for toolbar buttons.
static String ACTION_KEY_LOCATION
           
static String ACTION_KEY_PARENT
           
static String ACTION_KEY_PLACE_AFTER
           
static String ACTION_KEY_PLACE_BEFORE
           
static String ACTION_KEY_PLACE_CONTEXT_TOP
           
static String ACTION_KEY_POPUP_TEXT
           
static String ACTION_KEY_SEPARATOR_AFTER
           
static String ACTION_KEY_SEPARATOR_BEFORE
           
static String ACTION_KEY_SORT_CHILDREN
           
static String HELP_ID_KEY
           
 
Constructor Summary
protected Command()
           
protected Command(String commandID)
           
 
Method Summary
protected  void addEventListener(Class t, EventListener l)
          Adds a command event listener.
 void configure(com.bc.ceres.core.runtime.ConfigurationElement config)
           
 void configure(ResourceBundle resourceBundle)
          Configures this command with the properties (if any) found in the given recource bundle.
 boolean containsContext(String context)
           
 boolean containsLocation(String location)
           
protected  boolean containsProperty(String key, Object testValue)
           
protected  boolean containsPropertyValue(String key, Object value)
           
protected abstract  Action createAction()
          Creates an appropriate action instance for this command.
abstract  JMenuItem createMenuItem()
          Creates an appropriate menu item for this command.
protected  String createResourceKey(String commandPropertyName)
          Gets the key for the given command command-ID and command property name name as used in the resource bundle for this application.
abstract  AbstractButton createToolBarButton()
          Creates an appropriate tool bar button for this command.
protected  void fireUpdateState()
          Notify all listeners that have registered interest for notification on the 'update status' event type.
 KeyStroke getAccelerator()
           
 Action getAction()
           
 String getCommandID()
           
static CommandUIFactory getCommandUIFactory()
           
protected  Boolean getConfigBoolean(com.bc.ceres.core.runtime.ConfigurationElement config, String elementName)
          Gets the boolean resource value for the given command command-ID and command property name.
protected  Icon getConfigIcon(com.bc.ceres.core.runtime.ConfigurationElement config, String elementName)
           
protected  String getConfigString(com.bc.ceres.core.runtime.ConfigurationElement config, String elementName)
          Gets the resource string for the given command command-ID and command property name.
protected  String[] getConfigStrings(com.bc.ceres.core.runtime.ConfigurationElement config, String elementName)
          Gets the resource strings for the given command command-ID and command property name.
 String[] getContexts()
           
protected  EventListenerList getEventListenerList()
           
 String getHelpId()
           
 Icon getLargeIcon()
           
 String[] getLocations()
           
 String getLongDescription()
           
 int getMnemonic()
          Returns the integer value of command's mnemonic character.
 String getParent()
           
 String getPlaceAfter()
           
 String getPlaceBefore()
           
 String getPopupText()
           
protected  Object getProperty(String key)
           
protected  boolean getProperty(String key, boolean defaultValue)
           
protected  String getProperty(String key, String defaultValue)
           
protected  String[] getProperty(String key, String[] defaultValues)
           
protected  Boolean getResourceBoolean(ResourceBundle resourceBundle, String commandPropertyName)
          Gets the boolean resource value for the given command command-ID and command property name.
protected  Icon getResourceIcon(ResourceBundle resourceBundle, String commandPropertyName)
           
protected  String getResourceString(ResourceBundle resourceBundle, String commandPropertyName)
          Gets the resource string for the given command command-ID and command property name.
protected  String[] getResourceStringArray(ResourceBundle resourceBundle, String commandPropertyName)
          Gets the resource strings for the given command command-ID and command property name.
protected  String[] getResourceStrings(ResourceBundle resourceBundle, String commandPropertyName)
          Gets the resource strings for the given command command-ID and command property name.
 String getShortDescription()
           
 Icon getSmallIcon()
           
 Boolean getSortChildren()
           
 String getText()
           
protected  String getValue(com.bc.ceres.core.runtime.ConfigurationElement config, String elementName, String defaultValue)
           
 boolean isEnabled()
           
 boolean isPlaceAtContextTop()
           
 boolean isSeparatorAfter()
           
 boolean isSeparatorBefore()
           
protected  void removeEventListener(Class t, EventListener l)
          Removes a command event listener.
 void setAccelerator(KeyStroke accelerator)
           
 void setCommandID(String commandId)
           
static void setCommandUIFactory(CommandUIFactory commandUIFactory)
           
 void setContexts(String[] contexts)
           
 void setEnabled(boolean enabled)
           
 void setHelpId(String id)
           
 void setLargeIcon(Icon icon)
           
 void setLocations(String[] locations)
           
 void setLongDescription(String text)
           
 void setMnemonic(int mnemonic)
           
 void setParent(String value)
           
 void setPlaceAfter(String placeAfter)
           
 void setPlaceAtContextTop(boolean placeAtContextTop)
           
 void setPlaceBefore(String placeBefore)
           
 void setPopupText(String value)
           
protected  void setProperty(String key, boolean value)
           
protected  void setProperty(String key, Object value)
           
 void setSeparatorAfter(boolean separatorAfter)
           
 void setSeparatorBefore(boolean separatorBefore)
           
 void setShortDescription(String text)
           
 void setSmallIcon(Icon icon)
           
 void setText(String value)
           
 String toString()
           
 void updateComponentTreeUI()
          Lets an action update its component tree (if any) since the Java look-and-feel has changed.
 void updateState()
          Causes this command to fire the 'check status' event to all of its listeners.
 void updateState(CommandEvent event)
          Called when a command should update its state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ACTION_KEY_LARGE_ICON

public static final String ACTION_KEY_LARGE_ICON
The key used for storing a large icon for the action, used for toolbar buttons.

Note: Actually this key belongs in the javax.swing.Action interface, but Sun hasn't done this so far (why?).

See Also:
Constant Field Values

ACTION_KEY_SEPARATOR_BEFORE

public static final String ACTION_KEY_SEPARATOR_BEFORE
See Also:
Constant Field Values

ACTION_KEY_SEPARATOR_AFTER

public static final String ACTION_KEY_SEPARATOR_AFTER
See Also:
Constant Field Values

ACTION_KEY_PLACE_BEFORE

public static final String ACTION_KEY_PLACE_BEFORE
See Also:
Constant Field Values

ACTION_KEY_PLACE_AFTER

public static final String ACTION_KEY_PLACE_AFTER
See Also:
Constant Field Values

ACTION_KEY_PLACE_CONTEXT_TOP

public static final String ACTION_KEY_PLACE_CONTEXT_TOP
See Also:
Constant Field Values

ACTION_KEY_PARENT

public static final String ACTION_KEY_PARENT
See Also:
Constant Field Values

ACTION_KEY_LOCATION

public static final String ACTION_KEY_LOCATION
See Also:
Constant Field Values

ACTION_KEY_CONTEXT

public static final String ACTION_KEY_CONTEXT
See Also:
Constant Field Values

ACTION_KEY_POPUP_TEXT

public static final String ACTION_KEY_POPUP_TEXT
See Also:
Constant Field Values

ACTION_KEY_SORT_CHILDREN

public static final String ACTION_KEY_SORT_CHILDREN
See Also:
Constant Field Values

HELP_ID_KEY

public static final String HELP_ID_KEY
See Also:
Constant Field Values
Constructor Detail

Command

protected Command()

Command

protected Command(String commandID)
Method Detail

getCommandID

public String getCommandID()

setCommandID

public void setCommandID(String commandId)

getAction

public Action getAction()

isEnabled

public boolean isEnabled()

setEnabled

public void setEnabled(boolean enabled)

getParent

public String getParent()

setParent

public void setParent(String value)

getLocations

public String[] getLocations()

setLocations

public void setLocations(String[] locations)

containsLocation

public boolean containsLocation(String location)

getContexts

public String[] getContexts()

setContexts

public void setContexts(String[] contexts)

containsContext

public boolean containsContext(String context)

getText

public String getText()

setText

public void setText(String value)

getPopupText

public String getPopupText()

setPopupText

public void setPopupText(String value)

getSortChildren

public Boolean getSortChildren()

getMnemonic

public int getMnemonic()
Returns the integer value of command's mnemonic character.

Returns:
the integer value of command's mnemonic character or -1 if mnemonic property is null

setMnemonic

public void setMnemonic(int mnemonic)

getAccelerator

public KeyStroke getAccelerator()

setAccelerator

public void setAccelerator(KeyStroke accelerator)

getShortDescription

public String getShortDescription()

setShortDescription

public void setShortDescription(String text)

getLongDescription

public String getLongDescription()

setLongDescription

public void setLongDescription(String text)

getHelpId

public String getHelpId()

setHelpId

public void setHelpId(String id)

getSmallIcon

public Icon getSmallIcon()

setSmallIcon

public void setSmallIcon(Icon icon)

getLargeIcon

public Icon getLargeIcon()

setLargeIcon

public void setLargeIcon(Icon icon)

isSeparatorBefore

public boolean isSeparatorBefore()

setSeparatorBefore

public void setSeparatorBefore(boolean separatorBefore)

isSeparatorAfter

public boolean isSeparatorAfter()

setSeparatorAfter

public void setSeparatorAfter(boolean separatorAfter)

getPlaceAfter

public String getPlaceAfter()

setPlaceAfter

public void setPlaceAfter(String placeAfter)

getPlaceBefore

public String getPlaceBefore()

setPlaceBefore

public void setPlaceBefore(String placeBefore)

isPlaceAtContextTop

public boolean isPlaceAtContextTop()

setPlaceAtContextTop

public void setPlaceAtContextTop(boolean placeAtContextTop)

configure

public void configure(ResourceBundle resourceBundle)
Configures this command with the properties (if any) found in the given recource bundle. The resource keys for the corresponding properties are:

  • command.command-ID.text = display text
  • command.command-ID.popuptext = display text for popup menu
  • command.command-ID.mnemonic = mnemonic character
  • command.command-ID.accelerator = accelerator key
  • command.command-ID.shortdescr = text
  • command.command-ID.longdescr = text
  • command.command-ID.smallicon = image-path
  • command.command-ID.largeicon = image-path
  • command.command-ID.parent = command-COMMAND_ID or main-menu-name
  • command.command-ID.location = location-1, location-2, ...
  • command.command-ID.context = context-1, context-2, ...
  • command.command-COMMAND_ID.placeBefore = command-ID
  • command.command-ID.placeAfter = command-COMMAND_ID
  • command.command-ID.separatorBefore = true or false
  • command.command-ID.separatorAfter = true or false
  • Parameters:
    resourceBundle - the resource bundle from which the properties are received
    Throws:
    IllegalArgumentException - if the recource bundle is null

    updateState

    public void updateState()
    Causes this command to fire the 'check status' event to all of its listeners.


    createMenuItem

    public abstract JMenuItem createMenuItem()
    Creates an appropriate menu item for this command.


    createToolBarButton

    public abstract AbstractButton createToolBarButton()
    Creates an appropriate tool bar button for this command.


    createAction

    protected abstract Action createAction()
    Creates an appropriate action instance for this command.


    getProperty

    protected Object getProperty(String key)

    setProperty

    protected void setProperty(String key,
                               Object value)

    containsProperty

    protected boolean containsProperty(String key,
                                       Object testValue)

    getProperty

    protected String getProperty(String key,
                                 String defaultValue)

    getProperty

    protected String[] getProperty(String key,
                                   String[] defaultValues)

    getProperty

    protected boolean getProperty(String key,
                                  boolean defaultValue)

    setProperty

    protected void setProperty(String key,
                               boolean value)

    getEventListenerList

    protected EventListenerList getEventListenerList()

    addEventListener

    protected void addEventListener(Class t,
                                    EventListener l)
    Adds a command event listener.

    Parameters:
    t - the type of the listener to be added
    l - the command listener

    removeEventListener

    protected void removeEventListener(Class t,
                                       EventListener l)
    Removes a command event listener.

    Parameters:
    t - the type of the listener to be removed
    l - the command listener

    fireUpdateState

    protected void fireUpdateState()
    Notify all listeners that have registered interest for notification on the 'update status' event type. The event instance is lazily created using the parameters passed into the fire method.


    createResourceKey

    protected String createResourceKey(String commandPropertyName)
    Gets the key for the given command command-ID and command property name name as used in the resource bundle for this application.


    getResourceString

    protected String getResourceString(ResourceBundle resourceBundle,
                                       String commandPropertyName)
    Gets the resource string for the given command command-ID and command property name.


    getResourceStrings

    protected String[] getResourceStrings(ResourceBundle resourceBundle,
                                          String commandPropertyName)
    Gets the resource strings for the given command command-ID and command property name.


    getResourceStringArray

    protected String[] getResourceStringArray(ResourceBundle resourceBundle,
                                              String commandPropertyName)
    Gets the resource strings for the given command command-ID and command property name.


    getResourceBoolean

    protected Boolean getResourceBoolean(ResourceBundle resourceBundle,
                                         String commandPropertyName)
    Gets the boolean resource value for the given command command-ID and command property name.


    getResourceIcon

    protected Icon getResourceIcon(ResourceBundle resourceBundle,
                                   String commandPropertyName)

    containsPropertyValue

    protected boolean containsPropertyValue(String key,
                                            Object value)

    toString

    public String toString()
    Overrides:
    toString in class Object

    getCommandUIFactory

    public static CommandUIFactory getCommandUIFactory()

    setCommandUIFactory

    public static void setCommandUIFactory(CommandUIFactory commandUIFactory)

    updateComponentTreeUI

    public void updateComponentTreeUI()
    Lets an action update its component tree (if any) since the Java look-and-feel has changed.

    If a plug-in uses top-level containers such as dialogs or frames, implementors of this method should invoke SwingUtilities.updateComponentTreeUI() on such containers.

    The default implementation does nothing.


    updateState

    public void updateState(CommandEvent event)
    Called when a command should update its state.

    This method can contain some code which analyzes the underlying element and makes a decision whether this item or group should be made visible/invisible or enabled/disabled etc.

    Parameters:
    event - the command event

    configure

    public void configure(com.bc.ceres.core.runtime.ConfigurationElement config)
                   throws com.bc.ceres.core.CoreException
    Specified by:
    configure in interface com.bc.ceres.core.runtime.ConfigurableExtension
    Throws:
    com.bc.ceres.core.CoreException

    getValue

    protected String getValue(com.bc.ceres.core.runtime.ConfigurationElement config,
                              String elementName,
                              String defaultValue)

    getConfigString

    protected String getConfigString(com.bc.ceres.core.runtime.ConfigurationElement config,
                                     String elementName)
    Gets the resource string for the given command command-ID and command property name.


    getConfigStrings

    protected String[] getConfigStrings(com.bc.ceres.core.runtime.ConfigurationElement config,
                                        String elementName)
    Gets the resource strings for the given command command-ID and command property name.


    getConfigBoolean

    protected Boolean getConfigBoolean(com.bc.ceres.core.runtime.ConfigurationElement config,
                                       String elementName)
    Gets the boolean resource value for the given command command-ID and command property name.


    getConfigIcon

    protected Icon getConfigIcon(com.bc.ceres.core.runtime.ConfigurationElement config,
                                 String elementName)


    Copyright © 2002-2013 Brockmann Consult GmbH. All Rights Reserved.