diff options
author | Géry Deloge | 2016-08-05 07:50:08 +0000 |
---|---|---|
committer | Géry Deloge | 2016-08-05 07:50:08 +0000 |
commit | cbd2e8fc303f663f5de2388791ee3166eb20ea3b (patch) | |
tree | 7746d7eacf3d0b0e0d9d6c8363b7f864ccbc4e48 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication | |
parent | 493fe8d06924ce5667ad5ed566ff83910a1c4c46 (diff) | |
download | org.eclipse.papyrus-cbd2e8fc303f663f5de2388791ee3166eb20ea3b.tar.gz org.eclipse.papyrus-cbd2e8fc303f663f5de2388791ee3166eb20ea3b.tar.xz org.eclipse.papyrus-cbd2e8fc303f663f5de2388791ee3166eb20ea3b.zip |
Bug 497678: [SysML][Requirements] NPE while opening requirements diagram
change unknown visualID value from null to "" (empty String)
impact on all diagrams
Change-Id: Ib24d6d1bc5b64ba5338645b3d8abdaa74db528c3
Signed-off-by: Géry Deloge <gery.deloge@cea.fr>
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication')
3 files changed, 1121 insertions, 1196 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src-gen/org/eclipse/papyrus/uml/diagram/communication/edit/policies/ModelCanonicalEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src-gen/org/eclipse/papyrus/uml/diagram/communication/edit/policies/ModelCanonicalEditPolicy.java index a97651ad3f2..7394a9978fe 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src-gen/org/eclipse/papyrus/uml/diagram/communication/edit/policies/ModelCanonicalEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src-gen/org/eclipse/papyrus/uml/diagram/communication/edit/policies/ModelCanonicalEditPolicy.java @@ -211,7 +211,7 @@ public class ModelCanonicalEditPolicy extends CanonicalEditPolicy { for (Iterator<View> linksIterator = existingLinks.iterator(); linksIterator.hasNext();) {
Edge nextDiagramLink = (Edge) linksIterator.next();
String diagramLinkVisualID = UMLVisualIDRegistry.getVisualID(nextDiagramLink);
- if (diagramLinkVisualID == null) {
+ if (diagramLinkVisualID == null || diagramLinkVisualID.isEmpty()) {
if (nextDiagramLink.getSource() != null && nextDiagramLink.getTarget() != null) {
linksIterator.remove();
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src-gen/org/eclipse/papyrus/uml/diagram/communication/part/UMLVisualIDRegistry.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src-gen/org/eclipse/papyrus/uml/diagram/communication/part/UMLVisualIDRegistry.java index d422654ff8c..108d23d8057 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src-gen/org/eclipse/papyrus/uml/diagram/communication/part/UMLVisualIDRegistry.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src-gen/org/eclipse/papyrus/uml/diagram/communication/part/UMLVisualIDRegistry.java @@ -1,417 +1,417 @@ -/** - * Copyright (c) 2014 CEA LIST. - * - * 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: - * CEA LIST - Initial API and implementation - */ -package org.eclipse.papyrus.uml.diagram.communication.part; - -import org.eclipse.emf.ecore.EAnnotation; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.structure.DiagramStructure; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.AppliedStereotypeMessageEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.CommentBodyEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.CommentEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConstraintBodyEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConstraintEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConstraintNameEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.DiagramNameEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.DurationObservationEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.DurationObservationLabelEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.DurationObservationStereotypeLabelEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.InteractionCompartmentEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.InteractionEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.InteractionFloatingLabelEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.InteractionNameEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.LifelineEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.LifelineFloatingLabelEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.LifelineNameEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.MessageEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.MessageNameEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ModelEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ShortCutDiagramEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.TimeObservationEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.TimeObservationNameEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.TimeObservationStereotypeLabelEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.expressions.UMLOCLFactory; -import org.eclipse.uml2.uml.Message; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.UMLPackage; - -/** - * This registry is used to determine which type of visual object should be - * created for the corresponding Diagram, Node, ChildNode or Link represented - * by a domain model object. - * - * @generated - */ -public class UMLVisualIDRegistry { - - /** - * @generated - */ - private static final String DEBUG_KEY = "org.eclipse.papyrus.uml.diagram.communication/debug/visualID"; //$NON-NLS-1$ - - /** - * @generated - */ - public static String getVisualID(View view) { - if (view instanceof Diagram) { - if (ModelEditPart.MODEL_ID.equals(view.getType())) { - return ModelEditPart.VISUAL_ID; - } else { - return null; - } - } - return org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry.getVisualID(view.getType()); - } - - /** - * @generated - */ - public static String getModelID(View view) { - View diagram = view.getDiagram(); - while (view != diagram) { - EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$ - if (annotation != null) { - return annotation.getDetails().get("modelID"); //$NON-NLS-1$ - } - view = (View) view.eContainer(); - } - return diagram != null ? diagram.getType() : null; - } - - /** - * @generated - */ - public static String getVisualID(String type) { - return type; - } - - /** - * @generated - */ - public static String getType(String visualID) { - return visualID; - } - - /** - * @generated - */ - public static String getDiagramVisualID(EObject domainElement) { - if (domainElement == null) { - return null; - } - return ModelEditPart.VISUAL_ID; - } - - /** - * @generated - */ - public static String getNodeVisualID(View containerView, EObject domainElement) { - if (domainElement == null) { - return null; - } - String containerModelID = org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry - .getModelID(containerView); - if (!ModelEditPart.MODEL_ID.equals(containerModelID)) { - return null; - } - String containerVisualID; - if (ModelEditPart.MODEL_ID.equals(containerModelID)) { - containerVisualID = org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry - .getVisualID(containerView); - } else { - if (containerView instanceof Diagram) { - containerVisualID = ModelEditPart.VISUAL_ID; - } else { - return null; - } - } - if (containerVisualID != null) { - switch (containerVisualID) { - case ModelEditPart.VISUAL_ID: - if (UMLPackage.eINSTANCE.getInteraction().isSuperTypeOf(domainElement.eClass())) { - return InteractionEditPart.VISUAL_ID; - } - if (NotationPackage.eINSTANCE.getDiagram().isSuperTypeOf(domainElement.eClass())) { - return ShortCutDiagramEditPart.VISUAL_ID; - } - break; - case InteractionCompartmentEditPart.VISUAL_ID: - if (UMLPackage.eINSTANCE.getLifeline().isSuperTypeOf(domainElement.eClass())) { - return LifelineEditPartCN.VISUAL_ID; - } - if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) { - return CommentEditPartCN.VISUAL_ID; - } - if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) { - return ConstraintEditPartCN.VISUAL_ID; - } - if (UMLPackage.eINSTANCE.getTimeObservation().isSuperTypeOf(domainElement.eClass())) { - return TimeObservationEditPartCN.VISUAL_ID; - } - if (UMLPackage.eINSTANCE.getDurationObservation().isSuperTypeOf(domainElement.eClass())) { - return DurationObservationEditPartCN.VISUAL_ID; - } - break; - } - } - return null; - } - - /** - * @generated - */ - public static boolean canCreateNode(View containerView, String nodeVisualID) { - String containerModelID = org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry - .getModelID(containerView); - if (!ModelEditPart.MODEL_ID.equals(containerModelID)) { - return false; - } - String containerVisualID; - if (ModelEditPart.MODEL_ID.equals(containerModelID)) { - containerVisualID = org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry - .getVisualID(containerView); - } else { - if (containerView instanceof Diagram) { - containerVisualID = ModelEditPart.VISUAL_ID; - } else { - return false; - } - } - if (containerVisualID != null) { - switch (containerVisualID) { - case ModelEditPart.VISUAL_ID: - if (InteractionEditPart.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - if (ShortCutDiagramEditPart.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - break; - case InteractionEditPart.VISUAL_ID: - if (InteractionNameEditPart.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - if (InteractionFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - if (InteractionCompartmentEditPart.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - break; - case ShortCutDiagramEditPart.VISUAL_ID: - if (DiagramNameEditPart.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - break; - case LifelineEditPartCN.VISUAL_ID: - if (LifelineNameEditPart.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - if (LifelineFloatingLabelEditPartCN.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - break; - case ConstraintEditPartCN.VISUAL_ID: - if (ConstraintNameEditPartCN.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - if (ConstraintBodyEditPartCN.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - break; - case CommentEditPartCN.VISUAL_ID: - if (CommentBodyEditPartCN.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - break; - case TimeObservationEditPartCN.VISUAL_ID: - if (TimeObservationNameEditPartCN.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - if (TimeObservationStereotypeLabelEditPartCN.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - break; - case DurationObservationEditPartCN.VISUAL_ID: - if (DurationObservationLabelEditPartCN.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - if (DurationObservationStereotypeLabelEditPartCN.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - break; - case InteractionCompartmentEditPart.VISUAL_ID: - if (LifelineEditPartCN.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - if (CommentEditPartCN.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - if (ConstraintEditPartCN.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - if (TimeObservationEditPartCN.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - if (DurationObservationEditPartCN.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - break; - case MessageEditPart.VISUAL_ID: - if (MessageNameEditPart.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - if (AppliedStereotypeMessageEditPart.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - break; - } - } - return false; - } - - /** - * @generated - */ - public static String getLinkWithClassVisualID(EObject domainElement) { - if (domainElement == null) { - return null; - } - if (UMLPackage.eINSTANCE.getMessage().isSuperTypeOf(domainElement.eClass()) - && isPath_Edge((Message) domainElement)) { - return MessageEditPart.VISUAL_ID; - } - return null; - } - - /** - * User can change implementation of this method to handle some specific - * situations not covered by default logic. - * - * @generated - */ - private static boolean isDiagram(Package element) { - return true; - } - - /** - * @generated - */ - private static boolean isPath_Edge(Message domainElement) { - Object result = UMLOCLFactory.getExpression(5, UMLPackage.eINSTANCE.getMessage(), null).evaluate(domainElement); - return result instanceof Boolean && ((Boolean) result).booleanValue(); - } - - /** - * @generated - */ - public static boolean checkNodeVisualID(View containerView, EObject domainElement, String candidate) { - if (candidate == null) { - // unrecognized id is always bad - return false; - } - String basic = getNodeVisualID(containerView, domainElement); - return candidate.equals(basic); - } - - /** - * @generated - */ - public static boolean isCompartmentVisualID(String visualID) { - if (visualID != null) { - switch (visualID) { - case InteractionCompartmentEditPart.VISUAL_ID: - return true; - } - } - return false; - } - - /** - * @generated - */ - public static boolean isSemanticLeafVisualID(String visualID) { - if (visualID != null) { - switch (visualID) { - case ModelEditPart.VISUAL_ID: - return false; - case LifelineEditPartCN.VISUAL_ID: - case ConstraintEditPartCN.VISUAL_ID: - case CommentEditPartCN.VISUAL_ID: - case TimeObservationEditPartCN.VISUAL_ID: - case DurationObservationEditPartCN.VISUAL_ID: - case ShortCutDiagramEditPart.VISUAL_ID: - return true; - } - } - return false; - } - - /** - * @generated - */ - public static final DiagramStructure TYPED_INSTANCE = new DiagramStructure() { - /** - * @generated - */ - @Override - public String getVisualID(View view) { - return org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry.getVisualID(view); - } - - /** - * @generated - */ - @Override - public String getModelID(View view) { - return org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry.getModelID(view); - } - - /** - * @generated - */ - @Override - public String getNodeVisualID(View containerView, EObject domainElement) { - return org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry.getNodeVisualID(containerView, - domainElement); - } - - /** - * @generated - */ - @Override - public boolean checkNodeVisualID(View containerView, EObject domainElement, String candidate) { - return org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry - .checkNodeVisualID(containerView, domainElement, candidate); - } - - /** - * @generated - */ - @Override - public boolean isCompartmentVisualID(String visualID) { - return org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry - .isCompartmentVisualID(visualID); - } - - /** - * @generated - */ - @Override - public boolean isSemanticLeafVisualID(String visualID) { - return org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry - .isSemanticLeafVisualID(visualID); - } - }; -} +/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.communication.part;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.structure.DiagramStructure;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.AppliedStereotypeMessageEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.CommentBodyEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.CommentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConstraintBodyEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConstraintEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConstraintNameEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.DiagramNameEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.DurationObservationEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.DurationObservationLabelEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.DurationObservationStereotypeLabelEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.InteractionCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.InteractionEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.InteractionFloatingLabelEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.InteractionNameEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.LifelineEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.LifelineFloatingLabelEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.LifelineNameEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.MessageEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.MessageNameEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ModelEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ShortCutDiagramEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.TimeObservationEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.TimeObservationNameEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.TimeObservationStereotypeLabelEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.expressions.UMLOCLFactory;
+import org.eclipse.uml2.uml.Message;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * This registry is used to determine which type of visual object should be
+ * created for the corresponding Diagram, Node, ChildNode or Link represented
+ * by a domain model object.
+ *
+ * @generated
+ */
+public class UMLVisualIDRegistry {
+
+ /**
+ * @generated
+ */
+ private static final String DEBUG_KEY = "org.eclipse.papyrus.uml.diagram.communication/debug/visualID"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static String getVisualID(View view) {
+ if (view instanceof Diagram) {
+ if (ModelEditPart.MODEL_ID.equals(view.getType())) {
+ return ModelEditPart.VISUAL_ID;
+ } else {
+ return "";
+ }
+ }
+ return org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry.getVisualID(view.getType());
+ }
+
+ /**
+ * @generated
+ */
+ public static String getModelID(View view) {
+ View diagram = view.getDiagram();
+ while (view != diagram) {
+ EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
+ if (annotation != null) {
+ return annotation.getDetails().get("modelID"); //$NON-NLS-1$
+ }
+ view = (View) view.eContainer();
+ }
+ return diagram != null ? diagram.getType() : null;
+ }
+
+ /**
+ * @generated
+ */
+ public static String getVisualID(String type) {
+ return type;
+ }
+
+ /**
+ * @generated
+ */
+ public static String getType(String visualID) {
+ return visualID;
+ }
+
+ /**
+ * @generated
+ */
+ public static String getDiagramVisualID(EObject domainElement) {
+ if (domainElement == null) {
+ return "";
+ }
+ return ModelEditPart.VISUAL_ID;
+ }
+
+ /**
+ * @generated
+ */
+ public static String getNodeVisualID(View containerView, EObject domainElement) {
+ if (domainElement == null) {
+ return "";
+ }
+ String containerModelID = org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry
+ .getModelID(containerView);
+ if (!ModelEditPart.MODEL_ID.equals(containerModelID)) {
+ return "";
+ }
+ String containerVisualID;
+ if (ModelEditPart.MODEL_ID.equals(containerModelID)) {
+ containerVisualID = org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry
+ .getVisualID(containerView);
+ } else {
+ if (containerView instanceof Diagram) {
+ containerVisualID = ModelEditPart.VISUAL_ID;
+ } else {
+ return "";
+ }
+ }
+ if (containerVisualID != null) {
+ switch (containerVisualID) {
+ case ModelEditPart.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getInteraction().isSuperTypeOf(domainElement.eClass())) {
+ return InteractionEditPart.VISUAL_ID;
+ }
+ if (NotationPackage.eINSTANCE.getDiagram().isSuperTypeOf(domainElement.eClass())) {
+ return ShortCutDiagramEditPart.VISUAL_ID;
+ }
+ break;
+ case InteractionCompartmentEditPart.VISUAL_ID:
+ if (UMLPackage.eINSTANCE.getLifeline().isSuperTypeOf(domainElement.eClass())) {
+ return LifelineEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) {
+ return CommentEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) {
+ return ConstraintEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getTimeObservation().isSuperTypeOf(domainElement.eClass())) {
+ return TimeObservationEditPartCN.VISUAL_ID;
+ }
+ if (UMLPackage.eINSTANCE.getDurationObservation().isSuperTypeOf(domainElement.eClass())) {
+ return DurationObservationEditPartCN.VISUAL_ID;
+ }
+ break;
+ }
+ }
+ return "";
+ }
+
+ /**
+ * @generated
+ */
+ public static boolean canCreateNode(View containerView, String nodeVisualID) {
+ String containerModelID = org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry
+ .getModelID(containerView);
+ if (!ModelEditPart.MODEL_ID.equals(containerModelID)) {
+ return false;
+ }
+ String containerVisualID;
+ if (ModelEditPart.MODEL_ID.equals(containerModelID)) {
+ containerVisualID = org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry
+ .getVisualID(containerView);
+ } else {
+ if (containerView instanceof Diagram) {
+ containerVisualID = ModelEditPart.VISUAL_ID;
+ } else {
+ return false;
+ }
+ }
+ if (containerVisualID != null) {
+ switch (containerVisualID) {
+ case ModelEditPart.VISUAL_ID:
+ if (InteractionEditPart.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ if (ShortCutDiagramEditPart.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ break;
+ case InteractionEditPart.VISUAL_ID:
+ if (InteractionNameEditPart.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ if (InteractionFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ if (InteractionCompartmentEditPart.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ break;
+ case ShortCutDiagramEditPart.VISUAL_ID:
+ if (DiagramNameEditPart.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ break;
+ case LifelineEditPartCN.VISUAL_ID:
+ if (LifelineNameEditPart.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ if (LifelineFloatingLabelEditPartCN.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ break;
+ case ConstraintEditPartCN.VISUAL_ID:
+ if (ConstraintNameEditPartCN.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ if (ConstraintBodyEditPartCN.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ break;
+ case CommentEditPartCN.VISUAL_ID:
+ if (CommentBodyEditPartCN.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ break;
+ case TimeObservationEditPartCN.VISUAL_ID:
+ if (TimeObservationNameEditPartCN.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ if (TimeObservationStereotypeLabelEditPartCN.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ break;
+ case DurationObservationEditPartCN.VISUAL_ID:
+ if (DurationObservationLabelEditPartCN.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ if (DurationObservationStereotypeLabelEditPartCN.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ break;
+ case InteractionCompartmentEditPart.VISUAL_ID:
+ if (LifelineEditPartCN.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ if (CommentEditPartCN.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ if (ConstraintEditPartCN.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ if (TimeObservationEditPartCN.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ if (DurationObservationEditPartCN.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ break;
+ case MessageEditPart.VISUAL_ID:
+ if (MessageNameEditPart.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ if (AppliedStereotypeMessageEditPart.VISUAL_ID.equals(nodeVisualID)) {
+ return true;
+ }
+ break;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public static String getLinkWithClassVisualID(EObject domainElement) {
+ if (domainElement == null) {
+ return "";
+ }
+ if (UMLPackage.eINSTANCE.getMessage().isSuperTypeOf(domainElement.eClass())
+ && isPath_Edge((Message) domainElement)) {
+ return MessageEditPart.VISUAL_ID;
+ }
+ return "";
+ }
+
+ /**
+ * User can change implementation of this method to handle some specific
+ * situations not covered by default logic.
+ *
+ * @generated
+ */
+ private static boolean isDiagram(Package element) {
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ private static boolean isPath_Edge(Message domainElement) {
+ Object result = UMLOCLFactory.getExpression(5, UMLPackage.eINSTANCE.getMessage(), null).evaluate(domainElement);
+ return result instanceof Boolean && ((Boolean) result).booleanValue();
+ }
+
+ /**
+ * @generated
+ */
+ public static boolean checkNodeVisualID(View containerView, EObject domainElement, String candidate) {
+ if (candidate == null) {
+ // unrecognized id is always bad
+ return false;
+ }
+ String basic = getNodeVisualID(containerView, domainElement);
+ return candidate.equals(basic);
+ }
+
+ /**
+ * @generated
+ */
+ public static boolean isCompartmentVisualID(String visualID) {
+ if (visualID != null) {
+ switch (visualID) {
+ case InteractionCompartmentEditPart.VISUAL_ID:
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public static boolean isSemanticLeafVisualID(String visualID) {
+ if (visualID != null) {
+ switch (visualID) {
+ case ModelEditPart.VISUAL_ID:
+ return false;
+ case LifelineEditPartCN.VISUAL_ID:
+ case ConstraintEditPartCN.VISUAL_ID:
+ case CommentEditPartCN.VISUAL_ID:
+ case TimeObservationEditPartCN.VISUAL_ID:
+ case DurationObservationEditPartCN.VISUAL_ID:
+ case ShortCutDiagramEditPart.VISUAL_ID:
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public static final DiagramStructure TYPED_INSTANCE = new DiagramStructure() {
+ /**
+ * @generated
+ */
+ @Override
+ public String getVisualID(View view) {
+ return org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry.getVisualID(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getModelID(View view) {
+ return org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry.getModelID(view);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public String getNodeVisualID(View containerView, EObject domainElement) {
+ return org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry.getNodeVisualID(containerView,
+ domainElement);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean checkNodeVisualID(View containerView, EObject domainElement, String candidate) {
+ return org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry
+ .checkNodeVisualID(containerView, domainElement, candidate);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isCompartmentVisualID(String visualID) {
+ return org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry
+ .isCompartmentVisualID(visualID);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ public boolean isSemanticLeafVisualID(String visualID) {
+ return org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry
+ .isSemanticLeafVisualID(visualID);
+ }
+ };
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src-gen/org/eclipse/papyrus/uml/diagram/communication/providers/UMLViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src-gen/org/eclipse/papyrus/uml/diagram/communication/providers/UMLViewProvider.java index 204577e9e15..44d4f43f518 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src-gen/org/eclipse/papyrus/uml/diagram/communication/providers/UMLViewProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src-gen/org/eclipse/papyrus/uml/diagram/communication/providers/UMLViewProvider.java @@ -1,778 +1,703 @@ -/** - * Copyright (c) 2014 CEA LIST. - * - * 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: - * CEA LIST - Initial API and implementation - */ -package org.eclipse.papyrus.uml.diagram.communication.providers; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.ecore.EAnnotation; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EcoreFactory; -import org.eclipse.emf.transaction.util.TransactionUtil; -import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; -import org.eclipse.gmf.runtime.common.core.service.IOperation; -import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; -import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider; -import org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation; -import org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation; -import org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation; -import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation; -import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewOperation; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities; -import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; -import org.eclipse.gmf.runtime.emf.type.core.IHintedType; -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.Edge; -import org.eclipse.gmf.runtime.notation.FillStyle; -import org.eclipse.gmf.runtime.notation.FontStyle; -import org.eclipse.gmf.runtime.notation.Location; -import org.eclipse.gmf.runtime.notation.MeasurementUnit; -import org.eclipse.gmf.runtime.notation.Node; -import org.eclipse.gmf.runtime.notation.NotationFactory; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.RelativeBendpoints; -import org.eclipse.gmf.runtime.notation.Shape; -import org.eclipse.gmf.runtime.notation.TitleStyle; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper; -import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils; -import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter; -import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.AppliedStereotypeMessageEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.CommentAnnotatedElementEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.CommentBodyEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.CommentEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConnectorDurationObservationEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConnectorTimeObservationEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConstraintBodyEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConstraintConstrainedElementEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConstraintEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConstraintNameEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.DiagramNameEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.DurationObservationEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.DurationObservationLabelEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.DurationObservationStereotypeLabelEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.InteractionCompartmentEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.InteractionEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.InteractionFloatingLabelEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.InteractionNameEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.LifelineEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.LifelineFloatingLabelEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.LifelineNameEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.MessageEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.MessageNameEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ModelEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ShortCutDiagramEditPart; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.TimeObservationEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.TimeObservationNameEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.edit.parts.TimeObservationStereotypeLabelEditPartCN; -import org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.FontData; - -/** - * @generated - */ -public class UMLViewProvider extends AbstractProvider implements IViewProvider { - - /** - * @generated - */ - public final boolean provides(IOperation operation) { - if (operation instanceof CreateViewForKindOperation) { - return provides((CreateViewForKindOperation) operation); - } - assert operation instanceof CreateViewOperation; - if (operation instanceof CreateDiagramViewOperation) { - return provides((CreateDiagramViewOperation) operation); - } else if (operation instanceof CreateEdgeViewOperation) { - return provides((CreateEdgeViewOperation) operation); - } else if (operation instanceof CreateNodeViewOperation) { - return provides((CreateNodeViewOperation) operation); - } - return false; - } - - /** - * @generated - */ - protected boolean provides(CreateViewForKindOperation op) { - /* - * if (op.getViewKind() == Node.class) - * return getNodeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null; - * if (op.getViewKind() == Edge.class) - * return getEdgeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null; - */ - - // check Diagram Type should be the class diagram - String modelID = UMLVisualIDRegistry.getModelID(op.getContainerView()); - if (!getDiagramProvidedId().equals(modelID)) { - return false; - } - - String visualID = UMLVisualIDRegistry.getVisualID(op.getSemanticHint()); - if (Node.class.isAssignableFrom(op.getViewKind())) { - return UMLVisualIDRegistry.canCreateNode(op.getContainerView(), visualID); - } - - return true; - } - - /** - * @generated - */ - protected String getDiagramProvidedId() { - /* - * Indicates for which diagram this provider works for. - * <p> - * This method can be overloaded when diagram editor inherits from another one, but should never be <code>null</code> - * </p> - * - * @return the unique identifier of the diagram for which views are provided. - */ - return ModelEditPart.MODEL_ID; - } - - /** - * @generated - */ - protected boolean provides(CreateDiagramViewOperation op) { - return ModelEditPart.MODEL_ID.equals(op.getSemanticHint()) - && UMLVisualIDRegistry.getDiagramVisualID(getSemanticElement(op.getSemanticAdapter())) != null; - } - - /** - * @generated - */ - protected boolean provides(CreateNodeViewOperation op) { - if (op.getContainerView() == null) { - return false; - } - IElementType elementType = getSemanticElementType(op.getSemanticAdapter()); - EObject domainElement = getSemanticElement(op.getSemanticAdapter()); - String visualID; - if (op.getSemanticHint() == null) { - // Semantic hint is not specified. Can be a result of call from CanonicalEditPolicy. - // In this situation there should be NO elementType, visualID will be determined - // by VisualIDRegistry.getNodeVisualID() for domainElement. - if (elementType != null || domainElement == null) { - return false; - } - visualID = UMLVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement); - } else { - visualID = UMLVisualIDRegistry.getVisualID(op.getSemanticHint()); - if (elementType != null) { - - if (!UMLElementTypes.isKnownElementType(elementType) || (!(elementType instanceof IHintedType))) { - return false; // foreign element type - } - - String elementTypeHint = ((IHintedType) elementType).getSemanticHint(); - if (!op.getSemanticHint().equals(elementTypeHint)) { - return false; // if semantic hint is specified it should be the same as in element type - } - // if (domainElement != null && !visualID.equals(org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement))) { - // return false; // visual id for node EClass should match visual id from element type - // } - } else { - if (!ModelEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(op.getContainerView()))) { - return false; // foreign diagram - } - if (visualID != null) { - switch (visualID) { - case InteractionEditPart.VISUAL_ID: - case ShortCutDiagramEditPart.VISUAL_ID: - case LifelineEditPartCN.VISUAL_ID: - case ConstraintEditPartCN.VISUAL_ID: - case CommentEditPartCN.VISUAL_ID: - case TimeObservationEditPartCN.VISUAL_ID: - case DurationObservationEditPartCN.VISUAL_ID: - if (domainElement == null || !visualID - .equals(UMLVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement))) { - return false; // visual id in semantic hint should match visual id for domain element - } - break; - default: - return false; - } - } - } - } - - return UMLVisualIDRegistry.canCreateNode(op.getContainerView(), visualID); - } - - /** - * @generated - */ - protected boolean provides(CreateEdgeViewOperation op) { - IElementType elementType = getSemanticElementType(op.getSemanticAdapter()); - - if (!UMLElementTypes.isKnownElementType(elementType) || (!(elementType instanceof IHintedType))) { - return false; // foreign element type - } - - // if (!org.eclipse.papyrus.uml.diagram.communication.providers.UMLElementTypes.isKnownElementType(elementType) || (!(elementType instanceof org.eclipse.gmf.runtime.emf.type.core.IHintedType))) { - // return false; // foreign element type - // } - // END R.S. - String elementTypeHint = ((IHintedType) elementType).getSemanticHint(); - if (elementTypeHint == null - || (op.getSemanticHint() != null && !elementTypeHint.equals(op.getSemanticHint()))) { - return false; // our hint is visual id and must be specified, and it should be the same as in element type - } - // String visualID = org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry.getVisualID(elementTypeHint); - // org.eclipse.emf.ecore.EObject domainElement = getSemanticElement(op.getSemanticAdapter()); - // if (domainElement != null && !visualID.equals(org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry.getLinkWithClassVisualID(domainElement))) { - // return false; // visual id for link EClass should match visual id from element type - // } - return true; - } - - /** - * @generated - */ - @SuppressWarnings("unchecked") - public Diagram createDiagram(IAdaptable semanticAdapter, String diagramKind, PreferencesHint preferencesHint) { - Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); - DiagramVersioningUtils.stampCurrentVersion(diagram); - diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle()); - diagram.setType(ModelEditPart.MODEL_ID); - diagram.setElement(getSemanticElement(semanticAdapter)); - diagram.setMeasurementUnit(MeasurementUnit.PIXEL_LITERAL); - return diagram; - } - - /** - * @generated - */ - public Node createNode(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, - boolean persisted, PreferencesHint preferencesHint) { - final EObject domainElement = getSemanticElement(semanticAdapter); - final String visualID; - if (semanticHint == null) { - visualID = UMLVisualIDRegistry.getNodeVisualID(containerView, domainElement); - } else { - visualID = UMLVisualIDRegistry.getVisualID(semanticHint); - } - if (visualID != null) { - switch (visualID) { - case InteractionEditPart.VISUAL_ID: - return createInteraction_Shape(domainElement, containerView, index, persisted, preferencesHint); - case ShortCutDiagramEditPart.VISUAL_ID: - return createDiagram_ShortcutShape(domainElement, containerView, index, persisted, preferencesHint); - case LifelineEditPartCN.VISUAL_ID: - return createLifeline_Shape(domainElement, containerView, index, persisted, preferencesHint); - case ConstraintEditPartCN.VISUAL_ID: - return createConstraint_Shape(domainElement, containerView, index, persisted, preferencesHint); - case CommentEditPartCN.VISUAL_ID: - return createComment_Shape(domainElement, containerView, index, persisted, preferencesHint); - case TimeObservationEditPartCN.VISUAL_ID: - return createTimeObservation_Shape(domainElement, containerView, index, persisted, preferencesHint); - case DurationObservationEditPartCN.VISUAL_ID: - return createDurationObservation_Shape(domainElement, containerView, index, persisted, preferencesHint); - } - } - // can't happen, provided #provides(CreateNodeViewOperation) is correct - return null; - } - - /** - * @generated - */ - public Edge createEdge(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, - boolean persisted, PreferencesHint preferencesHint) { - IElementType elementType = getSemanticElementType(semanticAdapter); - String elementTypeHint = ((IHintedType) elementType).getSemanticHint(); - String vid = UMLVisualIDRegistry.getVisualID(elementTypeHint); - if (vid != null) { - switch (vid) { - case MessageEditPart.VISUAL_ID: - return createPath_Edge(getSemanticElement(semanticAdapter), containerView, index, persisted, - preferencesHint); - case CommentAnnotatedElementEditPart.VISUAL_ID: - return createComment_AnnotatedElementEdge(containerView, index, persisted, preferencesHint); - case ConstraintConstrainedElementEditPart.VISUAL_ID: - return createConstraint_ConstrainedElementEdge(containerView, index, persisted, preferencesHint); - case ConnectorDurationObservationEditPart.VISUAL_ID: - return createDurationObservation_EventEdge(containerView, index, persisted, preferencesHint); - case ConnectorTimeObservationEditPart.VISUAL_ID: - return createTimeObservation_EventEdge(containerView, index, persisted, preferencesHint); - } - } - // can never happen, provided #provides(CreateEdgeViewOperation) is correct - return null; - } - - /** - * @generated - */ - public Node createInteraction_Shape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Shape node = NotationFactory.eINSTANCE.createShape(); - node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - node.setType(UMLVisualIDRegistry.getType(InteractionEditPart.VISUAL_ID)); - ViewUtil.insertChildView(containerView, node, index, persisted); - node.setElement(domainElement); - stampShortcut(containerView, node); - // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - - PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Interaction"); - Node interaction_NameLabel = createLabel(node, UMLVisualIDRegistry.getType(InteractionNameEditPart.VISUAL_ID)); - Node interaction_FloatingNameLabel = createLabel(node, - UMLVisualIDRegistry.getType(InteractionFloatingLabelEditPart.VISUAL_ID)); - interaction_FloatingNameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location interaction_FloatingNameLabel_Location = (Location) interaction_FloatingNameLabel - .getLayoutConstraint(); - interaction_FloatingNameLabel_Location.setX(50); - interaction_FloatingNameLabel_Location.setY(0); - createCompartment(node, UMLVisualIDRegistry.getType(InteractionCompartmentEditPart.VISUAL_ID), true, false, - false, false); - PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Interaction"); - return node; - } - - /** - * @generated - */ - public Node createDiagram_ShortcutShape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Shape node = NotationFactory.eINSTANCE.createShape(); - node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - node.setType(UMLVisualIDRegistry.getType(ShortCutDiagramEditPart.VISUAL_ID)); - ViewUtil.insertChildView(containerView, node, index, persisted); - node.setElement(domainElement); - stampShortcut(containerView, node); - // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - - PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "ShortCutDiagram"); - Node diagram_NameLabel = createLabel(node, UMLVisualIDRegistry.getType(DiagramNameEditPart.VISUAL_ID)); - diagram_NameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location diagram_NameLabel_Location = (Location) diagram_NameLabel.getLayoutConstraint(); - diagram_NameLabel_Location.setX(0); - diagram_NameLabel_Location.setY(5); - return node; - } - - /** - * @generated - */ - public Node createLifeline_Shape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Shape node = NotationFactory.eINSTANCE.createShape(); - node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - node.setType(UMLVisualIDRegistry.getType(LifelineEditPartCN.VISUAL_ID)); - ViewUtil.insertChildView(containerView, node, index, persisted); - node.setElement(domainElement); - // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - - PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Lifeline"); - Node lifeline_NameLabel = createLabel(node, UMLVisualIDRegistry.getType(LifelineNameEditPart.VISUAL_ID)); - Node lifeline_FloatingNameLabel = createLabel(node, - UMLVisualIDRegistry.getType(LifelineFloatingLabelEditPartCN.VISUAL_ID)); - lifeline_FloatingNameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location lifeline_FloatingNameLabel_Location = (Location) lifeline_FloatingNameLabel.getLayoutConstraint(); - lifeline_FloatingNameLabel_Location.setX(0); - lifeline_FloatingNameLabel_Location.setY(5); - return node; - } - - /** - * @generated - */ - public Node createConstraint_Shape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Shape node = NotationFactory.eINSTANCE.createShape(); - node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - node.setType(UMLVisualIDRegistry.getType(ConstraintEditPartCN.VISUAL_ID)); - ViewUtil.insertChildView(containerView, node, index, persisted); - node.setElement(domainElement); - // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - - PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Constraint"); - Node constraint_NameLabel = createLabel(node, UMLVisualIDRegistry.getType(ConstraintNameEditPartCN.VISUAL_ID)); - Node constraint_BodyLabel = createLabel(node, UMLVisualIDRegistry.getType(ConstraintBodyEditPartCN.VISUAL_ID)); - return node; - } - - /** - * @generated - */ - public Node createComment_Shape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Shape node = NotationFactory.eINSTANCE.createShape(); - node.getStyles().add(NotationFactory.eINSTANCE.createHintedDiagramLinkStyle()); - node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - node.setType(UMLVisualIDRegistry.getType(CommentEditPartCN.VISUAL_ID)); - ViewUtil.insertChildView(containerView, node, index, persisted); - node.setElement(domainElement); - // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - - PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Comment"); - Node comment_BodyLabel = createLabel(node, UMLVisualIDRegistry.getType(CommentBodyEditPartCN.VISUAL_ID)); - return node; - } - - /** - * @generated - */ - public Node createTimeObservation_Shape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Shape node = NotationFactory.eINSTANCE.createShape(); - node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - node.setType(UMLVisualIDRegistry.getType(TimeObservationEditPartCN.VISUAL_ID)); - ViewUtil.insertChildView(containerView, node, index, persisted); - node.setElement(domainElement); - // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - - PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "TimeObservation"); - Node timeObservation_NameLabel = createLabel(node, - UMLVisualIDRegistry.getType(TimeObservationNameEditPartCN.VISUAL_ID)); - timeObservation_NameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location timeObservation_NameLabel_Location = (Location) timeObservation_NameLabel.getLayoutConstraint(); - timeObservation_NameLabel_Location.setX(25); - timeObservation_NameLabel_Location.setY(3); - Node timeObservation_StereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(TimeObservationStereotypeLabelEditPartCN.VISUAL_ID)); - timeObservation_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location timeObservation_StereotypeLabel_Location = (Location) timeObservation_StereotypeLabel - .getLayoutConstraint(); - timeObservation_StereotypeLabel_Location.setX(25); - timeObservation_StereotypeLabel_Location.setY(-10); - return node; - } - - /** - * @generated - */ - public Node createDurationObservation_Shape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Shape node = NotationFactory.eINSTANCE.createShape(); - node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - node.setType(UMLVisualIDRegistry.getType(DurationObservationEditPartCN.VISUAL_ID)); - ViewUtil.insertChildView(containerView, node, index, persisted); - node.setElement(domainElement); - // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - - PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "DurationObservation"); - Node durationObservation_NameLabel = createLabel(node, - UMLVisualIDRegistry.getType(DurationObservationLabelEditPartCN.VISUAL_ID)); - durationObservation_NameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location durationObservation_NameLabel_Location = (Location) durationObservation_NameLabel - .getLayoutConstraint(); - durationObservation_NameLabel_Location.setX(25); - durationObservation_NameLabel_Location.setY(3); - Node durationObservation_StereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(DurationObservationStereotypeLabelEditPartCN.VISUAL_ID)); - durationObservation_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location durationObservation_StereotypeLabel_Location = (Location) durationObservation_StereotypeLabel - .getLayoutConstraint(); - durationObservation_StereotypeLabel_Location.setX(25); - durationObservation_StereotypeLabel_Location.setY(-10); - return node; - } - - /** - * @generated - */ - public Edge createPath_Edge(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Connector edge = NotationFactory.eINSTANCE.createConnector(); - edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); - RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); - List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2); - points.add(new RelativeBendpoint()); - points.add(new RelativeBendpoint()); - bendpoints.setPoints(points); - edge.setBendpoints(bendpoints); - ViewUtil.insertChildView(containerView, edge, index, persisted); - edge.setType(UMLVisualIDRegistry.getType(MessageEditPart.VISUAL_ID)); - edge.setElement(domainElement); - // initializePreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - - PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "Message"); - // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE)); - // if (routing != null) { - // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); - // } - Node path_MessageLabel = createLabel(edge, UMLVisualIDRegistry.getType(MessageNameEditPart.VISUAL_ID)); - path_MessageLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location path_MessageLabel_Location = (Location) path_MessageLabel.getLayoutConstraint(); - path_MessageLabel_Location.setX(1); - path_MessageLabel_Location.setY(-23); - Node path_StereotypeLabel = createLabel(edge, - UMLVisualIDRegistry.getType(AppliedStereotypeMessageEditPart.VISUAL_ID)); - path_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location path_StereotypeLabel_Location = (Location) path_StereotypeLabel.getLayoutConstraint(); - path_StereotypeLabel_Location.setX(1); - path_StereotypeLabel_Location.setY(-53); - - return edge; - } - - /** - * @generated - */ - public Edge createComment_AnnotatedElementEdge(View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Connector edge = NotationFactory.eINSTANCE.createConnector(); - edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); - RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); - List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2); - points.add(new RelativeBendpoint()); - points.add(new RelativeBendpoint()); - bendpoints.setPoints(points); - edge.setBendpoints(bendpoints); - ViewUtil.insertChildView(containerView, edge, index, persisted); - edge.setType(UMLVisualIDRegistry.getType(CommentAnnotatedElementEditPart.VISUAL_ID)); - edge.setElement(null); - // initializePreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - - // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE)); - // if (routing != null) { - // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); - // } - - return edge; - } - - /** - * @generated - */ - public Edge createConstraint_ConstrainedElementEdge(View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Connector edge = NotationFactory.eINSTANCE.createConnector(); - edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); - RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); - List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2); - points.add(new RelativeBendpoint()); - points.add(new RelativeBendpoint()); - bendpoints.setPoints(points); - edge.setBendpoints(bendpoints); - ViewUtil.insertChildView(containerView, edge, index, persisted); - edge.setType(UMLVisualIDRegistry.getType(ConstraintConstrainedElementEditPart.VISUAL_ID)); - edge.setElement(null); - // initializePreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - - // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE)); - // if (routing != null) { - // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); - // } - - return edge; - } - - /** - * @generated - */ - public Edge createDurationObservation_EventEdge(View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Connector edge = NotationFactory.eINSTANCE.createConnector(); - edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); - RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); - List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2); - points.add(new RelativeBendpoint()); - points.add(new RelativeBendpoint()); - bendpoints.setPoints(points); - edge.setBendpoints(bendpoints); - ViewUtil.insertChildView(containerView, edge, index, persisted); - edge.setType(UMLVisualIDRegistry.getType(ConnectorDurationObservationEditPart.VISUAL_ID)); - edge.setElement(null); - // initializePreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - - // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE)); - // if (routing != null) { - // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); - // } - - return edge; - } - - /** - * @generated - */ - public Edge createTimeObservation_EventEdge(View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Connector edge = NotationFactory.eINSTANCE.createConnector(); - edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); - RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); - List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2); - points.add(new RelativeBendpoint()); - points.add(new RelativeBendpoint()); - bendpoints.setPoints(points); - edge.setBendpoints(bendpoints); - ViewUtil.insertChildView(containerView, edge, index, persisted); - edge.setType(UMLVisualIDRegistry.getType(ConnectorTimeObservationEditPart.VISUAL_ID)); - edge.setElement(null); - // initializePreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - - // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE)); - // if (routing != null) { - // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); - // } - - return edge; - } - - /** - * @generated - */ - protected void stampShortcut(View containerView, Node target) { - if (!ModelEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(containerView))) { - EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); - shortcutAnnotation.setSource("Shortcut"); //$NON-NLS-1$ - shortcutAnnotation.getDetails().put("modelID", ModelEditPart.MODEL_ID); //$NON-NLS-1$ - target.getEAnnotations().add(shortcutAnnotation); - } - } - - /** - * @generated - */ - protected Node createLabel(View owner, String hint) { - DecorationNode rv = NotationFactory.eINSTANCE.createDecorationNode(); - rv.setType(hint); - ViewUtil.insertChildView(owner, rv, ViewUtil.APPEND, true); - return rv; - } - - /** - * @generated - */ - protected Node createCompartment(View owner, String hint, boolean canCollapse, boolean hasTitle, boolean canSort, - boolean canFilter) { - // SemanticListCompartment rv = NotationFactory.eINSTANCE.createSemanticListCompartment(); - // rv.setShowTitle(showTitle); - // rv.setCollapsed(isCollapsed); - Node rv = NotationFactory.eINSTANCE.createBasicCompartment(); - - rv.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - - if (hasTitle) { - TitleStyle ts = NotationFactory.eINSTANCE.createTitleStyle(); - rv.getStyles().add(ts); - } - if (canSort) { - rv.getStyles().add(NotationFactory.eINSTANCE.createSortingStyle()); - } - if (canFilter) { - rv.getStyles().add(NotationFactory.eINSTANCE.createFilteringStyle()); - } - rv.setType(hint); - ViewUtil.insertChildView(owner, rv, ViewUtil.APPEND, true); - return rv; - } - - /** - * @generated - */ - protected EObject getSemanticElement(IAdaptable semanticAdapter) { - if (semanticAdapter == null) { - return null; - } - EObject eObject = (EObject) semanticAdapter.getAdapter(EObject.class); - if (eObject != null) { - return EMFCoreUtil.resolve(TransactionUtil.getEditingDomain(eObject), eObject); - } - return null; - } - - /** - * @generated - */ - protected IElementType getSemanticElementType(IAdaptable semanticAdapter) { - if (semanticAdapter == null) { - return null; - } - return (IElementType) semanticAdapter.getAdapter(IElementType.class); - } - - /** - * @generated - */ - private void initFontStyleFromPrefs(View view, final IPreferenceStore store, String elementName) { - String fontConstant = PreferencesConstantsHelper.getElementConstant(elementName, - PreferencesConstantsHelper.FONT); - String fontColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, - PreferencesConstantsHelper.COLOR_FONT); - - FontStyle viewFontStyle = (FontStyle) view.getStyle(NotationPackage.Literals.FONT_STYLE); - if (viewFontStyle != null) { - FontData fontData = PreferenceConverter.getFontData(store, fontConstant); - viewFontStyle.setFontName(fontData.getName()); - viewFontStyle.setFontHeight(fontData.getHeight()); - viewFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); - viewFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); - - org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(store, fontColorConstant); - viewFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue()); - } - } - - /** - * @generated - */ - private void initForegroundFromPrefs(View view, final IPreferenceStore store, String elementName) { - String lineColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, - PreferencesConstantsHelper.COLOR_LINE); - org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(store, lineColorConstant); - ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getLineStyle_LineColor(), - FigureUtilities.RGBToInteger(lineRGB)); - } - - /** - * @generated - */ - private void initBackgroundFromPrefs(View view, final IPreferenceStore store, String elementName) { - String fillColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, - PreferencesConstantsHelper.COLOR_FILL); - String gradientColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, - PreferencesConstantsHelper.COLOR_GRADIENT); - String gradientPolicyConstant = PreferencesConstantsHelper.getElementConstant(elementName, - PreferencesConstantsHelper.GRADIENT_POLICY); - - org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor(store, fillColorConstant); - ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getFillStyle_FillColor(), - FigureUtilities.RGBToInteger(fillRGB)); - - FillStyle fillStyle = (FillStyle) view.getStyle(NotationPackage.Literals.FILL_STYLE); - fillStyle.setFillColor(FigureUtilities.RGBToInteger(fillRGB).intValue()); - - ; - if (store.getBoolean(gradientPolicyConstant)) { - GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter( - store.getString(gradientColorConstant)); - fillStyle.setGradient(gradientPreferenceConverter.getGradientData()); - fillStyle.setTransparency(gradientPreferenceConverter.getTransparency()); - } - } -} +/**
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ */
+package org.eclipse.papyrus.uml.diagram.communication.providers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
+import org.eclipse.gmf.runtime.common.core.service.IOperation;
+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
+import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation;
+import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewOperation;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
+import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
+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.Edge;
+import org.eclipse.gmf.runtime.notation.FillStyle;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.Location;
+import org.eclipse.gmf.runtime.notation.MeasurementUnit;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.NotationFactory;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
+import org.eclipse.gmf.runtime.notation.Shape;
+import org.eclipse.gmf.runtime.notation.TitleStyle;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.reconciler.DiagramVersioningUtils;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter;
+import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.AppliedStereotypeMessageEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.CommentAnnotatedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.CommentBodyEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.CommentEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConnectorDurationObservationEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConnectorTimeObservationEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConstraintBodyEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConstraintConstrainedElementEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConstraintEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ConstraintNameEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.DiagramNameEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.DurationObservationEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.DurationObservationLabelEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.DurationObservationStereotypeLabelEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.InteractionCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.InteractionEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.InteractionFloatingLabelEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.InteractionNameEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.LifelineEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.LifelineFloatingLabelEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.LifelineNameEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.MessageEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.MessageNameEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ModelEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.ShortCutDiagramEditPart;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.TimeObservationEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.TimeObservationNameEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.edit.parts.TimeObservationStereotypeLabelEditPartCN;
+import org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontData;
+
+/**
+ * @generated
+ */
+public class UMLViewProvider extends AbstractProvider implements IViewProvider {
+
+ /**
+ * @generated
+ */
+ public final boolean provides(IOperation operation) {
+ if (operation instanceof CreateViewForKindOperation) {
+ return provides((CreateViewForKindOperation) operation);
+ }
+ assert operation instanceof CreateViewOperation;
+ if (operation instanceof CreateDiagramViewOperation) {
+ return provides((CreateDiagramViewOperation) operation);
+ } else if (operation instanceof CreateEdgeViewOperation) {
+ return provides((CreateEdgeViewOperation) operation);
+ } else if (operation instanceof CreateNodeViewOperation) {
+ return provides((CreateNodeViewOperation) operation);
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean provides(CreateViewForKindOperation op) {
+ /*
+ * if (op.getViewKind() == Node.class)
+ * return getNodeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
+ * if (op.getViewKind() == Edge.class)
+ * return getEdgeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null;
+ */
+ // check Diagram Type should be the class diagram
+ String modelID = UMLVisualIDRegistry.getModelID(op.getContainerView());
+ if (!getDiagramProvidedId().equals(modelID)) {
+ return false;
+ }
+ String visualID = UMLVisualIDRegistry.getVisualID(op.getSemanticHint());
+ if (Node.class.isAssignableFrom(op.getViewKind())) {
+ return UMLVisualIDRegistry.canCreateNode(op.getContainerView(), visualID);
+ }
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getDiagramProvidedId() {
+ /*
+ * Indicates for which diagram this provider works for.
+ * <p>
+ * This method can be overloaded when diagram editor inherits from another one, but should never be <code>null</code>
+ * </p>
+ *
+ * @return the unique identifier of the diagram for which views are provided.
+ */
+ return ModelEditPart.MODEL_ID;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean provides(CreateDiagramViewOperation op) {
+ return ModelEditPart.MODEL_ID.equals(op.getSemanticHint()) && UMLVisualIDRegistry.getDiagramVisualID(getSemanticElement(op.getSemanticAdapter())) != null
+ && !UMLVisualIDRegistry.getDiagramVisualID(getSemanticElement(op.getSemanticAdapter())).isEmpty();
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean provides(CreateNodeViewOperation op) {
+ if (op.getContainerView() == null) {
+ return false;
+ }
+ IElementType elementType = getSemanticElementType(op.getSemanticAdapter());
+ EObject domainElement = getSemanticElement(op.getSemanticAdapter());
+ String visualID;
+ if (op.getSemanticHint() == null) {
+ // Semantic hint is not specified. Can be a result of call from CanonicalEditPolicy.
+ // In this situation there should be NO elementType, visualID will be determined
+ // by VisualIDRegistry.getNodeVisualID() for domainElement.
+ if (elementType != null || domainElement == null) {
+ return false;
+ }
+ visualID = UMLVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement);
+ } else {
+ visualID = UMLVisualIDRegistry.getVisualID(op.getSemanticHint());
+ if (elementType != null) {
+ if (!UMLElementTypes.isKnownElementType(elementType) || (!(elementType instanceof IHintedType))) {
+ return false; // foreign element type
+ }
+ String elementTypeHint = ((IHintedType) elementType).getSemanticHint();
+ if (!op.getSemanticHint().equals(elementTypeHint)) {
+ return false; // if semantic hint is specified it should be the same as in element type
+ }
+ // if (domainElement != null && !visualID.equals(org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement))) {
+ // return false; // visual id for node EClass should match visual id from element type
+ // }
+ } else {
+ if (!ModelEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(op.getContainerView()))) {
+ return false; // foreign diagram
+ }
+ if (visualID != null) {
+ switch (visualID) {
+ case InteractionEditPart.VISUAL_ID:
+ case ShortCutDiagramEditPart.VISUAL_ID:
+ case LifelineEditPartCN.VISUAL_ID:
+ case ConstraintEditPartCN.VISUAL_ID:
+ case CommentEditPartCN.VISUAL_ID:
+ case TimeObservationEditPartCN.VISUAL_ID:
+ case DurationObservationEditPartCN.VISUAL_ID:
+ if (domainElement == null || !visualID.equals(UMLVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement))) {
+ return false; // visual id in semantic hint should match visual id for domain element
+ }
+ break;
+ default:
+ return false;
+ }
+ }
+ }
+ }
+ return UMLVisualIDRegistry.canCreateNode(op.getContainerView(), visualID);
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean provides(CreateEdgeViewOperation op) {
+ IElementType elementType = getSemanticElementType(op.getSemanticAdapter());
+ if (!UMLElementTypes.isKnownElementType(elementType) || (!(elementType instanceof IHintedType))) {
+ return false; // foreign element type
+ }
+ String elementTypeHint = ((IHintedType) elementType).getSemanticHint();
+ if (elementTypeHint == null || (op.getSemanticHint() != null && !elementTypeHint.equals(op.getSemanticHint()))) {
+ return false; // our hint is visual id and must be specified, and it should be the same as in element type
+ }
+ // String visualID = org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry.getVisualID(elementTypeHint);
+ // org.eclipse.emf.ecore.EObject domainElement = getSemanticElement(op.getSemanticAdapter());
+ // if (domainElement != null && !visualID.equals(org.eclipse.papyrus.uml.diagram.communication.part.UMLVisualIDRegistry.getLinkWithClassVisualID(domainElement))) {
+ // return false; // visual id for link EClass should match visual id from element type
+ // }
+ return true;
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ public Diagram createDiagram(IAdaptable semanticAdapter, String diagramKind, PreferencesHint preferencesHint) {
+ Diagram diagram = NotationFactory.eINSTANCE.createDiagram();
+ DiagramVersioningUtils.stampCurrentVersion(diagram);
+ diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle());
+ diagram.setType(ModelEditPart.MODEL_ID);
+ diagram.setElement(getSemanticElement(semanticAdapter));
+ diagram.setMeasurementUnit(MeasurementUnit.PIXEL_LITERAL);
+ return diagram;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createNode(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) {
+ final EObject domainElement = getSemanticElement(semanticAdapter);
+ final String visualID;
+ if (semanticHint == null) {
+ visualID = UMLVisualIDRegistry.getNodeVisualID(containerView, domainElement);
+ } else {
+ visualID = UMLVisualIDRegistry.getVisualID(semanticHint);
+ }
+ if (visualID != null) {
+ switch (visualID) {
+ case InteractionEditPart.VISUAL_ID:
+ return createInteraction_Shape(domainElement, containerView, index, persisted, preferencesHint);
+ case ShortCutDiagramEditPart.VISUAL_ID:
+ return createDiagram_ShortcutShape(domainElement, containerView, index, persisted, preferencesHint);
+ case LifelineEditPartCN.VISUAL_ID:
+ return createLifeline_Shape(domainElement, containerView, index, persisted, preferencesHint);
+ case ConstraintEditPartCN.VISUAL_ID:
+ return createConstraint_Shape(domainElement, containerView, index, persisted, preferencesHint);
+ case CommentEditPartCN.VISUAL_ID:
+ return createComment_Shape(domainElement, containerView, index, persisted, preferencesHint);
+ case TimeObservationEditPartCN.VISUAL_ID:
+ return createTimeObservation_Shape(domainElement, containerView, index, persisted, preferencesHint);
+ case DurationObservationEditPartCN.VISUAL_ID:
+ return createDurationObservation_Shape(domainElement, containerView, index, persisted, preferencesHint);
+ }
+ }
+ // can't happen, provided #provides(CreateNodeViewOperation) is correct
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createEdge(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) {
+ IElementType elementType = getSemanticElementType(semanticAdapter);
+ String elementTypeHint = ((IHintedType) elementType).getSemanticHint();
+ String vid = UMLVisualIDRegistry.getVisualID(elementTypeHint);
+ if (vid != null) {
+ switch (vid) {
+ case MessageEditPart.VISUAL_ID:
+ return createPath_Edge(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
+ case CommentAnnotatedElementEditPart.VISUAL_ID:
+ return createComment_AnnotatedElementEdge(containerView, index, persisted, preferencesHint);
+ case ConstraintConstrainedElementEditPart.VISUAL_ID:
+ return createConstraint_ConstrainedElementEdge(containerView, index, persisted, preferencesHint);
+ case ConnectorDurationObservationEditPart.VISUAL_ID:
+ return createDurationObservation_EventEdge(containerView, index, persisted, preferencesHint);
+ case ConnectorTimeObservationEditPart.VISUAL_ID:
+ return createTimeObservation_EventEdge(containerView, index, persisted, preferencesHint);
+ }
+ }
+ // can never happen, provided #provides(CreateEdgeViewOperation) is correct
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createInteraction_Shape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(InteractionEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ stampShortcut(containerView, node);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Interaction");
+ Node interaction_NameLabel = createLabel(node, UMLVisualIDRegistry.getType(InteractionNameEditPart.VISUAL_ID));
+ Node interaction_FloatingNameLabel = createLabel(node, UMLVisualIDRegistry.getType(InteractionFloatingLabelEditPart.VISUAL_ID));
+ interaction_FloatingNameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location interaction_FloatingNameLabel_Location = (Location) interaction_FloatingNameLabel.getLayoutConstraint();
+ interaction_FloatingNameLabel_Location.setX(50);
+ interaction_FloatingNameLabel_Location.setY(0);
+ createCompartment(node, UMLVisualIDRegistry.getType(InteractionCompartmentEditPart.VISUAL_ID), true, false, false, false);
+ PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Interaction");
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createDiagram_ShortcutShape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(ShortCutDiagramEditPart.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ stampShortcut(containerView, node);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "ShortCutDiagram");
+ Node diagram_NameLabel = createLabel(node, UMLVisualIDRegistry.getType(DiagramNameEditPart.VISUAL_ID));
+ diagram_NameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location diagram_NameLabel_Location = (Location) diagram_NameLabel.getLayoutConstraint();
+ diagram_NameLabel_Location.setX(0);
+ diagram_NameLabel_Location.setY(5);
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createLifeline_Shape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(LifelineEditPartCN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Lifeline");
+ Node lifeline_NameLabel = createLabel(node, UMLVisualIDRegistry.getType(LifelineNameEditPart.VISUAL_ID));
+ Node lifeline_FloatingNameLabel = createLabel(node, UMLVisualIDRegistry.getType(LifelineFloatingLabelEditPartCN.VISUAL_ID));
+ lifeline_FloatingNameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location lifeline_FloatingNameLabel_Location = (Location) lifeline_FloatingNameLabel.getLayoutConstraint();
+ lifeline_FloatingNameLabel_Location.setX(0);
+ lifeline_FloatingNameLabel_Location.setY(5);
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createConstraint_Shape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(ConstraintEditPartCN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Constraint");
+ Node constraint_NameLabel = createLabel(node, UMLVisualIDRegistry.getType(ConstraintNameEditPartCN.VISUAL_ID));
+ Node constraint_BodyLabel = createLabel(node, UMLVisualIDRegistry.getType(ConstraintBodyEditPartCN.VISUAL_ID));
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createComment_Shape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.getStyles().add(NotationFactory.eINSTANCE.createHintedDiagramLinkStyle());
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(CommentEditPartCN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Comment");
+ Node comment_BodyLabel = createLabel(node, UMLVisualIDRegistry.getType(CommentBodyEditPartCN.VISUAL_ID));
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createTimeObservation_Shape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(TimeObservationEditPartCN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "TimeObservation");
+ Node timeObservation_NameLabel = createLabel(node, UMLVisualIDRegistry.getType(TimeObservationNameEditPartCN.VISUAL_ID));
+ timeObservation_NameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location timeObservation_NameLabel_Location = (Location) timeObservation_NameLabel.getLayoutConstraint();
+ timeObservation_NameLabel_Location.setX(25);
+ timeObservation_NameLabel_Location.setY(3);
+ Node timeObservation_StereotypeLabel = createLabel(node, UMLVisualIDRegistry.getType(TimeObservationStereotypeLabelEditPartCN.VISUAL_ID));
+ timeObservation_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location timeObservation_StereotypeLabel_Location = (Location) timeObservation_StereotypeLabel.getLayoutConstraint();
+ timeObservation_StereotypeLabel_Location.setX(25);
+ timeObservation_StereotypeLabel_Location.setY(-10);
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Node createDurationObservation_Shape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Shape node = NotationFactory.eINSTANCE.createShape();
+ node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ node.setType(UMLVisualIDRegistry.getType(DurationObservationEditPartCN.VISUAL_ID));
+ ViewUtil.insertChildView(containerView, node, index, persisted);
+ node.setElement(domainElement);
+ // initializeFromPreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "DurationObservation");
+ Node durationObservation_NameLabel = createLabel(node, UMLVisualIDRegistry.getType(DurationObservationLabelEditPartCN.VISUAL_ID));
+ durationObservation_NameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location durationObservation_NameLabel_Location = (Location) durationObservation_NameLabel.getLayoutConstraint();
+ durationObservation_NameLabel_Location.setX(25);
+ durationObservation_NameLabel_Location.setY(3);
+ Node durationObservation_StereotypeLabel = createLabel(node, UMLVisualIDRegistry.getType(DurationObservationStereotypeLabelEditPartCN.VISUAL_ID));
+ durationObservation_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location durationObservation_StereotypeLabel_Location = (Location) durationObservation_StereotypeLabel.getLayoutConstraint();
+ durationObservation_StereotypeLabel_Location.setX(25);
+ durationObservation_StereotypeLabel_Location.setY(-10);
+ return node;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createPath_Edge(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Connector edge = NotationFactory.eINSTANCE.createConnector();
+ edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ points.add(new RelativeBendpoint());
+ points.add(new RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(UMLVisualIDRegistry.getType(MessageEditPart.VISUAL_ID));
+ edge.setElement(domainElement);
+ // initializePreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "Message");
+ // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ // if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ // }
+ Node path_MessageLabel = createLabel(edge, UMLVisualIDRegistry.getType(MessageNameEditPart.VISUAL_ID));
+ path_MessageLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location path_MessageLabel_Location = (Location) path_MessageLabel.getLayoutConstraint();
+ path_MessageLabel_Location.setX(1);
+ path_MessageLabel_Location.setY(-23);
+ Node path_StereotypeLabel = createLabel(edge, UMLVisualIDRegistry.getType(AppliedStereotypeMessageEditPart.VISUAL_ID));
+ path_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
+ Location path_StereotypeLabel_Location = (Location) path_StereotypeLabel.getLayoutConstraint();
+ path_StereotypeLabel_Location.setX(1);
+ path_StereotypeLabel_Location.setY(-53);
+ return edge;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createComment_AnnotatedElementEdge(View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Connector edge = NotationFactory.eINSTANCE.createConnector();
+ edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ points.add(new RelativeBendpoint());
+ points.add(new RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(UMLVisualIDRegistry.getType(CommentAnnotatedElementEditPart.VISUAL_ID));
+ edge.setElement(null);
+ // initializePreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ // if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ // }
+ return edge;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createConstraint_ConstrainedElementEdge(View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Connector edge = NotationFactory.eINSTANCE.createConnector();
+ edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ points.add(new RelativeBendpoint());
+ points.add(new RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(UMLVisualIDRegistry.getType(ConstraintConstrainedElementEditPart.VISUAL_ID));
+ edge.setElement(null);
+ // initializePreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ // if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ // }
+ return edge;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createDurationObservation_EventEdge(View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Connector edge = NotationFactory.eINSTANCE.createConnector();
+ edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ points.add(new RelativeBendpoint());
+ points.add(new RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(UMLVisualIDRegistry.getType(ConnectorDurationObservationEditPart.VISUAL_ID));
+ edge.setElement(null);
+ // initializePreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ // if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ // }
+ return edge;
+ }
+
+ /**
+ * @generated
+ */
+ public Edge createTimeObservation_EventEdge(View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
+ Connector edge = NotationFactory.eINSTANCE.createConnector();
+ edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
+ RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
+ List<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
+ points.add(new RelativeBendpoint());
+ points.add(new RelativeBendpoint());
+ bendpoints.setPoints(points);
+ edge.setBendpoints(bendpoints);
+ ViewUtil.insertChildView(containerView, edge, index, persisted);
+ edge.setType(UMLVisualIDRegistry.getType(ConnectorTimeObservationEditPart.VISUAL_ID));
+ edge.setElement(null);
+ // initializePreferences
+ final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
+ // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE));
+ // if (routing != null) {
+ // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
+ // }
+ return edge;
+ }
+
+ /**
+ * @generated
+ */
+ protected void stampShortcut(View containerView, Node target) {
+ if (!ModelEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(containerView))) {
+ EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ shortcutAnnotation.setSource("Shortcut"); //$NON-NLS-1$
+ shortcutAnnotation.getDetails().put("modelID", ModelEditPart.MODEL_ID); //$NON-NLS-1$
+ target.getEAnnotations().add(shortcutAnnotation);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Node createLabel(View owner, String hint) {
+ DecorationNode rv = NotationFactory.eINSTANCE.createDecorationNode();
+ rv.setType(hint);
+ ViewUtil.insertChildView(owner, rv, ViewUtil.APPEND, true);
+ return rv;
+ }
+
+ /**
+ * @generated
+ */
+ protected Node createCompartment(View owner, String hint, boolean canCollapse, boolean hasTitle, boolean canSort, boolean canFilter) {
+ // SemanticListCompartment rv = NotationFactory.eINSTANCE.createSemanticListCompartment();
+ // rv.setShowTitle(showTitle);
+ // rv.setCollapsed(isCollapsed);
+ Node rv = NotationFactory.eINSTANCE.createBasicCompartment();
+ rv.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ if (hasTitle) {
+ TitleStyle ts = NotationFactory.eINSTANCE.createTitleStyle();
+ rv.getStyles().add(ts);
+ }
+ if (canSort) {
+ rv.getStyles().add(NotationFactory.eINSTANCE.createSortingStyle());
+ }
+ if (canFilter) {
+ rv.getStyles().add(NotationFactory.eINSTANCE.createFilteringStyle());
+ }
+ rv.setType(hint);
+ ViewUtil.insertChildView(owner, rv, ViewUtil.APPEND, true);
+ return rv;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getSemanticElement(IAdaptable semanticAdapter) {
+ if (semanticAdapter == null) {
+ return null;
+ }
+ EObject eObject = (EObject) semanticAdapter.getAdapter(EObject.class);
+ if (eObject != null) {
+ return EMFCoreUtil.resolve(TransactionUtil.getEditingDomain(eObject), eObject);
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected IElementType getSemanticElementType(IAdaptable semanticAdapter) {
+ if (semanticAdapter == null) {
+ return null;
+ }
+ return (IElementType) semanticAdapter.getAdapter(IElementType.class);
+ }
+
+ /**
+ * @generated
+ */
+ private void initFontStyleFromPrefs(View view, final IPreferenceStore store, String elementName) {
+ String fontConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.FONT);
+ String fontColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.COLOR_FONT);
+ FontStyle viewFontStyle = (FontStyle) view.getStyle(NotationPackage.Literals.FONT_STYLE);
+ if (viewFontStyle != null) {
+ FontData fontData = PreferenceConverter.getFontData(store, fontConstant);
+ viewFontStyle.setFontName(fontData.getName());
+ viewFontStyle.setFontHeight(fontData.getHeight());
+ viewFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
+ viewFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);
+ org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(store, fontColorConstant);
+ viewFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void initForegroundFromPrefs(View view, final IPreferenceStore store, String elementName) {
+ String lineColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.COLOR_LINE);
+ org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(store, lineColorConstant);
+ ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getLineStyle_LineColor(), FigureUtilities.RGBToInteger(lineRGB));
+ }
+
+ /**
+ * @generated
+ */
+ private void initBackgroundFromPrefs(View view, final IPreferenceStore store, String elementName) {
+ String fillColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.COLOR_FILL);
+ String gradientColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.COLOR_GRADIENT);
+ String gradientPolicyConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.GRADIENT_POLICY);
+ org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor(store, fillColorConstant);
+ ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getFillStyle_FillColor(), FigureUtilities.RGBToInteger(fillRGB));
+ FillStyle fillStyle = (FillStyle) view.getStyle(NotationPackage.Literals.FILL_STYLE);
+ fillStyle.setFillColor(FigureUtilities.RGBToInteger(fillRGB).intValue());
+ ;
+ if (store.getBoolean(gradientPolicyConstant)) {
+ GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(store.getString(gradientColorConstant));
+ fillStyle.setGradient(gradientPreferenceConverter.getGradientData());
+ fillStyle.setTransparency(gradientPreferenceConverter.getTransparency());
+ }
+ }
+}
|