@Override protected boolean isCompatibleMetaclass(Object containerElement, Object metaclass) { Element semanticElement = UMLUtil.resolveUMLElement(containerElement); if (semanticElement == null) { return false; } if (metaclass instanceof Stereotype) { Stereotype stereotype = (Stereotype) metaclass; boolean res = semanticElement.getAppliedStereotype(stereotype.getQualifiedName()) != null; if (!res) { EClass definition = stereotype.getDefinition(); for (EObject e : semanticElement.getStereotypeApplications()) { EClass c = e.eClass(); if (definition != null && definition.isSuperTypeOf(c)) { res = true; break; } } } return res; } // TODO : We should use super.isCompatibleMetaclass(), but the super-implementation // may not be compatible with our implementation of getAdaptedValue() if (metaclass instanceof EClassifier) { return ((EClassifier) metaclass).isInstance(semanticElement); } return false; }
/** * @see * org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener#notifyChanged(org.eclipse.emf.common.notify.Notification) * @param notification */ public void notifyChanged(Notification notification) { Object feature = notification.getFeature(); boolean headChanged = false; if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { headChanged = true; } else if (notification.getNotifier() instanceof EAnnotation && UMLVisualInformationPapyrusConstant.STEREOTYPE_ANNOTATION == ((EAnnotation) notification.getNotifier()).getSource()) { headChanged = true; } else if ((notification.getNotifier() instanceof DynamicEObjectImpl) && (hostSemanticElement != null) && (hostSemanticElement.getStereotypeApplications().contains(notification.getNotifier()))) { headChanged = true; } else if (PapyrusStereotypeListener.MODIFIED_STEREOTYPE == notification.getEventType()) { headChanged = true; } else if (notification instanceof StereotypeCustomNotification) { headChanged = true; } if (headChanged) { Display.getDefault() .asyncExec( new Runnable() { public void run() { impactLayout(); } }); } }
@Override public void activate() { super.activate(); // if stereotype has been applied, compartment has to be created final GraphicalEditPart editPart = (GraphicalEditPart) getHost(); Element UMLEelement = (Element) editPart.resolveSemanticElement(); Iterator<EObject> iterator = UMLEelement.getStereotypeApplications().iterator(); while (iterator.hasNext()) { final EObject appliedstereotype = (EObject) iterator.next(); createAppliedStereotypeCompartment(appliedstereotype); } }
/** {@inheritDoc} */ public void deactivate() { // retrieve the view and the element managed by the edit part View view = getView(); if (view == null) { return; } getDiagramEventBroker().removeNotificationListener(view, this); if (hostSemanticElement == null) { return; } // remove listeners to applied stereotyped for (EObject stereotypeApplication : hostSemanticElement.getStereotypeApplications()) { getDiagramEventBroker().removeNotificationListener(stereotypeApplication, this); } // remove notification on element getDiagramEventBroker().removeNotificationListener(hostSemanticElement, this); // removes the reference to the semantic element hostSemanticElement = null; }
public void activate() { // retrieve the view and the element managed by the edit part View view = getView(); if (view == null) { return; } hostSemanticElement = getUMLElement(); // adds a listener on the view and the element controlled by the // editpart getDiagramEventBroker().addNotificationListener(view, this); if (hostSemanticElement == null) { return; } getDiagramEventBroker().addNotificationListener(hostSemanticElement, this); // adds the listener for stereotype application and applied stereotypes // add listener to react to the application and remove of a stereotype // add a lister to each already applied stereotyped for (EObject stereotypeApplication : hostSemanticElement.getStereotypeApplications()) { getDiagramEventBroker().addNotificationListener(stereotypeApplication, this); } currentHeadHeight = getHeadHeight(); }