public class CreateModuleCommand extends EditModuleCommand
This command acts exactly as the EditModuleCommand
, except it starts by creating the module before executing the command fragments.
When instantiating an create command, you indicate the expected behavior at the end of a successful execution:
TerminationMode.SAVE_AND_CLOSE
: the created module is saved and closed. This is the typical mode in which the command is usually
executedTerminationMode.SAVE
: the created module is saved but isn't closed. Use this mode if you need to store the modifications made but
also want to execute an additional edit command on the same module.TerminationMode.LEAVE_OPEN
: the created module is left open and modifications are not saved. Use this mode if you want to execute
an additional edit command on the same module and need to ensure all modifications are discarded if one command fails to execute properly.When creating a link module, you need to set the desired link mapping, which determines the number of potential outgoing and incoming links on objects.
Below is a snippet illustrating how to use this command (see CommandRunner
for a full snippet and EditModuleFragment
subclasses for details):
ModuleRef module = ModuleRef.qualifiedName("/MyFolder/MyNewModule"); CreateModuleCommand command = new CreateModuleCommand(module, TerminationMode.SAVE_AND_CLOSE); // create a new object CreateObjectFragment creationFragment = new CreateObjectFragment(); command.add(creationFragment); // set its heading ObjectRef createdObject = ObjectRef.created(creationFragment); String heading = "Introduction"; command.add(new SetAttributeValueFragment(createdObject, "Object Heading", heading)); myCommandRunner.run(command);
This class is not intended to be subclassed by clients but may be instantiated.
CommandRunner
,
EditModuleCommand
EditModuleCommand.TerminationMode
Constructor and Description |
---|
CreateModuleCommand(ModuleRef module,
EditModuleCommand.TerminationMode terminationMode)
Instantiates a command to create a new formal module.
|
CreateModuleCommand(ModuleRef module,
EditModuleCommand.TerminationMode terminationMode,
LinkKind linkKind)
Instantiates a command to create a new link module.
|
add, remove
run
public CreateModuleCommand(ModuleRef module, EditModuleCommand.TerminationMode terminationMode)
module
- the formal module to be created.terminationMode
- determines the behavior of the command when it successfully completes.public CreateModuleCommand(ModuleRef module, EditModuleCommand.TerminationMode terminationMode, LinkKind linkKind)
module
- the link module to be created.terminationMode
- determines the behavior of the command when it successfully completes.linkKind
- the link mapping, which determines the number of potential outgoing and incoming links on objects.