Package org.gjt.sp.jedit
Class ActionSet
- java.lang.Object
-
- org.gjt.sp.jedit.JEditActionSet<EditAction>
-
- org.gjt.sp.jedit.ActionSet
-
- All Implemented Interfaces:
java.lang.Comparable,InputHandlerProvider
public class ActionSet extends JEditActionSet<EditAction> implements java.lang.Comparable
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:actions.xml- actions made available for use in jEdit views, including the view's Plugins menu, the tool bar, etc.browser.actions.xml- actions for the file system browser's Plugins menu.
<?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:-
ACTIONSis the top-level element and refers to the set of actions used by the plugin. -
An
ACTIONcontains the data for a particular action. It has three attributes: a requiredNAME; an optionalNO_REPEAT, which is a flag indicating whether the action should not be repeated with the C+ENTER command; and an optionalNO_RECORDwhich is a a flag indicating whether the action should be recorded if it is invoked while the user is recording a macro. The two flag attributes can have two possible values, "TRUE" or "FALSE". In both cases, "FALSE" is the default if the attribute is not specified. -
An
ACTIONcan have two child elements within it: a requiredCODEelement which specifies the BeanShell code that will be executed when the action is invoked, and an optionalIS_SELECTEDelement, used for checkbox menu items. TheIS_SELECTEDelement contains BeanShell code that returns a boolean flag that will determine the state of the checkbox.
name.labelcontaining the action's menu item label.View actions
Actions defined inactions.xmlcan be added to the view's Plugins menu; seeEditPlugin. The action code may use any standard predefined BeanShell variable; seeBeanShell.File system browser actions
Actions defined inactions.xmlcan be added to the file system browser's Plugins menu; seeEditPlugin. The action code may use any standard predefined BeanShell variable, in addition to a variablebrowserwhich contains a reference to the currentVFSBrowserinstance.File system browser actions should not define
<IS_SELECTED>blocks.Custom action sets
CalljEdit.addActionSet(ActionSet)to add a custom action set to jEdit's action context. You must also callJEditActionSet.initKeyBindings()for new action sets. Don't forget to calljEdit.removeActionSet(ActionSet)before your plugin is unloaded, too.
-
-
Field Summary
-
Fields inherited from class org.gjt.sp.jedit.JEditActionSet
actions, loaded, placeholder, uri
-
-
Constructor Summary
Constructors Constructor Description ActionSet()Creates a new action set.ActionSet(java.lang.String label)Creates a new action set.ActionSet(PluginJAR plugin, java.lang.String[] cachedActionNames, boolean[] cachedActionToggleFlags, java.net.URL uri)Creates a new action set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAction(EditAction action)Adds an action to the action set.intcompareTo(java.lang.Object o)protected EditActioncreateBeanShellAction(java.lang.String actionName, java.lang.String code, java.lang.String selected, boolean noRepeat, boolean noRecord, boolean noRememberLast)Creates a BeanShellAction.EditAction[]getActions()Returns an array of all actions in this action set.protected EditAction[]getArray(int size)Returns an empty array E[].java.lang.String[]getCacheableActionNames()Returns an array of all action names in this action set that should be cached; namely,BeanShellActions.AbstractInputHandlergetInputHandler()java.lang.StringgetLabel()PluginJARgetPluginJAR()java.lang.StringgetProperty(java.lang.String name)Returns a property for the given name.voidsetLabel(java.lang.String label)Sets the action source label.java.lang.StringtoString()-
Methods inherited from class org.gjt.sp.jedit.JEditActionSet
contains, getAction, getActionCount, getActionNames, initKeyBindings, load, removeAction, removeAllActions, size
-
-
-
-
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 plugincachedActionNames- The list of cached action namescachedActionToggleFlags- The list of cached action toggle flagsuri- The actions.xml URI- Since:
- jEdit 4.2pre2
-
ActionSet
public ActionSet(@Nonnull 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
-
addAction
public void addAction(EditAction action)
Adds an action to the action set. It exists for binary compatibility issues- Overrides:
addActionin classJEditActionSet<EditAction>- Parameters:
action- The action- Since:
- jEdit 4.0pre1
-
getArray
protected EditAction[] getArray(int size)
Description copied from class:JEditActionSetReturns an empty array E[]. I know it is bad, if you find a method to instantiate a generic Array, tell me- Specified by:
getArrayin classJEditActionSet<EditAction>- Parameters:
size- the size of the array- Returns:
- the empty array
-
getActions
public EditAction[] getActions()
Returns an array of all actions in this action set.Deferred loading: this will load the action set if necessary.
- Overrides:
getActionsin classJEditActionSet<EditAction>- Returns:
- an array of all actions in this action set.
Deferred loading: this will load the action set if necessary.
- Since:
- jEdit 4.0pre1
-
getLabel
public java.lang.String getLabel()
- Returns:
- the action source label.
- Since:
- jEdit 4.0pre1
-
setLabel
public void setLabel(@Nonnull java.lang.String label)Sets the action source label.- Parameters:
label- The label- Since:
- jEdit 4.0pre1
-
getPluginJAR
public PluginJAR getPluginJAR()
- Returns:
- the plugin this action set was loaded from, or null.
- Since:
- jEdit 4.2pre13
-
getCacheableActionNames
public java.lang.String[] getCacheableActionNames()
Returns an array of all action names in this action set that should be cached; namely,BeanShellActions.- Overrides:
getCacheableActionNamesin classJEditActionSet<EditAction>- Returns:
- an array of all action names in this action set that should
be cached; namely,
BeanShellActions. - Since:
- jEdit 4.2pre1
-
getProperty
public java.lang.String getProperty(java.lang.String name)
Description copied from class:JEditActionSetReturns a property for the given name. In jEdit it will returns a jEdit.getProperty(name), but it can return something else for a standalone textarea.- Specified by:
getPropertyin classJEditActionSet<EditAction>- Parameters:
name- the property name- Returns:
- the property value
-
getInputHandler
public AbstractInputHandler getInputHandler()
- Specified by:
getInputHandlerin interfaceInputHandlerProvider
-
compareTo
public int compareTo(java.lang.Object o)
- Specified by:
compareToin interfacejava.lang.Comparable
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
createBeanShellAction
protected EditAction createBeanShellAction(java.lang.String actionName, java.lang.String code, java.lang.String selected, boolean noRepeat, boolean noRecord, boolean noRememberLast)
Creates a BeanShellAction.- Specified by:
createBeanShellActionin classJEditActionSet<EditAction>- Parameters:
actionName- the action namecode- the codeselected- selectednoRepeat- noRepeatnoRecord- noRecordnoRememberLast- noRememberLast- Returns:
- an action
- Since:
- 4.3pre13
-
-