com.japisoft.xmlpad.action
Class ActionModel

java.lang.Object
  extended bycom.japisoft.xmlpad.action.ActionModel
All Implemented Interfaces:
ActionSet

public class ActionModel
extends java.lang.Object
implements ActionSet

ActionModel

Here a model managing available action for the XMLContainer. This class manage actions and actionGroup. An ActionGroup is a set of Action. As example, inside the XMLContainer component a group is delimited by a separator inside the main toolbar.

This ActionModel is initialized using the 'xmlpad.properties' file. This properties are managed by the XMLPadProperties class, thus with it user can avoid the file usage working directly in memory to build its own action model.

Version:
1.5
Author:
(c) 2002-2004 JAPISOFT

Field Summary
static java.lang.String EDIT_GROUP
          Edit group
static java.lang.String FILE_GROUP
          File group
static java.lang.String OTHER_GROUP
          Other group
static java.lang.String SEARCH_GROUP
          Search group
static java.lang.String TOOLKIT_GROUP
          Toolkit group
static java.lang.String TREE_GROUP
          Tree group
static java.lang.String XML_GROUP
          XML group
 
Fields inherited from interface com.japisoft.xmlpad.action.ActionSet
COMMENT_ACTION, COPY_ACTION, CUT_ACTION, FAST_COMMENT_ACTION, FORMAT_ACTION, INSERT_ACTION, LOAD_ACTION, NEW_ACTION, PARSE_ACTION, PASTE_ACTION, REDO_ACTION, SAVE_ACTION, SAVEAS_ACTION, SEARCH_ACTION, SPLIT_ACTION, SPLIT_ACTION_HOR, TREE_ADDHISTORY_ACTION, TREE_CLEANHISTORY_ACTION, TREE_COMMENTNODE_ACTION, TREE_COPYNODE_ACTION, TREE_CUTNODE_ACTION, TREE_EDITNODE_ACTION, TREE_NEXT_ACTION, TREE_PREVIOUS_ACTION, TREE_SELECTNODE_ACTION, UNDO_ACTION
 
Constructor Summary
ActionModel()
           
 
Method Summary
static boolean activeActionByName(java.lang.String name)
          Active an action by its name
static boolean activeActionByName(java.lang.String name, XMLContainer container, XMLEditor editor)
          Active an action changing the current container and editor this these ones.
static void activeActionForSelection(boolean selection)
          Enabled/Disabled all action implementing the ActicateOnSelection interface
static void addActionForGroup(java.lang.String groupName, java.lang.String actionClass)
          Add a new action for this groupName.
static void addActionForGroup(java.lang.String groupName, XMLAction a)
          Add this action 'a' for the followed groupName.
static void addGroup(ActionGroup group)
          Insert a new group of actions
static void buildPopupMenu(javax.swing.JPopupMenu popupMenu)
          Build the toolBar by adding all available action (in a toolbarable state)
static void buildToolBar(javax.swing.JToolBar toolBar)
          Build the toolBar by adding all available action (in a toolbarable state)
static javax.swing.Action getActionByName(java.lang.String name)
           
static ActionGroup getGroupByName(java.lang.String groupName)
           
static java.util.Enumeration getGroups()
           
static java.lang.Object getParam(java.lang.String actionName)
           
static java.lang.Object getProperty(java.lang.String actionName, java.lang.String propertyName, java.lang.Object defaultValue)
           
static boolean hasFeature(java.lang.String actionName, java.lang.String featureName)
          Check a feature for this action name
static boolean hasGroup(java.lang.String name)
           
static boolean isEnabledAction(java.lang.String name)
           
static void removeActionByName(java.lang.String name)
          Remove an action by its name
static void removeActionForGroup(java.lang.String groupName, XMLAction a)
          Remove this action 'a' from the following groupName.
static void removeGroup(ActionGroup group)
          Remove a group of action
static void replaceActionByName(java.lang.String name, javax.swing.Action newAction)
          Replace an action matching the name by the newAction
static void resetActionState(XMLContainer container)
          Reset the current Action state for this editor and this container
static void resetActionState(XMLEditor editor, XMLContainer container)
          Deprecated. Use only the version with the XMLContainer as parameter Reset the current Action state for this editor and this container, thus action will work on the good editor.
static void setEnabledAction(java.lang.String name, boolean enabled)
          Enabled/Disabled an action by its name
static void setEnabledAutoResetActionState(boolean enabled)
          Decide or not to reset the action model with the last XMLContainer getting the focus.
static void setFeature(java.lang.String actionName, java.lang.String featureName, boolean enabled)
          Set a feature for this action name
static void setIcon(java.lang.String actionName, javax.swing.Icon newIcon)
          Reset the default icon for this actionName by this one
static void setIconForAction(java.lang.String name, javax.swing.Icon icon)
          Replace an action icon by this one
static void setParam(java.lang.String actionName, java.lang.Object param)
          Set this param for the action related to the actionName
static void setProperty(java.lang.String actionName, java.lang.String propertyName, java.lang.Object value)
          Reset a property value by calling setProperty on the action known by actionName.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_GROUP

public static java.lang.String FILE_GROUP
File group


EDIT_GROUP

public static java.lang.String EDIT_GROUP
Edit group


