public class CreatePictureFragment extends com.sodius.mdw.internal.metamodel.doors.io.commands.CreatePictureFragmentImpl implements ObjectFragment
When instantiating this command, an InsertLocation
can be used to determine the location where to insert the created object (e.g.
below another object).
This fragment is intended to be combined into an EditModuleCommand
instance.
Below is a snippet illustrating how to use this fragment (see CommandRunner
for a full snippet):
ModuleRef module = ModuleRef.qualifiedName("/MyFolder/MyModule"); EditModuleCommand command = new EditModuleCommand(module, TerminationMode.SAVE_AND_CLOSE); PictureRef picture = PictureRef.create(new File("c:\\pictures\\myPicture.png")); ObjectRef parentObject = ObjectRef.absoluteNumber(5); InsertLocation location = InsertLocation.below(parentObject); CreatePictureFragment fragment = new CreatePictureFragment(picture, location); command.add(fragment); myCommandRunner.run(command);
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.
CreatePictureFragment fragment = new CreatePictureFragment(picture, location); command.add(fragment); // obtain a reference on the picture object that is going to be created by the command ObjectRef object = ObjectRef.created(fragment); myCommand.add(new SetAttributeValueFragment(object, "myAttribute", "test")); myCommandRunner.run(myCommand);
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:
CreatePictureFragment fragment = new CreatePictureFragment(picture, location); 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, "myAttribute", "test"); mySecondCommand.add(fragment);
This class is not intended to be subclassed by clients but may be instantiated.
CommandRunner
,
EditModuleCommand
,
ObjectRef.created(ObjectFragment)
Constructor and Description |
---|
CreatePictureFragment(PictureRef picture,
InsertLocation insertLocation)
Instantiates a fragment to create a new picture object in the DOORS formal module,
at the specified location.
|
Modifier and Type | Method and Description |
---|---|
int |
getAbsoluteNumber()
Returns the absolute number of the object created when executing the command fragment.
|
public CreatePictureFragment(PictureRef picture, InsertLocation insertLocation)
picture
- contains information on the picture to insert in the created object.insertLocation
- the location in the module where to insert the created picture object.public int getAbsoluteNumber()
ObjectFragment
getAbsoluteNumber
in interface ObjectFragment
getAbsoluteNumber
in class com.sodius.mdw.internal.metamodel.doors.io.commands.CreateObjectFragmentImpl
0
if the fragment has not been execute (and therefore the object has not been created).