com.borland.primetime.actions
Class UpdateAction

java.lang.Object
  |
  +--javax.swing.AbstractAction
        |
        +--com.borland.primetime.actions.UpdateAction
Direct Known Subclasses:
ActionGroup, DelegateAction, KeymapManager.SubKeymapAction, SearchManager.RemoveMessageAction, StateAction, WizardAction

public abstract class UpdateAction
extends javax.swing.AbstractAction
implements UpdateableAction

A UpdateAction functions as a regular Swing Action object - it stores the shortText, longText, icon, and enabled state for a single action. The primary difference is that an UpdateAction implements the UpdateableAction interface which also enables updating of an Action's state before the item is displayed in UI.

Subclasses of UpdateAction can optionally override the public method: public void update(Object source) to initialize the UpdateAction object immediately before it is represented as UI somewhere in the environment.

Several convenience methods surface the common properties of the Action object, like name, shortText, longText, and mnemonic.

See Also:
Action, Serialized Form

Field Summary
static java.lang.String ACCELERATOR
          The storage attribute key for the ACCELERATOR (KeyStroke) property.
static UpdateAction[] EMPTY_ARRAY
          Used as a quick return for an empty array of UpdateAction objects.
static java.lang.String HELP_TOPIC
          The storage attribute key for the HELP_TOPIC (HelpTopic) property.
static java.lang.String LARGE_ICON
          The storage attribute key for the LARGE_ICON (Icon) property.
static java.lang.String MNEMONIC
          The storage attribute key for the MNEMONIC (Character) property.
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
DEFAULT, LONG_DESCRIPTION, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
UpdateAction()
          Constructs an UpdateAction will all default properties.
UpdateAction(java.lang.String shortText)
          Constructs an UpdateAction will the specified short text.
UpdateAction(java.lang.String shortText, char mnemonic)
          Constructs an UpdateAction will the specified short text and mnemonic.
UpdateAction(java.lang.String shortText, char mnemonic, java.lang.String longText)
          Constructs an UpdateAction will the specified short text, mnemonic, and long text.
UpdateAction(java.lang.String shortText, char mnemonic, java.lang.String longText, javax.swing.Icon smallIcon)
          Constructs an UpdateAction will the specified short text, mnemonic, long text, and small icon.
UpdateAction(java.lang.String shortText, char mnemonic, java.lang.String longText, javax.swing.Icon smallIcon, javax.swing.Icon largeIcon)
          Constructs an UpdateAction will the specified short text, mnemonic, long text, small icon, and large icon.
 
Method Summary
 com.borland.primetime.help.HelpTopic getHelpTopic()
          Returns the helpTopic property setting.
 javax.swing.Icon getLargeIcon()
          Returns the largeIcon property setting.
 java.lang.String getLongText()
          Returns the longText property setting.
 char getMnemonic()
          Returns the mnemonic property setting.
 java.lang.String getShortText()
          Returns the shortText property setting.
 javax.swing.Icon getSmallIcon()
          Returns the smallIcon property setting.
 void setHelpTopic(com.borland.primetime.help.HelpTopic helpTopic)
          Sets the helpTopic property.
 void setLargeIcon(javax.swing.Icon largeIcon)
          Sets the largeIcon property.
 void setLongText(java.lang.String longText)
          Sets the longText property.
 void setMnemonic(char mnemonic)
          Sets the mnemonic property.
 void setShortText(java.lang.String shortText)
          Sets the shortText property.
 void setSmallIcon(javax.swing.Icon smallIcon)
          Sets the smallIcon property.
 void update(java.lang.Object source)
           The update method is called when the UpdateAction is about to be displayed in UI.
 
Methods inherited from class javax.swing.AbstractAction
actionPerformed, addPropertyChangeListener, clone, firePropertyChange, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ARRAY

public static final UpdateAction[] EMPTY_ARRAY
Used as a quick return for an empty array of UpdateAction objects.

MNEMONIC

public static final java.lang.String MNEMONIC
The storage attribute key for the MNEMONIC (Character) property. The MNEMONIC property value is used as the mnemonic for the UI widget representing the Action. NOTE: Any Action subclass (not only UpdateAction subclasses) can store a java.lang.Character under a MNEMONIC attribute, and it will be used as a mnemonic for the UI widget representing the Action.

ACCELERATOR

public static final java.lang.String ACCELERATOR
The storage attribute key for the ACCELERATOR (KeyStroke) property. The ACCELERATOR property value is used as the keyboard shortcut for the UI widget representing the Action. NOTE: Any Action subclass (not only UpdateAction subclasses) can store a javax.swing.KeyStroke in the ACCELERATOR attribute, and it will be used as a shortcut for the UI widget representing the Action.

HELP_TOPIC

public static final java.lang.String HELP_TOPIC
The storage attribute key for the HELP_TOPIC (HelpTopic) property. The HELP_TOPIC property value is used when help is invoked on an ActionWidget representing the Action. NOTE: Any Action subclass (not only UpdateAction subclasses) can store a com.borland.primetime.help.HelpTopic in the HELP_TOPIC attribute, and it will be used when help is invoked on the widget representing the Action.

LARGE_ICON