SEARCH_GROUP

public static java.lang.String SEARCH_GROUP
Search group


XML_GROUP

public static java.lang.String XML_GROUP
XML group


OTHER_GROUP

public static java.lang.String OTHER_GROUP
Other group


TREE_GROUP

public static java.lang.String TREE_GROUP
Tree group


TOOLKIT_GROUP

public static java.lang.String TOOLKIT_GROUP
Toolkit group

Constructor Detail

ActionModel

public ActionModel()
Method Detail

buildToolBar

public static void buildToolBar(javax.swing.JToolBar toolBar)
Build the toolBar by adding all available action (in a toolbarable state)


buildPopupMenu

public static void buildPopupMenu(javax.swing.JPopupMenu popupMenu)
Build the toolBar by adding all available action (in a toolbarable state)


setEnabledAutoResetActionState

public static void setEnabledAutoResetActionState(boolean enabled)
Decide or not to reset the action model with the last XMLContainer getting the focus. By default true


setIconForAction

public static void setIconForAction(java.lang.String name,
                                    javax.swing.Icon icon)
Replace an action icon by this one


resetActionState

public static void resetActionState(XMLEditor editor,
                                    XMLContainer container)
Deprecated. Use only the version with the XMLContainer as parameter Reset the current Action state for this editor and this container, thus action will work on the good editor.

Parameters:
editor -
container -

resetActionState

public static void resetActionState(XMLContainer container)
Reset the current Action state for this editor and this container

Parameters:
container -

addGroup

public static void addGroup(ActionGroup group)
Insert a new group of actions


hasGroup

public static boolean hasGroup(java.lang.String name)
Returns:
true if this group name is known

removeGroup

public static void removeGroup(ActionGroup group)
Remove a group of action


getGroupByName

public static ActionGroup getGroupByName(java.lang.String groupName)
Returns:
an actions group for a name. null is returned for unknown group

addActionForGroup

public static void addActionForGroup(java.lang.String groupName,
                                     XMLAction a)
Add this action 'a' for the followed groupName. If the groupName is not known then the action a is added to a new ActionGroup getting the groupName.

Parameters:
groupName - existing group name
a - XML action

addActionForGroup

public static void addActionForGroup(java.lang.String groupName,
                                     java.lang.String actionClass)
                              throws java.lang.ClassNotFoundException
Add a new action for this groupName. If the action is not found a ClassNotFoundException will be thrown

Throws:
java.lang.ClassNotFoundException

removeActionForGroup

public static void removeActionForGroup(java.lang.String groupName,
                                        XMLAction a)
Remove this action 'a' from the following groupName. If no action group is found then then nothing is done.

Parameters:
groupName -
a -

removeActionByName

public static void removeActionByName(java.lang.String name)
Remove an action by its name


getActionByName

public static javax.swing.Action getActionByName(java.lang.String name)
Returns:
current action by name

replaceActionByName

public static void replaceActionByName(java.lang.String name,
                                       javax.swing.Action newAction)
Replace an action matching the name by the newAction


setEnabledAction

public static void setEnabledAction(java.lang.String name,
                                    boolean enabled)
Enabled/Disabled an action by its name


isEnabledAction

public static boolean isEnabledAction(java.lang.String name)
Returns:
the current action state. If the action is not know it will return false

activeActionByName

public static boolean activeActionByName(java.lang.String name)
Active an action by its name

Returns:
true is the action is possible else false if something is wrong

activeActionByName

public static boolean activeActionByName(java.lang.String name,
                                         XMLContainer container,
                                         XMLEditor editor)
Active an action changing the current container and editor this these ones. The previous XMLContainer and XMLEditor for each action is maintained at the end of the processing.

Returns:
true is the action is possible else false if something is wrong

activeActionForSelection

public static void activeActionForSelection(boolean selection)
Enabled/Disabled all action implementing the ActicateOnSelection interface


getGroups

public static java.util.Enumeration getGroups()
Returns:
available groups

setFeature

public static void setFeature(java.lang.String actionName,
                              java.lang.String featureName,
                              boolean enabled)
Set a feature for this action name


hasFeature

public static boolean hasFeature(java.lang.String actionName,
                                 java.lang.String featureName)
Check a feature for this action name


setParam

public static void setParam(java.lang.String actionName,
                            java.lang.Object param)
Set this param for the action related to the actionName


getParam

public static java.lang.Object getParam(java.lang.String actionName)
Returns:
the current param for this action or null

setProperty

public static void setProperty(java.lang.String actionName,
                               java.lang.String propertyName,
                               java.lang.Object value)
Reset a property value by calling setProperty on the action known by actionName. If the action is not found, this method will has no effect

Parameters:
actionName - XMLAction name
propertyName - Property name
value - Property value

getProperty

public static java.lang.Object getProperty(java.lang.String actionName,
                                           java.lang.String propertyName,
                                           java.lang.Object defaultValue)
Returns:
a property value by calling getProperty on the action known by the actionName. If the actionName is invalid a null value will be returned

setIcon

public static void setIcon(java.lang.String actionName,
                           javax.swing.Icon newIcon)
Reset the default icon for this actionName by this one



Copyright © 2006 JAPISoft. All Rights Reserved.