Java Reference
In-Depth Information
@Override
protected void
handleNotificationEvent(Notification notification) {
int
type = notification.getEventType();
Object feature = notification.getFeature();
if
(MindmapPackage.eINSTANCE.getTopic_Subtopics().equals(feature) &&
(type == Notification.ADD || type == Notification.REMOVE)) {
CanonicalEditPolicy canonicalEditPolicy = (CanonicalEditPolicy)
getParent().getEditPolicy(EditPolicyRoles.CANONICAL_ROLE);
canonicalEditPolicy.refresh();
if
(getParent().getEditPolicy(
EditPolicyRoles.CANONICAL_ROLE)
instanceof
MapCanonicalEditPolicy) {
((MapCanonicalEditPolicy)canonicalEditPolicy).layout();
}
}
super
.handleNotificationEvent(notification);
}
In our
MapCanonicalEditPolicy
class, we override
handleNotifi-
cationEvent()
and look for additions or removals from our Map's elements
feature and invoke a new
layout()
method. Finally, we modify the
refreshSemantic()
method to invoke layout if it's detected that a new view
was created in the process.
@Override
protected void
handleNotificationEvent(Notification event) {
int
type = event.getEventType();
Object feature = event.getFeature();
if
(MindmapPackage.eINSTANCE.getMap_Elements().equals(feature) &&
(type == Notification.ADD || type == Notification.REMOVE)) {
layout();
}
super
.handleNotificationEvent(event);
}
/**
* @generated
NOT
*/
protected void refreshSemantic() {
List createdViews = new LinkedList();
createdViews.addAll(refreshSemanticChildren());
List createdConnectionViews = new LinkedList();
createdConnectionViews.addAll(refreshSemanticConnections());
createdConnectionViews.addAll(refreshConnections());
if (createdViews.size() > 1) {
// perform a layout of the container
DeferredLayoutCommand layoutCmd = new
DeferredLayoutCommand(host()
.getEditingDomain(), createdViews, host());
executeCommand(new ICommandProxy(layoutCmd));
}
Search WWH ::
Custom Search