com.japisoft.xmlpad.action
Class ActionModel

java.lang.Object
  extended bycom.japisoft.xmlpad.action.ActionModel

public class ActionModel
extends java.lang.Object

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) 2003 JAPISOFT / A.Brillant

Field Summary
static java.lang.String COMMENT_ACTION
          Comment action
static java.lang.String COPY_ACTION
          Copy action
static java.lang.String CUT_ACTION
          Cut action
static java.lang.String EDIT_GROUP
          Edit group
static java.lang.String FAST_COMMENT_ACTION
          Fast comment/uncomment action
static java.lang.String FILE_GROUP
          File group
static java.lang.String FORMAT_ACTION
          Format action
static java.lang.String INSERT_ACTION
          Insert file action
static java.lang.String LOAD_ACTION
          Load action
static java.lang.String NEW_ACTION
          New action
static java.lang.String OTHER_GROUP
          Other group
static java.lang.String PARSE_ACTION
          Refresh action
static java.lang.String PASTE_ACTION
          Paste action
static java.lang.String REDO_ACTION
          Redo action
static java.lang.String SAVE_ACTION
          Save action
static java.lang.String SAVEAS_ACTION
          SaveAs action
static java.lang.String SEARCH_ACTION
          Search action
static java.lang.String SEARCH_GROUP
          Search group
static java.lang.String SPLIT_ACTION
          Split action
static java.lang.String TOOLKIT_GROUP
          Toolkit group
static java.lang.String TREE_ADDHISTORY_ACTION
          Add the current node in the history
static java.lang.String TREE_CLEANHISTORY_ACTION
          Clean the history
static java.lang.String TREE_COMMENTNODE_ACTION
          Tree comment node
static java.lang.String TREE_COPYNODE_ACTION
          Tree copy node
static java.lang.String TREE_CUTNODE_ACTION
          Tree cut node
static java.lang.String TREE_EDITNODE_ACTION
          Tree edit node
static java.lang.String TREE_GROUP
          Tree group
static java.lang.String TREE_NEXT_ACTION
          Retreive the next history node
static java.lang.String TREE_PREVIOUS_ACTION
          Retreive the previous history node
static java.lang.String TREE_SELECTNODE_ACTION
          Tree select node
static java.lang.String UNDO_ACTION
          Undo action
static java.lang.String XML_GROUP
          XML group
 
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 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 XMLAction 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 isEnabledAction(java.lang.String 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, XMLAction 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 setFeature(java.lang.String actionName, java.lang.String featureName, boolean enabled)
          Set a feature for this action name
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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEW_ACTION

public static java.lang.String NEW_ACTION
New action


UNDO_ACTION

public static java.lang.String UNDO_ACTION
Undo action


REDO_ACTION

public static java.lang.String REDO_ACTION
Redo action


COPY_ACTION

public static java.lang.String COPY_ACTION
Copy action


CUT_ACTION

public static java.lang.String CUT_ACTION
Cut action


PASTE_ACTION

public static java.lang.String PASTE_ACTION
Paste action


PARSE_ACTION

public static java.lang.String PARSE_ACTION
Refresh action


SEARCH_ACTION

public static java.lang.String SEARCH_ACTION
Search action


COMMENT_ACTION

public static java.lang.String COMMENT_ACTION
Comment action


FAST_COMMENT_ACTION

public static java.lang.String FAST_COMMENT_ACTION
Fast comment/uncomment action


SAVEAS_ACTION

public static java.lang.String SAVEAS_ACTION
SaveAs action


SAVE_ACTION

public static java.lang.String SAVE_ACTION
Save action


INSERT_ACTION

public static java.lang.String INSERT_ACTION
Insert file action


LOAD_ACTION

public static java.lang.String LOAD_ACTION
Load action


SPLIT_ACTION

public static java.lang.String SPLIT_ACTION
Split action


FORMAT_ACTION

public static java.lang.String FORMAT_ACTION
Format action


TREE_SELECTNODE_ACTION

public static java.lang.String TREE_SELECTNODE_ACTION
Tree select node


TREE_COPYNODE_ACTION

public static java.lang.String TREE_COPYNODE_ACTION
Tree copy node


TREE_CUTNODE_ACTION

public static java.lang.String TREE_CUTNODE_ACTION
Tree cut node


TREE_EDITNODE_ACTION

public static java.lang.String TREE_EDITNODE_ACTION
Tree edit node


TREE_COMMENTNODE_ACTION

public static java.lang.String TREE_COMMENTNODE_ACTION
Tree comment node


TREE_PREVIOUS_ACTION

public static java.lang.String TREE_PREVIOUS_ACTION
Retreive the previous history node


TREE_NEXT_ACTION

public static java.lang.String TREE_NEXT_ACTION
Retreive the next history node


TREE_CLEANHISTORY_ACTION

public static java.lang.String TREE_CLEANHISTORY_ACTION
Clean the history


TREE_ADDHISTORY_ACTION

public static java.lang.String TREE_ADDHISTORY_ACTION
Add the current node in the history


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)


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


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 -

getActionByName

public static XMLAction getActionByName(java.lang.String name)
Returns:
current action by name

replaceActionByName

public static void replaceActionByName(java.lang.String name,
                                       XMLAction 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

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