public class GenDocCommandStandardHandler extends DefaultModuleCommandHandler
Needs the DocumentPublisher module to be deployed in the project.
This handler uses the following command parameters:
PARAM_STYLESHEET
: the base style sheet file path
PARAM_TARGETFILE
: the target file name
PARAM_TARGETFORMAT
: the target file format
PARAM_TEMPLATE
: the document template identifier
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PARAM_OPEN_AFTER_GENERATE
Command parameter for "open after generation".
|
static java.lang.String |
PARAM_STYLESHEET
Command parameter for base stylesheet file path.
|
static java.lang.String |
PARAM_TARGETFILE
Command parameter for target file path.
|
static java.lang.String |
PARAM_TARGETFORMAT
Command parameter for target format.
|
static java.lang.String |
PARAM_TEMPLATE
Command parameter for template name.
|
Constructor and Description |
---|
GenDocCommandStandardHandler() |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.util.List<MObject> selectedElements,
IModule module)
Execute the action.
|
protected boolean |
askForParameters(java.util.List<MObject> selectedElements,
IModule module,
java.util.Map<java.lang.String,java.lang.String> execParameters)
Ask the user for the document generation path and other parameters.
|
protected java.nio.file.Path |
getDocTemplatePath(IModule module,
java.util.Map<java.lang.String,java.lang.String> execParameters)
Retrieve from the given parameters the document template jar file path.
|
protected java.util.List<ModelElement> |
getElementsToGenerate(IModule module,
java.util.List<MObject> selectedElements,
java.util.Map<java.lang.String,java.lang.String> execParameters)
Get the elements on which the documentation must be generated.
|
protected java.lang.String |
getStyleSheetFile(IModule module,
java.util.Map<java.lang.String,java.lang.String> execParameters)
Retrieve from the given parameters the style sheet file absolute path.
|
protected java.lang.String |
getTargetFile(IModule module,
java.util.Map<java.lang.String,java.lang.String> execParameters)
Retrieve from the given parameters the target file name.
|
protected java.lang.String |
getTargetFormat(IModule module,
java.util.Map<java.lang.String,java.lang.String> execParameters)
Retrieve from the given parameters the target file format.
|
protected java.util.Map<java.lang.String,java.lang.String> |
getTemplateParameterValues(java.util.Map<java.lang.String,java.lang.String> execParameters)
Get the document template parameter values from the current execution parameters.
|
boolean |
isActiveFor(java.util.List<MObject> selectedElements,
IModule module)
The handler is active by default.
|
protected boolean |
isOpenAfterGenerate(java.util.Map<java.lang.String,java.lang.String> execParameters)
Tells whether to open the generated document after generation.
|
protected void |
postConfigure(java.util.List<MObject> selectedElements,
IModule module,
java.util.Map<java.lang.String,java.lang.String> execParameters)
Hook called after generation.
|
protected void |
preConfigure(java.util.List<MObject> selectedElements,
IModule module,
java.util.Map<java.lang.String,java.lang.String> execParameters)
Hook called before asking the user for parameters.
|
protected void |
reportFailure(java.lang.Throwable error,
IModule module)
Report failure to the user.
|
accept, findStereotypeFromSpec, getParameter, getParameters, getScopes, initialize
public static final java.lang.String PARAM_TARGETFILE
public static final java.lang.String PARAM_STYLESHEET
public static final java.lang.String PARAM_TEMPLATE
public static final java.lang.String PARAM_TARGETFORMAT
public static final java.lang.String PARAM_OPEN_AFTER_GENERATE
public void actionPerformed(java.util.List<MObject> selectedElements, IModule module)
The execution order is by follow:
preConfigure(List, IModule, Map)
with the current execution parameters.
askForParameters(List, IModule, Map)
with the current execution parameters.
postConfigure(List, IModule, Map)
with the current execution parameters.
selectedElements
- the elements on which the command was launchedmodule
- the current moduleprotected void reportFailure(java.lang.Throwable error, IModule module)
By default log the error and display a message dialog.
error
- the failure causemodule
- the moduleprotected boolean askForParameters(java.util.List<MObject> selectedElements, IModule module, java.util.Map<java.lang.String,java.lang.String> execParameters)
By default opens a simple dialog asking the user for the file path where the document should be generated. If the user selects a file it puts the file name into the execParameters map with "TARGET" as key.
The user may also choose to cancel the operation in which case the method returns false.
Sub classes may redefine this method and do anything else. In this case they may modify the execParameters map.
selectedElements
- the elements on which the command is run.module
- the module owning this command.execParameters
- the document generation parameters.protected void postConfigure(java.util.List<MObject> selectedElements, IModule module, java.util.Map<java.lang.String,java.lang.String> execParameters)
Does nothing by default.
selectedElements
- the elements on which the command is runmodule
- the moduleexecParameters
- the current execution parameters.protected void preConfigure(java.util.List<MObject> selectedElements, IModule module, java.util.Map<java.lang.String,java.lang.String> execParameters)
Does nothing by default. Sub classes may redefine this method to modify the execParameters execution parameters that will be used to configure the documentation generation. The execution parameters contain initially all the command parameters.
selectedElements
- the elements on which the command is runmodule
- the moduleexecParameters
- the current execution parameters.protected java.util.Map<java.lang.String,java.lang.String> getTemplateParameterValues(java.util.Map<java.lang.String,java.lang.String> execParameters)
By default return the command handler parameters. Subclasses may redefine.
execParameters
- the action execution parameters.protected java.lang.String getTargetFormat(IModule module, java.util.Map<java.lang.String,java.lang.String> execParameters)
The returned string must be compatible with the DocumentPublisher 'Target' enumeration.
This method won't call askForParameters(List, IModule, Map)
if the target file name is not yet specified.
By default reads the PARAM_TARGETFORMAT
parameter from execParameters.
module
- the module.execParameters
- the current execution parametersprotected java.util.List<ModelElement> getElementsToGenerate(IModule module, java.util.List<MObject> selectedElements, java.util.Map<java.lang.String,java.lang.String> execParameters)
By default returns the selectedElements list filtered by elements deriving from ModelElement
.
module
- the moduleselectedElements
- the Modelio selectionexecParameters
- the current execution parameters.protected java.lang.String getTargetFile(IModule module, java.util.Map<java.lang.String,java.lang.String> execParameters)
This method won't call askForParameters(List, IModule, Map)
if the target file name is not yet specified.
By default reads the PARAM_TARGETFILE
parameter from execParameters.
module
- the moduleexecParameters
- the current execution parametersprotected java.lang.String getStyleSheetFile(IModule module, java.util.Map<java.lang.String,java.lang.String> execParameters)
This method won't call askForParameters(List, IModule, Map)
if the information is not yet specified.
By default reads the PARAM_STYLESHEET
parameter from execParameters.
module
- the moduleexecParameters
- the current execution parametersprotected java.nio.file.Path getDocTemplatePath(IModule module, java.util.Map<java.lang.String,java.lang.String> execParameters)
This method won't call askForParameters(List, IModule, Map)
if the information is not yet specified.
By default reads the PARAM_TEMPLATE
parameter from execParameters.
module
- the moduleexecParameters
- the current execution parametersprotected boolean isOpenAfterGenerate(java.util.Map<java.lang.String,java.lang.String> execParameters)
By default returns true unless "open_generated" execution parameter is set to "false".
execParameters
- the action execution parameters.public boolean isActiveFor(java.util.List<MObject> selectedElements, IModule module)
DefaultModuleCommandHandler
isActiveFor
in interface IModuleCommandHandler
isActiveFor
in class DefaultModuleCommandHandler
selectedElements
- Current selectionmodule
- Owner of the command