Commando files are written in XML. A commando file must have a certain preamble, along with a root element:
<?xml version="1.0"?> <!DOCTYPE COMMANDO SYSTEM "commando.dtd"> <COMMANDO> ... </COMMANDO> |
Each command file must define one and only one UI element inside the COMMANDO element. The UI element does not have any defined attributes.
A TOGGLE element adds a check box to the commando panel. It must be placed inside the UI element. The following attributes are supported:
LABEL - the check box caption. This attribute is required.
VARNAME - the state of the checkbox will be stored in the BeanShell variable with this name. This attribute is required.
DEFAULT - The default value; this should be either "TRUE" or "FALSE".
EVAL - The default value will be the result of evaluating this BeanShell script. The script must return a boolean value. Note that only one of DEFAULT and EVAL should be specified.
Here is an example TOGGLE element:
<TOGGLE LABEL="Ignore case" VARNAME="ignoreCase" /> |
An ENTRY element adds a text field to the commando panel. It must be placed inside the UI element. The following attributes are supported:
LABEL - the text field's caption. This attribute is required.
VARNAME - the contents of the text field will be stored in the BeanShell variable with this name. This attribute is required.
DEFAULT - The default contents of the text field.
EVAL - The default content will be the result of evaluating this BeanShell script. The script must return a string value. Note that only one of DEFAULT and EVAL should be specified.
Here is an example ENTRY element:
<ENTRY LABEL="File name" VARNAME="file" EVAL="buffer.getPath()" /> |
A CHOICE element adds a combo box to the commando panel. It must be placed inside the UI element. The following attributes are supported:
LABEL - the combo box caption. This attribute is required.
VARNAME - the selected option will be stored in the BeanShell variable with this name. This attribute is required.
DEFAULT - The initially selected option of the text field.
EVAL - The initially selected option will be the result of evaluating this BeanShell script. The script must return a string value. Note that only one of DEFAULT and EVAL should be specified.
Possible options are specified in OPTION elements inside the CHOICE element. Here is an example CHOICE element:
<CHOICE LABEL="Output format" VARNAME="output" DEFAULT="unified"> <OPTION LABEL="Brief" VALUE="brief" /> <OPTION LABEL="Context" VALUE="context" /> <OPTION LABEL="ED script" VALUE="ed" /> <OPTION LABEL="RCS" VALUE="rcs" /> <OPTION LABEL="Side by side" VALUE="sideBySide" /> <OPTION LABEL="Unified" VALUE="unified" /> </CHOICE> |
A CAPTION element adds a labeled box to the commando panel that other UI elements can be added to. It must be placed inside the UI element. The only defined attribute is LABEL. It is required.
Any UI control can be placed inside the CAPTION element.
Here is an example of the CAPTION element:
<CAPTION LABEL="File specification"> <ENTRY LABEL="Original file" VARNAME="from" EVAL="buffer.getPath() + '~'" /> <ENTRY LABEL="Changed file" VARNAME="to" EVAL="buffer.getPath()" /> <TOGGLE LABEL="Recursively compare directories" VARNAME="recursive" /> <ENTRY LABEL="Ignore files regexp" VARNAME="ignore" /> </CAPTION> |
One or more COMMAND elements can be defined inside the COMMANDO element. Each COMMAND element defines a command to execute. The following attributes are supported:
CONFIRM - Of "TRUE", a confirmation dialog will be shown before running this command.
SHELL - The name of the shell to run this command in.
TO_BUFFER - If "TRUE", the command output will be shown in a new buffer.
BUFFER_MODE - If TO_BUFFER is "TRUE", this parameter can be used to specify the edit mode of the new buffer. The default value is "text".
A BeanShell script placed between the start and end COMMAND tags should construct a command line using the values of the variables set by the UI controls. The final command line should be returned by the last statement in the script.
Here is an example COMMAND element:
<COMMAND CONFIRM="FALSE" SHELL="System"> buf = new StringBuffer("jmk"); if(!makefile.equals("")) { buf.append(" -f \""); buf.append(makefile); buf.append('"'); } if(!targets.equals("")) { buf.append(' '); buf.append(targets); } if(debug) buf.append(" -d"); if(norun) buf.append(" -n"); if(output.equals("awt")) buf.append(" -w"); if(output.equals("swing")) buf.append(" -s"); // return value buf; </COMMAND> |