From 1feec0aec5250f6ac60db9bd7e0dcf65b8a8bf31 Mon Sep 17 00:00:00 2001 From: Saadia Dhouib Date: Fri, 13 Mar 2015 11:48:14 +0100 Subject: Resolving Bug #462061 [Composite Structure Diagram] Display of stereotype's icon on ports Resolving Bug #462062 [RobotML Diagrams] Display of ports icons --- .../css/style.css | 2 +- .../PortNodeLabelDisplayEditPolicy.java | 2 +- .../RobotMLDiagramsEditPolicyProvider.java | 56 +++++++++++++--------- 3 files changed, 35 insertions(+), 25 deletions(-) (limited to 'extraplugins') diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/css/style.css b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/css/style.css index abcf14dcf50..320ae53c773 100644 --- a/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/css/style.css +++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/css/style.css @@ -1,5 +1,5 @@ Property {maskLabel:name; elementIcon:false;} Property[type] {maskLabel:name type; } -Port>Label {maskLabel:name; elementIcon:flase;} +Port {maskLabel:name;} Port>Label:stereotype{visible: false;} Class {elementIcon:false;} \ No newline at end of file diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/editpolicies/PortNodeLabelDisplayEditPolicy.java b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/editpolicies/PortNodeLabelDisplayEditPolicy.java index 01216cfb0d2..52062f2d1d5 100644 --- a/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/editpolicies/PortNodeLabelDisplayEditPolicy.java +++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/editpolicies/PortNodeLabelDisplayEditPolicy.java @@ -51,7 +51,7 @@ public class PortNodeLabelDisplayEditPolicy extends AppliedStereotypeNodeLabelDi // retrieve the first stereotype in the list of displayed stereotype - // String firstStereotypeName = tokenizer.nextToken(); + EList stereotype_list = getUMLElement().getAppliedStereotypes(); if (stereotype_list.size() != 0) { Stereotype stereotype = stereotype_list.get(0); diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/editpolicy/provider/RobotMLDiagramsEditPolicyProvider.java b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/editpolicy/provider/RobotMLDiagramsEditPolicyProvider.java index 6e63543f3e2..141e92434ff 100644 --- a/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/editpolicy/provider/RobotMLDiagramsEditPolicyProvider.java +++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.diagram.common/src/org/eclipse/papyrus/robotml/diagram/common/editpolicy/provider/RobotMLDiagramsEditPolicyProvider.java @@ -11,6 +11,8 @@ *****************************************************************************/ package org.eclipse.papyrus.robotml.diagram.common.editpolicy.provider; +import java.util.Iterator; + import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.InternalEObject; @@ -32,6 +34,7 @@ import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabe import org.eclipse.papyrus.uml.diagram.composite.edit.parts.CompositeStructureDiagramEditPart; import org.eclipse.papyrus.uml.diagram.composite.edit.parts.PortEditPart; import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Profile; public class RobotMLDiagramsEditPolicyProvider extends AbstractProvider implements IEditPolicyProvider { @@ -61,29 +64,36 @@ public class RobotMLDiagramsEditPolicyProvider extends AbstractProvider if (editPart.getModel() instanceof View) { EObject element = ((View) editPart.getModel()).getElement(); if (element instanceof Element) { - if (((Element) element).getNearestPackage().getAppliedProfile( - ROBOTML_ID) != null) { - // System.err.println(list.get(i).getProfile().getName()); - if (editPart instanceof PortEditPart) { - NotificationListener editPolicy = new PortNodeLabelDisplayEditPolicy(); - editPart.installEditPolicy( - AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - (EditPolicy) editPolicy); - Object model = editPart.getModel(); - LayoutConstraint notifier = ((Shape) model) - .getLayoutConstraint(); - if (model instanceof Shape) { - // to force refreshing the port icon when the - // diagram is opening - Notification notification = new ENotificationImpl( - (InternalEObject) notifier, - Notification.SET, - NotationPackage.eINSTANCE.getLocation_X(), - 0, 0); - editPolicy.notifyChanged(notification); - } - } - } + + Iterator itr = ((Element) element).getNearestPackage().getAllAppliedProfiles().iterator(); + while(itr.hasNext()) { + Profile profile = itr.next(); + + if(profile.getName().equals(ROBOTML_ID)) + { + + if (editPart instanceof PortEditPart) { + NotificationListener editPolicy = new PortNodeLabelDisplayEditPolicy(); + editPart.installEditPolicy( + AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + (EditPolicy) editPolicy); + Object model = editPart.getModel(); + LayoutConstraint notifier = ((Shape) model) + .getLayoutConstraint(); + if (model instanceof Shape) { + // to force refreshing the port icon when the + // diagram is opening + Notification notification = new ENotificationImpl( + (InternalEObject) notifier, + Notification.SET, + NotationPackage.eINSTANCE.getLocation_X(), + 0, 0); + editPolicy.notifyChanged(notification); + } + } + } + } + } } } -- cgit v1.2.3