org.gjt.sp.jedit
Class ActionSet

java.lang.Object
  extended by org.gjt.sp.jedit.ActionSet

public class ActionSet
extends java.lang.Object

A set of actions, either loaded from an XML file, or constructed at runtime by a plugin.

Action sets loaded from XML files

Action sets are read from these files inside the plugin JAR: An action definition file has the following form:
<?xml version="1.0"?>
<!DOCTYPE ACTIONS SYSTEM "actions.dtd">
<ACTIONS>
    <ACTION NAME="some-action">
        <CODE>
            // BeanShell code evaluated when the action is invoked
        </CODE>
    </ACTION>
    <ACTION NAME="some-toggle-action">
        <CODE>
            // BeanShell code evaluated when the action is invoked
        </CODE>
        <IS_SELECTED>
            // BeanShell code that should evaluate to true or false
        </IS_SELECTED>
    </ACTION>
</ACTIONS>
The following elements are valid: Each action must have a property name.label containing the action's menu item label.

View actions

Actions defined in actions.xml can be added to the view's Plugins menu; see EditPlugin. The action code may use any standard predefined BeanShell variable; see BeanShell.

File system browser actions

Actions defined in actions.xml can be added to the file system browser's Plugins menu; see EditPlugin. The action code may use any standard predefined BeanShell variable, in addition to a variable browser which contains a reference to the current VFSBrowser instance.

File system browser actions should not define <IS_SELECTED> blocks.

Custom action sets

Call jEdit.addActionSet(ActionSet) to add a custom action set to jEdit's action context. You must also call initKeyBindings() for new action sets. Don't forget to call jEdit.removeActionSet(ActionSet) before your plugin is unloaded, too.

Since:
jEdit 4.0pre1
See Also:
jEdit.getActionContext(), VFSBrowser.getActionContext(), ActionContext.getActionNames(), ActionContext.getAction(String), jEdit.addActionSet(ActionSet), jEdit.removeActionSet(ActionSet), PluginJAR.getActionSet(), BeanShell, View

Constructor Summary
ActionSet()
          Creates a new action set.
ActionSet(PluginJAR plugin, java.lang.String[] cachedActionNames, boolean[] cachedActionToggleFlags, java.net.URL uri)
          Creates a new action set.
ActionSet(java.lang.String label)
          Creates a new action set.
 
Method Summary
 void addAction(EditAction action)
          Adds an action to the action set.
 boolean contains(java.lang.String action)
          Returns if this action set contains the specified action.
 EditAction getAction(java.lang.String name)
          Returns an action with the specified name.
 int getActionCount()
          Returns the number of actions in the set.
 java.lang.String[] getActionNames()
          Returns an array of all action names in this action set.
 EditAction[] getActions()
          Returns an array of all actions in this action set.
 java.lang.String[] getCacheableActionNames()
          Returns an array of all action names in this action set that should be cached; namely, BeanShellActions.
 java.lang.String getLabel()
          Return the action source label.
 PluginJAR getPluginJAR()
          Return the plugin this action set was loaded from, or null.
 void initKeyBindings()
          Initializes the action set's key bindings.
 void load()
          Forces the action set to be loaded.
 void removeAction(java.lang.String name)
          Removes an action from the action set.
 void removeAllActions()
          Removes all actions from the action set.
 void setLabel(java.lang.String label)
          Sets the action source label.
 int size()
          Returns the number of actions in this action set.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ActionSet

public ActionSet()
Creates a new action set.

Since:
jEdit 4.0pre1

ActionSet

public ActionSet(PluginJAR plugin,
                 java.lang.String[] cachedActionNames,
                 boolean[] cachedActionToggleFlags,
                 java.net.URL uri)
Creates a new action set.

Parameters:
plugin - The plugin
cachedActionNames - The list of cached action names
cachedActionToggleFlags - The list of cached action toggle flags
uri - The actions.xml URI
Since:
jEdit 4.2pre2

ActionSet

public ActionSet(java.lang.String label)
Creates a new action set.

Parameters:
label - The label, shown in the shortcuts option pane
Since:
jEdit 4.0pre1
Method Detail

getLabel

public java.lang.String getLabel()
Return the action source label.

Since:
jEdit 4.0pre1

setLabel

public void setLabel(java.lang.String label)
Sets the action source label.

Parameters:
label - The label
Since:
jEdit 4.0pre1

getPluginJAR

public PluginJAR getPluginJAR()
Return the plugin this action set was loaded from, or null.

Since:
jEdit 4.2pre13

addAction

public void addAction(EditAction action)
Adds an action to the action set.

Parameters:
action - The action
Since:
jEdit 4.0pre1

removeAction

public void removeAction(java.lang.String name)
Removes an action from the action set.

Parameters:
name - The action name
Since:
jEdit 4.0pre1

removeAllActions

public void removeAllActions()
Removes all actions from the action set.

Since:
jEdit 4.0pre1

getAction

public EditAction getAction(java.lang.String name)
Returns an action with the specified name.

Deferred loading: this will load the action set if necessary.

Parameters:
name - The action name
Since:
jEdit 4.0pre1

getActionCount

public int getActionCount()
Returns the number of actions in the set.

Since:
jEdit 4.0pre1

getActionNames

public java.lang.String[] getActionNames()
Returns an array of all action names in this action set.

Since:
jEdit 4.2pre1

getCacheableActionNames

public java.lang.String[] getCacheableActionNames()
Returns an array of all action names in this action set that should be cached; namely, BeanShellActions.

Since:
jEdit 4.2pre1

getActions

public EditAction[] getActions()
Returns an array of all actions in this action set.

Deferred loading: this will load the action set if necessary.

Since:
jEdit 4.0pre1

contains

public boolean contains(java.lang.String action)
Returns if this action set contains the specified action.

Parameters:
action - The action
Since:
jEdit 4.2pre1

size

public int size()
Returns the number of actions in this action set.

Since:
jEdit 4.2pre2

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

initKeyBindings

public void initKeyBindings()
Initializes the action set's key bindings. jEdit calls this method for all registered action sets when the user changes key bindings in the Global Options dialog box.

Note if your plugin adds a custom action set to jEdit's collection, it must also call this method on the action set after adding it.

Since:
jEdit 4.2pre1

load

public void load()
Forces the action set to be loaded. Plugins and macros should not call this method.

Since:
jEdit 4.2pre1