Java Reference
In-Depth Information
return
(Node) node;
}
}
return null
;
}
public void
refresh() {
removeDecoration();
Node node = getDecoratorTargetNode(getDecoratorTarget());
if
(node !=
null
) {
CustomStyle style = (CustomStyle)
node.getStyle(StylePackage.eINSTANCE.getCustomStyle());
if
(style !=
null
) {
boolean
linked = style.getHyperlink() !=
null
&& style.getHyperlink().length() > 0;
if
(linked) {
setDecoration(getDecoratorTarget().addShapeDecoration(
LINK, IDecoratorTarget.Direction.NORTH_EAST, 1,
false
));
}
}
}
}
private
NotificationListener notificationListener =
new
NotificationListener() {
public void
notifyChanged(Notification notification) {
refresh();
}
};
public void
activate() {
IGraphicalEditPart gep = (IGraphicalEditPart)
getDecoratorTarget().getAdapter(IGraphicalEditPart.
class
);
assert
gep !=
null
;
DiagramEventBroker.getInstance(
gep.getEditingDomain()).addNotificationListener(
gep.getNotationView(),
StylePackage.eINSTANCE.getCustomStyle_Hyperlink(),
notificationListener);
}
public void
deactivate() {
removeDecoration();
IGraphicalEditPart gep = (IGraphicalEditPart)
getDecoratorTarget().getAdapter(IGraphicalEditPart.
class
);
assert
gep !=
null
;
DiagramEventBroker.getInstance(
gep.getEditingDomain()).removeNotificationListener(
gep.getNotationView(), notificationListener);
}
}
Search WWH ::
Custom Search