|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openbp.common.generic.description.DescriptionObjectImpl
org.openbp.common.generic.description.DisplayObjectImpl
org.openbp.jaspira.action.JaspiraAction
public class JaspiraAction
Base class for actions within the Jaspria framework.
Each action has an optional name, display name and a description.
The display will be show as menu item text, the description will be used as tool tip
of a component that activates the action.
if the actionPerformed(java.awt.event.ActionEvent) method is not overriden, it will fire an JaspiraActionEvent
using the name of the action as event name. The source plugin of the event will be the
currently focused plugin or (if none) the owner plugin of the action.
Actions can contain several icons and descriptions. The small icon is
used in Menus. The large icon is used in toolbars.
Jaspira actions are also used to build menu and toolbar structures.
The type of the action determines what the action represents:
TYPE_ACTION or null: Regular action
TYPE_MENU: Menu (used to hold sub menu items; it doesn't have a real action functionality)
TYPE_GROUP: Menu or toolbar group
An action can have a menu parent and/or a toolbar parent, which determines where to place
the action in the main menu or the main toolbar.
Group or menu actions may also have menu or toolbar children.
| Field Summary | |
|---|---|
static int |
DFLT_PRIORITY
Default priority of an action |
static java.lang.String |
KEY_SEQUENCE_DELIM
Delimiter for multiple key sequences |
static java.lang.String |
MENU_ROOT
Id for the menu root - top level of a menu |
static java.lang.String |
MNEMONIC_DELIMITER
Delimiter to show the mnemonic key - key after delimiter gets mnemonic |
static java.lang.String |
PROPERTY_CONDITION
Property id for the conditional expression |
static java.lang.String |
PROPERTY_DESCRIPTION
Property id for description |
static java.lang.String |
PROPERTY_DISABLED_ICON
Property id for disabled icon |
static java.lang.String |
PROPERTY_DISPLAY_NAME
Property id for display name |
static java.lang.String |
PROPERTY_ENABLED
Property id for enabled option |
static java.lang.String |
PROPERTY_ICON
Property id for normal icon |
static java.lang.String |
PROPERTY_MENU_PARENT
Property id for menu parent if action has to be displayed in the menu |
static java.lang.String |
PROPERTY_NAME
Property id for name |
static java.lang.String |
PROPERTY_PAGE_NAMES
Property id for the names of the Jaspira pages that should display this action in the page menu or toolbar |
static java.lang.String |
PROPERTY_PRIO
Property id for priority of the action |
static java.lang.String |
PROPERTY_SCOPE
Property id for action scope |
static java.lang.String |
PROPERTY_SELECTED
Propertyid for selected option |
static java.lang.String |
PROPERTY_SEQUENCE
Property id for key sequences |
static java.lang.String |
PROPERTY_TOOLBAR_PARENT
Property id for toolbar parent if action has to be displayed in teh toolbar |
static java.lang.String |
PROPERTY_TYPE
Property id for the type of action |
static java.lang.String |
TOOLBAR_ROOT
Id for the toolbar root - top level of a toolbar |
static java.lang.String |
TYPE_ACTION
Regular action |
static java.lang.String |
TYPE_COMBO
Combo box action |
static java.lang.String |
TYPE_GROUP
Menu or toolbar group |
static java.lang.String |
TYPE_MENU
Menu (used to hold sub menu items; it doesn't have a real action functionality) |
| Fields inherited from interface javax.swing.Action |
|---|
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON |
| Fields inherited from interface org.openbp.common.generic.Copyable |
|---|
COPY_DEEP, COPY_FIRST_LEVEL, COPY_SHALLOW |
| Constructor Summary | |
|---|---|
JaspiraAction(DisplayObject obj)
Constructor using the given display object. |
|
JaspiraAction(Plugin owner,
java.lang.String name)
Constructor. |
|
JaspiraAction(ResourceCollection res,
java.lang.String name)
Constructor. |
|
JaspiraAction(java.lang.String name,
java.lang.String displayName,
java.lang.String description,
MultiIcon icon,
KeySequence[] keySequences,
int priority,
java.lang.String type)
Explicit constructor. |
|
| Method Summary | |
|---|---|
void |
actionPerformed(java.awt.event.ActionEvent ae)
Called if the action has been activated. |
void |
addMenuChild(JaspiraAction action)
Registers an action at this parent. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a property change listener to the listener list. |
void |
addToolbarChild(JaspiraAction action)
Registers an action at this parent. |
void |
checkForMnemonic()
Checks the Title of the Menu for Mnemonic. |
void |
clearValues()
Clears all action values. |
boolean |
decreaseCounter()
Decrease the reference counter of the action. |
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Supports reporting bound property changes. |
java.lang.Object |
getActionProperty(java.lang.String key)
Gets an action property, either from the action's property map or from the resource file. |
boolean |
getActionPropertyBoolean(java.lang.String key,
boolean dflt)
Gets an action property of type boolean. |
int |
getActionPropertyInt(java.lang.String key,
int dflt)
Gets an action property of type int. |
java.lang.String |
getActionPropertyString(java.lang.String key)
Gets an action property of type String. |
java.lang.String |
getActionPropertyString(java.lang.String key,
java.lang.String dflt)
Gets an action property of type String. |
ResourceCollection |
getActionResource()
Gets the resource containing the action properties. |
java.lang.String |
getCondition()
Gets the conditional expression that determines if the plugin should be active. |
int |
getCounter()
Returns the current value of the reference counter. |
MultiIcon |
getDisabledIcon()
Gets the disabled version of the icon. |
MultiIcon |
getIcon()
Gets the toolbar/menu icon. |
KeySequence[] |
getKeySequences()
Gets the key sequences for action activation. |
java.util.SortedSet |
getMenuchildren()
Returns the menu children. |
char |
getMnemonicChar()
Returns the mnemonic char of this action. |
int |
getMnemonicPos()
Returns the position of the mnemonic underscore in the display name of the action. |
java.lang.String[] |
getPageNames()
Gets the names of the Jaspira pages that should display this action in the page menu or toolbar. |
int |
getPriority()
Gets the priority. |
java.util.SortedSet |
getToolbarchildren()
Returns the toolbarchildren. |
java.lang.String |
getType()
Returns the type. |
java.lang.Object |
getValue(java.lang.String key)
|
void |
increaseCounter()
Increases the reference counter of the action. |
boolean |
isEnabled()
Gets the enabled status. |
boolean |
isMnemonic()
Returns true if the Action has mnemonic. |
boolean |
isSelected()
Returns the selected status. |
boolean |
matchesPageName(java.lang.String currentPageName)
Checks if an action should be added to the menu or toolbar of this page. |
void |
putValue(java.lang.String key,
java.lang.Object value)
|
protected void |
removeMenuChild(JaspiraAction action)
Unregisters an action from this parent. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a property change listener from the listener list. |
protected void |
removeToolbarChild(JaspiraAction action)
Unregisters an action from this parent. |
void |
setDescription(java.lang.String description)
Sets a new description for the action. |
void |
setDisabledIcon(MultiIcon disabledIcon)
Sets the disabled version of the icon. |
void |
setDisplayName(java.lang.String displayName)
Sets a new displayname for the action. |
void |
setEnabled(boolean enabled)
Sets the enabled status. |
void |
setIcon(MultiIcon icon)
Sets the toolbar/menu icon. |
void |
setPageNames(java.lang.String[] pageNames)
Sets the names of the Jaspira pages that should display this action in the page menu or toolbar. |
void |
setPriority(int priority)
Sets the priority. |
void |
setSelected(boolean selected)
Sets the selected status. |
javax.swing.JComponent |
toComponent()
Constructs a component from this action. |
javax.swing.JMenuItem |
toMenuItem()
Constructs a menu item from this action. |
javax.swing.JMenuItem |
toMenuItem(java.lang.String currentPageName)
Constructs a menu item from this action, considering the given page name. |
javax.swing.JComponent |
toToolBarComponent()
Constructs a tool bar component from this action. |
javax.swing.JComponent |
toToolBarComponent(java.lang.String currentPageName)
Constructs a tool bar component from this action, considering the given page name. |
| Methods inherited from class org.openbp.common.generic.description.DisplayObjectImpl |
|---|
copyFrom, getDisplayName, getDisplayText |
| Methods inherited from class org.openbp.common.generic.description.DescriptionObjectImpl |
|---|
clone, compareTo, getDescription, getDescriptionEscape, getDescriptionText, getName, setDescriptionEscape, setName, toString, validate |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.openbp.common.generic.description.DescriptionObject |
|---|
clone, getDescription, getDescriptionText, getName, setName |
| Methods inherited from interface java.lang.Comparable |
|---|
compareTo |
| Field Detail |
|---|
public static final java.lang.String PROPERTY_NAME
public static final java.lang.String PROPERTY_DISPLAY_NAME
public static final java.lang.String PROPERTY_DESCRIPTION
public static final java.lang.String PROPERTY_ICON
public static final java.lang.String PROPERTY_DISABLED_ICON
public static final java.lang.String PROPERTY_SEQUENCE
public static final java.lang.String PROPERTY_ENABLED
public static final java.lang.String PROPERTY_SELECTED
public static final java.lang.String PROPERTY_PRIO
public static final java.lang.String PROPERTY_SCOPE
public static final java.lang.String PROPERTY_TYPE
public static final java.lang.String PROPERTY_MENU_PARENT
public static final java.lang.String PROPERTY_TOOLBAR_PARENT
public static final java.lang.String PROPERTY_PAGE_NAMES
public static final java.lang.String PROPERTY_CONDITION
public static final java.lang.String MENU_ROOT
public static final java.lang.String TOOLBAR_ROOT
public static final java.lang.String TYPE_ACTION
public static final java.lang.String TYPE_COMBO
public static final java.lang.String TYPE_MENU
public static final java.lang.String TYPE_GROUP
public static final java.lang.String KEY_SEQUENCE_DELIM
public static final int DFLT_PRIORITY
public static final java.lang.String MNEMONIC_DELIMITER
| Constructor Detail |
|---|
public JaspiraAction(Plugin owner,
java.lang.String name)
owner - Owner plugin of the actionname - Action name
public JaspiraAction(ResourceCollection res,
java.lang.String name)
res - Action resourcename - Action name
public JaspiraAction(java.lang.String name,
java.lang.String displayName,
java.lang.String description,
MultiIcon icon,
KeySequence[] keySequences,
int priority,
java.lang.String type)
name - The internal name of the objectdisplayName - Display name of this objectdescription - Description of this objecticon - Toolbar/menu iconkeySequences - Key sequences for action activationpriority - Prioritytype - Type of the action (TYPE_ACTION/TYPE_COMBO/TYPE_MENU/TYPE_GROUP/null)public JaspiraAction(DisplayObject obj)
obj - Display object to copy name, display name and description from| Method Detail |
|---|
public void actionPerformed(java.awt.event.ActionEvent ae)
JaspiraActionEvent that has the
same name as the action either to the currently focused plugin (if there is one) or
to the global application plugin.
actionPerformed in interface java.awt.event.ActionListenerae - Action eventpublic javax.swing.JComponent toComponent()
public javax.swing.JComponent toToolBarComponent()
JaspiraToolbarButton if the action is a regular action,
a JaspiraToolbar if the action has toolbar children, null otherwisepublic javax.swing.JComponent toToolBarComponent(java.lang.String currentPageName)
matchesPageName(java.lang.String)).
currentPageName - Name of the Jaspira page to check against or null
JaspiraToolbarButton if the action is a regular action,
a JaspiraToolbar if the action has toolbar children, null otherwisepublic javax.swing.JMenuItem toMenuItem()
JaspiraMenuItem if the action is a regular action,
a JaspiraMenu if the action is a menu action and has menu children, null otherwisepublic javax.swing.JMenuItem toMenuItem(java.lang.String currentPageName)
matchesPageName(java.lang.String)).
currentPageName - Name of the Jaspira page to check against or null
JaspiraMenuItem if the action is a regular action,
a JaspiraMenu if the action is a menu action and has menu children, null otherwisepublic boolean matchesPageName(java.lang.String currentPageName)
Plugin.getName()) matches the page names
defined for the action (getPageNames()), in detail if:
currentPageName - Name of the Jaspira page to check against
public void checkForMnemonic()
public int getMnemonicPos()
public boolean isMnemonic()
public char getMnemonicChar()
public ResourceCollection getActionResource()
public java.util.SortedSet getMenuchildren()
public void addMenuChild(JaspiraAction action)
action - the childaction that wants to registerprotected void removeMenuChild(JaspiraAction action)
action - the child action that wants to unregisterpublic java.util.SortedSet getToolbarchildren()
public void addToolbarChild(JaspiraAction action)
action - the childaction that wants to registerprotected void removeToolbarChild(JaspiraAction action)
action - the child action that wants to unregisterpublic java.lang.String[] getPageNames()
public void setPageNames(java.lang.String[] pageNames)
pageNames - The list of page names (see JaspiraPage.getName) or null if the action
should appear for all pagespublic java.lang.String getType()
TYPE_ACTION/TYPE_COMBO/TYPE_MENU/TYPE_GROUP/null)public MultiIcon getIcon()
public void setIcon(MultiIcon icon)
public MultiIcon getDisabledIcon()
public void setDisabledIcon(MultiIcon disabledIcon)
public KeySequence[] getKeySequences()
public boolean isEnabled()
isEnabled in interface javax.swing.Actionpublic void setEnabled(boolean enabled)
setEnabled in interface javax.swing.Actionpublic boolean isSelected()
public void setDisplayName(java.lang.String displayName)
setDisplayName in interface DisplayObjectsetDisplayName in class DisplayObjectImplDisplayObjectImpl.setDisplayName(String)public void setDescription(java.lang.String description)
setDescription in interface DescriptionObjectsetDescription in class DescriptionObjectImplDescriptionObjectImpl.setDescription(String)public void setSelected(boolean selected)
public int getPriority()
public void setPriority(int priority)
public java.lang.String getCondition()
public int getCounter()
ActionMgrpublic void increaseCounter()
public boolean decreaseCounter()
public java.lang.Object getValue(java.lang.String key)
getValue in interface javax.swing.ActionAction.getValue(String)
public void putValue(java.lang.String key,
java.lang.Object value)
putValue in interface javax.swing.ActionAction.putValue(String, Object)public void clearValues()
public java.lang.Object getActionProperty(java.lang.String key)
key - Key of the property
public java.lang.String getActionPropertyString(java.lang.String key)
key - Key of the property
public java.lang.String getActionPropertyString(java.lang.String key,
java.lang.String dflt)
key - Key of the propertydflt - Default value
public boolean getActionPropertyBoolean(java.lang.String key,
boolean dflt)
key - Key of the propertydflt - Default value
public int getActionPropertyInt(java.lang.String key,
int dflt)
key - Key of the propertydflt - Default value
protected void firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
propertyName - Name of the bound propertyoldValue - Old value of the propertynewValue - New value of the propertypublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener in interface javax.swing.Actionlistener - The listener to be addedpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener in interface javax.swing.Actionlistener - The listener to be removed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||