Java Reference
In-Depth Information
Tools on the palette, action contributions in the UI, and programmatic inter-
action all create Request s and call upon the EditPart to handle the Request .
The EditPart interface defines several methods that respond to Request
objects, including those listed here.
EditPart getTargetEditPart(Request request);
boolean understandsRequest(Request request);
void showSourceFeedback(Request request);
void eraseSourceFeedback(Request request);
void showTargetFeedback(Request request);
void eraseTargetFeedback(Request request);
Command getCommand(Request request);
void performRequest(Request request);
Before safe editing of the underlying model can take place, it's important to
know which EditPart s are involved and whether they are capable of handling
certain requests. Between those elements selected in the view and those under the
mouse pointer (the target ), you can capture this information using the first two
API methods getTargetEditPart() and understandsRequest() .
When interacting with the diagram with a mouse—particularly when drag-
ging a node or making connections—it's important to provide feedback to the
user. The role an EditPart plays in these interactions is important to know
when providing feedback because source and target feedback is typically distinct.
This functionality is provided using the next four API methods shown earlier that
are related to showing/erasing source/target feedback.
EditPart s are responsible for returning the appropriate Command for a
given Request , as provided by the getCommand() contract. Command s ulti-
mately operate on the underlying model element within the EditingDomain . If
a particular request cannot be performed, the EditPart returns a null or
nonexecutable Command , which can be rendered in the UI to indicate this to the
user.
Finally, the EditPart might just need to perform a Request. Typically, this
does not result in an underlying model change; instead, it opens a dialog, col-
lapses a compartment, or activates an in-place editor. For these cases, the
performRequest(Request) method is called.
Commands
As mentioned, Command s are the primary means of effecting change in the under-
lying model. Command s encapsulate changes to the model, can be combined with
other commands, and must be executed using a command stack. One of the pri-
mary complications with using GEF and EMF together has been that each frame-
work provides its own command infrastructure. Add to that the platform's
Search WWH ::




Custom Search