Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCéline Janssens2015-03-05 11:54:25 -0500
committerCéline Janssens2015-05-06 09:21:44 -0400
commitaa51f9ee3eddf8ba18a418ffb8de9ec77a0be103 (patch)
treee6af296d74979ddb0559cf5f7edea625d06a4237
parent90dfa151d07cc8b8146a69f235255a9c99caa3b4 (diff)
downloadorg.eclipse.papyrus-aa51f9ee3eddf8ba18a418ffb8de9ec77a0be103.tar.gz
org.eclipse.papyrus-aa51f9ee3eddf8ba18a418ffb8de9ec77a0be103.tar.xz
org.eclipse.papyrus-aa51f9ee3eddf8ba18a418ffb8de9ec77a0be103.zip
Bug 460356: [Stereotype Display] Objective 4c. Display properties into a
comment thanks to CSS. Bug 461561: [Stereotype Display] The reference Element should be the Stereotype instead of StereotypeApplication Bug 461559: [Stereotype Display] Brace Properties should be store in a different Compartment into Notation View https://bugs.eclipse.org/bugs/show_bug.cgi?id=460356 https://bugs.eclipse.org/bugs/show_bug.cgi?id=461559 https://bugs.eclipse.org/bugs/show_bug.cgi?id=461561 - Point to Stereotype instead of Stereotype Application - Dupplicated Compartment for Brace Properties - EditPolicy Hierarchy change - Not Display Comment, and Properties by Default into base.css - Creation of AppliedStereotypeEmptyEditPart and InvisibleRectangleFigure to Avoid DefaultNodeEditPart of GMF not well interpreted into CornerBentFigure. - Fix Operation and Property Stereotype Display - Refactor the EditPolicy Hierarchy - Comment Creation is independent of Compartment creation - Label and Brace structure created into Abstract EditPolicy - Base.CSS file update for Stereotypes Change-Id: Ia5afc63639f64590748db3a9c9844bee7351344a Signed-off-by: Céline Janssens <Celine.Janssens@all4tec.net>
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/resources/base.css394
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/GMFElementAdapter.java14
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/DiagramCSSEngine.java2
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/CSSDOMSemanticElementHelper.java52
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CSSCustomStyleDelegate.java3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypeOperationDisplayEditPolicy.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/UMLConnectionNodeEditPart.java101
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AbstractAppliedStereotypeDisplayEditPolicy.java629
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeExternalNodeEditPolicy.java32
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeLabelDisplayEditPolicy.java544
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeLinkLabelDisplayEditPolicy.java33
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeNodeLabelDisplayEditPolicy.java30
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CommentShapeForAppliedStereotypeEditPolicy.java108
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/CornerBentFigure.java21
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java16
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/StereotypedElementLabelHelper.java103
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/StereotypePropertyParser.java11
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/stereotype/AppliedStereotypeParser.java23
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypeCommentContentCommand.java103
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypeCommentViewCommand.java7
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypePropertyViewCommand.java7
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypeViewCommand.java22
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateStereotypeLabelCommand.java17
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeDisplayHelper.java429
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeDisplayUtils.java39
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/dom/GMFUMLElementAdapter.java22
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/helper/CSSDOMUMLSemanticElementHelper.java87
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AppliedStereotypeExternalNodeLabelEditPolicy.java35
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/plugin.xml2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeCompartmentEditPart.java11
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeEmptyEditPart.java98
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeMultilinePropertyEditPart.java5
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCommentCreationEditPolicy.java419
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCompartmentEditPolicy.java207
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCompartmentForCommentShapeEditPolicy.java21
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeLabelEditPolicy.java30
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/provider/StereotypePropertiesEditPartProvider.java10
38 files changed, 1967 insertions, 1726 deletions
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/resources/base.css b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/resources/base.css
index d0e8bc4f33e..66034b275dc 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/resources/base.css
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/resources/base.css
@@ -9,6 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr
* Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Generic shape default value implementation. Default symbol implementation.
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 Stereotype Display
*
*****************************************************************************/
@@ -31,3 +32,396 @@ Compartment[kind=symbol]{
showTitle:false;
}
+
+/*
+ * The Actor element icon is not useful either
+ */
+UseCaseDiagram Actor {
+ elementIcon:false;
+}
+
+TimingDiagram * {
+ gradient:none;
+}
+
+/*----------- Stereotype Display --------- */
+Shape[type=StereotypeComment]{
+ visible:false;
+}
+
+Shape[type=StereotypeComment] Compartment[type=StereotypeBrace]{
+ visible:false;
+}
+
+Compartment[type=StereotypeCompartment]{
+ visible:false;
+}
+
+Compartment[type=StereotypeBrace]{
+ visible:false;
+}
+
+Label[type=StereotypeLabel]{
+ depth:"none";
+}
+
+
+/*---------- Default SVG symbols ----------*/
+
+/* Round full */
+StateMachineDiagram Pseudostate[kind="initial"],
+StateMachineDiagram Pseudostate[kind="junction"],
+ActivityDiagram InitialNode,
+InteractionOverviewDiagram InitialNode
+{
+svgFile:"platform:/plugin/org.eclipse.papyrus.infra.gmfdiag.common/icons/symbols/round_full.svg";
+}
+
+ActivityDiagram ActivityFinalNode,
+InteractionOverviewDiagram ActivityFinalNode,
+StateMachineDiagram FinalState
+{
+svgFile:"platform:/plugin/org.eclipse.papyrus.infra.gmfdiag.common/icons/symbols/round_with_dot.svg";
+}
+
+ActivityDiagram FlowFinalNode,
+InteractionOverviewDiagram FlowFinalNode
+{
+svgFile:"platform:/plugin/org.eclipse.papyrus.infra.gmfdiag.common/icons/symbols/round_with_cross.svg";
+}
+
+ActivityDiagram SendSignalAction
+{
+svgFile:"platform:/plugin/org.eclipse.papyrus.infra.gmfdiag.common/icons/symbols/arrow.svg";
+}
+
+StateMachineDiagram Pseudostate[kind="terminate"]
+{
+svgFile:"platform:/plugin/org.eclipse.papyrus.infra.gmfdiag.common/icons/symbols/cross.svg";
+}
+
+ActivityDiagram MergeNode,
+ActivityDiagram DecisionNode,
+InteractionOverviewDiagram MergeNode,
+InteractionOverviewDiagram DecisionNode,
+StateMachineDiagram Pseudostate[kind="choice"],
+ClassDiagram Association
+{
+svgFile:"platform:/plugin/org.eclipse.papyrus.infra.gmfdiag.common/icons/symbols/diamond.svg";
+}
+
+Actor
+{
+svgFile:"platform:/plugin/org.eclipse.papyrus.infra.gmfdiag.common/icons/symbols/stickman.svg";
+}
+
+DurationObservation
+{
+svgFile:"platform:/plugin/org.eclipse.papyrus.uml.diagram.common/icons/symbols/durationObservation.svg";
+}
+
+TimeObservation
+{
+svgFile:"platform:/plugin/org.eclipse.papyrus.uml.diagram.common/icons/symbols/timeObservation.svg";
+}
+
+StateMachineDiagram Pseudostate[kind="shallowHistory"]
+{
+svgFile:"platform:/plugin/org.eclipse.papyrus.uml.diagram.common/icons/symbols/shallowHistory.svg";
+}
+
+StateMachineDiagram Pseudostate[kind="deepHistory"]
+{
+svgFile:"platform:/plugin/org.eclipse.papyrus.uml.diagram.common/icons/symbols/deepHistory.svg";
+}
+
+/*---------- Activity Diagram ----------*/
+
+ActivityDiagram MergeNode,
+ActivityDiagram InitialNode,
+ActivityDiagram ActivityFinalNode,
+ActivityDiagram FlowFinalNode,
+ActivityDiagram DecisionNode,
+ActivityDiagram SendSignalAction,
+ActivityDiagram AcceptEventAction
+{
+ displayBorder:false;
+ displayName:false;
+ diplayIcon:false;
+ displayTag:false;
+ followSVGSymbol:true;
+ maintainSymbolRatio:true;
+ transparency:100;
+ /*displayFloatingLabel:true;*/
+ maxNumberOfSymbol:1;
+ useOriginalColors:false;
+ gradient:none;
+ fillColor:white;
+}
+
+ActivityDiagram InitialNode{
+ fillColor: black;
+}
+
+/*symbol compartment set to visible */
+ActivityDiagram MergeNode > Compartment[kind="symbol"],
+ActivityDiagram InitialNode > Compartment[kind="symbol"],
+ActivityDiagram ActivityFinalNode > Compartment[kind="symbol"],
+ActivityDiagram FlowFinalNode > Compartment[kind="symbol"],
+ActivityDiagram MergeNode > Compartment[kind="symbol"],
+ActivityDiagram SendSignalAction > Compartment[kind="symbol"],
+ActivityDiagram DecisionNode > Compartment[kind="symbol"],
+ActivityDiagram AcceptEventAction > Compartment[kind="symbol"]
+{
+ visible:true;
+}
+
+/*External Label set to visible*/
+ActivityDiagram MergeNode > Label,
+ActivityDiagram InitialNode > Label,
+ActivityDiagram ActivityFinalNode > Label,
+ActivityDiagram FlowFinalNode > Label,
+ActivityDiagram DecisionNode > Label,
+ActivityDiagram SendSignalAction > Label,
+ActivityDiagram ForkNode > Label,
+ActivityDiagram JoinNode > Label
+{
+ visible:true;
+}
+
+ActivityDiagram SendSignalAction,
+ActivityDiagram AcceptEventAction
+{
+ maintainSymbolRatio:false;
+ displayName:true;
+}
+
+ActivityDiagram Activity
+{
+ leftMarginLabel:10;
+ rightMarginLabel:5;
+ topMarginLabel:5;
+ bottomMarginLabel:5;
+}
+
+/* For most Activity diagram nodes (e.g. initial, final, fork, decision, ...),
+ * the element icon is displayed next to the actual object.
+ * By default, we prevent this.
+ *
+ * For standard nodes (OpaqueAction, ...), they are not implemented at all,
+ * so a global selector will not have side effects (yet).
+ */
+ActivityDiagram Activity *,InteractionOverviewDiagram Activity * {
+ elementIcon:false;
+}
+
+/*---------- Class Diagram ----------*/
+ClassDiagram Association
+{
+ displayBorder:false;
+ displayName:false;
+ diplayIcon:false;
+ displayTag:false;
+ followSVGSymbol:true;
+ maintainSymbolRatio:true;
+ transparency:100;
+ displayFloatingLabel:true;
+ maxNumberOfSymbol:1;
+ useOriginalColors:false;
+ gradient:none;
+ fillColor:white;
+}
+
+ClassDiagram Association > Compartment[kind="symbol"],
+ClassDiagram DurationObservation > Compartment[kind="symbol"],
+ClassDiagram TimeObservation > Compartment[kind="symbol"]
+{
+ visible:true;
+}
+
+ClassDiagram Dependency
+{
+ fillColor:Black;
+ gradient:none;
+}
+
+/*---------- UseCase Diagram ----------*/
+UseCaseDiagram UseCase > Compartment {
+ lineLengthRatio:"0.70";
+}
+
+UseCaseDiagram UseCase {
+ topMarginLabel:10;
+}
+
+UseCaseDiagram Actor
+{
+ displayBorder:false;
+ displayName:false;
+ diplayIcon:false;
+ displayTag:false;
+ followSVGSymbol:true;
+ maintainSymbolRatio:true;
+ transparency:100;
+ /*displayFloatingLabel:true;*/
+ maxNumberOfSymbol:1;
+ useOriginalColors:false;
+ gradient:none;
+ fillColor:white;
+}
+
+UseCaseDiagram Actor > Compartment[kind="symbol"]
+{
+ visible:true;
+}
+
+/*---------- Communication Diagram ----------*/
+CommunicationDiagram DurationObservation > Compartment[kind="symbol"],
+CommunicationDiagram TimeObservation > Compartment[kind="symbol"]
+{
+ visible:true;
+}
+CommunicationDiagram Interaction > Compartment
+{
+ lineLength:0;
+}
+
+/*---------- State Machine Diagram ----------*/
+StateMachineDiagram Pseudostate[kind="initial"],
+StateMachineDiagram Pseudostate[kind="junction"],
+StateMachineDiagram Pseudostate[kind="shallowHistory"],
+StateMachineDiagram Pseudostate[kind="terminate"],
+StateMachineDiagram Pseudostate[kind="deepHistory"],
+StateMachineDiagram Pseudostate[kind="choice"],
+StateMachineDiagram FinalState
+{
+ displayBorder:false;
+ displayName:false;
+ diplayIcon:false;
+ displayTag:false;
+ followSVGSymbol:true;
+ maintainSymbolRatio:true;
+ transparency:100;
+ displayFloatingLabel:true;
+ maxNumberOfSymbol:1;
+ useOriginalColors:false;
+ gradient:none;
+ fillColor:white;
+}
+
+StateMachineDiagram Pseudostate[kind="initial"],
+StateMachineDiagram Pseudostate[kind="junction"]
+{
+ gradient:none;
+ fillColor:black;
+}
+
+StateMachineDiagram Pseudostate[kind="initial"] > Label,
+StateMachineDiagram Pseudostate[kind="junction"] > Label,
+StateMachineDiagram Pseudostate[kind="shallowHistory"] > Label,
+StateMachineDiagram Pseudostate[kind="terminate"] > Label,
+StateMachineDiagram Pseudostate[kind="deepHistory"] > Label,
+StateMachineDiagram Pseudostate[kind="choice"] > Label,
+StateMachineDiagram FinalState> Label,
+StateMachineDiagram Pseudostate[kind="exitPoint"] > Label,
+StateMachineDiagram Pseudostate[kind="entryPoint"] > Label,
+StateMachineDiagram Pseudostate[kind="join"] > Label,
+StateMachineDiagram Pseudostate[kind="fork"] > Label
+{
+ visible:true;
+ textAlignment:"Left";
+}
+
+StateMachineDiagram Pseudostate[kind="initial"] > Compartment[kind="symbol"],
+StateMachineDiagram Pseudostate[kind="shallowHistory"] > Compartment[kind="symbol"],
+StateMachineDiagram Pseudostate[kind="terminate"] > Compartment[kind="symbol"],
+StateMachineDiagram Pseudostate[kind="deepHistory"] > Compartment[kind="symbol"],
+StateMachineDiagram Pseudostate[kind="choice"] > Compartment[kind="symbol"],
+StateMachineDiagram Pseudostate[kind="junction"] > Compartment[kind="symbol"],
+StateMachineDiagram FinalState > Compartment[kind="symbol"]
+{
+ visible:true;
+}
+
+StateMachineDiagram Pseudostate[kind="choice"]{
+ maintainSymbolRatio:false;
+}
+
+/*---------- Composite Diagram ---------*/
+
+CompositeStructureDiagram Property[aggregation="shared"]{
+ borderStyle: custom;
+}
+
+CompositeStructureDiagram DurationObservation > Compartment[kind="symbol"],
+CompositeStructureDiagram TimeObservation > Compartment[kind="symbol"]
+{
+ visible:true;
+}
+
+CompositeStructureDiagram DurationObservation > Label,
+CompositeStructureDiagram TimeObservation > Label,
+CompositeStructureDiagram Port > Label
+{
+ visible:true;
+ textAlignment:"left";
+}
+
+
+/*---------- Interaction Overview Diagram ----------*/
+
+InteractionOverviewDiagram MergeNode,
+InteractionOverviewDiagram InitialNode,
+InteractionOverviewDiagram ActivityFinalNode,
+InteractionOverviewDiagram FlowFinalNode,
+InteractionOverviewDiagram DecisionNode
+{
+ displayBorder:false;
+ displayName:false;
+ diplayIcon:false;
+ displayTag:false;
+ followSVGSymbol:true;
+ maintainSymbolRatio:true;
+ transparency:100;
+ maxNumberOfSymbol:1;
+ useOriginalColors:false;
+ gradient:none;
+ fillColor:white;
+}
+
+InteractionOverviewDiagram InitialNode{
+ fillColor:black;
+}
+
+/*symbol compartment set to visible */
+InteractionOverviewDiagram MergeNode > Compartment[kind="symbol"],
+InteractionOverviewDiagram InitialNode > Compartment[kind="symbol"],
+InteractionOverviewDiagram ActivityFinalNode > Compartment[kind="symbol"],
+InteractionOverviewDiagram FlowFinalNode > Compartment[kind="symbol"],
+InteractionOverviewDiagram MergeNode > Compartment[kind="symbol"],
+InteractionOverviewDiagram DecisionNode > Compartment[kind="symbol"],
+InteractionOverviewDiagram SendSignalAction > Compartment[kind="symbol"]
+{
+ visible:true;
+}
+
+/*External Label set to visible*/
+InteractionOverviewDiagram MergeNode > Label,
+InteractionOverviewDiagram InitialNode > Label,
+InteractionOverviewDiagram ActivityFinalNode > Label,
+InteractionOverviewDiagram FlowFinalNode > Label,
+InteractionOverviewDiagram DecisionNode > Label,
+InteractionOverviewDiagram ForkNode > Label,
+InteractionOverviewDiagram JoinNode > Label
+{
+ visible:true;
+}
+
+InteractionOverviewDiagram Activity
+{
+ leftMarginLabel:10;
+ rightMarginLabel:5;
+ topMarginLabel:5;
+ bottomMarginLabel:5;
+}
+
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/GMFElementAdapter.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/GMFElementAdapter.java
index d912d4f4723..3a4432ccc14 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/GMFElementAdapter.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/GMFElementAdapter.java
@@ -67,6 +67,8 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan
public static final String CSS_VALUES_SEPARATOR = " "; //$NON-NLS-1$
+ public CSSDOMSemanticElementHelper helper = CSSDOMSemanticElementHelper.getInstance();
+
/**
* The Semantic Model Element associated to the current styled element
* Might also be a GMF Diagram
@@ -232,7 +234,7 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan
*/
public EObject getSemanticElement() {
if (semanticElement == null) {
- semanticElement = CSSDOMSemanticElementHelper.findSemanticElement(notationElement);
+ semanticElement = helper.findSemanticElement(notationElement);
computePseudoInstances();
listenSemanticElement();
}
@@ -240,7 +242,7 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan
}
private void computePseudoInstances() {
- if (CSSDOMSemanticElementHelper.isFloatingLabel(notationElement)) {
+ if (helper.isFloatingLabel(notationElement)) {
String humanType = NotationTypesMap.instance.getHumanReadableType(notationElement);
if (humanType == null) {
humanType = notationElement.getType();
@@ -287,7 +289,7 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan
if (parentNode == null) {
View gmfElement = notationElement;
while (gmfElement != null) {
- EObject semanticElement = CSSDOMSemanticElementHelper.findSemanticElement(gmfElement);
+ EObject semanticElement = helper.findSemanticElement(gmfElement);
if (semanticElement != this.getSemanticElement()) {
break;
@@ -376,7 +378,7 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan
}
} else if (getNotationElement() instanceof BasicCompartment) {
return "Compartment";
- } else if (CSSDOMSemanticElementHelper.isFloatingLabel(getNotationElement())) {
+ } else if (helper.isFloatingLabel(getNotationElement())) {
return "Label";
} else {
localName = getSemanticElement().eClass().getName();
@@ -520,8 +522,8 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan
* If a notation child element represents the same semantic element
* than self, returns its own children (Recursively).
*/
- protected static Node[] computeChildren(View notationElement, CSSEngine engine) {
- EObject semanticElement = CSSDOMSemanticElementHelper.findSemanticElement(notationElement);
+ protected Node[] computeChildren(View notationElement, CSSEngine engine) {
+ EObject semanticElement = helper.findSemanticElement(notationElement);
List<Node> childList = new LinkedList<Node>();
for (EObject child : notationElement.eContents()) {
if (child instanceof View) {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/DiagramCSSEngine.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/DiagramCSSEngine.java
index c92efa9bf3e..1b10842c426 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/DiagramCSSEngine.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/DiagramCSSEngine.java
@@ -128,7 +128,7 @@ public class DiagramCSSEngine extends ExtendedCSSEngineImpl implements IChangeLi
}
EObject notationElement = getNativeWidget(node);
- View canonicalNotationElement = CSSDOMSemanticElementHelper.findPrimaryView(notationElement);
+ View canonicalNotationElement = CSSDOMSemanticElementHelper.getInstance().findPrimaryView(notationElement);
// Orphaned view
if (canonicalNotationElement.getDiagram() == null) {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/CSSDOMSemanticElementHelper.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/CSSDOMSemanticElementHelper.java
index 31367b0f6f2..37ec09bd06a 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/CSSDOMSemanticElementHelper.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/helper/CSSDOMSemanticElementHelper.java
@@ -16,10 +16,8 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.notation.BasicCompartment;
import org.eclipse.gmf.runtime.notation.Connector;
import org.eclipse.gmf.runtime.notation.DecorationNode;
-import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.Shape;
import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayHelper;
/**
@@ -37,6 +35,29 @@ import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayHelper
public class CSSDOMSemanticElementHelper {
/**
+ * singleton instance
+ */
+ private static CSSDOMSemanticElementHelper elementHelper;
+
+ /** Private Constructor. */
+ protected CSSDOMSemanticElementHelper() {
+
+ }
+
+ /**
+ * Returns the singleton instance of this class
+ *
+ * @return the singleton instance.
+ */
+ public static CSSDOMSemanticElementHelper getInstance() {
+ if (elementHelper == null) {
+ elementHelper = new CSSDOMSemanticElementHelper();
+ }
+ return elementHelper;
+ }
+
+
+ /**
* Returns the semantic element attached to the given notation element
*
* The result element can also be a Diagram
@@ -44,38 +65,19 @@ public class CSSDOMSemanticElementHelper {
* @param notationElement
* @return
*/
- public static EObject findSemanticElement(EObject notationElement) {
+ public EObject findSemanticElement(EObject notationElement) {
if (notationElement == null) {
return null;
}
- // Add diagrams to the DOM model
- if (notationElement instanceof Diagram) {
- return notationElement;
- }
-
- // Add Stereotype Comment
- if (notationElement instanceof Shape) {
- if (StereotypeDisplayHelper.getInstance().isStereotypeComment(notationElement)) {
- return notationElement;
- }
- }
-
// Add compartments to the DOM model
if (notationElement instanceof BasicCompartment) {
return notationElement;
}
- // Add StereotypeProperty to the DOM model
- if (notationElement instanceof DecorationNode) {
- if (StereotypeDisplayHelper.getInstance().isStereotypeProperty(notationElement)) {
- return notationElement;
- }
- }
-
// Add floating labels to the DOM model
if (isFloatingLabel(notationElement)) {
return notationElement;
@@ -128,7 +130,7 @@ public class CSSDOMSemanticElementHelper {
* @param notationElement
* @return
*/
- public static View findPrimaryView(EObject notationElement) {
+ public View findPrimaryView(EObject notationElement) {
return findTopView(notationElement);
}
@@ -139,7 +141,7 @@ public class CSSDOMSemanticElementHelper {
* @param notationElement
* @return
*/
- public static View findTopView(EObject notationElement) {
+ public View findTopView(EObject notationElement) {
EObject semanticElement = findSemanticElement(notationElement);
if (semanticElement == notationElement) {
@@ -168,7 +170,7 @@ public class CSSDOMSemanticElementHelper {
* @return
* True if this is a Floating Label
*/
- public static boolean isFloatingLabel(EObject notationElement) {
+ public boolean isFloatingLabel(EObject notationElement) {
if (!(notationElement instanceof DecorationNode)) {
return false;
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CSSCustomStyleDelegate.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CSSCustomStyleDelegate.java
index 65c174c750f..0b95acfc913 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CSSCustomStyleDelegate.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/provider/CSSCustomStyleDelegate.java
@@ -56,7 +56,8 @@ public class CSSCustomStyleDelegate implements CustomStyle {
* The CSS engine used to handle the custom properties
*/
public CSSCustomStyleDelegate(View view, ExtendedCSSEngine engine) {
- this.view = CSSDOMSemanticElementHelper.findPrimaryView(view);
+
+ this.view = CSSDOMSemanticElementHelper.getInstance().findPrimaryView(view);
this.engine = engine;
this.element = engine.getElement(this.view);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypeOperationDisplayEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypeOperationDisplayEditPolicy.java
index 742dbd1a7cb..b4e3d919794 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypeOperationDisplayEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/policies/AppliedStereotypeOperationDisplayEditPolicy.java
@@ -46,4 +46,6 @@ public class AppliedStereotypeOperationDisplayEditPolicy extends AbstractApplied
// calls the helper for this edit Part
OperationLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart) getHost());
}
+
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF
index 3cf80e81dba..5d8a68c0840 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF
@@ -103,7 +103,9 @@ Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="1.1.0",
org.eclipse.papyrus.emf.facet.custom.core;bundle-version="1.1.0",
org.eclipse.papyrus.infra.gmfdiag.menu;bundle-version="1.1.0",
org.eclipse.e4.ui.css.core,
- org.eclipse.papyrus.infra.gmfdiag.canonical;bundle-version="1.1.0"
+ org.eclipse.papyrus.infra.gmfdiag.canonical;bundle-version="1.1.0",
+ org.eclipse.gmf.runtime.diagram.ui,
+ org.eclipse.gef
Bundle-Vendor: %providerName
Ant-Version: Apache Ant 1.7.0
Bundle-Version: 1.1.0.qualifier
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/UMLConnectionNodeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/UMLConnectionNodeEditPart.java
index d10313fed05..98964d1ad62 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/UMLConnectionNodeEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/UMLConnectionNodeEditPart.java
@@ -22,7 +22,6 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.Request;
import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ConnectionEditPart;
import org.eclipse.papyrus.uml.appearance.helper.AppliedStereotypeHelper;
import org.eclipse.papyrus.uml.appearance.helper.UMLVisualInformationPapyrusConstant;
@@ -31,6 +30,7 @@ import org.eclipse.papyrus.uml.diagram.common.editpolicies.ApplyStereotypeEditPo
import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.figure.edge.UMLEdgeFigure;
import org.eclipse.papyrus.uml.diagram.common.service.ApplyStereotypeRequest;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayHelper;
import org.eclipse.papyrus.uml.tools.listeners.StereotypeElementListener.StereotypeExtensionNotification;
import org.eclipse.swt.graphics.Image;
import org.eclipse.uml2.uml.Element;
@@ -187,22 +187,10 @@ public abstract class UMLConnectionNodeEditPart extends ConnectionEditPart imple
* @return the list of stereotypes to display
*/
public String stereotypesToDisplay() {
- String stereotypesToDisplay = AppliedStereotypeHelper.getStereotypesToDisplay((View) getModel());
- String stereotypespresentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind((View) getModel());
+ String stereotypesToDisplay = StereotypeDisplayHelper.getInstance().getStereotypeTextToDisplay((View) getModel());
- // check the presentation kind. if only icon => do not display
- // stereotypes
- if (UMLVisualInformationPapyrusConstant.ICON_STEREOTYPE_PRESENTATION.equals(stereotypespresentationKind)) {
- return ""; // empty string, so stereotype label should not be
- // displayed
- }
+ return stereotypesToDisplay;
- String stereotypesToDisplayWithQN = AppliedStereotypeHelper.getStereotypesQNToDisplay(((View) getModel()));
- if (UMLVisualInformationPapyrusConstant.STEREOTYPE_TEXT_VERTICAL_PRESENTATION.equals(stereotypespresentationKind)) {
- return stereotypesToDisplay(Activator.ST_RIGHT + "\n" + Activator.ST_LEFT, stereotypesToDisplay, stereotypesToDisplayWithQN);
- } else {
- return stereotypesToDisplay(", ", stereotypesToDisplay, stereotypesToDisplayWithQN);
- }
}
/**
@@ -229,89 +217,6 @@ public abstract class UMLConnectionNodeEditPart extends ConnectionEditPart imple
return null;
}
- /**
- * Computes the string that displays the stereotypes for the current element
- *
- * @param separator
- * the separator used to split the string representing the
- * stereotypes.
- * @param stereotypesToDisplay
- * the list of stereotypes displayed
- * @param stereotypeWithQualifiedName
- * the list of stereotypes displayed using their qualified names
- * @return the string that represent the stereotypes
- */
- public String stereotypesToDisplay(String separator, String stereotypesToDisplay, String stereotypeWithQualifiedName) {
-
- // AL Changes Feb. 07 - Beg
- // Style Handling for STEREOTYPE_NAME_APPEARANCE from
- // ProfileApplicationPreferencePage
- // Stereotype displayed according to UML standard (first letter forced
- // to lower case) -
- // default -
- // or kept as entered by user (user controlled)
-
- // Get the preference from PreferenceStore. there should be an assert
- final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- if (store == null) {
- Activator.log.warn("The preference store was not found");
- return "";
- }
- String sNameAppearance = store.getString(UMLVisualInformationPapyrusConstant.P_STEREOTYPE_NAME_APPEARANCE);
-
- StringTokenizer strQualifiedName = new StringTokenizer(stereotypesToDisplay, ",");
- String out = "";
- while (strQualifiedName.hasMoreElements()) {
- String currentStereotype = strQualifiedName.nextToken();
-
- // check if current stereotype is applied
- final Element umlElement = getUMLElement();
- Stereotype stereotype = umlElement.getAppliedStereotype(currentStereotype);
- if (stereotype != null) {
- String name = currentStereotype;
- if ((stereotypeWithQualifiedName.indexOf(currentStereotype)) == -1) {
- // property value contains qualifiedName ==> extract name
- // from it
- StringTokenizer strToken = new StringTokenizer(currentStereotype, "::");
-
- while (strToken.hasMoreTokens()) {
- name = strToken.nextToken();
- }
- }
- // AL Changes Feb. 07 - Beg
- // Handling STEREOTYPE_NAME_APPEARANCE preference (from
- // ProfileApplicationPreferencePage)
- // Previously lowercase forced onto first letter (standard UML)
- // stereotypesToDisplay = stereotypesToDisplay+name.substring(0,
- // 1).toLowerCase()+name.substring(1,
- // name.length())+","+separator;
-
- // check that the name has not already been added to the
- // displayed string
- if (sNameAppearance.equals(UMLVisualInformationPapyrusConstant.P_STEREOTYPE_NAME_DISPLAY_USER_CONTROLLED)) {
- if (out.indexOf(name) == -1) {
- out = out + name + separator;
- }
- } else { // VisualInformationPapyrusConstants.P_STEREOTYPE_NAME_DISPLAY_UML_CONFORM))
- // {
- name = name.substring(0, 1).toLowerCase() + name.substring(1, name.length());
- if (out.indexOf(name) == -1) {
- out = out + name + separator;
- }
- }
- }
- }
- if (out.endsWith(",")) {
- out = out.substring(0, out.length() - 1);
- }
- if (out.endsWith(separator)) {
- out = out.substring(0, out.length() - separator.length());
- }
- if (out != "") {
- out = Activator.ST_LEFT + out + Activator.ST_RIGHT;
- }
- return out;
- }
/**
* {@inheritDoc}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AbstractAppliedStereotypeDisplayEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AbstractAppliedStereotypeDisplayEditPolicy.java
index b22e74bd8a8..e9e841f381e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AbstractAppliedStereotypeDisplayEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AbstractAppliedStereotypeDisplayEditPolicy.java
@@ -11,48 +11,49 @@
* Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
* Nizar GUEDIDI (CEA LIST) - update getUMLElement()
* Christian W. Damus (CEA) - bug 440197
- * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.fr - Bug 393532
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 393532
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 Stereotype Display
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.editpolicies;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.StringTokenizer;
import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.impl.DynamicEObjectImpl;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.RollbackException;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker;
import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.gef.ui.internal.editpolicies.GraphicalEditPolicyEx;
+import org.eclipse.gmf.runtime.notation.BasicCompartment;
+import org.eclipse.gmf.runtime.notation.DecorationNode;
+import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.core.listenerservice.IPapyrusListener;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.GMFUnsafe;
-import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
import org.eclipse.papyrus.uml.appearance.helper.AppliedStereotypeHelper;
import org.eclipse.papyrus.uml.appearance.helper.UMLVisualInformationPapyrusConstant;
import org.eclipse.papyrus.uml.diagram.common.Activator;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.CreateAppliedStereotypePropertyViewCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.CreateAppliedStereotypeViewCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.CreateStereotypeLabelCommand;
import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayHelper;
-import org.eclipse.papyrus.uml.modelrepair.service.IStereotypeRepairService;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayUtils;
import org.eclipse.papyrus.uml.tools.listeners.StereotypeElementListener.StereotypeExtensionNotification;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Extension;
+import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Stereotype;
-import com.google.common.collect.Lists;
-
/**
* Specific edit policy for label displaying stereotypes and their properties
* for representing UML elements.
@@ -68,6 +69,13 @@ public abstract class AbstractAppliedStereotypeDisplayEditPolicy extends Graphic
/** Helper to manipulate applied Stereotype Display model */
protected StereotypeDisplayHelper helper = StereotypeDisplayHelper.getInstance();
+ protected IGraphicalEditPart hostEditPart;
+
+ protected View hostView = null;
+
+ protected EList<Stereotype> stereotypeList;
+
+
/**
* Creates a new AppliedStereotype display edit policy
*/
@@ -76,117 +84,375 @@ public abstract class AbstractAppliedStereotypeDisplayEditPolicy extends Graphic
}
/**
- * clean stereotype to display in Eannotation this method can be called directly
- * at the activation of this class
+ *
+ * {@inheritDoc}
*/
- protected void cleanStereotypeDisplayInEAnnotation() {
- // Resolve the UML element first, to trigger stereotype repair
- final Element umlElement = getUMLElement();
- Collection<String> missingStereotypes = null;
-
- String stereotypesToDisplay = AppliedStereotypeHelper.getStereotypesToDisplay((View) getHost().getModel());
- StringTokenizer strQualifiedName = new StringTokenizer(stereotypesToDisplay, ",");
- while (strQualifiedName.hasMoreElements()) {
- String currentStereotype = strQualifiedName.nextToken();
- // check if current stereotype is applied
- Stereotype stereotype = umlElement.getAppliedStereotype(currentStereotype);
- if (stereotype == null) {
- if (missingStereotypes == null) {
- missingStereotypes = Lists.newArrayListWithExpectedSize(1);
- }
- missingStereotypes.add(currentStereotype);
+ @Override
+ public void activate() {
+
+ if (getHost() instanceof IGraphicalEditPart) {
+ initialisation();
+ // getDiagramEventBroker().addNotificationListener(view, this);
+ getDiagramEventBroker().addNotificationListener(hostSemanticElement, this);
+
+ // Create and Delete nodes if necessary
+ refreshNotationStructure();
+
+ }
+
+ }
+
+ /**
+ * Initialize Variables.
+ */
+ private void initialisation() {
+ hostEditPart = (IGraphicalEditPart) getHost();
+ hostSemanticElement = getUMLElement();
+ hostView = hostEditPart.getNotationView();
+ if (hostSemanticElement != null) {
+ stereotypeList = hostSemanticElement.getAppliedStereotypes();
+ }
+ }
+
+
+
+ /**
+ * @see org.eclipse.gmf.runtime.gef.ui.internal.editpolicies.GraphicalEditPolicyEx#refresh()
+ * This method must extend GraphicalEditPolicyEx, in order to call the edit policy refresh method when the EditPart is Refreshed
+ */
+ @Override
+ public void refresh() {
+
+ initialisation();
+ refreshDisplay();
+ }
+
+ /**
+ * Refreshes the display for the element controlled by the edit part with
+ * this edit policies
+ */
+ public abstract void refreshDisplay();
+
+
+
+ /**
+ *
+ * {@inheritedDoc}
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+
+ int eventType = notification.getEventType();
+
+ if (eventType == StereotypeExtensionNotification.STEREOTYPE_APPLIED_TO_ELEMENT) {
+ initialisation();
+ refreshNotationStructure();
+
+ } else if (eventType == StereotypeExtensionNotification.STEREOTYPE_UNAPPLIED_FROM_ELEMENT) {
+ initialisation();
+ refreshNotationStructure();
+ }
+ }
+
+ /**
+ * Create the Notation Structure according to the UML Model for the Stereotypes
+ */
+ public void refreshNotationStructure() {
+
+ if (hostView != null) {
+
+ removeUnappliedStereotypes(hostView);
+
+ if (!stereotypeList.isEmpty()) {
+ refreshStereotypeStructure();
}
}
+ }
- if (missingStereotypes != null) {
- final Collection<String> _missingStereotypes = missingStereotypes;
- Runnable cleanStereotypesOperation = new Runnable() {
+ /**
+ * Refresh the NotationStructure of the Node for the StereotypeList
+ *
+ */
+ public void refreshStereotypeStructure() {
- @Override
- public void run() {
- doCleanStereotypeDisplay(umlElement, _missingStereotypes);
- }
- };
-
- try {
- // In case there are stereotypes being repaired, we should postpone cleaning up stereotype display until after
- // the repair has finished, because the stereotypes we find missing may not be missing, after all
- IStereotypeRepairService repair = ServiceUtilsForEditPart.getInstance().getService(IStereotypeRepairService.class, getHost());
- repair.getPostRepairExecutor().execute(cleanStereotypesOperation);
- } catch (ServiceException e) {
- // Fine. No service? Then we're not repairing anything, obviously
- cleanStereotypesOperation.run();
+ // rebuild the structure from the Stereotype List
+ if (!stereotypeList.isEmpty()) {
+ for (Stereotype stereotype : stereotypeList) {
+ refreshStereotypeLabelStructure(stereotype);
+ refreshStereotypeBraceStructure(stereotype);
}
}
}
- protected void doCleanStereotypeDisplay(Element umlElement, Collection<String> missingStereotypes) {
- for (String currentStereotype : missingStereotypes) {
- // check if current stereotype is applied (stereotype repair may have restored it)
- Stereotype stereotype = umlElement.getAppliedStereotype(currentStereotype);
- if (stereotype == null) {
- removeEAnnotationAboutStereotype(currentStereotype);
- } else {
- // The stereotype was repaired, so refresh
- refreshDisplay();
+ /**
+ * Refresh Brace Compartment and Properties Structure into notation model.
+ *
+ * @param stereotype
+ * The stereotype for which the Structure is Refreshed
+ */
+ public void refreshStereotypeBraceStructure(Stereotype stereotype) {
+ BasicCompartment compartment = helper.getStereotypeBraceCompartment(hostView, stereotype);
+ if (compartment == null) { // No Label Exist for this Stereotype
+ createAppliedStereotypeBraceCompartment(stereotype);
+ createAppliedStereotypeBraceProperties(stereotype);
+
+ }
+
+ }
+
+ /**
+ * Refresh The StereotypeLabel notation structure.
+ *
+ * @param stereotype
+ * The stereotype of which the Label has to be refreshed.
+ */
+ public void refreshStereotypeLabelStructure(Stereotype stereotype) {
+
+ DecorationNode label = helper.getStereotypeLabel(hostView, stereotype);
+ if (label == null) { // No Label Exist for this Stereotype
+ createAppliedStereotypeLabel(stereotype);
+ }
+ }
+
+ /**
+ * Returns the image to be displayed for the applied stereotypes.
+ *
+ * @return the image that represents the first applied stereotype or <code>null</code> if no image has to be displayed
+ */
+ public Image stereotypeIconToDisplay() {
+ Image icon = null;
+ String stereotypespresentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind((View) getHost().getModel());
+ if (stereotypespresentationKind == null) {
+ icon = null;
+ }
+ if (stereotypespresentationKind.equals(UMLVisualInformationPapyrusConstant.ICON_STEREOTYPE_PRESENTATION) || stereotypespresentationKind.equals(UMLVisualInformationPapyrusConstant.TEXT_ICON_STEREOTYPE_PRESENTATION)) {
+ // retrieve the first stereotype in the list of displayed stereotype
+ String stereotypesToDisplay = AppliedStereotypeHelper.getStereotypesToDisplay((View) getHost().getModel());
+ StringTokenizer tokenizer = new StringTokenizer(stereotypesToDisplay, ",");
+ if (tokenizer.hasMoreTokens()) {
+ String firstStereotypeName = tokenizer.nextToken();
+ Stereotype stereotype = getUMLElement().getAppliedStereotype(firstStereotypeName);
+ icon = Activator.getIconElement(getUMLElement(), stereotype, false);
}
}
+ return icon;
}
/**
+ * This method creates a node for the compartment of stereotype if it does not exist.
*
- * {@inheritDoc}
+ * @param stereotype
+ * the stereotype of which the Label is created
*/
- @Override
- public void activate() {
- // retrieve the view and the element managed by the edit part
- View view = getView();
- if (view == null) {
- return;
+ protected void createAppliedStereotypeLabel(final Stereotype stereotype) {
+
+ final View node = hostEditPart.getNotationView();
+ // create only if the Label doesn't exist yet
+ if (!helper.isLabelExist(node, stereotype)) {
+ // Create the Decoration Node
+ executeStereotypeLabelCreation(hostEditPart, stereotype);
}
- hostSemanticElement = getUMLElement();
- // adds a listener on the view and the element controlled by the
- // editPart
- getDiagramEventBroker().addNotificationListener(view, this);
- if (hostSemanticElement == null) {
- return;
+ }
+
+
+ /**
+ * This method creates a node for the compartment of stereotype if it does not exist.
+ *
+ * @param stereotypeApplication
+ * the stereotype application
+ */
+ protected void createAppliedStereotypeBraceCompartment(final Stereotype stereotype) {
+ final View node = hostEditPart.getNotationView();
+ // doesn't exist already
+ if (!helper.isBraceCompartmentExist(node, stereotype)) {
+ // Create Compartment
+ executeAppliedStereotypeBraceCompartmentCreation(hostEditPart, stereotype);
+
}
- 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);
+ }
+
+ /**
+ * In charge of properties view creation
+ *
+ * @param stereotype
+ * The stereotype of which the Properties should be created
+ */
+ protected void createAppliedStereotypeBraceProperties(final Stereotype stereotype) {
+
+ Node compartment = helper.getStereotypeBraceCompartment(hostEditPart.getNotationView(), stereotype);
+ if (compartment != null && stereotype != null) {
+
+ EList<Property> properties = stereotype.allAttributes();
+ for (Property property : properties) {
+ createAppliedStereotypeBraceProperty(compartment, property);
+ }
}
- refreshDisplay();
+ }
+
+
+
+ /**
+ * In Charge of PropertyView Creation
+ *
+ * @param compartment
+ * The Compartment owner of the Property that will be created
+ * @param property
+ * The UML Property of the View to create
+ */
+ protected void createAppliedStereotypeBraceProperty(Node compartment, Property property) {
+ // if stereotype is null all property of stereotype has to be removed!
+ if (property != null && !property.getName().startsWith(Extension.METACLASS_ROLE_PREFIX)) {
+ if (!helper.isBracePropertyExist(compartment, property)) {
+ // go through each stereotype property
+ executeAppliedStereotypeBracePropertyViewCreation(hostEditPart, compartment, property);
+ }
+ }
}
/**
+ * List on all the existing node contained into the main view.
+ * For each node related to the stereotype structure, check if the related Stereotype is still applied
+ * If no, remove the non relevant node.
+ *
+ * @param view
+ * The main parent view of the host EditPart
+ */
+ protected void removeUnappliedStereotypes(View view) {
+
+ if (view != null) {
+ List<Object> children = new ArrayList<Object>(view.getChildren());
+ Iterator<Object> iter = children.iterator();
+ while (iter.hasNext()) {
+ Object child = iter.next();
+ if (helper.isStereotypeView(child)) {
+ if (((View) child).getElement() instanceof Stereotype) {
+ Stereotype childStereotype = (Stereotype) ((View) child).getElement();
+ if (!hostSemanticElement.isStereotypeApplied(childStereotype)) {
+ executeStereotypeViewRemove(hostEditPart, (View) child);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * The goal of this method is to execute the a command to create a notation node for a compartment of stereotype
*
- * {@inheritDoc}
+ * @param editPart
+ * the editPart owner of the new compartment
+ * @param appliedstereotype
+ * the stereotype application
*/
- @Override
- public void deactivate() {
- // retrieve the view and the element managed by the edit part
- View view = getView();
- if (view == null) {
- return;
+ protected void executeAppliedStereotypeBraceCompartmentCreation(final IGraphicalEditPart editPart, final Stereotype stereotype) {
+ try {
+ editPart.getEditingDomain().runExclusive(new Runnable() {
+
+ @Override
+ public void run() {
+ Display.getCurrent().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ CreateAppliedStereotypeViewCommand command = new CreateAppliedStereotypeViewCommand(editPart.getEditingDomain(), editPart.getNotationView(), stereotype, StereotypeDisplayUtils.STEREOTYPE_BRACE_TYPE);
+
+ // use to avoid to put it in the command stack
+ try {
+ GMFUnsafe.write(editPart.getEditingDomain(), command);
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+ });
+
+ }
+ });
+ } catch (Exception e) {
+ Activator.log.error(e);
}
- getDiagramEventBroker().removeNotificationListener(view, this);
- if (hostSemanticElement == null) {
- return;
+ }
+
+
+ /**
+ * This method is used to create a notation node for the property of the stereotype.
+ *
+ * @param editPart
+ * the editPart container
+ * @param compartment
+ * @param stereotypeApplication
+ * @param stereotype
+ * the stereotype associated to compartment node
+ */
+ protected void executeAppliedStereotypeBracePropertyViewCreation(final IGraphicalEditPart editPart, final Node compartment, final Property stereotypeProperty) {
+ try {
+ editPart.getEditingDomain().runExclusive(new Runnable() {
+
+ @Override
+ public void run() {
+ Display.getCurrent().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+
+ // use to avoid to put it in the command stack
+ CreateAppliedStereotypePropertyViewCommand command = new CreateAppliedStereotypePropertyViewCommand(editPart.getEditingDomain(), compartment, stereotypeProperty, StereotypeDisplayUtils.STEREOTYPE_PROPERTY_BRACE_TYPE);
+ try {
+ GMFUnsafe.write(editPart.getEditingDomain(), command);
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+ });
+ }
+ });
+
+ } catch (Exception e) {
+ Activator.log.error(e);
}
- // remove listeners to applied stereotyped
- for (EObject stereotypeApplication : hostSemanticElement.getStereotypeApplications()) {
- getDiagramEventBroker().removeNotificationListener(stereotypeApplication, this);
+ }
+
+
+
+
+ /**
+ * The goal of this method is to execute the a command to create a notation node for a stereotype Label.
+ *
+ * @param editPart
+ * The editPart owner of the new compartment
+ * @param stereotype
+ * The stereotype related to the Label
+ */
+ protected void executeStereotypeLabelCreation(final IGraphicalEditPart editPart, final Stereotype stereotype) {
+ try {
+ editPart.getEditingDomain().runExclusive(new Runnable() {
+ @Override
+ public void run() {
+ Display.getCurrent().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+
+ CreateStereotypeLabelCommand command = new CreateStereotypeLabelCommand(editPart.getEditingDomain(), editPart.getNotationView(), stereotype);
+ // use to avoid to put it in the command stack
+ try {
+ GMFUnsafe.write(editPart.getEditingDomain(), command);
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+ });
+
+ }
+ });
+ } catch (Exception e) {
+ Activator.log.error(e);
}
- // remove notification on element
- getDiagramEventBroker().removeNotificationListener(hostSemanticElement, this);
- // removes the reference to the semantic element
- hostSemanticElement = null;
}
+
+
+
/**
* Gets the diagram event broker from the editing domain.
*
@@ -222,157 +488,58 @@ public abstract class AbstractAppliedStereotypeDisplayEditPolicy extends Graphic
return (View) getHost().getModel();
}
- protected void removeEAnnotationAboutStereotype(final String stereotypeQN) {
+ /**
+ * Execute the command to remove the Stereotype.
+ *
+ * @param editPart
+ * Edit Part on which the command is executed
+ * @param label
+ * DecorationNode of the Stereotype Label that has to be removed
+ */
+ protected void executeStereotypeViewRemove(final IGraphicalEditPart editPart, final View view) {
try {
- if (getView() != null) {
- final TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(getView());
- if (editingDomain != null) {
- editingDomain.runExclusive(new Runnable() {
+ TransactionUtil.getEditingDomain(getView()).runExclusive(new Runnable() {
- @Override
- public void run() {
- Display.getCurrent().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- if (getView() != null && editingDomain != null) {
- String presentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(getView());
- final RecordingCommand command = AppliedStereotypeHelper.getRemoveAppliedStereotypeCommand(editingDomain, getView(), stereotypeQN, presentationKind);
-
- // This repair operation shouldn't go on the undo history because the user didn't initiate it.
- // Also, we don't want to prompt the user for write access to a read-only diagram because it
- // won't matter whether the change can't be saved: we'll just clean up again the next time
- try {
- GMFUnsafe.write(editingDomain, new Runnable() {
-
- @Override
- public void run() {
- command.execute();
- }
- });
- } catch (RollbackException e) {
- // This really shouldn't happen because it's just too simple a command
- Activator.log.error(e);
- } catch (InterruptedException e) {
- Activator.log.error(e);
- }
- }
- }
- });
- }
- });
+ @Override
+ public void run() {
+ DeleteCommand command = new DeleteCommand(view);
+ // use to avoid to put it in the command stack
+ try {
+ GMFUnsafe.write(editPart.getEditingDomain(), command);
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
}
- }
- } catch (InterruptedException e) {
- Activator.log.error(e);
- }
- }
+ });
- /**
- *
- * {@inheritedDoc}
- */
- @Override
- public void notifyChanged(Notification notification) {
- // change the label of the figure managed by the host edit part (managed
- // by the parent edit
- // part in general...)
- // it must be changed only if:
- // - the annotation corresponding to the display of the stereotype
- // changes
- // - the stereotype application list has changed
- final int eventType = notification.getEventType();
- if (eventType == StereotypeExtensionNotification.STEREOTYPE_APPLIED_TO_ELEMENT) {
- // a stereotype was applied to the notifier
- // then a new listener should be added to the stereotype application
- getDiagramEventBroker().addNotificationListener((EObject) notification.getNewValue(), this);
- } else if (eventType == StereotypeExtensionNotification.STEREOTYPE_UNAPPLIED_FROM_ELEMENT) {
- getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this);
- cleanStereotypeDisplayInEAnnotation();
- }
- // if element that has changed is a stereotype => refresh the label.
- if (notification.getNotifier() instanceof EAnnotation) {
- if (UMLVisualInformationPapyrusConstant.STEREOTYPE_ANNOTATION == ((EAnnotation) notification.getNotifier()).getSource()) {
- // stereotype annotation has changed => refresh label display
- refreshDisplay();
- }
- }
- // if element that has changed is a stereotype => refresh the label.
- if ((eventType == StereotypeExtensionNotification.MODIFIED_STEREOTYPE_OF_ELEMENT)) {
- // stereotype annotation has changed => refresh label display
- refreshDisplay();
- }
- // The value of a property of stereotype (dynamic profile) has changed
- // To avoid refresh to be called during stereotype removal (stereotype#base_xxx set to null in particular) a complementary test is
- // added here to ensure the stereotype is still applied (the notifier is a stereotype application of the semantic element).
- if ((notification.getNotifier() instanceof DynamicEObjectImpl) && (hostSemanticElement != null) && (hostSemanticElement.getStereotypeApplications().contains(notification.getNotifier()))) {
- refreshDisplay();
+ } catch (Exception e) {
+ Activator.log.error(e);
}
}
- /**
- * Refreshes the display for the element controlled by the edit part with
- * this edit policies
- */
- public abstract void refreshDisplay();
/**
- * @see org.eclipse.gmf.runtime.gef.ui.internal.editpolicies.GraphicalEditPolicyEx#refresh()
- * This method must extend GraphicalEditPolicyEx, in order to call the edit policy refresh method when the EditPart is Refreshed
+ *
+ * {@inheritDoc}
*/
@Override
- public void refresh() {
- refreshDisplay();
- }
+ public void deactivate() {
+ // retrieve the view and the element managed by the edit part
+ View view = getView();
+ if (view != null) {
+ getDiagramEventBroker().removeNotificationListener(view, this);
+ if (hostSemanticElement != null) {
- /**
- * Parses the string containing the complete definition of properties to be
- * displayed, and generates a map.
- *
- * @param stereotypesToDisplay
- * the list of stereotypes to display
- * @param stereotypesPropertiesToDisplay
- * the properties of stereotypes to display
- * @return a map. The keys are the name of displayed stereotypes, the
- * corresponding data is a collection of its properties to be
- * displayed
- */
- protected Map<String, List<String>> parseStereotypeProperties(String stereotypesToDisplay, String stereotypesPropertiesToDisplay) {
- Map<String, List<String>> propertiesMap = new HashMap<String, List<String>>();
- StringTokenizer stringTokenizer = new StringTokenizer(stereotypesPropertiesToDisplay, UMLVisualInformationPapyrusConstant.STEREOTYPE_PROPERTIES_LIST_SEPARATOR);
- while (stringTokenizer.hasMoreTokens()) {
- String propertyName = stringTokenizer.nextToken();
- // retrieve the name of the stereotype for this property
- String stereotypeName = propertyName.substring(0, propertyName.lastIndexOf(".")); // stereotypequalifiedName.propertyname
- if (!propertiesMap.containsKey(stereotypeName)) {
- List<String> propertiesForStereotype = new ArrayList<String>();
- propertiesMap.put(stereotypeName, propertiesForStereotype);
+ // 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;
}
- propertiesMap.get(stereotypeName).add(propertyName.substring(propertyName.lastIndexOf(".") + 1, propertyName.length()));
}
- return propertiesMap;
}
- /**
- * Returns the image to be displayed for the applied stereotypes.
- *
- * @return the image that represents the first applied stereotype or <code>null</code> if no image has to be displayed
- */
- public Image stereotypeIconToDisplay() {
- String stereotypespresentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind((View) getHost().getModel());
- if (stereotypespresentationKind == null) {
- return null;
- }
- if (stereotypespresentationKind.equals(UMLVisualInformationPapyrusConstant.ICON_STEREOTYPE_PRESENTATION) || stereotypespresentationKind.equals(UMLVisualInformationPapyrusConstant.TEXT_ICON_STEREOTYPE_PRESENTATION)) {
- // retrieve the first stereotype in the list of displayed stereotype
- String stereotypesToDisplay = AppliedStereotypeHelper.getStereotypesToDisplay((View) getHost().getModel());
- StringTokenizer tokenizer = new StringTokenizer(stereotypesToDisplay, ",");
- if (tokenizer.hasMoreTokens()) {
- String firstStereotypeName = tokenizer.nextToken();
- Stereotype stereotype = getUMLElement().getAppliedStereotype(firstStereotypeName);
- return Activator.getIconElement(getUMLElement(), stereotype, false);
- }
- }
- return null;
- }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeExternalNodeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeExternalNodeEditPolicy.java
index efb168b467f..9c60341b523 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeExternalNodeEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeExternalNodeEditPolicy.java
@@ -10,6 +10,7 @@
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Patrick Tessier (CEA LIST) - Initial API and implementation
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 Stereotype Display
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.editpolicies;
@@ -17,10 +18,8 @@ import org.eclipse.draw2d.IFigure;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
-import org.eclipse.papyrus.uml.appearance.helper.AppliedStereotypeHelper;
-import org.eclipse.papyrus.uml.appearance.helper.UMLVisualInformationPapyrusConstant;
import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusUMLElementFigure;
-import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil;
+import org.eclipse.uml2.uml.Stereotype;
/**
* This edit policy is used to display only applied stereotypes and properties
@@ -88,24 +87,27 @@ public class AppliedStereotypeExternalNodeEditPolicy extends AppliedStereotypeLa
}
// try to display stereotype properties
- String stereotypesPropertiesToDisplay = AppliedStereotypeHelper.getAppliedStereotypesPropertiesToDisplay(parentView);
String stereotypesToDisplay = helper.getStereotypeTextToDisplay(parentView);
- String stereotypespresentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(parentView);
-
+ return stereotypesToDisplay;
+ }
- // check the presentation kind. if only icon => do not display
- // stereotype, only values
- if (UMLVisualInformationPapyrusConstant.ICON_STEREOTYPE_PRESENTATION.equals(stereotypespresentationKind)) {
- return StereotypeUtil.getPropertiesValuesInBrace(stereotypesPropertiesToDisplay, getUMLElement());
- }
- return stereotypesToDisplay;
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy#refreshStereotypeBraceStructure(org.eclipse.uml2.uml.Stereotype)
+ *
+ * @param stereotype
+ * Stereotype related to the Brace to refresh
+ */
+ @Override
+ public void refreshStereotypeBraceStructure(Stereotype stereotype) {
+ // Nothing to Do
}
+
+
/**
* Refresh the text of the stereotype
*/
-
@Override
protected void refreshStereotypeDisplay() {
if (getHost() instanceof IPapyrusEditPart) {
@@ -114,8 +116,10 @@ public class AppliedStereotypeExternalNodeEditPolicy extends AppliedStereotypeLa
if (figure instanceof IPapyrusUMLElementFigure) {// calculate text
// and icon to display
final String stereotypesToDisplay = stereotypesToDisplay();
- ((IPapyrusUMLElementFigure) figure).setStereotypeDisplay(tag + (stereotypesToDisplay == null ? "" : stereotypesToDisplay), null);
+ ((IPapyrusUMLElementFigure) figure).setStereotypeDisplay(tag + (stereotypesToDisplay), null);
+
}
+
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeLabelDisplayEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeLabelDisplayEditPolicy.java
index 1638064687a..4f66d31474b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeLabelDisplayEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeLabelDisplayEditPolicy.java
@@ -13,42 +13,8 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.editpolicies;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.BasicCompartment;
-import org.eclipse.gmf.runtime.notation.DecorationNode;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
-import org.eclipse.papyrus.infra.gmfdiag.common.utils.GMFUnsafe;
-import org.eclipse.papyrus.uml.appearance.helper.AppliedStereotypeHelper;
-import org.eclipse.papyrus.uml.appearance.helper.UMLVisualInformationPapyrusConstant;
import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.CreateAppliedStereotypePropertyViewCommand;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.CreateAppliedStereotypeViewCommand;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.CreateStereotypeLabelCommand;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayUtils;
-import org.eclipse.papyrus.uml.tools.listeners.StereotypeElementListener.StereotypeExtensionNotification;
-import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Extension;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.Usage;
-import org.eclipse.uml2.uml.util.UMLUtil;
/**
* Specific edit policy for label displaying stereotypes and their properties
@@ -66,20 +32,6 @@ public abstract class AppliedStereotypeLabelDisplayEditPolicy extends AbstractAp
public String tag;
/**
- * Map between Stereotype Name and StereotypeLabel displayed
- */
- private Map<EObject, DecorationNode> stereotypeMap = new HashMap<EObject, DecorationNode>();
-
- /**
- * Map between Stereotype Name and StereotypeLabel displayed
- */
- private Map<EObject, BasicCompartment> stereotypePropertyMap = new HashMap<EObject, BasicCompartment>();
-
-
- private GraphicalEditPart hostEditPart;
-
-
- /**
* Creates a new AppliedStereotypeLabelDisplayEditPolicy, with the specified
* tag for the element.
*
@@ -100,20 +52,6 @@ public abstract class AppliedStereotypeLabelDisplayEditPolicy extends AbstractAp
this.tag = "";
}
- /**
- * @return the stereotypePropertyMap
- */
- public Map<EObject, BasicCompartment> getStereotypePropertyMap() {
- return stereotypePropertyMap;
- }
-
- /**
- * @param stereotypePropertyMap
- * the stereotypePropertyMap to set
- */
- public void setStereotypePropertyMap(Map<EObject, BasicCompartment> stereotypePropertyMap) {
- this.stereotypePropertyMap = stereotypePropertyMap;
- }
/**
* {@inheritDoc}
@@ -123,490 +61,20 @@ public abstract class AppliedStereotypeLabelDisplayEditPolicy extends AbstractAp
refreshStereotypeDisplay();
}
- @Override
- public void activate() {
- super.activate();
- if (getHost() instanceof GraphicalEditPart) {
- hostEditPart = (GraphicalEditPart) getHost();
- }
- // if stereotype has been applied, compartment has to be created
- Element umlElement = getUMLElement();
- // umlElement may be null if the semantic element has been deleted and the view hasn't been cleaned
- if (umlElement != null) {
- Iterator<EObject> iterator = umlElement.getStereotypeApplications().iterator();
- while (iterator.hasNext()) {
- final EObject appliedstereotype = iterator.next();
- createAppliedStereotypeLabel(appliedstereotype);
- createAppliedStereotypeCompartment(appliedstereotype);
- createAppliedStereotypeProperty(appliedstereotype);
- }
- }
- }
-
- /**
- *
- * {@inheritedDoc}
- */
- @Override
- public void notifyChanged(Notification notification) {
- // change the label of the figure managed by the host edit part (managed
- // by the parent edit part in general...)
- // it must be changed only if:
- // - the stereotype application list has changed
- final int eventType = notification.getEventType();
-
- if (eventType == StereotypeExtensionNotification.STEREOTYPE_APPLIED_TO_ELEMENT) {
- // a stereotype was applied to the notifier
- // then a new listener should be added to the stereotype application
- getDiagramEventBroker().addNotificationListener((EObject) notification.getNewValue(), this);
- createAppliedStereotypeLabel((EObject) notification.getNewValue());
- createAppliedStereotypeCompartment((EObject) notification.getNewValue());
- createAppliedStereotypeProperty((EObject) notification.getNewValue());
-
- // Store entry in the Map
- storeInMap((EObject) notification.getNewValue(), hostEditPart.getNotationView());
-
-
- } else if (eventType == StereotypeExtensionNotification.STEREOTYPE_UNAPPLIED_FROM_ELEMENT) {
- getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this);
- removeAppliedStereotypeLabel((EObject) notification.getOldValue());
- removeAppliedStereotypeCompartment((EObject) notification.getOldValue());
-
- // delete entry in the Map
- deleteInMap((EObject) notification.getOldValue());
-
- }
-
- }
-
- /**
- * Returns the image to be displayed for the applied stereotypes.
- *
- * @return the image that represents the first applied stereotype or <code>null</code> if no image has to be displayed
- */
- @Override
- public Image stereotypeIconToDisplay() {
- String stereotypespresentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind((View) getHost().getModel());
- if (stereotypespresentationKind == null) {
- return null;
- }
- if (stereotypespresentationKind.equals(UMLVisualInformationPapyrusConstant.ICON_STEREOTYPE_PRESENTATION) || stereotypespresentationKind.equals(UMLVisualInformationPapyrusConstant.TEXT_ICON_STEREOTYPE_PRESENTATION)) {
-
- // retrieve the first stereotype in the list of displayed stereotype
- String stereotypesToDisplay = AppliedStereotypeHelper.getStereotypesToDisplay((View) getHost().getModel());
- StringTokenizer tokenizer = new StringTokenizer(stereotypesToDisplay, ",");
- if (tokenizer.hasMoreTokens()) {
- String firstStereotypeName = tokenizer.nextToken();
- Stereotype stereotype = getUMLElement().getAppliedStereotype(firstStereotypeName);
- return Activator.getIconElement(getUMLElement(), stereotype, false);
- }
- }
- return null;
- }
-
- /**
- * Returns a String that displays stereotypes (using their simple name or
- * their qualified name) and their properties
- *
- * @param separator
- * the separator used to split the string representing the
- * stereotypes.
- * @param stereotypesToDisplay
- * the list of stereotypes displayed
- * @param stereotypeWithQualifiedName
- * the list of stereotypes displayed using their qualified names
- * @param stereotypesPropertiesToDisplay
- * the list of properties to display
- * @return a string that displays stereotypes (using their simple name or
- * their qualified name) and their properties
- */
- public String stereotypesAndPropertiesToDisplay(String separator, String stereotypesToDisplay, String stereotypesPropertiesToDisplay) {
- // Get the preference from PreferenceStore. there should be an assert
- final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- if (store == null) {
- Activator.log.warn("The preference store was not found");
- return "";
- }
-
- // changes the string of properties into a map, where the entries of the
- // map are the stereotype qualified name, and the properties to display are the data
- Map<String, List<String>> propertiesToDisplay = parseStereotypeProperties(stereotypesToDisplay, stereotypesPropertiesToDisplay);
-
- StringTokenizer strQualifiedName = new StringTokenizer(stereotypesToDisplay, StereotypeDisplayUtils.STEREOTYPE_LABEL_SEPARATOR);
- String out = "";
- while (strQualifiedName.hasMoreElements()) {
- String currentStereotype = strQualifiedName.nextToken();
-
- // check if current stereotype is applied
- final Element umlElement = getUMLElement();
- Stereotype stereotype = umlElement.getAppliedStereotype(currentStereotype);
- if (stereotype != null) {
-
- // now should add all properties associated to this stereotype
- List<String> properties = propertiesToDisplay.get(stereotype.getQualifiedName());
- if (properties != null) {
- // retrieve property
- for (String propertyName : properties) {
- out = out + StereotypeUtil.displayPropertyValue(stereotype, StereotypeUtil.getPropertyByName(stereotype, propertyName), getUMLElement(), "\n");
- }
- }
- }
- }
- if (out.endsWith(",")) {
- return out.substring(0, out.length() - 1);
- }
- if (out.endsWith(separator)) {
- return out.substring(0, out.length() - separator.length());
- }
- return out;
- }
-
- /**
- * Get the list of stereotype to display.
- *
- * @return the list of stereotypes to display
- */
- public String stereotypesToDisplay() {
-
- // try to display stereotype properties
- String stereotypesToDisplay = helper.getStereotypeTextToDisplay((View) getHost().getModel());
- return stereotypesToDisplay;
- }
-
- /**
- * @return the stereotypeMap
- */
- public Map<EObject, DecorationNode> getStereotypeMap() {
- return stereotypeMap;
- }
-
- /**
- * @param stereotypeMap
- * the stereotypeMap to set
- */
- public void setStereotypeMap(Map<EObject, DecorationNode> stereotypeMap) {
- this.stereotypeMap = stereotypeMap;
- }
-
-
/**
- * the goal of this method is to execute the a command to create a notation node for a compartment of stereotype
- *
- * @param editPart
- * the editPart owner of the new compartment
- * @param appliedstereotype
- * the stereotype application
- */
- protected void executeAppliedStereotypeCompartmentCreation(final GraphicalEditPart editPart, final EObject stereotypeApplication) {
- try {
- editPart.getEditingDomain().runExclusive(new Runnable() {
-
- @Override
- public void run() {
- Display.getCurrent().syncExec(new Runnable() {
-
- @Override
- public void run() {
- CreateAppliedStereotypeViewCommand command = new CreateAppliedStereotypeViewCommand(editPart.getEditingDomain(), editPart.getNotationView(), stereotypeApplication);
-
- // use to avoid to put it in the command stack
- try {
- GMFUnsafe.write(editPart.getEditingDomain(), command);
- } catch (Exception e) {
- Activator.log.error(e);
- }
- }
- });
-
- }
- });
- } catch (Exception e) {
- Activator.log.error(e);
- }
- }
-
-
- /**
- * this method is used to create a notation node for the property of the stereotype
- *
- * @param editPart
- * the editPart container
- * @param compartment
- * @param stereotypeApplication
- * @param stereotype
- * the stereotype associated to compartment node
- */
- protected void executeAppliedStereotypePropertyViewCreation(final GraphicalEditPart editPart, final Node compartment, final Property stereotypeProperty) {
- try {
- editPart.getEditingDomain().runExclusive(new Runnable() {
-
- @Override
- public void run() {
- Display.getCurrent().syncExec(new Runnable() {
-
- @Override
- public void run() {
-
- // use to avoid to put it in the command stack
- CreateAppliedStereotypePropertyViewCommand command = new CreateAppliedStereotypePropertyViewCommand(editPart.getEditingDomain(), compartment, stereotypeProperty);
- try {
- GMFUnsafe.write(editPart.getEditingDomain(), command);
- } catch (Exception e) {
- Activator.log.error(e);
- }
- }
- });
- }
- });
-
- } catch (Exception e) {
- Activator.log.error(e);
- }
- }
-
-
- /**
- * Execute the command to remove the Stereotype Compartment with Properties.
- *
- * @param editPart
- * Edit Part on which the command is executed
- * @param label
- * DecorationNode of the Stereotype Label that has to be removed
- */
- protected void executeAppliedStereotypeCompartmentRemove(final GraphicalEditPart editPart, final View compartment) {
- try {
-
- editPart.getEditingDomain().runExclusive(new Runnable() {
-
- @Override
- public void run() {
- DeleteCommand command = new DeleteCommand(compartment);
- // use to avoid to put it in the command stack
- try {
- GMFUnsafe.write(editPart.getEditingDomain(), command);
- } catch (Exception e) {
- Activator.log.error(e);
- }
- }
- });
-
- } catch (Exception e) {
- Activator.log.error(e);
- }
- }
-
- /**
- * This method creates a node for the compartment of stereotype if it does not exist.
- *
- * @param stereotypeApplication
- * the stereotype application
- */
- protected void createAppliedStereotypeLabel(final EObject stereotypeApplication) {
-
-
- if (hostEditPart instanceof IPapyrusEditPart) {
-
- final View node = hostEditPart.getNotationView();
- // create only if the Label doesn't exist yet
- if (!helper.isLabelExist(node, stereotypeApplication)) {
- // Create the Decoration Node
- executeStereotypeLabelCreation(hostEditPart, stereotypeApplication, StereotypeDisplayUtils.DEFAULT_VISIBILITY_VALUE);
-
-
- }
- }
-
- }
-
-
- /**
- * This method creates a node for the compartment of stereotype if it does not exist.
- *
- * @param stereotypeApplication
- * the stereotype application
- */
- protected void createAppliedStereotypeCompartment(final EObject stereotypeApplication) {
- final View node = hostEditPart.getNotationView();
- // doesn't exist already
- if (!helper.isCompartmentExist(node, stereotypeApplication)) {
- // Create Compartment
- executeAppliedStereotypeCompartmentCreation(hostEditPart, stereotypeApplication);
- }
- }
-
-
- /**
- * In charge of property view creation
- *
- * @param eObject
- * The Edit Part of which the Properties should be created
- */
- protected void createAppliedStereotypeProperty(EObject stereotypeApplication) {
-
- Node compartment = helper.getStereotypeCompartment(hostEditPart.getNotationView(), stereotypeApplication);
- if (compartment != null && helper.isStereotypeCompartment(compartment)) {
- Stereotype stereotype = UMLUtil.getStereotype(stereotypeApplication);
- if (stereotype != null) {
- EList<Property> properties = stereotype.allAttributes();
- for (Property property : properties) {
- // if stereotype is null all property of stereotype has to be removed!
- if (property != null && !property.getName().startsWith(Extension.METACLASS_ROLE_PREFIX)) {
- if (!helper.isPropertyExist((BasicCompartment) compartment, property)) {
- // go through each stereotype property
- executeAppliedStereotypePropertyViewCreation(hostEditPart, compartment, property);
-
- }
- }
- }
- }
- }
- }
-
-
- /**
- * this method suppress the sub-nodes that references the stereotype application
- * it cleans also all sub-nodes with the type ApplicationStereotype that not references an application of stereotypes
- * (this is the case when a stereotype has been unapplied without suppress the compartment.
- *
- * @param stereotypeApplication
- */
- protected void removeAppliedStereotypeCompartment(final EObject stereotypeApplication) {
-
- GraphicalEditPart editPart = (GraphicalEditPart) getHost();
-
- // Remove the Label node
- BasicCompartment compartment = getStereotypePropertyMap().get(stereotypeApplication);
- if (compartment != null && TransactionUtil.getEditingDomain(compartment) != null) {
- executeAppliedStereotypeCompartmentRemove(editPart, compartment);
- }
- }
-
-
- /**
- * Remove the stereotype entry from the Map
- *
- * @param stereotypeApplication
- * The Stereotype Application reference to delete
- */
- protected void deleteInMap(EObject stereotypeApplication) {
- getStereotypePropertyMap().remove(stereotypeApplication);
- getStereotypeMap().remove(stereotypeApplication);
- }
-
-
- /**
- * Store the entry (stereotypeApplication, StereotypeLabel)
- *
- * @param stereotypeApplication
- * The Stereotype Application instance to store
- * @param node
- * The parent view (i.e: CSSShapeImpl)
- */
- protected void storeInMap(EObject stereotypeApplication, View node) {
-
- // String stereoQN = UMLUtil.getStereotype(stereotypeApplication).getQualifiedName();
- if (stereotypeApplication != null && node != null) {
- BasicCompartment compartment = helper.getStereotypeCompartment(node, stereotypeApplication);
- getStereotypePropertyMap().put(stereotypeApplication, compartment);
- DecorationNode label = helper.getStereotypeLabel(node, stereotypeApplication);
- getStereotypeMap().put(stereotypeApplication, label);
- }
- }
-
-
- /**
- * The goal of this method is to execute the a command to create a notation node for a stereotype Label.
- *
- * @param editPart
- * the editPart owner of the new compartment
- * @param appliedstereotype
- * the stereotype application
- */
- protected void executeStereotypeLabelCreation(final GraphicalEditPart editPart, final EObject appliedstereotype, final boolean isVisible) {
- try {
- editPart.getEditingDomain().runExclusive(new Runnable() {
- @Override
- public void run() {
- Display.getCurrent().syncExec(new Runnable() {
-
- @Override
- public void run() {
-
- CreateStereotypeLabelCommand command = new CreateStereotypeLabelCommand(editPart.getEditingDomain(), editPart.getNotationView(), appliedstereotype, isVisible);
- // use to avoid to put it in the command stack
- try {
- GMFUnsafe.write(editPart.getEditingDomain(), command);
- } catch (Exception e) {
- Activator.log.error(e);
- }
- }
- });
-
- }
- });
- } catch (Exception e) {
- Activator.log.error(e);
- }
- }
-
-
- /**
- * Execute the command to remove the Stereotype.
- *
- * @param editPart
- * Edit Part on which the command is executed
- * @param label
- * DecorationNode of the Stereotype Label that has to be removed
+ * Refreshes the stereotype display
*/
- protected void executeStereotypeLabelRemove(final GraphicalEditPart editPart, final View label) {
- try {
-
-
- TransactionUtil.getEditingDomain(getView()).runExclusive(new Runnable() {
-
- @Override
- public void run() {
- DeleteCommand command = new DeleteCommand(label);
- // use to avoid to put it in the command stack
- try {
- GMFUnsafe.write(editPart.getEditingDomain(), command);
- } catch (Exception e) {
- Activator.log.error(e);
- }
- }
- });
-
- } catch (Exception e) {
- Activator.log.error(e);
- }
- }
-
+ protected abstract void refreshStereotypeDisplay();
/**
- * Remove the StereotypeLabel from an element from it's stereotype application.
+ * Get the Stereotype text to display into the Label.
*
- * @param stereotypeApplication
- * Associated Stereotype application to remove
+ * @return The stereotype name Label to display according to the depth
*/
- protected void removeAppliedStereotypeLabel(EObject stereotypeApplication) {
- if (stereotypeApplication == null) {
- return;
- }
-
- // Remove the Label node
- DecorationNode label = getStereotypeMap().get(stereotypeApplication);
- if (label != null && TransactionUtil.getEditingDomain(label) != null) {
- executeStereotypeLabelRemove(hostEditPart, label);
- }
-
-
+ public String stereotypesToDisplay() {
+ return helper.getStereotypeTextToDisplay(hostView);
}
- /**
- * Refreshes the stereotype display
- */
- protected abstract void refreshStereotypeDisplay();
-
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeLinkLabelDisplayEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeLinkLabelDisplayEditPolicy.java
index e9900c30fe9..a9b62e17cff 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeLinkLabelDisplayEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeLinkLabelDisplayEditPolicy.java
@@ -15,11 +15,9 @@ package org.eclipse.papyrus.uml.diagram.common.editpolicies;
import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.appearance.helper.AppliedStereotypeHelper;
-import org.eclipse.papyrus.uml.appearance.helper.UMLVisualInformationPapyrusConstant;
import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusUMLElementFigure;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.uml2.uml.Stereotype;
/**
* the goal of this edit policy is to display applied stereotype and properties
@@ -36,14 +34,32 @@ public class AppliedStereotypeLinkLabelDisplayEditPolicy extends AppliedStereoty
super(tag);
}
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy#activate()
+ *
+ */
+ @Override
+ public void activate() {
+ super.activate();
+
+ }
+
@Override
public String stereotypesToDisplay() {
// if the display is not as Brace location the properties of the stereotype is not display
- String stereotypespresentationLocation = AppliedStereotypeHelper.getAppliedStereotypesPropertiesLocalization(((View) getHost().getModel()));
- if (UMLVisualInformationPapyrusConstant.STEREOTYPE_BRACE_LOCATION.equals(stereotypespresentationLocation)) {
- return super.stereotypesToDisplay();
- }
- return "";
+ return super.stereotypesToDisplay();
+
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy#refreshStereotypeBraceStructure(org.eclipse.uml2.uml.Stereotype)
+ *
+ * @param stereotype
+ */
+ @Override
+ public void refreshStereotypeBraceStructure(Stereotype stereotype) {
+ // Do nothing
+ // No brace for link Label
}
/**
@@ -61,7 +77,6 @@ public class AppliedStereotypeLinkLabelDisplayEditPolicy extends AppliedStereoty
// if the string is not empty, then, the figure has to display it. Else,
// it displays nothing
- // if (stereotypesToDisplay != "" || imageToDisplay != null) {
if (figure instanceof IPapyrusUMLElementFigure) {
((IPapyrusUMLElementFigure) figure).setStereotypeDisplay(tag + (stereotypesToDisplay.equals("") ? stereotypesToDisplay : "\n" + stereotypesToDisplay), imageToDisplay);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeNodeLabelDisplayEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeNodeLabelDisplayEditPolicy.java
index e2ec84e7bd0..325180b9bde 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeNodeLabelDisplayEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/AppliedStereotypeNodeLabelDisplayEditPolicy.java
@@ -10,11 +10,12 @@
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 429275
- * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 460356 : Refactor Stereotype Display
+ * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 : Refactor Stereotype Display
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.editpolicies;
+import org.eclipse.draw2d.IFigure;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusNodeUMLElementFigure;
@@ -24,6 +25,8 @@ import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusNodeUMLElement
*/
public class AppliedStereotypeNodeLabelDisplayEditPolicy extends AppliedStereotypeLabelDisplayEditPolicy {
+ private String EMPTY_STRING = "";
+
public AppliedStereotypeNodeLabelDisplayEditPolicy() {
super();
}
@@ -33,13 +36,34 @@ public class AppliedStereotypeNodeLabelDisplayEditPolicy extends AppliedStereoty
}
/**
- * Refreshes the stereotype display
+ * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy#refreshStereotypeDisplay()
+ *
*/
@Override
protected void refreshStereotypeDisplay() {
- // do nothing
+ IFigure figure = ((IPapyrusEditPart) hostEditPart).getPrimaryShape();
+ if (figure instanceof IPapyrusNodeUMLElementFigure) {
+
+ refreshAppliedStereotypesPropertiesInBrace((IPapyrusNodeUMLElementFigure) figure);
+ }
}
+ /**
+ * Refreshes the stereotypes properties displayed in Braces above name of the element
+ * in this edit part.
+ *
+ * @param stereotypesPropertiesToDisplay
+ */
+ protected void refreshAppliedStereotypesPropertiesInBrace(IPapyrusNodeUMLElementFigure figure) {
+ String toDisplayInBrace = helper.getStereotypePropertiesInBrace(hostView);
+
+ if (!EMPTY_STRING.equals(toDisplayInBrace)) {
+ figure.setStereotypePropertiesInBrace(toDisplayInBrace);
+ } else {
+ figure.setStereotypePropertiesInBrace(null);
+ }
+ }
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CommentShapeForAppliedStereotypeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CommentShapeForAppliedStereotypeEditPolicy.java
index 7be9f8e68d8..f0d5ecf4514 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CommentShapeForAppliedStereotypeEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/CommentShapeForAppliedStereotypeEditPolicy.java
@@ -17,7 +17,7 @@ package org.eclipse.papyrus.uml.diagram.common.editpolicies;
import java.util.Iterator;
-import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.draw2d.IFigure;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
@@ -27,17 +27,17 @@ import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker;
import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-import org.eclipse.gmf.runtime.gef.ui.internal.editpolicies.GraphicalEditPolicyEx;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.core.listenerservice.IPapyrusListener;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.GMFUnsafe;
import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayHelper;
+import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusNodeUMLElementFigure;
import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayUtils;
import org.eclipse.swt.widgets.Display;
import org.eclipse.uml2.uml.Element;
@@ -48,35 +48,15 @@ import org.eclipse.uml2.uml.util.UMLUtil;
* and launch command of deletion if it detect that no property of applied stereotype are displayed.
*
*/
-public class CommentShapeForAppliedStereotypeEditPolicy extends GraphicalEditPolicyEx implements NotificationListener, IPapyrusListener {
+public class CommentShapeForAppliedStereotypeEditPolicy extends AbstractAppliedStereotypeDisplayEditPolicy implements NotificationListener, IPapyrusListener {
- @Override
- public void notifyChanged(Notification notification) {
- View commentNode = getView();
- if (commentNode != null) {
- final TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(commentNode);
-
- // if Base_Element is deleted, the Comment is deleted as well
- if (getUMLElement() == null) {
- executeAppliedStereotypeCommentDeletion(domain, commentNode);
- }
-
- // if notification Set the visibility and none of Compartment is Visible, delete the Comment
- final int eventType = notification.getEventType();
- if (eventType == Notification.SET && notification.getFeature().equals(NotationPackage.eINSTANCE.getView_Visible())) {
- if (getVisibleAppliedStereotypeCompartmentNumber(commentNode) == 0) {
- executeAppliedStereotypeCommentDeletion(domain, commentNode);
- }
-
- }
- }
- }
/**
* Returns the uml element controlled by the host edit part
*
* @return the uml element controlled by the host edit part
*/
+ @Override
protected Element getUMLElement() {
Element element = null;
if ((Element) getView().getElement() != null) {
@@ -107,19 +87,23 @@ public class CommentShapeForAppliedStereotypeEditPolicy extends GraphicalEditPol
return super.getCommand(request);
}
-
/**
- * @see org.eclipse.gmf.runtime.gef.ui.internal.editpolicies.GraphicalEditPolicyEx#refresh()
- *
+ * Refreshes the stereotypes properties displayed above name of the element
+ * in this edit part.
+ *
+ * @param stereotypesPropertiesToDisplay
*/
- @Override
- public void refresh() {
- View commentNode = getView();
- final TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(commentNode);
- if (getVisibleAppliedStereotypeCompartmentNumber(commentNode) == 0) {
- executeAppliedStereotypeCommentDeletion(domain, commentNode);
+ protected void refreshAppliedStereotypesPropertiesInBrace(IPapyrusNodeUMLElementFigure figure) {
+ String toDisplayInBrace = helper.getStereotypePropertiesInBrace(((GraphicalEditPart) getHost()).getNotationView());
+ // if the string is not empty, then, the figure has to display it. Else,
+ // it displays nothing
+ if (!"".equals(toDisplayInBrace)) {
+ // it has to be displayed in braces, so compute the string to
+ // display
+ figure.setStereotypePropertiesInBrace(toDisplayInBrace);
+ } else {
+ figure.setStereotypePropertiesInBrace(null);
}
- super.refresh();
}
/**
@@ -157,12 +141,12 @@ public class CommentShapeForAppliedStereotypeEditPolicy extends GraphicalEditPol
*
* @return the number of Visible Stereotype Compartment
*/
- protected int getVisibleAppliedStereotypeCompartmentNumber(View view) {
+ protected int getAppliedStereotypeCompartmentNumber(View view) {
int nbVisibleCompartment = 0;
Iterator<View> iteratorView = view.getChildren().iterator();
while (iteratorView.hasNext()) {
View subview = iteratorView.next();
- if (subview.isVisible() && StereotypeDisplayHelper.getInstance().isStereotypeCompartment(subview)) {
+ if (helper.isStereotypeBrace(subview) || helper.isStereotypeCompartment(subview)) {
nbVisibleCompartment++;
}
}
@@ -170,6 +154,8 @@ public class CommentShapeForAppliedStereotypeEditPolicy extends GraphicalEditPol
}
+
+
@Override
public void activate() {
// retrieve the view and the element managed by the edit part
@@ -179,7 +165,7 @@ public class CommentShapeForAppliedStereotypeEditPolicy extends GraphicalEditPol
}
// adds a listener on the view and the element controlled by the
- // editpart
+ // editpartrefr
getDiagramEventBroker().addNotificationListener(view, this);
}
@@ -203,6 +189,7 @@ public class CommentShapeForAppliedStereotypeEditPolicy extends GraphicalEditPol
*
* @return the diagram event broker
*/
+ @Override
protected DiagramEventBroker getDiagramEventBroker() {
TransactionalEditingDomain theEditingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
if (theEditingDomain != null) {
@@ -216,7 +203,50 @@ public class CommentShapeForAppliedStereotypeEditPolicy extends GraphicalEditPol
*
* @return the view controlled by the host edit part
*/
+ @Override
protected View getView() {
return (View) getHost().getModel();
}
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy#refreshStereotypeDisplay()
+ *
+ */
+
+ protected void refreshStereotypeDisplay() {
+ IFigure figure = ((IPapyrusEditPart) getHost()).getPrimaryShape();
+
+ // refresh Brace display
+ if (figure instanceof IPapyrusNodeUMLElementFigure) {
+ refreshAppliedStereotypesPropertiesInBrace((IPapyrusNodeUMLElementFigure) figure);
+ }
+
+ // Deletion of Comment
+ View commentNode = getView();
+ if (commentNode != null) {
+ final TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(commentNode);
+
+ // if Base_Element is deleted, the Comment is deleted as well
+ if (getUMLElement() == null) {
+ executeAppliedStereotypeCommentDeletion(domain, commentNode);
+ }
+
+ // If no more Compartment, delete the Comment
+ if (getAppliedStereotypeCompartmentNumber(commentNode) == 0) {
+ executeAppliedStereotypeCommentDeletion(domain, commentNode);
+ }
+
+ }
+
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy#refreshDisplay()
+ *
+ */
+ @Override
+ public void refreshDisplay() {
+ refreshStereotypeDisplay();
+
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/CornerBentFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/CornerBentFigure.java
index c2ac28a81dc..c29a927cae0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/CornerBentFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/CornerBentFigure.java
@@ -9,6 +9,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 Stereotype Display
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.figure.node;
@@ -26,6 +27,7 @@ import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.gmf.runtime.diagram.ui.figures.NoteFigure;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayUtils;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
@@ -42,7 +44,7 @@ public class CornerBentFigure extends NoteFigure implements IPapyrusNodeUMLEleme
protected NoteFigureBorder noteBorder = null;
/**
- * Added for stereptypes properties
+ * Added for stereotypes properties
*/
protected StereotypePropertiesCompartment stereotypePropertiesContent;
@@ -51,6 +53,7 @@ public class CornerBentFigure extends NoteFigure implements IPapyrusNodeUMLEleme
*/
protected Label stereotypePropertiesInBraceContent;
+ /** Stereotype Wrapping Label */
protected PapyrusWrappingLabel stereotypesLabel;
/**
@@ -84,6 +87,9 @@ public class CornerBentFigure extends NoteFigure implements IPapyrusNodeUMLEleme
this.add(stereotypesLabel, getStereotypeLabelPosition());
}
+ /**
+ * Create Properties Content
+ */
protected void createStereotypePropertiesContent() {
stereotypePropertiesContent = new StereotypePropertiesCompartment();
stereotypePropertiesContent.setFill(false);
@@ -105,6 +111,12 @@ public class CornerBentFigure extends NoteFigure implements IPapyrusNodeUMLEleme
}
+ /**
+ * Fill the Compartment with the properties
+ *
+ * @param stereotypeProperties
+ * Properties List to display
+ */
private void fillStereotypePropertiesInCompartment(String stereotypeProperties) {
stereotypePropertiesContent.getChildren().clear();
@@ -120,6 +132,11 @@ public class CornerBentFigure extends NoteFigure implements IPapyrusNodeUMLEleme
repaint();
}
+ /**
+ * Retrieve the Property position
+ *
+ * @return The integer for the Position of the property by incrementation
+ */
protected int getStereotypePropertiesCompartmentPosition() {
int position = getChildren().indexOf(stereotypesLabel);
position++;
@@ -184,7 +201,7 @@ public class CornerBentFigure extends NoteFigure implements IPapyrusNodeUMLEleme
// Set stereotype text on figure
if (!"".equals(stereotypeProperties)) {
- this.stereotypePropertiesInBraceContent.setText("{" + stereotypeProperties + "}");
+ this.stereotypePropertiesInBraceContent.setText(StereotypeDisplayUtils.BRACE_LEFT + stereotypeProperties + StereotypeDisplayUtils.BRACE_RIGHT);
} else {
this.stereotypePropertiesInBraceContent.setText("");
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java
index 044afc93658..77bee35759a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/NodeNamedElementFigure.java
@@ -126,14 +126,16 @@ public class NodeNamedElementFigure extends PapyrusNodeFigure implements IPapyru
@Override
public void add(IFigure figure, Object constraint, int index) {
- if (figure instanceof AppliedStereotypeCompartmentFigure) {
- if (stereotypePropertiesContent == null) {
- this.createStereotypePropertiesContent();
- }
- stereotypePropertiesContent.add(figure);
- } else {
+ if (figure != null) {
+ if (figure instanceof AppliedStereotypeCompartmentFigure) {
+ if (stereotypePropertiesContent == null) {
+ this.createStereotypePropertiesContent();
+ }
+ stereotypePropertiesContent.add(figure);
+ } else {
- super.add(figure, constraint, index);
+ super.add(figure, constraint, index);
+ }
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/StereotypedElementLabelHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/StereotypedElementLabelHelper.java
index d66fcf17a39..3ced407cc8a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/StereotypedElementLabelHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/StereotypedElementLabelHelper.java
@@ -27,7 +27,6 @@ import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.papyrus.infra.emf.appearance.helper.AppearanceHelper;
@@ -35,7 +34,7 @@ import org.eclipse.papyrus.uml.appearance.helper.AppliedStereotypeHelper;
import org.eclipse.papyrus.uml.appearance.helper.UMLVisualInformationPapyrusConstant;
import org.eclipse.papyrus.uml.diagram.common.Activator;
import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayHelper;
-import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayUtils;
import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.swt.graphics.Image;
import org.eclipse.uml2.uml.Element;
@@ -47,6 +46,8 @@ import org.eclipse.uml2.uml.Stereotype;
*/
public abstract class StereotypedElementLabelHelper {
+ private final static String EMPTY_STRING = "";
+
/**
* {@inheritDoc}
*/
@@ -111,87 +112,6 @@ public abstract class StereotypedElementLabelHelper {
}
/**
- * Returns a String that displays stereotypes (using their simple name or
- * their qualified name) and their properties
- *
- * @param editPart
- * the edit part for which the label is edited
- * @param separator
- * the separator used to split the string representing the
- * stereotypes.
- * @param stereotypesToDisplay
- * the list of stereotypes displayed
- * @param stereotypeWithQualifiedName
- * the list of stereotypes displayed using their qualified names
- * @param stereotypesPropertiesToDisplay
- * the list of properties to display
- * @return a string that displays stereotypes (using their simple name or
- * their qualified name) and their properties
- */
- public String stereotypesAndPropertiesToDisplay(GraphicalEditPart editPart, String separator, String stereotypesToDisplay, String stereotypesPropertiesToDisplay) {
- // Get the preference from PreferenceStore. there should be an assert
- final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- if (store == null) {
- Activator.log.warn("The preference store was not found");
- return "";
- }
- // retrieve if the name of the stereotype has to put to lower case or
- // not
- String sNameAppearance = store.getString(UMLVisualInformationPapyrusConstant.P_STEREOTYPE_NAME_APPEARANCE);
- // changes the string of properties into a map, where the entries of the
- // map are the
- // stereotype qualified name, and the properties to display are the data
- Map<String, List<String>> propertiesToDisplay = parseStereotypeProperties(editPart, stereotypesToDisplay, stereotypesPropertiesToDisplay);
- StringTokenizer strQualifiedName = new StringTokenizer(stereotypesToDisplay, ",");
- String out = "";
- while (strQualifiedName.hasMoreElements()) {
- String currentStereotype = strQualifiedName.nextToken();
- // check if current stereotype is applied
- final Element umlElement = getUMLElement(editPart);
- Stereotype stereotype = umlElement.getAppliedStereotype(currentStereotype);
- if (stereotype != null) {
- String name = currentStereotype;
-
- // AL Changes Feb. 07 - Beg
- // Handling STEREOTYPE_NAME_APPEARANCE preference (from
- // ProfileApplicationPreferencePage)
- // Previously lowercase forced onto first letter (standard UML)
- // stereotypesToDisplay = stereotypesToDisplay+name.substring(0,
- // 1).toLowerCase()+name.substring(1,
- // name.length())+","+separator;
- // check that the name has not already been added to the
- // displayed string
- if (sNameAppearance.equals(UMLVisualInformationPapyrusConstant.P_STEREOTYPE_NAME_DISPLAY_USER_CONTROLLED)) {
- if (out.indexOf(name) == -1) {
- out = out + Activator.ST_LEFT + name + Activator.ST_RIGHT + separator;
- }
- } else { // VisualInformationPapyrusConstants.P_STEREOTYPE_NAME_DISPLAY_UML_CONFORM))
- // {
-
- if (out.indexOf(name) == -1) {
- out = out + Activator.ST_LEFT + name + Activator.ST_RIGHT + separator;
- }
- }
- // now should add all properties associated to this stereotype
- List<String> properties = propertiesToDisplay.get(stereotype.getQualifiedName());
- if (properties != null) {
- // retrieve property
- for (String propertyName : properties) {
- out = out + StereotypeUtil.displayPropertyValue(stereotype, StereotypeUtil.getPropertyByName(stereotype, propertyName), getUMLElement(editPart), " ");
- }
- }
- }
- }
- if (out.endsWith(",")) {
- return out.substring(0, out.length() - 1);
- }
- if (out.endsWith(separator)) {
- return out.substring(0, out.length() - separator.length());
- }
- return out;
- }
-
- /**
* get Stereotype String to display
*
* @return the list of stereotypes to display
@@ -204,19 +124,14 @@ public abstract class StereotypedElementLabelHelper {
String stereotypesPropertiesToDisplay = StereotypeDisplayHelper.getInstance().getStereotypePropertiesInBrace(view);
- String display = "";
- display += stereotypesAndPropertiesToDisplay(editPart, "\n", stereotypesToDisplay, stereotypesPropertiesToDisplay);
-
+ String display = EMPTY_STRING;
- if (stereotypesToDisplay != null && !stereotypesToDisplay.equals("")) {
- display += Activator.ST_LEFT + stereotypesToDisplay + Activator.ST_RIGHT + " ";
+ if (stereotypesToDisplay != null && !stereotypesToDisplay.equals(EMPTY_STRING)) {
+ display += stereotypesToDisplay + StereotypeDisplayUtils.STEREOTYPE_PROPERTIES_SEPARATOR;
}
- final String propSt = StereotypeUtil.getPropertiesValuesInBrace(stereotypesPropertiesToDisplay, getUMLElement(editPart));
- if (propSt != null && !propSt.equals("")) {
- if (stereotypesToDisplay != null && !stereotypesToDisplay.equals("")) {
- // display += "\n";
- }
- display += "{" + propSt + "} ";
+ if (stereotypesPropertiesToDisplay != null && !stereotypesPropertiesToDisplay.equals(EMPTY_STRING)) {
+
+ display += StereotypeDisplayUtils.BRACE_LEFT + stereotypesPropertiesToDisplay + StereotypeDisplayUtils.BRACE_RIGHT;
}
return display;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/StereotypePropertyParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/StereotypePropertyParser.java
index c12c824aa2b..96a0ae779cf 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/StereotypePropertyParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/StereotypePropertyParser.java
@@ -30,12 +30,10 @@ import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayHelper;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeLocationEnum;
import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Property;
@@ -155,15 +153,8 @@ public class StereotypePropertyParser implements IParser, ISemanticParser {
final Property property = ((Property) (EMFHelper.getEObject(element)));
final View view = ((View) element.getAdapter(View.class));
- StereotypeLocationEnum location;
- if (helper.isInStereotypeComment((Node) view)) {
- location = StereotypeLocationEnum.IN_COMMENT_COMPARTMENT;
- } else {
- location = StereotypeLocationEnum.IN_COMPARTMENT;
- }
-
if (view != null && property != null) {
- return helper.getStereotypePropertyToDisplay(view, property, location);
+ return helper.getStereotypePropertyToDisplay(view, property);
}
}
return DEFAULT_VALUE;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/stereotype/AppliedStereotypeParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/stereotype/AppliedStereotypeParser.java
index 28ac8c419ae..75fddc56543 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/stereotype/AppliedStereotypeParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/stereotype/AppliedStereotypeParser.java
@@ -1,4 +1,4 @@
-/*
+/*****************************************************************************
* Copyright (c) 2006 Borland Software Corporation
*
* All rights reserved. This program and the accompanying materials
@@ -8,7 +8,9 @@
*
* Contributors:
* Michael Golubev (Borland) - initial API and implementation
- */
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 Stereotype Display
+ *
+ *****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.parser.stereotype;
import java.text.MessageFormat;
@@ -26,6 +28,7 @@ import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.papyrus.uml.diagram.common.parser.assist.FixedSetCompletionProcessor;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayUtils;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Extension;
import org.eclipse.uml2.uml.Stereotype;
@@ -34,16 +37,6 @@ public class AppliedStereotypeParser implements ISemanticParser {
private static final MessageFormat APPLIED_PROFILE = new MessageFormat("\u00AB{0}\u00BB"); //$NON-NLS-1$
- private final String myDefaultPrintString;
-
- public AppliedStereotypeParser() {
- this(null);
- }
-
- public AppliedStereotypeParser(String defaultPrintString) {
- myDefaultPrintString = defaultPrintString;
- }
-
@Override
public boolean areSemanticElementsAffected(EObject listener, Object notification) {
if (notification instanceof Notification) {
@@ -104,8 +97,10 @@ public class AppliedStereotypeParser implements ISemanticParser {
@Override
public String getPrintString(IAdaptable element, int flags) {
String editString = getEditString(element, flags);
- editString = editString == null || editString.isEmpty() ? myDefaultPrintString : editString;
- return editString == null || editString.isEmpty() ? "" : APPLIED_PROFILE.format(new Object[] { editString });
+ if (editString != null && !editString.isEmpty()) {
+ return StereotypeDisplayUtils.QUOTE_LEFT + editString + StereotypeDisplayUtils.QUOTE_RIGHT;
+ }
+ return editString;
}
@Override
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypeCommentContentCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypeCommentContentCommand.java
deleted file mode 100644
index 206c021efa8..00000000000
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypeCommentContentCommand.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 460356 : Refactor Stereotype Display
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.diagram.common.stereotype;
-
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.BasicCompartment;
-import org.eclipse.gmf.runtime.notation.Node;
-
-/**
- * @author Céline JANSSENS
- *
- */
-public class CreateAppliedStereotypeCommentContentCommand extends RecordingCommand {
-
- private StereotypeDisplayHelper helper = StereotypeDisplayHelper.getInstance();
-
- private Node appliedStereotypeComment;
- private GraphicalEditPart host;
- private Node originalCompartment;
-
- /**
- * Constructor.
- *
- */
- public CreateAppliedStereotypeCommentContentCommand(TransactionalEditingDomain domain, String name) {
- super(domain, name);
- }
-
- /**
- * Constructor.
- *
- * @param stereotypeApplication
- *
- */
- public CreateAppliedStereotypeCommentContentCommand(String name, Node appliedStereotypeComment, GraphicalEditPart host, Node compartment) {
- super(host.getEditingDomain(), name);
- this.appliedStereotypeComment = appliedStereotypeComment;
- this.host = host;
- this.originalCompartment = compartment;
-
- }
-
-
- /**
- * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
- *
- */
- @Override
- protected void doExecute() {
-
- // if it has to be displayed into the comment
-
- BasicCompartment compartmentComment = helper.getStereotypeCompartment(appliedStereotypeComment, originalCompartment.getElement());
-
- if (helper.isStereotypeCompartment(originalCompartment)) {
-
- if (compartmentComment == null) {
-
- boolean visibility = !isCommentEmpty((BasicCompartment) originalCompartment);
- BasicCompartment compartmentCopy = EcoreUtil.copy((BasicCompartment) originalCompartment); // Copy the compartment into the Comment EditPart
- compartmentCopy.setVisible(visibility);
- ViewUtil.insertChildView(appliedStereotypeComment, compartmentCopy, ViewUtil.APPEND, true);
-
- }
- }
-
- }
-
- /**
- * Define if the Comment is empty and should be displayed.
- *
- * @param compartment
- * The Compartment view
- * @return false by default, true if properties displayed in Brace and in Compartment Comment are empty
- */
- private boolean isCommentEmpty(BasicCompartment compartment) {
- boolean commentEmpty = false;
-
- if ((helper.isEmpty(compartment, StereotypeLocationEnum.IN_COMMENT_BRACE))
- && (helper.isEmpty(compartment, StereotypeLocationEnum.IN_COMMENT_COMPARTMENT))) {
- commentEmpty |= true;
-
- }
- return commentEmpty;
- }
-
-
-}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypeCommentViewCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypeCommentViewCommand.java
index 30b0a90f7d5..bd054e7351e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypeCommentViewCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypeCommentViewCommand.java
@@ -74,7 +74,6 @@ public class CreateAppliedStereotypeCommentViewCommand extends RecordingCommand
// create the node
Node node = NotationFactory.eINSTANCE.createShape();
- node.setVisible(true);
Bounds bounds = NotationFactory.eINSTANCE.createBounds();
bounds.setX(x);
bounds.setY(y);
@@ -100,7 +99,7 @@ public class CreateAppliedStereotypeCommentViewCommand extends RecordingCommand
points.add(new RelativeBendpoint());
bendpoints.setPoints(points);
edge.setBendpoints(bendpoints);
- ViewUtil.insertChildView(owner.getDiagram(), edge, -1, true);
+ ViewUtil.insertChildView(owner.getDiagram(), edge, -1, false);
edge.setType(StereotypeDisplayUtils.STEREOTYPE_COMMENT_LINK_TYPE);
edge.setElement(base_element);
IdentityAnchor anchor = NotationFactory.eINSTANCE.createIdentityAnchor();
@@ -154,7 +153,7 @@ public class CreateAppliedStereotypeCommentViewCommand extends RecordingCommand
if (commonParent != null) {
((Bounds) commentNode.getLayoutConstraint()).setX(100);
((Bounds) commentNode.getLayoutConstraint()).setY(100);
- ViewUtil.insertChildView(commonParent, commentNode, ViewUtil.APPEND, true);
+ ViewUtil.insertChildView(commonParent, commentNode, ViewUtil.APPEND, StereotypeDisplayUtils.PERSISTENT);
return;
}
}
@@ -166,7 +165,7 @@ public class CreateAppliedStereotypeCommentViewCommand extends RecordingCommand
econtainer = (View) econtainer.eContainer();
}
}
- ViewUtil.insertChildView(econtainer, commentNode, ViewUtil.APPEND, true);
+ ViewUtil.insertChildView(econtainer, commentNode, ViewUtil.APPEND, StereotypeDisplayUtils.PERSISTENT);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypePropertyViewCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypePropertyViewCommand.java
index afb56815d33..593ba37a70f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypePropertyViewCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypePropertyViewCommand.java
@@ -38,11 +38,14 @@ public class CreateAppliedStereotypePropertyViewCommand extends RecordingCommand
protected Element element;
- public CreateAppliedStereotypePropertyViewCommand(TransactionalEditingDomain domain, View owner, Property property) {
+ protected String type;
+
+ public CreateAppliedStereotypePropertyViewCommand(TransactionalEditingDomain domain, View owner, Property property, final String type) {
super(domain, "CreateStereotypePropertyView");
this.owner = owner;
this.property = property;
+ this.type = type;
}
@@ -53,7 +56,7 @@ public class CreateAppliedStereotypePropertyViewCommand extends RecordingCommand
// Create property Label
DecorationNode propertyLabel = NotationFactory.eINSTANCE.createDecorationNode();
- propertyLabel.setType(StereotypeDisplayUtils.STEREOTYPE_PROPERTY_TYPE);
+ propertyLabel.setType(type);
propertyLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
propertyLabel.setElement(property);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypeViewCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypeViewCommand.java
index 342d0c20f7e..1c01ebc3e1b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypeViewCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateAppliedStereotypeViewCommand.java
@@ -13,7 +13,6 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.stereotype;
-import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
@@ -23,7 +22,6 @@ import org.eclipse.gmf.runtime.notation.StringValueStyle;
import org.eclipse.gmf.runtime.notation.TitleStyle;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.uml2.uml.Stereotype;
-import org.eclipse.uml2.uml.util.UMLUtil;
/**
* the goal of this command is to create a basic compartment in the notation that represent a compartment of stereotypes
@@ -35,10 +33,12 @@ public class CreateAppliedStereotypeViewCommand extends RecordingCommand {
protected View node;
- protected EObject stereotypeApplication;
+ protected Stereotype stereotype;
protected Node parent;
+ protected String type;
+
/**
*
* Constructor.
@@ -49,11 +49,12 @@ public class CreateAppliedStereotypeViewCommand extends RecordingCommand {
* @param StereotypeApplication
* @param displayit
*/
- public CreateAppliedStereotypeViewCommand(TransactionalEditingDomain domain, View node, EObject stereotypeApplication) {
+ public CreateAppliedStereotypeViewCommand(TransactionalEditingDomain domain, View node, Stereotype stereotype, String type) {
super(domain, "CreateStereotypeCompartment");
this.node = node;
- this.stereotypeApplication = stereotypeApplication;
- parent = helper.getStereotypeLabel(node, stereotypeApplication);
+ this.stereotype = stereotype;
+ parent = helper.getStereotypeLabel(node, stereotype);
+ this.type = type;
}
@@ -62,11 +63,9 @@ public class CreateAppliedStereotypeViewCommand extends RecordingCommand {
public void doExecute() {
- Stereotype stereotype = UMLUtil.getStereotype(stereotypeApplication);
// Create the Graphical Compartment
Node compartment = NotationFactory.eINSTANCE.createBasicCompartment();
- compartment.setVisible(true);
compartment.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
// Create Title Style
@@ -81,12 +80,13 @@ public class CreateAppliedStereotypeViewCommand extends RecordingCommand {
compartment.getStyles().add(stereotypeNameStyle);
// Complete the creation
- compartment.setElement(stereotypeApplication);
- compartment.setType(StereotypeDisplayUtils.STEREOTYPE_COMPARTMENT_TYPE);
- ViewUtil.insertChildView(node, compartment, ViewUtil.APPEND, true);
+ compartment.setElement(stereotype);
+ compartment.setType(type);
+ ViewUtil.insertChildView(node, compartment, ViewUtil.APPEND, StereotypeDisplayUtils.PERSISTENT);
compartment.setMutable(true);
}
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateStereotypeLabelCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateStereotypeLabelCommand.java
index cbd917f6bdd..912498db127 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateStereotypeLabelCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/CreateStereotypeLabelCommand.java
@@ -14,7 +14,6 @@
package org.eclipse.papyrus.uml.diagram.common.stereotype;
-import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
@@ -24,7 +23,6 @@ import org.eclipse.gmf.runtime.notation.StringValueStyle;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Stereotype;
-import org.eclipse.uml2.uml.util.UMLUtil;
/**
* @author Céline JANSSENS
@@ -37,7 +35,7 @@ public class CreateStereotypeLabelCommand extends RecordingCommand {
protected View owner;
- protected EObject stereoApplication;
+ protected Stereotype stereotype;
protected boolean isVisible;
@@ -55,11 +53,11 @@ public class CreateStereotypeLabelCommand extends RecordingCommand {
* @param isVisible
* if the Label is Visible when created
*/
- public CreateStereotypeLabelCommand(TransactionalEditingDomain domain, View owner, EObject stereoApplication, boolean isVisible) {
+ public CreateStereotypeLabelCommand(TransactionalEditingDomain domain, View owner, Stereotype stereotype) {
super(domain, STEREOTYPE_LABEL_COMMAND_NAME);
this.owner = owner;
- this.stereoApplication = stereoApplication;
- this.isVisible = isVisible;
+ this.stereotype = stereotype;
+
}
/**
@@ -70,12 +68,12 @@ public class CreateStereotypeLabelCommand extends RecordingCommand {
@Override
protected void doExecute() {
- Stereotype stereotype = UMLUtil.getStereotype(stereoApplication);
+
// Create Label
DecorationNode label = NotationFactory.eINSTANCE.createDecorationNode();
label.setType(StereotypeDisplayUtils.STEREOTYPE_LABEL_TYPE);
label.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
- label.setElement(stereoApplication);
+ label.setElement(stereotype);
// Create Stereotype Name Style
StringValueStyle stereotypeNameStyle = NotationFactory.eINSTANCE.createStringValueStyle();
@@ -84,7 +82,8 @@ public class CreateStereotypeLabelCommand extends RecordingCommand {
label.getStyles().add(stereotypeNameStyle);
// Add the new Label to it's owner Object
- ViewUtil.insertChildView(owner, label, ViewUtil.APPEND, true);
+ ViewUtil.insertChildView(owner, label, ViewUtil.APPEND, StereotypeDisplayUtils.PERSISTENT);
+
label.setMutable(true);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeDisplayHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeDisplayHelper.java
index 7b2d8635386..ada69ce8eb3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeDisplayHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeDisplayHelper.java
@@ -19,7 +19,7 @@ import java.util.StringTokenizer;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.notation.BasicCompartment;
import org.eclipse.gmf.runtime.notation.DecorationNode;
import org.eclipse.gmf.runtime.notation.Edge;
@@ -52,6 +52,10 @@ public class StereotypeDisplayHelper {
*/
private static StereotypeDisplayHelper labelHelper;
+ /** Singleton contructor */
+ private StereotypeDisplayHelper() {
+ }
+
/**
* Returns the singleton instance of this class
*
@@ -65,6 +69,96 @@ public class StereotypeDisplayHelper {
}
+
+ /**
+ * Return Stereotype application according to the Stereotype applied on the main Owner of the view
+ *
+ * @param view
+ * The view of which the Stereotype Application is Required (StereotypeCompartment, StereotypeProperty,...)
+ * @return The Direct AppliedStereotype when possible or the Applied Stereotype of the Base Element when the view is in the Comment Shape.
+ */
+ public EObject getStereotypeApplication(final View view, Stereotype stereo) {
+ EObject appliedStereotypes = null;
+
+ if (isInStereotypeComment((Node) view)) {
+ if (getCommentSemanticElement(getTopContainer(view)) != null) {
+ appliedStereotypes = getCommentSemanticElement(getTopContainer(view)).getStereotypeApplication(stereo);
+ }
+ }
+
+ if (getContainerSemanticElement(view) != null) {
+ appliedStereotypes = getContainerSemanticElement(view).getStereotypeApplication(stereo);
+ }
+
+ return appliedStereotypes;
+
+ }
+
+ /**
+ * Get the Semantic Element of the Comment View.
+ * The Comment View is not attached to its semantic element through the method {@link View#getElement()}.
+ * To retrieve the semantic element, it has been added as a namedStyle with the name {@link StereotypeDisplayUtils#STEREOTYPE_COMMENT_RELATION_NAME}
+ *
+ * @param view
+ * The Stereotype Comment View (of type "StereotypeComment")
+ * @return The Base Element of the Comment
+ */
+ protected Element getCommentSemanticElement(View view) {
+
+ Element elementSemantic = null;
+ if (isStereotypeComment(view)) {
+ // Retrieve the Base Element of the Comment as the Semantic element
+ EObject baseElement = NotationUtils.getEObjectValue(view, StereotypeDisplayUtils.STEREOTYPE_COMMENT_RELATION_NAME, null);
+
+ if (baseElement instanceof Element) {
+ elementSemantic = (Element) baseElement;
+
+ }
+ }
+ return elementSemantic;
+ }
+
+ /**
+ * Retrieve the Container View of the Object on which the Stereotype is applied.
+ * By default the container is the direct parent, but in case of Property, the top Container is the grand Parent.
+ *
+ * @param view
+ * @return the Container that support the Stereotype Application
+ */
+ public View getTopContainer(final View view) {
+ View topView = null;
+ if (view != null) {
+ EObject container = view.eContainer();
+ if (isStereotypeCompartment(container) || isStereotypeBrace(container) || isStereotypeLabel(container)) {
+ container = container.eContainer();
+ }
+ if (container instanceof View) {
+ topView = (View) container;
+ }
+ }
+
+
+ return topView;
+ }
+
+ /**
+ * Return the Semantic Element of the Container.
+ *
+ * @param view
+ * (i.e: LabelStereotype, CompartmentStereotype)
+ * @return The semantic Element of the container (Class , Operation, ...)
+ */
+ public Element getContainerSemanticElement(final View view) {
+ Element elementUML = null;
+ EObject parentElement = getTopContainer(view).getElement();
+ if (parentElement instanceof Element) {
+ elementUML = (Element) parentElement;
+ }
+
+ return elementUML;
+ }
+
+
/**
* Get the Full label to display into the header
*
@@ -73,6 +167,7 @@ public class StereotypeDisplayHelper {
* @return The label with Stereotype Name to display (i.e: "Blocks::Block, Allocation, SysML::Requirements::Requirement" )
*/
public String getStereotypeTextToDisplay(View model) {
+
String textToDisplay = EMPTY_STRING;
String finalText = EMPTY_STRING;
Iterator<?> iter = model.getChildren().iterator();
@@ -93,7 +188,7 @@ public class StereotypeDisplayHelper {
// Then add the ornament around the text.
if ((textToDisplay != null) && (!EMPTY_STRING.equals(textToDisplay))) {
- finalText = StereotypeDisplayUtils.BRACE_LEFT + textToDisplay + StereotypeDisplayUtils.BRACE_RIGHT;
+ finalText = StereotypeDisplayUtils.QUOTE_LEFT + textToDisplay + StereotypeDisplayUtils.QUOTE_RIGHT;
}
// Return the text or null if empty
@@ -118,7 +213,7 @@ public class StereotypeDisplayHelper {
// For each Stereotype Compartment, retrieve the property text to be added in Braces
while (iter.hasNext()) {
object = iter.next();
- if (isStereotypeCompartment(object)) {
+ if (isStereotypeBrace(object)) {
BasicCompartment compartment = (BasicCompartment) object;
textToDisplay = addStereotypeCompartmentProperties(textToDisplay, compartment);
@@ -294,17 +389,17 @@ public class StereotypeDisplayHelper {
* Stereotype Application of the Label to be retrieved.
* @return associated StereotypeLabel
*/
- public DecorationNode getStereotypeLabel(View node, EObject stereotypeApplication) {
+ public DecorationNode getStereotypeLabel(View node, Stereotype stereotype) {
- if ((stereotypeApplication != null) && (node != null)) {
+ if ((stereotype != null) && (node != null)) {
Object obj;
Iterator<?> iter = node.getChildren().iterator();
while (iter.hasNext()) {
obj = iter.next();
if (obj instanceof DecorationNode) {
DecorationNode label = (DecorationNode) obj;
- if (StereotypeDisplayUtils.STEREOTYPE_LABEL_TYPE.equals(label.getType())) {
- if (label.getElement().equals(stereotypeApplication)) {
+ if (isStereotypeLabel(label)) {
+ if (label.getElement().equals(stereotype)) {
return label;
}
}
@@ -324,9 +419,9 @@ public class StereotypeDisplayHelper {
* Stereotype Application of the Label to be retrieved.
* @return associated StereotypeLabel or null if none
*/
- public BasicCompartment getStereotypeCompartment(View node, EObject stereotypeApplication) {
+ public BasicCompartment getStereotypeCompartment(View node, Stereotype stereotype) {
- if ((stereotypeApplication != null) && (node != null)) {
+ if ((stereotype != null) && (node != null)) {
Object obj;
Iterator<?> iter = node.getChildren().iterator();
while (iter.hasNext()) {
@@ -334,7 +429,7 @@ public class StereotypeDisplayHelper {
if (isStereotypeCompartment(obj)) {
BasicCompartment compartment = (BasicCompartment) obj;
if (compartment.getElement() != null) {
- if (compartment.getElement().equals(stereotypeApplication)) {
+ if (compartment.getElement().equals(stereotype)) {
return compartment;
}
}
@@ -407,17 +502,52 @@ public class StereotypeDisplayHelper {
*
* @param element
* The object on which the test is done
- *
* @return true if Object is a StereotypeProperty Label
*/
public boolean isStereotypeProperty(Object element) {
boolean stereotypeProperty = Boolean.FALSE;
if (element instanceof DecorationNode) {
stereotypeProperty = StereotypeDisplayUtils.STEREOTYPE_PROPERTY_TYPE.equals(((DecorationNode) element).getType());
+
}
return stereotypeProperty;
}
+
+ /**
+ * Define if an object is a Stereotype Brace View
+ *
+ * @param element
+ * The Object to test
+ * @return true if it's a Stereotype Brace View
+ */
+ public boolean isStereotypeBrace(Object element) {
+ boolean stereotypeBraceCmpt = Boolean.FALSE;
+ if (element instanceof BasicCompartment) {
+ stereotypeBraceCmpt = StereotypeDisplayUtils.STEREOTYPE_BRACE_TYPE.equals(((BasicCompartment) element).getType());
+
+ }
+ return stereotypeBraceCmpt;
+ }
+
+
+ /**
+ * Define if an object is a Stereotype Brace Property Node. A Stereotype Property into Brace
+ *
+ * @param element
+ * The Object to test
+ * @return true if it's a Stereotype Brace Property Node
+ */
+ public boolean isStereotypeBraceProperty(Object element) {
+ boolean stereotypeProperty = Boolean.FALSE;
+ if (element instanceof DecorationNode) {
+ stereotypeProperty = StereotypeDisplayUtils.STEREOTYPE_PROPERTY_BRACE_TYPE.equals(((DecorationNode) element).getType());
+ }
+ return stereotypeProperty;
+ }
+
+
+
/**
* Defines if the Object is a StereotypeComment
*
@@ -435,7 +565,6 @@ public class StereotypeDisplayHelper {
}
-
/**
* Get the name of the Stereotype Label (it should be the Qualified Name of the related Stereotype )
*
@@ -461,7 +590,7 @@ public class StereotypeDisplayHelper {
*/
public String getName(BasicCompartment compartment) {
String name = EMPTY_STRING;
- if (StereotypeDisplayUtils.STEREOTYPE_COMPARTMENT_TYPE.equals(compartment.getType())) {
+ if (isStereotypeCompartment(compartment) || isStereotypeBrace(compartment)) {
// Retrieve Name from CSS or NamedStyle from the Notation model.
name = NotationUtils.getStringValue(compartment, StereotypeDisplayUtils.STEREOTYPE_COMPARTMENT_NAME, EMPTY_STRING);
}
@@ -496,7 +625,7 @@ public class StereotypeDisplayHelper {
* The stereotype Application of the Label on which the test is done.
* @return True is the Node contains already a Label for the stereotype Application
*/
- public boolean isLabelExist(View node, EObject stereotypeApplication) {
+ public boolean isLabelExist(View node, Stereotype stereotype) {
boolean exist = false;
Iterator<?> iter = node.getChildren().iterator();
@@ -507,7 +636,7 @@ public class StereotypeDisplayHelper {
DecorationNode stereo = (DecorationNode) obj;
if (StereotypeDisplayUtils.STEREOTYPE_LABEL_TYPE.equals(stereo.getType())) {
- exist = stereo.getElement().equals(stereotypeApplication);
+ exist = stereo.getElement().equals(stereotype);
}
}
}
@@ -523,7 +652,7 @@ public class StereotypeDisplayHelper {
* The stereotype Application of the Label on which the test is done.
* @return True is the Node contains already a Label for the stereotype Application
*/
- public boolean isCompartmentExist(View node, EObject stereotypeApplication) {
+ public boolean isCompartmentExist(View node, Stereotype stereotype) {
boolean exist = false;
Iterator<?> iter = node.getChildren().iterator();
while (!exist && iter.hasNext()) {
@@ -532,8 +661,8 @@ public class StereotypeDisplayHelper {
BasicCompartment compartment = (BasicCompartment) obj;
- if (StereotypeDisplayUtils.STEREOTYPE_COMPARTMENT_TYPE.equals(compartment.getType())) {
- exist = compartment.getElement().equals(stereotypeApplication);
+ if (isStereotypeCompartment(compartment)) {
+ exist = compartment.getElement().equals(stereotype);
}
}
}
@@ -548,7 +677,7 @@ public class StereotypeDisplayHelper {
* @param stereotypeApplication
* @return
*/
- public boolean isPropertyExist(BasicCompartment compartment, Property propertyUML) {
+ public boolean isPropertyExist(View compartment, Property propertyUML) {
boolean exist = false;
Iterator<?> iter = compartment.getChildren().iterator();
while (!exist && iter.hasNext()) {
@@ -557,7 +686,7 @@ public class StereotypeDisplayHelper {
DecorationNode property = (DecorationNode) obj;
- if (StereotypeDisplayUtils.STEREOTYPE_PROPERTY_TYPE.equals(property.getType())) {
+ if (isStereotypeProperty(property)) {
exist = property.getElement().equals(propertyUML);
}
}
@@ -575,7 +704,7 @@ public class StereotypeDisplayHelper {
* @param isVisible
* True to make the Compartment visible
*/
- public void setVisibility(final GraphicalEditPart editPart, final View view, final boolean isVisible) {
+ public void setVisibility(final IGraphicalEditPart editPart, final View view, final boolean isVisible) {
try {
editPart.getEditingDomain().runExclusive(new Runnable() {
@@ -606,19 +735,20 @@ public class StereotypeDisplayHelper {
* The UML Property required to retrieve the value
* @return The property text to be displayed with the property name and its value (i.e.: "allocatedFrom=[]")
*/
- public String getStereotypePropertyToDisplay(View view, Property property, StereotypeLocationEnum location) {
+ public String getStereotypePropertyToDisplay(View view, Property property) {
String propertyAndValue = EMPTY_STRING;
if (view instanceof DecorationNode) {
DecorationNode node = ((DecorationNode) view);
- if (isStereotypeProperty(node)) {
- final EObject stereotypeApplication = ((View) node.eContainer()).getElement();
- final Stereotype stereotype = UMLUtil.getStereotype(stereotypeApplication);
- final Element umlElement = UMLUtil.getBaseElement(stereotypeApplication);
+ if (isStereotypeProperty(node) || isStereotypeBraceProperty(node)) {
+
+ final Stereotype stereotype = (Stereotype) ((Property) node.getElement()).getClass_();
+ final Element umlElement = UMLUtil.getBaseElement(getStereotypeApplication(view, stereotype));
- if (isDisplayedAtLocation(node, location)) {
+ if (isDisplayed(node)) {
+ // if (node.isVisible()) {
if (stereotype != null && property != null && umlElement != null) {
- propertyAndValue = StereotypeUtil.displayPropertyValue(stereotype, property, umlElement, EMPTY_STRING);
+ propertyAndValue = StereotypeUtil.displayPropertyValue(stereotype, property, umlElement, StereotypeDisplayUtils.STEREOTYPE_PROPERTIES_SEPARATOR);
}
}
@@ -627,7 +757,6 @@ public class StereotypeDisplayHelper {
return propertyAndValue;
}
-
/**
* Defines if the Property should be displayed in the location
*
@@ -637,99 +766,13 @@ public class StereotypeDisplayHelper {
* The Location on which the test is done
* @return True if the property node should be displayed at the location.
*/
- public boolean isDisplayedAtLocation(Node node, StereotypeLocationEnum location) {
+ public boolean isDisplayed(Node node) {
boolean visibility = true;
-
- switch (location) {
- case IN_BRACE:
- visibility = isDisplayInBrace(node) && node.isVisible() && ((Node) node.eContainer()).isVisible();
- break;
- case IN_COMPARTMENT:
- visibility = isDisplayInCompartment(node) && node.isVisible() && ((Node) node.eContainer()).isVisible();
- break;
- case IN_COMMENT_BRACE:
- visibility = isDisplayInCommentBrace(node) && node.isVisible() && ((Node) node.eContainer()).isVisible();
- break;
- case IN_COMMENT_COMPARTMENT:
- visibility = isDisplayInCommentCompartment(node) && node.isVisible() && ((Node) node.eContainer()).isVisible();
- break;
- default:
- break;
- }
-
+ visibility = node.isVisible() && ((Node) node.eContainer()).isVisible();
return visibility;
}
- /**
- * Tests if the Property node should be displayed in the compartment of the Comment .
- *
- * @param node
- * The property Node or the Compartment Node
- * @return true if it should be displayed in The Compartment Comment
- */
- protected boolean isDisplayInCommentCompartment(Node node) {
- boolean display = false;
- if (isStereotypeProperty(node)) {
- display = NotationUtils.getBooleanValue(node, StereotypeDisplayUtils.STEREOTYPE_PROPERTY_LOCATION_COMMENT, StereotypeDisplayUtils.DEFAULT_STEREOTYPE_PROPERTY_DISPLAY_COMMENT);
- } else {
- Activator.log.warn("The node " + node + " is not a StereotypeProperty node 1 ");
- }
- return display;
- }
-
- /**
- * Tests if the Property node should be displayed in Comment.
- *
- * @param property
- * The property Node
- * @return the NamedStyle Value of the property "inBrace" that define if the node should be displayed into braces
- */
- protected boolean isDisplayInCommentBrace(Node node) {
- boolean display = false;
- if (isStereotypeProperty(node)) {
- display = NotationUtils.getBooleanValue(node, StereotypeDisplayUtils.STEREOTYPE_PROPERTY_LOCATION_COMMENT_BRACE, StereotypeDisplayUtils.DEFAULT_STEREOTYPE_PROPERTY_DISPLAY_COMMENT_BRACE);
- } else {
- Activator.log.warn("The node " + node + " is not a StereotypeProperty node 2 ");
- }
-
- return display;
-
- }
-
- /**
- * Tests if the Property node should be displayed in Compartment.
- *
- * @param property
- * The property Node
- * @return the NamedStyle Value of the property "inBrace" that define if the node should be displayed into braces
- */
- protected boolean isDisplayInCompartment(Node node) {
- boolean display = false;
- if (isStereotypeProperty(node)) {
- display = NotationUtils.getBooleanValue(node, StereotypeDisplayUtils.STEREOTYPE_PROPERTY_LOCATION_COMPARTMENT, StereotypeDisplayUtils.DEFAULT_STEREOTYPE_PROPERTY_DISPLAY_COMPARTMENT);
- } else {
- Activator.log.warn("The node " + node + " is not a StereotypeProperty node 3");
- }
- return display;
- }
-
- /**
- * Tests if the Property node should be displayed in Braces.
- *
- * @param property
- * The property Node
- * @return the NamedStyle Value of the property "inBrace" that define if the node should be displayed into braces
- */
- protected boolean isDisplayInBrace(Node node) {
- boolean display = false;
- if (isStereotypeProperty(node)) {
- display = NotationUtils.getBooleanValue(node, StereotypeDisplayUtils.STEREOTYPE_PROPERTY_LOCATION_BRACE, StereotypeDisplayUtils.DEFAULT_STEREOTYPE_PROPERTY_DISPLAY_BRACE);
- } else {
- Activator.log.warn("The node " + node + " is not a StereotypeProperty node 4");
- }
- return display;
- }
/**
* Tests if the node is contained into a Stereotype Comment.
@@ -741,15 +784,9 @@ public class StereotypeDisplayHelper {
*/
public boolean isInStereotypeComment(Node node) {
boolean isComment = false;
- Object container = node.eContainer();
- if (container != null) {
- if (isStereotypeCompartment(node) || isStereotypeLabel(node)) {
- isComment = isStereotypeComment(node.eContainer());
+ View container = getTopContainer(node);
- } else if (isStereotypeProperty(node)) {
- isComment = isStereotypeComment(node.eContainer().eContainer());
- }
- }
+ isComment = isStereotypeComment(container);
return isComment;
}
@@ -775,21 +812,16 @@ public class StereotypeDisplayHelper {
EList<?> properties = compartment.getChildren();
// For the compartment, concatenate all the properties Text (property name and values) that should be displayed in Braces
for (Object property : properties) {
- if (isStereotypeProperty(property)) {
+ if (isStereotypeBraceProperty(property)) {
DecorationNode propertyNode = (DecorationNode) property;
Property propertyElement = (Property) propertyNode.getElement();
// get the properties and values text (i.e: "allocatedFrom=[]")
- StereotypeLocationEnum location;
- if (isInStereotypeComment(compartment)) {
- location = StereotypeLocationEnum.IN_COMMENT_BRACE;
- } else {
- location = StereotypeLocationEnum.IN_BRACE;
- }
- String propAndValueText = getStereotypePropertyToDisplay(propertyNode, propertyElement, location);
-
- // add it to the String (i.e: "allocatedTo=[], allocatedFrom=[]")
- propertiesText = addTextWithSeparator(propertiesText, propAndValueText, StereotypeDisplayUtils.STEREOTYPE_LABEL_SEPARATOR);
+ if (isDisplayed(propertyNode)) {
+ String propAndValueText = getStereotypePropertyToDisplay(propertyNode, propertyElement);
+ // add it to the String (i.e: "allocatedTo=[], allocatedFrom=[]")
+ propertiesText = addTextWithSeparator(propertiesText, propAndValueText, StereotypeDisplayUtils.STEREOTYPE_LABEL_SEPARATOR);
+ }
}
}
@@ -800,6 +832,7 @@ public class StereotypeDisplayHelper {
return finalText;
}
+
/**
* Concatenates Text to another text with a separator.
*
@@ -847,13 +880,13 @@ public class StereotypeDisplayHelper {
/**
* Defines if the Node has at least one Stereotype Compartment as Child
*
- * @param node
+ * @param view
* The node on which we do the test
* @return true if at least one Stereotype Compartment
*/
- public boolean hasStereotypeCompartment(Node node) {
+ public boolean hasStereotypeCompartment(View view) {
Object obj;
- Iterator<?> iter = node.getChildren().iterator();
+ Iterator<?> iter = view.getChildren().iterator();
boolean compartmentExist = false;
while (iter.hasNext() && !compartmentExist) {
obj = iter.next();
@@ -887,12 +920,12 @@ public class StereotypeDisplayHelper {
* Location for which the test is done.
* @return true by default, false if at least one property node is displayed.
*/
- public boolean isEmpty(Node compartment, StereotypeLocationEnum location) {
+ public boolean isEmpty(Node compartment) {
boolean empty = true;
if (compartment != null) {
for (Object property : compartment.getChildren()) {
- if (isStereotypeProperty(property)) {
- if (isDisplayedAtLocation((Node) property, location)) {
+ if (isStereotypeProperty(property) || isStereotypeBraceProperty(property)) {
+ if (isDisplayed((Node) property)) {
empty &= false;
}
}
@@ -901,6 +934,118 @@ public class StereotypeDisplayHelper {
return empty;
}
+ /**
+ * @param stereotype
+ * @param hostSemanticElement
+ * @return
+ */
+ public boolean isAppliedStereotype(Stereotype stereotype, Element hostSemanticElement) {
+ return hostSemanticElement.isStereotypeApplied(stereotype);
+
+ }
+
+ /**
+ * Defines if an object is a Stereotype View
+ *
+ * @param element
+ * @return
+ */
+ public boolean isStereotypeView(Object element) {
+
+ boolean stereotypeView = (
+ isStereotypeCompartment(element) ||
+ isStereotypeBrace(element) ||
+ isStereotypeLabel(element) ||
+ isStereotypeBraceProperty(element) ||
+ isStereotypeProperty(element));
+
+
+ return stereotypeView;
+ }
+
+
+ /**
+ * Define if the Brace Compartment Exist already
+ *
+ * @param node
+ * Node container of the Brace
+ * @param stereotype
+ * Related Brace Stereotype
+ * @return true is at least one Brace Compartment for the specified stereotype exist
+ */
+ public boolean isBraceCompartmentExist(View node, Stereotype stereotype) {
+ boolean exist = false;
+ Iterator<?> iter = node.getChildren().iterator();
+ while (!exist && iter.hasNext()) {
+ Object obj = iter.next();
+ if (obj instanceof BasicCompartment) {
+
+ BasicCompartment compartment = (BasicCompartment) obj;
+
+ if (isStereotypeBrace(compartment)) {
+ exist = compartment.getElement().equals(stereotype);
+ }
+ }
+ }
+ return exist;
+ }
+
+ /**
+ * Define if the Brace Property Exist already
+ *
+ * @param compartment
+ * The Brace compartment
+ * @param propertyUML
+ * Related Brace Property
+ * @return true is at least one Brace Property for the specified stereotype exist
+ */
+ public boolean isBracePropertyExist(Node compartment, Property propertyUML) {
+
+ boolean exist = false;
+ Iterator<?> iter = compartment.getChildren().iterator();
+ while (!exist && iter.hasNext()) {
+ Object obj = iter.next();
+ if (obj instanceof DecorationNode) {
+
+ DecorationNode property = (DecorationNode) obj;
+
+ if (isStereotypeBraceProperty(property)) {
+ exist = property.getElement().equals(propertyUML);
+ }
+ }
+ }
+ return exist;
+ }
+
+
+ /**
+ * Get the Brace Compartment of a node
+ *
+ * @param node
+ * View of the node of which the compartment is looking for.
+ * @param stereotype
+ * Stereotype of the Brace Compartment we are searching for.
+ * @return The Basic Compartment if any or null if not.
+ */
+ public BasicCompartment getStereotypeBraceCompartment(View node, Stereotype stereotype) {
+ if ((stereotype != null) && (node != null)) {
+ Object obj;
+ Iterator<?> iter = node.getChildren().iterator();
+ while (iter.hasNext()) {
+ obj = iter.next();
+ if (isStereotypeBrace(obj)) {
+ BasicCompartment compartment = (BasicCompartment) obj;
+ if (compartment.getElement() != null) {
+ if (compartment.getElement().equals(stereotype)) {
+ return compartment;
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeDisplayUtils.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeDisplayUtils.java
index 134b9eacd01..502b4cb59f0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeDisplayUtils.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/stereotype/StereotypeDisplayUtils.java
@@ -14,7 +14,6 @@
package org.eclipse.papyrus.uml.diagram.common.stereotype;
-import org.eclipse.papyrus.uml.diagram.common.Activator;
/**
* This Class regroups the Constants required for the Stereotype Display
@@ -30,21 +29,25 @@ public class StereotypeDisplayUtils {
// Name of Style for Comment Node to point to related main Object
public static final String STEREOTYPE_COMMENT_RELATION_NAME = "BASE_ELEMENT";//$NON-NLS-1$
- // Name Style of Name, Type and Depth for Stereotype Display
+ // Type Notation Value
public static final String STEREOTYPE_LABEL_TYPE = "StereotypeLabel"; //$NON-NLS-1$
- public static final String STEREOTYPE_PROPERTY_TYPE = "StereotypeProperty";//$NON-NLS-1$
+
public static final String STEREOTYPE_COMPARTMENT_TYPE = "StereotypeCompartment";//$NON-NLS-1$
+ public static final String STEREOTYPE_BRACE_TYPE = "StereotypeBrace";//$NON-NLS-1$
+
+ public static final String STEREOTYPE_PROPERTY_TYPE = "StereotypeProperty";//$NON-NLS-1$
+ public static final String STEREOTYPE_PROPERTY_BRACE_TYPE = "StereotypePropertyBrace";//$NON-NLS-1$
+
public static final String STEREOTYPE_COMMENT_TYPE = "StereotypeComment";//$NON-NLS-1$
public static final String STEREOTYPE_COMMENT_LINK_TYPE = "StereotypeCommentLink";
+
+ // Name notation value
public static final String STEREOTYPE_LABEL_NAME = "stereotype";//$NON-NLS-1$
public static final String STEREOTYPE_COMPARTMENT_NAME = "stereotype";//$NON-NLS-1$
public static final String STEREOTYPE_PROPERTY_NAME = "property";//$NON-NLS-1$
- public static final String STEREOTYPE_LABEL_DEPTH = "depth";//$NON-NLS-1$
- // Visibility Constants
- public static final String STEREOTYPE_LABEL_VSISIBLE = "visible";//$NON-NLS-1$
- public static final Boolean DEFAULT_VISIBILITY_VALUE = Boolean.TRUE;//$NON-NLS-1$
- public static final Boolean DEFAULT_PROPERTY_VISIBILITY_VALUE = Boolean.TRUE;//$NON-NLS-1$
+ // Depth Named Style
+ public static final String STEREOTYPE_LABEL_DEPTH = "depth";//$NON-NLS-1$
// Depth Constants
public static final String DEPTH_MAX = "full";//$NON-NLS-1$
@@ -52,27 +55,21 @@ public class StereotypeDisplayUtils {
public static final String DEPTH_AUTO = "auto";//$NON-NLS-1$
public static final String DEFAULT_DEPTH_VALUE = "full";//$NON-NLS-1$
- // Property Constants
- public static final String STEREOTYPE_PROPERTY_LOCATION_BRACE = "inBrace";//$NON-NLS-1$
- public static final String STEREOTYPE_PROPERTY_LOCATION_COMPARTMENT = "inCompartment";//$NON-NLS-1$
- public static final String STEREOTYPE_PROPERTY_LOCATION_COMMENT_BRACE = "inCommentBrace";//$NON-NLS-1$
- public static final String STEREOTYPE_PROPERTY_LOCATION_COMMENT = "inCommentCompartment";//$NON-NLS-1$
-
- // Default Display Location
- public static final boolean DEFAULT_STEREOTYPE_PROPERTY_DISPLAY_BRACE = true;//$NON-NLS-1$
- public static final boolean DEFAULT_STEREOTYPE_PROPERTY_DISPLAY_COMPARTMENT = true;//$NON-NLS-1$
- public static final boolean DEFAULT_STEREOTYPE_PROPERTY_DISPLAY_COMMENT_BRACE = true;//$NON-NLS-1$
- public static final boolean DEFAULT_STEREOTYPE_PROPERTY_DISPLAY_COMMENT = true;//$NON-NLS-1$
// Special Char Constants
public final static String STEREOTYPE_LABEL_SEPARATOR = ", ";//$NON-NLS-1$
public static final String STEREOTYPE_PROPERTY_SEPARATOR = "\n";//$NON-NLS-1$
public static final String STEREOTYPE_PROPERTY_VALUE_SEPARATOR = " = ";//$NON-NLS-1$
+ public static final String STEREOTYPE_PROPERTIES_SEPARATOR = " ";//$NON-NLS-1$
// Ornament Constants
- public final static String BRACE_LEFT = Activator.ST_LEFT;
- public final static String BRACE_RIGHT = Activator.ST_RIGHT;
+ public final static String QUOTE_LEFT = "<==";// Activator.ST_LEFT;
+ public final static String QUOTE_RIGHT = "==>";// Activator.ST_RIGHT;
+ public final static String BRACE_LEFT = "{";
+ public final static String BRACE_RIGHT = "}";
+
+ public static final boolean PERSISTENT = true;//$NON-NLS-1$
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/dom/GMFUMLElementAdapter.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/dom/GMFUMLElementAdapter.java
index 724a8fe7f4c..5c048a9dc0f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/dom/GMFUMLElementAdapter.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/dom/GMFUMLElementAdapter.java
@@ -26,6 +26,7 @@ import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
import org.eclipse.papyrus.infra.tools.util.ListHelper;
import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayHelper;
import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayUtils;
+import org.eclipse.papyrus.uml.diagram.css.helper.CSSDOMUMLSemanticElementHelper;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Property;
@@ -41,9 +42,13 @@ import org.eclipse.uml2.uml.Stereotype;
*/
public class GMFUMLElementAdapter extends GMFElementAdapter {
- public final StereotypeDisplayHelper helper = StereotypeDisplayHelper.getInstance();
+
+
+ public final StereotypeDisplayHelper stereotypeHelper = StereotypeDisplayHelper.getInstance();
public static final String APPLIED_STEREOTYPES_PROPERTY = "appliedStereotypes"; //$NON-NLS-1$
+
+
/**
* The CSS Separator for qualifiers, when we must use CSS ID
* When we can use CSS String, we use the standard UML "::" qualifier separator
@@ -54,6 +59,7 @@ public class GMFUMLElementAdapter extends GMFElementAdapter {
public GMFUMLElementAdapter(View view, ExtendedCSSEngine engine) {
super(view, engine);
+ helper = CSSDOMUMLSemanticElementHelper.getInstance();
}
/**
@@ -72,7 +78,7 @@ public class GMFUMLElementAdapter extends GMFElementAdapter {
// get stereotype Label attribute
- if (helper.isStereotypeLabel(semanticElement)) {
+ if (stereotypeHelper.isStereotypeLabel(semanticElement)) {
String value = getStereotypeLabelAttribute(attr);
if (value != null && !value.isEmpty()) {
return value;
@@ -80,7 +86,7 @@ public class GMFUMLElementAdapter extends GMFElementAdapter {
}
// get stereotype Compartment attribute
- if (helper.isStereotypeCompartment(semanticElement)) {
+ if (stereotypeHelper.isStereotypeCompartment(semanticElement) || stereotypeHelper.isStereotypeBrace(semanticElement)) {
String value = getStereotypeCompartmentAttribute(attr);
if (value != null && !value.isEmpty()) {
return value;
@@ -89,7 +95,7 @@ public class GMFUMLElementAdapter extends GMFElementAdapter {
// get stereotype Property attribute
- if (helper.isStereotypeProperty(semanticElement)) {
+ if (stereotypeHelper.isStereotypeProperty(semanticElement) || stereotypeHelper.isStereotypeBraceProperty(semanticElement)) {
String value = getStereotypePropertyAttribute(attr);
if (value != null && !value.isEmpty()) {
@@ -162,7 +168,7 @@ public class GMFUMLElementAdapter extends GMFElementAdapter {
if (StereotypeDisplayUtils.STEREOTYPE_COMPARTMENT_NAME.equals(attr)) {
BasicCompartment propertyCompartment = (BasicCompartment) semanticElement;
- return helper.getName(propertyCompartment);
+ return stereotypeHelper.getName(propertyCompartment);
}
return "";
@@ -189,9 +195,9 @@ public class GMFUMLElementAdapter extends GMFElementAdapter {
} else if (StereotypeDisplayUtils.STEREOTYPE_COMPARTMENT_NAME.equals(attr)) {
EObject propertyCompartment = ((DecorationNode) semanticElement).eContainer();
- if (helper.isStereotypeCompartment(propertyCompartment)) {
+ if (stereotypeHelper.isStereotypeCompartment(propertyCompartment)) {
- return helper.getName((DecorationNode) propertyCompartment);
+ return stereotypeHelper.getName((DecorationNode) propertyCompartment);
}
}
@@ -211,7 +217,7 @@ public class GMFUMLElementAdapter extends GMFElementAdapter {
if (StereotypeDisplayUtils.STEREOTYPE_LABEL_NAME.equals(attr)) {
DecorationNode label = (DecorationNode) semanticElement;
- String stereoName = helper.getName(label);
+ String stereoName = stereotypeHelper.getName(label);
return stereoName;
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/helper/CSSDOMUMLSemanticElementHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/helper/CSSDOMUMLSemanticElementHelper.java
new file mode 100644
index 00000000000..a61a71d0df8
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/helper/CSSDOMUMLSemanticElementHelper.java
@@ -0,0 +1,87 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 Stereotype Display
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.css.helper;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.notation.DecorationNode;
+import org.eclipse.gmf.runtime.notation.Shape;
+import org.eclipse.papyrus.infra.gmfdiag.css.helper.CSSDOMSemanticElementHelper;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayHelper;
+
+/**
+ * This class is a helper for retrieving view and semantic element from a compatible object related to UML.
+ *
+ * @author Céline JANSSENS
+ *
+ */
+public class CSSDOMUMLSemanticElementHelper extends CSSDOMSemanticElementHelper {
+
+
+ /**
+ * singleton instance
+ */
+ private static CSSDOMUMLSemanticElementHelper elementHelper;
+
+ /** Private Constructor. */
+ protected CSSDOMUMLSemanticElementHelper() {
+ super();
+ }
+
+ /**
+ * Returns the singleton instance of this class
+ *
+ * @return the singleton instance.
+ */
+ public static CSSDOMUMLSemanticElementHelper getInstance() {
+ if (elementHelper == null) {
+ elementHelper = new CSSDOMUMLSemanticElementHelper();
+ }
+ return elementHelper;
+ }
+
+
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.css.helper.CSSDOMSemanticElementHelper#findSemanticElement(org.eclipse.emf.ecore.EObject)
+ *
+ * @param notationElement
+ * @return
+ */
+ @Override
+ public EObject findSemanticElement(EObject notationElement) {
+
+ StereotypeDisplayHelper stereotypeHelper = StereotypeDisplayHelper.getInstance();
+
+ // Add Stereotype Comment
+ if (notationElement instanceof Shape) {
+ if (stereotypeHelper.isStereotypeComment(notationElement)) {
+ return notationElement;
+ }
+ }
+
+
+ // Add StereotypeProperty to the DOM model
+ if (notationElement instanceof DecorationNode) {
+ if (stereotypeHelper.isStereotypeProperty(notationElement)
+ || stereotypeHelper.isStereotypeBraceProperty(notationElement)) {
+ return notationElement;
+ }
+
+ }
+
+ return super.findSemanticElement(notationElement);
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AppliedStereotypeExternalNodeLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AppliedStereotypeExternalNodeLabelEditPolicy.java
index ef6f66fba1b..4137a63c2ee 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AppliedStereotypeExternalNodeLabelEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AppliedStereotypeExternalNodeLabelEditPolicy.java
@@ -19,7 +19,6 @@ import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
import org.eclipse.papyrus.uml.appearance.helper.AppliedStereotypeHelper;
import org.eclipse.papyrus.uml.appearance.helper.UMLVisualInformationPapyrusConstant;
-import org.eclipse.papyrus.uml.diagram.common.Activator;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusNodeUMLElementFigure;
import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusUMLElementFigure;
@@ -93,38 +92,6 @@ public class AppliedStereotypeExternalNodeLabelEditPolicy extends AppliedStereot
}
}
- @Override
- public String stereotypesToDisplay() {
- if (hostView == null) {
- return "";
- }
- // list of stereotypes to display
- String stereotypesToDisplay = AppliedStereotypeHelper.getStereotypesToDisplay(hostView);
- // Kind of the representation
- String stereotypespresentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(hostView);
-
- // check the presentation kind. if only icon => do not display
- // stereotypes
- if (UMLVisualInformationPapyrusConstant.ICON_STEREOTYPE_PRESENTATION.equals(stereotypespresentationKind)) {
- return ""; // empty string, so stereotype label should not be
- // displayed
- }
-
- // stereotypes with qualified name to display
- String stereotypesToDisplayWithQN = AppliedStereotypeHelper.getStereotypesQNToDisplay(hostView);
-
- // the set is empty
- if (stereotypesToDisplayWithQN.length() == 0 && stereotypesToDisplay.length() == 0) {
- return "";
- }
- // vertical representation
- if (UMLVisualInformationPapyrusConstant.STEREOTYPE_TEXT_VERTICAL_PRESENTATION.equals(stereotypespresentationKind)) {
- return Activator.ST_LEFT + stereotypesToDisplay() + Activator.ST_RIGHT;
- } else {// horizontal representation
- return Activator.ST_LEFT + stereotypesToDisplay() + Activator.ST_RIGHT;
-
- }
- }
protected void refreshAppliedStereotypesProperties(IPapyrusNodeUMLElementFigure figure) {
if (hostView == null) {
@@ -199,7 +166,7 @@ public class AppliedStereotypeExternalNodeLabelEditPolicy extends AppliedStereot
if (figure instanceof IPapyrusUMLElementFigure) {// calculate text
// and icon to
// display
- final String stereotypesToDisplay = stereotypesToDisplay();
+ final String stereotypesToDisplay = helper.getStereotypeTextToDisplay(hostView);
((IPapyrusUMLElementFigure) figure).setStereotypeDisplay(tag + (stereotypesToDisplay), null);
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/plugin.xml
index 5331d355cfe..4a838ce0dad 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/plugin.xml
@@ -20,7 +20,7 @@
<object
class="org.eclipse.gmf.runtime.notation.Node(org.eclipse.gmf.runtime.notation)"
id="StereotypePropertiesEditPartProvider">
- <method name="getType()" value="StereotypeComment,StereotypeCompartment,StereotypeProperty,StereotypeCommentLink"/>
+ <method name="getType()" value="StereotypePropertyBrace, StereotypeBrace, StereotypeLabel, StereotypeComment,StereotypeCompartment,StereotypeProperty,StereotypeCommentLink"/>
</object>
</editpartProvider>
</extension>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeCompartmentEditPart.java
index 18c32c0cd37..a037a41105c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeCompartmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeCompartmentEditPart.java
@@ -18,6 +18,7 @@ import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.OrderedLayout;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
@@ -34,7 +35,6 @@ import org.eclipse.papyrus.uml.diagram.common.editpolicies.PasteEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.figure.node.AppliedStereotypeCompartmentFigure;
import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayUtils;
import org.eclipse.uml2.uml.Stereotype;
-import org.eclipse.uml2.uml.util.UMLUtil;
/**
* this compartment is the an editpart associated to an applied stereotype
@@ -67,9 +67,12 @@ public class AppliedStereotypeCompartmentEditPart extends ResizeableListCompartm
@Override
public String getCompartmentName() {
- Stereotype stereotype = UMLUtil.getStereotype(resolveSemanticElement());
- if (stereotype != null) {
- return (StereotypeDisplayUtils.BRACE_LEFT + stereotype.getName() + StereotypeDisplayUtils.BRACE_RIGHT);
+ EObject element = resolveSemanticElement();
+ if (element instanceof Stereotype) {
+ Stereotype stereotype = (Stereotype) resolveSemanticElement();
+ if (stereotype != null) {
+ return (StereotypeDisplayUtils.QUOTE_LEFT + stereotype.getName() + StereotypeDisplayUtils.QUOTE_RIGHT);
+ }
}
return NO_STEREOTYPE_COMPARTMENT;
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeEmptyEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeEmptyEditPart.java
new file mode 100644
index 00000000000..85cce7c3e2e
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeEmptyEditPart.java
@@ -0,0 +1,98 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Celine JANSSENS (ALL4TEC) - Initial API and implementation
+ * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Bug 455311 Stereotype Display
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart;
+
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.stereotype.edition.provider.StereotypePropertiesEditPartProvider;
+
+/**
+ * This Edit Part is a dummy edit part with no figure to be linked to a Notation View that is not representing a graphical object.
+ * The Views related to this edit Part are Views of type StereotypeBrace, StereotypeLabel and StereotypeBraceProperty
+ *
+ * @see StereotypePropertiesEditPartProvider
+ *
+ * @author Celine JANSSENS
+ *
+ */
+public class AppliedStereotypeEmptyEditPart
+ extends GraphicalEditPart {
+
+ public static final String ID = "AppliedStereotypesEmptyNode";
+ private IFigure figure;
+
+ /**
+ * Constructor.
+ *
+ * @param view
+ */
+ public AppliedStereotypeEmptyEditPart(View view) {
+ super(view);
+ }
+
+ @Override
+ protected void addNotationalListeners() {
+ // no need for Listeners
+ }
+
+ @Override
+ protected void addSemanticListeners() {
+ // no need for Listeners
+ }
+
+
+ /**
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getFigure()
+ *
+ * @return
+ */
+ @Override
+ public IFigure getFigure() {
+ return super.getFigure();
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.diagram.ui.internal.editparts.DummyEditPart#createFigure()
+ *
+ * @return An invisible rectangle of size null.
+ */
+ @Override
+ protected IFigure createFigure() {
+ if (figure == null) {
+ figure = new Figure() {
+ @Override
+ public void paint(org.eclipse.draw2d.Graphics graphics) {
+ // Nothing to do
+ };
+
+ /**
+ * @see org.eclipse.draw2d.Figure#getBounds()
+ *
+ * @return
+ */
+ @Override
+ public Rectangle getBounds() {
+ return new Rectangle();
+ }
+
+ };
+ }
+ return figure;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeMultilinePropertyEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeMultilinePropertyEditPart.java
index 68d9c8c48dc..cd0654b352d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeMultilinePropertyEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpart/AppliedStereotypeMultilinePropertyEditPart.java
@@ -77,6 +77,7 @@ import org.eclipse.papyrus.uml.diagram.common.figure.node.EditingFlowPage;
import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
import org.eclipse.papyrus.uml.diagram.common.figure.node.IMultilineEditableFigure;
import org.eclipse.papyrus.uml.diagram.common.parser.StereotypePropertyParser;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayHelper;
import org.eclipse.papyrus.uml.profile.structure.AppliedStereotypeProperty;
import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.AccessibleEvent;
@@ -89,6 +90,7 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.util.UMLUtil;
/**
@@ -879,7 +881,8 @@ public class AppliedStereotypeMultilinePropertyEditPart extends CompartmentEditP
if (((View) getNotationView().eContainer() != null) && ((View) getNotationView().eContainer()).getElement() != null) {
super.activate();
addOwnerElementListeners();
- stereotypeApplication = ((View) getNotationView().eContainer()).getElement();
+ Stereotype stereotype = (Stereotype) ((View) getNotationView().eContainer()).getElement();
+ stereotypeApplication = StereotypeDisplayHelper.getInstance().getStereotypeApplication(getNotationView(), stereotype);
final Element umlElement = UMLUtil.getBaseElement(stereotypeApplication);
getDiagramEventBroker().addNotificationListener(stereotypeApplication, this);
getDiagramEventBroker().addNotificationListener(umlElement, this);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCommentCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCommentCreationEditPolicy.java
index 095da1025af..cb1994c0855 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCommentCreationEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCommentCreationEditPolicy.java
@@ -15,20 +15,15 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.stereotype.edition.editpolicies;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
import org.eclipse.gmf.runtime.diagram.ui.editparts.BorderedBorderItemEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.notation.BasicCompartment;
import org.eclipse.gmf.runtime.notation.Bounds;
import org.eclipse.gmf.runtime.notation.Edge;
@@ -38,17 +33,20 @@ import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.GMFUnsafe;
import org.eclipse.papyrus.uml.diagram.common.Activator;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.CreateAppliedStereotypeCommentContentCommand;
import org.eclipse.papyrus.uml.diagram.common.stereotype.CreateAppliedStereotypeCommentViewCommand;
-import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeLocationEnum;
-import org.eclipse.papyrus.uml.tools.listeners.StereotypeElementListener.StereotypeExtensionNotification;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.CreateAppliedStereotypePropertyViewCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.CreateAppliedStereotypeViewCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayUtils;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Extension;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
/**
* This editpolicy has in charge to :
* - create or destroy the appliedStereotypesCommentEditpart
- * - adapt the information about stereotype display into appliedstereotypeCommentEditPart
+ * - create notation view associated to this CommentEditPart
+ * - refresh the Comment content based on the UML information
* by using NamedStyle mechanism into Notation model
*
*
@@ -59,75 +57,80 @@ public class AppliedStereotypeCommentCreationEditPolicy extends AppliedStereotyp
/** constant for this edit policy role */
public final static String APPLIED_STEREOTYPE_COMMENT = "AppliedStereotypeComment";// $NON-NLS-1$
- protected GraphicalEditPart hostEditPart;
- private Node node;
+ /** the comment node associated to the Host EditPart */
private Node comment;
/**
- * Map between Stereotype Name and StereotypeLabel displayed
+ * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy#refreshNotationStructure()
+ *
*/
- private Map<EObject, BasicCompartment> stereotypeCommentMap = new HashMap<EObject, BasicCompartment>();
+ @Override
+ public void refreshNotationStructure() {
+
+ if (hostView != null) {
+
+ removeUnappliedStereotypes(comment);
+ if (!stereotypeList.isEmpty()) {
+ refreshStereotypeCommentStructure();
+ }
+ }
+ }
/**
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy#activate()
- *
+ * Refresh the structure for the Stereotype List
+ *
+ * @param stereotypeList
+ * The list of Stereotype applied on the Element.
*/
- @Override
- public void activate() {
- super.activate();
- if (getHost() instanceof GraphicalEditPart) {
- hostEditPart = (GraphicalEditPart) getHost();
- node = getNotationNode();
+ public void refreshStereotypeCommentStructure() {
+ if (comment != null) {
+ removeUnappliedStereotypes(comment);
}
-
- // if stereotype has been applied, compartment has to be created
- Element umlElement = getUMLElement();
- // umlElement may be null if the semantic element has been deleted and the view hasn't been cleaned
- if (umlElement != null) {
- Iterator<EObject> iterator = umlElement.getStereotypeApplications().iterator();
- while (iterator.hasNext()) {
- final EObject appliedstereotype = iterator.next();
- createAppliedStereotypeCompartmentComment(appliedstereotype);
+ // rebuild the structure from the Stereotype List
+ if (!stereotypeList.isEmpty()) {
+ comment = createCommentNode();
+ for (Stereotype stereotype : stereotypeList) {
+ refreshStereotypeCompartmentStructure(stereotype);
+ refreshStereotypeBraceStructure(stereotype);
}
}
+
}
/**
+ * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy#refreshStereotypeCompartmentStructure(org.eclipse.uml2.uml.Stereotype)
*
- * {@inheritedDoc}
+ * @param stereotype
*/
@Override
- public void notifyChanged(Notification notification) {
-
- final int eventType = notification.getEventType();
-
- if (eventType == StereotypeExtensionNotification.STEREOTYPE_APPLIED_TO_ELEMENT) {
- super.notifyChanged(notification);
-
- getDiagramEventBroker().addNotificationListener((EObject) notification.getNewValue(), this);
- createAppliedStereotypeCompartmentComment((EObject) notification.getNewValue());
-
-
- } else if (eventType == StereotypeExtensionNotification.STEREOTYPE_UNAPPLIED_FROM_ELEMENT) {
- // super.notifyChanged(notification);
- getDiagramEventBroker().removeNotificationListener((EObject) notification.getOldValue(), this);
- removeAppliedStereotypeCompartmentComment((EObject) notification.getOldValue());
-
+ public void refreshStereotypeBraceStructure(Stereotype stereotype) {
+ BasicCompartment compartment = helper.getStereotypeCompartment(hostView, stereotype);
+ if (compartment == null) { // No Label Exist for this Stereotype
+ createAppliedStereotypeBraceCompartment(stereotype);
+ createAppliedStereotypeBraceProperties(stereotype);
}
-
}
/**
- * @return the stereotypeCommentMap
+ * Refresh The StereotypeCompartment notation structure.
+ *
+ * @param stereotype
+ * Stereotype related to the Compartment to created
*/
- public Map<EObject, BasicCompartment> getStereotypeCommentMap() {
- return stereotypeCommentMap;
+ public void refreshStereotypeCompartmentStructure(Stereotype stereotype) {
+
+ BasicCompartment compartment = helper.getStereotypeCompartment(comment, stereotype);
+ if (compartment == null) { // No Compartment Exist for this Stereotype
+ createAppliedStereotypeCompartment(stereotype);
+ createAppliedStereotypeProperties(stereotype);
+
+ }
}
@@ -137,85 +140,192 @@ public class AppliedStereotypeCommentCreationEditPolicy extends AppliedStereotyp
* @param stereotypeApplication
* the stereotype application
*/
- protected void createAppliedStereotypeCompartmentComment(final EObject stereotypeApplication) {
+ protected void createAppliedStereotypeCompartment(final Stereotype stereotype) {
+ final View node = hostEditPart.getNotationView();
+ // doesn't exist already
+ if (!helper.isCompartmentExist(node, stereotype)) {
+ // Create Compartment
+ executeAppliedStereotypeCompartmentCreation(hostEditPart, stereotype, StereotypeDisplayUtils.STEREOTYPE_COMPARTMENT_TYPE);
+ }
+ }
- Node compartment = helper.getStereotypeCompartment(node, stereotypeApplication);
- if (compartment != null) {
- // If the node should be displayed in a Compartment or Brace Comment then create the Comment and its content
- if (!helper.isEmpty(compartment, StereotypeLocationEnum.IN_COMMENT_BRACE)
- || (!helper.isEmpty(compartment, StereotypeLocationEnum.IN_COMMENT_COMPARTMENT))) {
- if (helper.getStereotypeComment(node) == null) {
- // if Comment doesn't exist => Create it and copy the structure from the host
+ /**
+ * In charge of properties view creation
+ *
+ * @param eObject
+ * The Edit Part of which the Properties should be created
+ */
- if (getHost() instanceof ConnectionEditPart) {
- executeAppliedStereotypeCommentCreation(((ConnectionEditPart) getHost()).resolveSemanticElement());
- }
- if (getHost() instanceof GraphicalEditPart) {
- executeAppliedStereotypeCommentCreation(((GraphicalEditPart) getHost()).resolveSemanticElement());
- }
+ protected void createAppliedStereotypeProperties(final Stereotype stereotype) {
- }
+ Node compartment = helper.getStereotypeCompartment(comment, stereotype);
+ if (compartment != null && stereotype != null) {
- executeAppliedStereotypeCommentContent(compartment, stereotypeApplication);
+ EList<Property> properties = stereotype.allAttributes();
+ for (Property property : properties) {
+ createAppliedStereotypeProperty(compartment, property);
}
}
}
/**
- * Remove the Compartment into the Comment associated to the stereotypeApplication
+ * In Charge of PropertyView Creation
*
- * @param stereotypeApplication
- * the stereotypeApplication associated to the compartment to be deleted
+ * @param propertyType
+ * Type of Property {@link StereotypeDisplayUtils#STEREOTYPE_PROPERTY_TYPE} or {@link StereotypeDisplayUtils#STEREOTYPE_PROPERTY_BRACE_TYPE}
+ * @param compartment
+ * The Compartment owner of the Property that will be created
+ * @param property
+ * The UML Property of the View to create
*/
- protected void removeAppliedStereotypeCompartmentComment(EObject stereotypeApplication) {
- // Remove the Label node
- BasicCompartment compartment = getStereotypeCommentMap().get(stereotypeApplication);
- if ((compartment != null) && (TransactionUtil.getEditingDomain(compartment) != null)) {
- executeAppliedStereotypeCompartmentRemove(hostEditPart, compartment);
- // Delete entry from the Map
- deleteInCommentMap(stereotypeApplication);
+
+ protected void createAppliedStereotypeProperty(Node compartment, Property property) {
+ // if stereotype is null all property of stereotype has to be removed!
+ if (property != null && !property.getName().startsWith(Extension.METACLASS_ROLE_PREFIX)) {
+ if (!helper.isPropertyExist(compartment, property)) {
+ // go through each stereotype property
+ executeAppliedStereotypePropertyViewCreation(hostEditPart, compartment, property);
+
+ }
}
}
/**
- * Add the compartment into the Comment Edit Part
- *
- * @param stereotypeApplication
- * The Stereotype Application associated to the new Compartment
+ * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy#createAppliedStereotypeBraceCompartment(org.eclipse.uml2.uml.Stereotype)
+ *
+ * @param stereotype
+ * Stereotype related to the Brace Compartment to created
*/
- protected void executeAppliedStereotypeCommentContent(Node compartment, EObject stereotypeApplication) {
- comment = helper.getStereotypeComment(node);
- if (comment != null) {
- executeAppliedStereotypeCommentContentCreationCommand(compartment);
+ @Override
+ protected void createAppliedStereotypeBraceCompartment(Stereotype stereotype) {
+ final View node = hostEditPart.getNotationView();
+ // doesn't exist already
+ if (!helper.isCompartmentExist(node, stereotype)) {
+ // Create Compartment
+ executeAppliedStereotypeCompartmentCreation(hostEditPart, stereotype, StereotypeDisplayUtils.STEREOTYPE_BRACE_TYPE);
- // Store entry in the Map
- storeInCommentMap(stereotypeApplication, comment);
}
}
/**
- * Create the Comment content based on the original model content
+ * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy#createAppliedStereotypeBraceProperties(org.eclipse.uml2.uml.Stereotype)
+ *
+ * @param stereotype
+ * Stereotype related to the Brace Properties to created
+ */
+ @Override
+ protected void createAppliedStereotypeBraceProperties(Stereotype stereotype) {
+ Node compartment = helper.getStereotypeBraceCompartment(comment, stereotype);
+ if (compartment != null && stereotype != null) {
+
+ EList<Property> properties = stereotype.allAttributes();
+ for (Property property : properties) {
+ createAppliedStereotypeBraceProperty(compartment, property);
+ }
+ }
+ }
+
+ /**
+ * In charge of Comment Node creation.
*
+ * @return The Comment Node newly created
+ */
+ private Node createCommentNode() {
+ if (helper.getStereotypeComment(hostView) == null) {
+ // if Comment doesn't exist => Create it and copy the structure from the host
+
+ if (getHost() instanceof ConnectionEditPart) {
+ executeAppliedStereotypeCommentCreation(((ConnectionEditPart) getHost()).resolveSemanticElement());
+ }
+ if (getHost() instanceof GraphicalEditPart) {
+ executeAppliedStereotypeCommentCreation(((GraphicalEditPart) getHost()).resolveSemanticElement());
+ }
+
+ }
+ return helper.getStereotypeComment(hostView);
+
+ }
+
+
+ /**
+ * The goal of this method is to execute the a command to create a notation node for a compartment of stereotype
+ *
+ * @param editPart
+ * the editPart owner of the new compartment
+ * @param appliedstereotype
+ * the stereotype application
+ */
+
+ protected void executeAppliedStereotypeCompartmentCreation(final IGraphicalEditPart editPart, final Stereotype stereotype, final String type) {
+ try {
+ editPart.getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ Display.getCurrent().syncExec(new Runnable() {
+
+
+ public void run() {
+ CreateAppliedStereotypeViewCommand command = new CreateAppliedStereotypeViewCommand(editPart.getEditingDomain(), comment, stereotype, type);
+
+ // use to avoid to put it in the command stack
+ try {
+ GMFUnsafe.write(editPart.getEditingDomain(), command);
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+ });
+
+ }
+ });
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+
+
+ /**
+ * This method is used to create a notation node for the property of the stereotype
+ *
+ * @param editPart
+ * the editPart container
* @param compartment
- * The original compartment on which is based the Comment compartment to be added into the Comment model
+ * @param stereotypeApplication
+ * @param stereotype
+ * the stereotype associated to compartment node
*/
- protected void executeAppliedStereotypeCommentContentCreationCommand(Node compartment) {
- final RecordingCommand cmd = new CreateAppliedStereotypeCommentContentCommand("Applied Stereotype Delegation", comment, hostEditPart, compartment);
- final TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(getView());
- Display.getCurrent().syncExec(new Runnable() {
- public void run() {
- // use to avoid to put it in the command stack
- try {
- GMFUnsafe.write(domain, cmd);
- } catch (Exception e) {
- Activator.log.error(e);
+ protected void executeAppliedStereotypePropertyViewCreation(final IGraphicalEditPart editPart, final Node compartment, final Property stereotypeProperty) {
+ try {
+ editPart.getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ Display.getCurrent().syncExec(new Runnable() {
+
+ public void run() {
+
+ // use to avoid to put it in the command stack
+ CreateAppliedStereotypePropertyViewCommand command = new CreateAppliedStereotypePropertyViewCommand(editPart.getEditingDomain(), compartment, stereotypeProperty, StereotypeDisplayUtils.STEREOTYPE_PROPERTY_TYPE);
+ try {
+ GMFUnsafe.write(editPart.getEditingDomain(), command);
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+ });
}
- }
- });
+ });
+
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
}
+
+
+
+
/**
* The goal of this method is to execute the a command to create a notation node for applied stereotype
* as "Comment" shape.
@@ -293,108 +403,6 @@ public class AppliedStereotypeCommentCreationEditPolicy extends AppliedStereotyp
});
}
-
-
- /**
- * This method has in charge to refresh the presence of the view that represent the comment
- */
- protected void updateAppliedStereotypeCommentShape() {
-
-
- // look for the AppliedStereotypesCommentEditPart
- Node commentNode = helper.getStereotypeComment(node);
-
- if (helper.hasStereotypeCompartment(node)) {
-
- // if Comment doesn't exist => Create it and copy the structure from the host
- if (commentNode == null) {
-
- if (getHost() instanceof ConnectionEditPart) {
- executeAppliedStereotypeCommentCreation(((ConnectionEditPart) getHost()).resolveSemanticElement());
- }
- if (getHost() instanceof GraphicalEditPart) {
- executeAppliedStereotypeCommentCreation(((GraphicalEditPart) getHost()).resolveSemanticElement());
- }
- }
-
- } else {
- // If the host doesn't have compartment remove the Comment if any
- if (commentNode != null) {
- final TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(commentNode);
- executeAppliedStereotypeCommentDeletion(domain, commentNode);
- }
- }
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy#refreshStereotypeDisplay()
- *
- */
- @Override
- protected void refreshStereotypeDisplay() {
- refreshComment();
- }
-
- /**
- * Refresh The Comment Figure. Delete if empty.
- */
- protected void refreshComment() {
-
- // Refresh to create Comment if CSS Change
- if (node != null) {
- if (node.getElement() instanceof Element) {
- Element elt = (Element) node.getElement();
- EList<EObject> appliedStereotypes = elt.getStereotypeApplications();
- for (EObject obj : appliedStereotypes) {
- getDiagramEventBroker().addNotificationListener(obj, this);
- createAppliedStereotypeCompartmentComment(obj);
-
- }
- }
- }
-
- // Delete Comment if empty
- comment = helper.getStereotypeComment(node);
- if (comment != null) {
- if (helper.isCommentEmpty(comment)) {
- // Delete the Comment Node
- executeAppliedStereotypeCommentDeletion(hostEditPart.getEditingDomain(), comment);
- }
- }
-
-
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy#storeInMap(org.eclipse.emf.ecore.EObject, org.eclipse.gmf.runtime.notation.View)
- *
- * @param stereotypeApplication
- * The Application Of the stereotype to be stored
- * @param node
- * the Comment Node which contains the Applied Stereotype Compartments
- */
-
- protected void storeInCommentMap(EObject stereotypeApplication, View node) {
-
- if (stereotypeApplication != null && node != null) {
- BasicCompartment compartment = helper.getStereotypeCompartment(node, stereotypeApplication);
- getStereotypeCommentMap().put(stereotypeApplication, compartment);
-
-
- }
-
- }
-
- /**
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy#deleteInMap(org.eclipse.emf.ecore.EObject)
- *
- * @param stereotypeApplication
- */
-
- protected void deleteInCommentMap(EObject stereotypeApplication) {
- getStereotypeCommentMap().remove(stereotypeApplication);
- }
-
/**
* Get the Node (notation) corresponding to the Host editpart
*/
@@ -411,5 +419,4 @@ public class AppliedStereotypeCommentCreationEditPolicy extends AppliedStereotyp
}
-
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCompartmentEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCompartmentEditPolicy.java
index aca154fd354..6ccd91e7cfb 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCompartmentEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCompartmentEditPolicy.java
@@ -16,14 +16,23 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.stereotype.edition.editpolicies;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.BasicCompartment;
+import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.GMFUnsafe;
+import org.eclipse.papyrus.uml.diagram.common.Activator;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusNodeUMLElementFigure;
-import org.eclipse.uml2.uml.Element;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.CreateAppliedStereotypePropertyViewCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.CreateAppliedStereotypeViewCommand;
+import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayUtils;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.uml2.uml.Extension;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
/**
* this edit policy can be apply only on {@link IPapyrusEditPart} in order to
@@ -44,79 +53,185 @@ public class AppliedStereotypeCompartmentEditPolicy extends AppliedStereotypeNod
}
/**
+ * Refresh the NotationStructure of the Node for this Stereotype
+ *
+ * @param notationView
+ * @param stereo
+ */
+ @Override
+ public void refreshStereotypeStructure() {
+
+ // Build the structure from the Stereotype List
+ if (!stereotypeList.isEmpty()) {
+ for (Stereotype stereotype : stereotypeList) {
+ refreshStereotypeCompartmentStructure(stereotype);
+ }
+ }
+ }
+
+ /**
* @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy#refreshStereotypeDisplay()
*
*/
@Override
protected void refreshStereotypeDisplay() {
- if (getHost() instanceof IPapyrusEditPart) {
- IFigure figure = ((IPapyrusEditPart) getHost()).getPrimaryShape();
- // Refresh Properties in braces
- refreshAppliedStereotypesPropertiesInBrace((IPapyrusNodeUMLElementFigure) figure);
- }
+ // Nothing to refresh
}
/**
- * Refreshes the stereotypes properties displayed above name of the element
- * in this edit part.
+ * Refresh The StereotypeCompartment notation structure.
*
- * @param stereotypesPropertiesToDisplay
+ * @param view
+ * @param stereotype
*/
- protected void refreshAppliedStereotypesPropertiesInBrace(IPapyrusNodeUMLElementFigure figure) {
- String toDisplayInBrace = helper.getStereotypePropertiesInBrace(((GraphicalEditPart) getHost()).getNotationView());
- // if the string is not empty, then, the figure has to display it. Else,
- // it displays nothing
- if (!"".equals(toDisplayInBrace)) {
- // it has to be displayed in braces, so compute the string to
- // display
- figure.setStereotypePropertiesInBrace(toDisplayInBrace);
- } else {
- figure.setStereotypePropertiesInBrace(null);
+
+ protected void refreshStereotypeCompartmentStructure(Stereotype stereotype) {
+
+ BasicCompartment compartment = helper.getStereotypeCompartment(hostView, stereotype);
+ if (compartment == null) { // No Label Exist for this Stereotype
+ createAppliedStereotypeCompartment(stereotype);
+ createAppliedStereotypeProperties(stereotype);
+
}
}
-
/**
- * Returns the uml element controlled by the host edit part
+ * This method creates a node for the compartment of stereotype if it does not exist.
*
- * @return the uml element controlled by the host edit part
+ * @param stereotypeApplication
+ * the stereotype application
+ */
+ protected void createAppliedStereotypeCompartment(final Stereotype stereotype) {
+ final View node = hostEditPart.getNotationView();
+ // doesn't exist already
+ if (!helper.isCompartmentExist(node, stereotype)) {
+ // Create Compartment
+ executeAppliedStereotypeCompartmentCreation(hostEditPart, stereotype);
+
+ }
+ }
+
+
+ /**
+ * In charge of properties view creation
+ *
+ * @param eObject
+ * The Edit Part of which the Properties should be created
*/
- @Override
- protected Element getUMLElement() {
- Element element = null;
- View view = getView();
- if (view != null) {
+ protected void createAppliedStereotypeProperties(final Stereotype stereotype) {
- EObject container = view.eContainer();
- if (container instanceof View) {
- element = (Element) ((View) container).getElement();
+ Node compartment = helper.getStereotypeCompartment(hostEditPart.getNotationView(), stereotype);
+ if (compartment != null && stereotype != null) {
+
+ EList<Property> properties = stereotype.allAttributes();
+ for (Property property : properties) {
+ createAppliedStereotypeProperty(compartment, property);
}
+
+
}
+ }
- return element;
+ /**
+ * In Charge of PropertyView Creation
+ *
+ * @param propertyType
+ * Type of Property {@link StereotypeDisplayUtils#STEREOTYPE_PROPERTY_TYPE} or {@link StereotypeDisplayUtils#STEREOTYPE_PROPERTY_BRACE_TYPE}
+ * @param compartment
+ * The Compartment owner of the Property that will be created
+ * @param property
+ * The UML Property of the View to create
+ */
+
+ protected void createAppliedStereotypeProperty(Node compartment, Property property) {
+ // if stereotype is null all property of stereotype has to be removed!
+ if (property != null && !property.getName().startsWith(Extension.METACLASS_ROLE_PREFIX)) {
+ if (!helper.isPropertyExist(compartment, property)) {
+ // go through each stereotype property
+ executeAppliedStereotypePropertyViewCreation(hostEditPart, compartment, property);
+
+ }
+ }
}
+
/**
+ * the goal of this method is to execute the a command to create a notation node for a compartment of stereotype
*
- * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy#getView()
+ * @param editPart
+ * the editPart owner of the new compartment
+ * @param appliedstereotype
+ * the stereotype application
+ */
+
+ protected void executeAppliedStereotypeCompartmentCreation(final IGraphicalEditPart editPart, final Stereotype stereotype) {
+ try {
+ editPart.getEditingDomain().runExclusive(new Runnable() {
+
+
+ public void run() {
+ Display.getCurrent().syncExec(new Runnable() {
+
+
+ public void run() {
+ CreateAppliedStereotypeViewCommand command = new CreateAppliedStereotypeViewCommand(editPart.getEditingDomain(), editPart.getNotationView(), stereotype, StereotypeDisplayUtils.STEREOTYPE_COMPARTMENT_TYPE);
+
+ // use to avoid to put it in the command stack
+ try {
+ GMFUnsafe.write(editPart.getEditingDomain(), command);
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+ });
+
+ }
+ });
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+
+
+ /**
+ * this method is used to create a notation node for the property of the stereotype
*
- * @return
+ * @param editPart
+ * the editPart container
+ * @param compartment
+ * @param stereotypeApplication
+ * @param stereotype
+ * the stereotype associated to compartment node
*/
- @Override
- protected View getView() {
- View view = null;
- Object model = getHost().getModel();
- if (model instanceof View) {
+ protected void executeAppliedStereotypePropertyViewCreation(final IGraphicalEditPart editPart, final Node compartment, final Property stereotypeProperty) {
+ try {
+ editPart.getEditingDomain().runExclusive(new Runnable() {
- EObject container = ((View) model).eContainer();
- if (container instanceof View) {
- view = (View) container;
- }
+
+ public void run() {
+ Display.getCurrent().syncExec(new Runnable() {
+
+
+ public void run() {
+
+ // use to avoid to put it in the command stack
+ CreateAppliedStereotypePropertyViewCommand command = new CreateAppliedStereotypePropertyViewCommand(editPart.getEditingDomain(), compartment, stereotypeProperty, StereotypeDisplayUtils.STEREOTYPE_PROPERTY_TYPE);
+ try {
+ GMFUnsafe.write(editPart.getEditingDomain(), command);
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+ });
+ }
+ });
+
+ } catch (Exception e) {
+ Activator.log.error(e);
}
- return view;
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCompartmentForCommentShapeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCompartmentForCommentShapeEditPolicy.java
index 9e2c0ad84ed..5f67f1c2db7 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCompartmentForCommentShapeEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeCompartmentForCommentShapeEditPolicy.java
@@ -15,10 +15,8 @@
package org.eclipse.papyrus.uml.diagram.stereotype.edition.editpolicies;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.notation.EObjectValueStyle;
import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusNodeUMLElementFigure;
import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayUtils;
import org.eclipse.uml2.uml.Element;
@@ -49,24 +47,15 @@ public class AppliedStereotypeCompartmentForCommentShapeEditPolicy extends Appli
return null;
}
+
/**
- * @see org.eclipse.papyrus.uml.diagram.stereotype.edition.editpolicies.AppliedStereotypeCompartmentEditPolicy#refreshAppliedStereotypesPropertiesInBrace(org.eclipse.papyrus.uml.diagram.common.figure.node.IPapyrusNodeUMLElementFigure)
+ * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy#refreshNotationStructure()
*
- * @param figure
*/
@Override
- protected void refreshAppliedStereotypesPropertiesInBrace(IPapyrusNodeUMLElementFigure figure) {
-
- String toDisplayInBrace = helper.getStereotypePropertiesInBrace(((GraphicalEditPart) getHost()).getNotationView());
- // if the string is not empty, then, the figure has to display it. Else,
- // it displays nothing
- if (!"".equals(toDisplayInBrace)) {
- // it has to be displayed in braces, so compute the string to
- // display
- figure.setStereotypePropertiesInBrace(toDisplayInBrace);
- } else {
- figure.setStereotypePropertiesInBrace(null);
- }
+ public void refreshNotationStructure() {
+ // NothingToDo
}
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeLabelEditPolicy.java
index ac73c609ed4..20f57affed3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeLabelEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/editpolicies/AppliedStereotypeLabelEditPolicy.java
@@ -15,7 +15,6 @@
package org.eclipse.papyrus.uml.diagram.stereotype.edition.editpolicies;
import org.eclipse.draw2d.IFigure;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
@@ -34,26 +33,13 @@ public class AppliedStereotypeLabelEditPolicy extends AppliedStereotypeNodeLabel
/** constant for this edit policy role */
public final static String STEREOTYPE_LABEL_POLICY = "AppliedStereotypeLabelEditPolicy"; //$NON-NLS-1$
- private GraphicalEditPart hostEditPart = null;
-
/**
* Creates a new AppliedStereotype display edit policy
*/
public AppliedStereotypeLabelEditPolicy() {
super();
-
- }
-
-
- @Override
- public void activate() {
- super.activate();
- if (getHost() instanceof GraphicalEditPart) {
- hostEditPart = (GraphicalEditPart) getHost();
- }
}
-
/**
* @see org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy#refreshStereotypeDisplay()
*
@@ -61,8 +47,6 @@ public class AppliedStereotypeLabelEditPolicy extends AppliedStereotypeNodeLabel
@Override
protected void refreshStereotypeDisplay() {
refreshStereotypeLabelDisplay();
-
-
}
protected void refreshStereotypeLabelDisplay() {
@@ -71,7 +55,6 @@ public class AppliedStereotypeLabelEditPolicy extends AppliedStereotypeNodeLabel
// calculate text and icon to display
final String stereotypesToDisplay = helper.getStereotypeTextToDisplay((View) getHost().getModel());
- // computes the icon to be displayed
final Image imageToDisplay = stereotypeIconToDisplay();
// if the string is not empty, then, the figure has to display it.
@@ -79,13 +62,10 @@ public class AppliedStereotypeLabelEditPolicy extends AppliedStereotypeNodeLabel
if (figure instanceof IPapyrusNodeUMLElementFigure) {
// Refresh Stereotype Label
- // Stereotype should be passed as "" if null, in order to avoid "null" string.
- ((IPapyrusNodeUMLElementFigure) figure).setStereotypeDisplay(tag + (stereotypesToDisplay == null ? "" : stereotypesToDisplay), imageToDisplay);
+ ((IPapyrusNodeUMLElementFigure) figure).setStereotypeDisplay(tag + stereotypesToDisplay, imageToDisplay);
+
+ refreshAppliedStereotypesLabel((IPapyrusNodeUMLElementFigure) figure);
- // Refresh Stereotype Label
- if (figure instanceof IPapyrusNodeNamedElementFigure) {
- refreshAppliedStereotypesLabel((IPapyrusNodeUMLElementFigure) figure);
- }
}
}
@@ -93,7 +73,7 @@ public class AppliedStereotypeLabelEditPolicy extends AppliedStereotypeNodeLabel
/**
- * Refreshes the displayed stereotypes properties for this edit part.
+ * Refreshes the displayed stereotypes for this edit part.
*/
protected void refreshAppliedStereotypesLabel(IPapyrusNodeUMLElementFigure figure) {
// If node has a Label
@@ -109,4 +89,6 @@ public class AppliedStereotypeLabelEditPolicy extends AppliedStereotypeNodeLabel
}
}
+
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/provider/StereotypePropertiesEditPartProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/provider/StereotypePropertiesEditPartProvider.java
index eb3fe9c8d7f..9b3c073594e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/provider/StereotypePropertiesEditPartProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.stereotype.edition/src/org/eclipse/papyrus/uml/diagram/stereotype/edition/provider/StereotypePropertiesEditPartProvider.java
@@ -25,9 +25,10 @@ import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.providers.RestrictedAbstractEditPartProvider;
import org.eclipse.papyrus.uml.diagram.common.stereotype.StereotypeDisplayUtils;
+import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeCommentEditPart;
import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeEmptyEditPart;
import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeMultilinePropertyEditPart;
-import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypeCommentEditPart;
import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpart.AppliedStereotypesCommentLinkEditPart;
@@ -46,8 +47,15 @@ public class StereotypePropertiesEditPartProvider extends RestrictedAbstractEdit
nodeMap.put(StereotypeDisplayUtils.STEREOTYPE_COMPARTMENT_TYPE, AppliedStereotypeCompartmentEditPart.class);
nodeMap.put(StereotypeDisplayUtils.STEREOTYPE_PROPERTY_TYPE, AppliedStereotypeMultilinePropertyEditPart.class);
nodeMap.put(StereotypeDisplayUtils.STEREOTYPE_COMMENT_TYPE, AppliedStereotypeCommentEditPart.class);
+ nodeMap.put(StereotypeDisplayUtils.STEREOTYPE_LABEL_TYPE, AppliedStereotypeEmptyEditPart.class);
+ nodeMap.put(StereotypeDisplayUtils.STEREOTYPE_BRACE_TYPE, AppliedStereotypeEmptyEditPart.class);
+ nodeMap.put(StereotypeDisplayUtils.STEREOTYPE_PROPERTY_BRACE_TYPE, AppliedStereotypeEmptyEditPart.class);
+
+
edgeMap.put(StereotypeDisplayUtils.STEREOTYPE_COMMENT_LINK_TYPE, AppliedStereotypesCommentLinkEditPart.class);
+
+
}
/**

Back to the top