Java Reference
In-Depth Information
Figure 9-13
Delete menu
The DeleteAction sends a GroupRequest of type REQ_DELETE to the
viewer's current selection. All EditPart s should have an EditPolicy that
either supports delete or prevents it from occurring.
Every EditPart is either a component or a connection. A component is a
basic EditPart that is the child of a parent. A connection is slightly different
because it is owned by its source and target.
The COMPONENT_ROLE key is used when installing an EditPolicy on a
component EditPart . Applications can extend the provided ComponentEdit
Policy to fill in the commands for deletion. The RootComponentEditPolicy
should be used on the contents EditPart . This policy prevents the diagram itself
from being deleted. Here, root refers to the model root and is not related to the
viewer's root EditPart.
The CONNECTION_ROLE key is used when installing a policy on a connection
EditPart . Applications can extend the provided ConnectionEditPolicy to
fill in the command for deletion.
These EditPolicies should handle the tasks most closely associated with the
model. In the logic example, this role is responsible for the LED's increment and
decrement behavior, which adds or subtracts 1 from the LED's value.
Implementing the command that performs delete can be difficult, especially
when connections are involved. The command must consider whether the object
being deleted has connections or whether children of the object being deleted
have connections, and delete the connections as well. But you don't want to
delete the same connection twice if both source and target nodes are being
deleted as part of multiple selection. The logic example's delete command
addresses all these concerns.
Search WWH ::




Custom Search