public interface ObjectFragment extends ShareModuleFragment
This fragment is intended to be combined into an EditModuleCommand
instance.
The absolute number of the object can of course not be determined before the command fragment is executed. When attribute values need to be set on
the object within the same command that creates it, the ObjectRef.created(objectFragment)
method can be used to get a reference on the
object before the command is executed, as demonstrated in the following snippet.
ModuleRef module = ModuleRef.qualifiedName("/MyFolder/MyModule"); EditModuleCommand command = new EditModuleCommand(module, TerminationMode.SAVE_AND_CLOSE); CreateObjectFragment fragment = new CreateObjectFragment(); command.add(fragment); // obtain a reference on the object that is going to be created by the command ObjectRef object = ObjectRef.created(fragment); command.add(new SetAttributeValueFragment(object, "Object Heading", "test")); myCommandRunner.run(command);
Once the fragment is executed, the getAbsoluteNumber()
method gives the absolute number of the created object. This can be useful to
reference this object in other commands, later executed to edit this module. Below is a snippet illustrating the usage:
CreateObjectFragment fragment = new CreateObjectFragment(); myCommand.add(fragment); myCommandRunner.run(myCommand); String absoluteNumber = fragment.getAbsoluteNumber(); // the command has been executed, the absolute number is known ... ObjectRef object = ObjectRef.absoluteNumber(absoluteNumber); SetAttributeValueFragment fragment = new SetAttributeValueFragment(object, "Object Heading", "test"); mySecondCommand.add(fragment);
CommandRunner
,
EditModuleCommand
,
ObjectRef.created(ObjectFragment)
Modifier and Type | Method and Description |
---|---|
int |
getAbsoluteNumber()
Returns the absolute number of the object created when executing the command fragment.
|
int getAbsoluteNumber()
0
if the fragment has not been execute (and therefore the object has not been created).