Show the equipment detail view by
double-clicking a network element.
First, you create an action,
doubleClickAction
, to show the equipment detail view.
Action doubleClickAction = new AbstractAction("Show equipment details") {
public void actionPerformed(ActionEvent e) {
if (e instanceof IlpViewActionEvent) {
IlpViewActionEvent viewEvent = (IlpViewActionEvent)e;
IlpObject ilpObj = viewEvent.getIlpObject();
if (ilpObj!=null) {
equipmentDialog.setVisible(true);
return;
}
log.info("Double-click action detected at " + viewEvent.getPosition()
+ ", not on IlpObject");
} else
log.info("Non-CPL action detected");
}
};
The class
IlpViewActionEvent is used to discover
the context of the interaction that triggered the action. When
an action is triggered by a view interactor that has
recognized a gesture, the action event received by the action
is a view action event.
Then, you associate the action with a
double-click gesture in the interactors of the various
components.
networkInteractor.setGestureAction(IlpGesture.BUTTON1_DOUBLE_CLICKED,
doubleClickAction);
tableComponent.getViewInteractor().setGestureAction(
IlpGesture.BUTTON1_DOUBLE_CLICKED,
doubleClickAction);
treeComponent.getViewInteractor().setGestureAction(
IlpGesture.BUTTON1_DOUBLE_CLICKED,
doubleClickAction);
The first parameter,
BUTTON1_DOUBLE_CLICKED, identifies the
gesture that should trigger the action. A gesture is a series
of one or more graphic events triggered by the end user.
The class
IlpGesture contains (as static fields) a
number of gestures that are recognized by some or all
interactors. Its subclasses contain additional gestures that
are specific to individual interactors.