public static final java.lang.String LARGE_ICON
The storage attribute key for the LARGE_ICON (Icon) property. The LARGE_ICON is used to when displaying an Action in the Gallery or on a palette page.
Constructor Detail

UpdateAction

public UpdateAction()
Constructs an UpdateAction will all default properties.

UpdateAction

public UpdateAction(java.lang.String shortText)
Constructs an UpdateAction will the specified short text.
Parameters:
shortText - The short text for the action

UpdateAction

public UpdateAction(java.lang.String shortText,
                    char mnemonic)
Constructs an UpdateAction will the specified short text and mnemonic.
Parameters:
shortText - The short text for the action
mnemonic - The mnemonic character for the action

UpdateAction

public UpdateAction(java.lang.String shortText,
                    char mnemonic,
                    java.lang.String longText)
Constructs an UpdateAction will the specified short text, mnemonic, and long text.
Parameters:
shortText - The short text for the action
mnemonic - The mnemonic character for the action
longText - The long text for the action

UpdateAction

public UpdateAction(java.lang.String shortText,
                    char mnemonic,
                    java.lang.String longText,
                    javax.swing.Icon smallIcon)
Constructs an UpdateAction will the specified short text, mnemonic, long text, and small icon.
Parameters:
shortText - The short text for the action
mnemonic - The mnemonic character for the action
longText - The long text for the action
smallIcon - The small icon for the action (16x16)

UpdateAction

public UpdateAction(java.lang.String shortText,
                    char mnemonic,
                    java.lang.String longText,
                    javax.swing.Icon smallIcon,
                    javax.swing.Icon largeIcon)
Constructs an UpdateAction will the specified short text, mnemonic, long text, small icon, and large icon.
Parameters:
shortText - The short text for the action
mnemonic - The mnemonic character for the action
longText - The long text for the action
smallIcon - The small icon for the action (16x16)
largeIcon - The large icon for the action (32x32)
Method Detail

setShortText

public void setShortText(java.lang.String shortText)
Sets the shortText property. The shortText may be displayed as a menu item's text or possibly as the label or tooltip for a button. This should be relatively short (one or two words if possible).
Parameters:
shortText - The short text for the action

getShortText

public java.lang.String getShortText()
Returns the shortText property setting.
Returns:
The short text for the action

setMnemonic

public void setMnemonic(char mnemonic)
Sets the mnemonic property. The mnemonic character is the 'hotkey' for the menu item or button displaying the action. This *must* be a character in the 'shortText' property, or it will have no effect.
Parameters:
mnemonic - The mnemonic character for the action

getMnemonic

public char getMnemonic()
Returns the mnemonic property setting.
Returns:
The mnemonic character for the action

setLongText

public void setLongText(java.lang.String longText)
Sets the longText property. The longText may be displayed in the status bar as a user scans over menu items or toolbar buttons. This can be a bit more wordy than the shortText, as the whole status bar width will be available.
Parameters:
longText - The long text for the action

getLongText

public java.lang.String getLongText()
Returns the longText property setting.
Returns:
The long text for the action

setSmallIcon

public void setSmallIcon(javax.swing.Icon smallIcon)
Sets the smallIcon property. The smallIcon may be displayed as a menu item's icon or possibly as the icon for a button. This icon should be 16x16 pixels in size.
Parameters:
smallIcon - The small icon for the action

getSmallIcon

public javax.swing.Icon getSmallIcon()
Returns the smallIcon property setting.
Returns:
The small icon for the action

setLargeIcon

public void setLargeIcon(javax.swing.Icon largeIcon)
Sets the largeIcon property. The largeIcon may be displayed as an item in the gallery list or possibly as the icon for a larger button. This icon should be 32x32 pixels in size.
Parameters:
largeIcon - The large icon for the action

getLargeIcon

public javax.swing.Icon getLargeIcon()
Returns the largeIcon property setting.
Returns:
The large icon for the action

setHelpTopic

public void setHelpTopic(com.borland.primetime.help.HelpTopic helpTopic)
Sets the helpTopic property. The helpTopic value is used when help is invoked on an action widget representing this action.
Parameters:
helpTopic - The helpTopic for the action

getHelpTopic

public com.borland.primetime.help.HelpTopic getHelpTopic()
Returns the helpTopic property setting.
Returns:
The helpTopic for the action

update

public void update(java.lang.Object source)

The update method is called when the UpdateAction is about to be displayed in UI. At this point, the UpdateAction may optionally update it's enabled state, shortText, longText, icon, etc so that it may be represented in appropriate state for the passed source.

Subclasses can override this method to dynamically change their state based on the current Node in the Browser, the current selected Node in the ProjectView, or whatever they like. Typically, the static method: public static Browser findBrowser(Object source) is called to acquire a Browser instance during the update process. If your action *always* requires a browser, use the BrowserAction subclass in the ide package.

NOTE: This method is called EVERY TIME a menu is about to display, or EVERY few milliseconds for toolbar buttons displaying this action. The code in the update method should be VERY SLIM and VERY FAST.

ANOTHER NOTE: This method is called EVERY few milliseconds if it is ever bound to a keystroke in the KeymapManager. When called from the KeymapManager, the passed source will *always* be the active Browser.

Specified by:
update in interface UpdateableAction
Parameters:
source - The source of the action that is about to be displayed as UI.