public class RunJythonScriptBasicHandler extends DefaultModuleCommandHandler
The jython script must be in the "JY_SCRIPT" command parameter.
The scripts are run with the bindings configured by configure(ScriptEngine, List, IModule)
.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SCRIPT_PARAM
Command parameter containing the Jython script to run.
|
Constructor and Description |
---|
RunJythonScriptBasicHandler() |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.util.List<MObject> selectedElements,
IModule module)
Method invoked when the command is launched.
|
protected javax.script.Bindings |
configure(javax.script.ScriptEngine engine,
java.util.List<MObject> selectedElements,
IModule module)
Computes the bindings to use to run the scripts.
|
protected boolean |
runBooleanScript(java.lang.String scriptParamName,
java.util.List<MObject> selectedElements,
IModule module)
Run a Jython script stored in the given command parameter.
|
accept, findStereotypeFromSpec, getParameter, getParameters, getScopes, initialize, isActiveFor
public static final java.lang.String SCRIPT_PARAM
public void actionPerformed(java.util.List<MObject> selectedElements, IModule module)
IModuleCommandHandler
This command is launched by Modelio when the user clicks on the contextual menu command. The selected elements that corresponds to the current selection are given as parameter.
The module that is passed as parameter corresponds to the owner of the command.
selectedElements
- Current selectionmodule
- Owner of the commandprotected javax.script.Bindings configure(javax.script.ScriptEngine engine, java.util.List<MObject> selectedElements, IModule module)
By defaults creates the following bindings:
engine
- the script engine that will be used.selectedElements
- the Modelio selection.module
- the module owning the commandprotected boolean runBooleanScript(java.lang.String scriptParamName, java.util.List<MObject> selectedElements, IModule module)
The Jython script should return a boolean value. Returns false if the script does not return a boolean or fails.
Does nothing and returns true if no script is present for the given command parameter.
scriptParamName
- the command parameter where the script is stored.selectedElements
- the current Modelio selectionmodule
- the module owing the command