Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-02-03 10:10:35 +0000
committerCamille Letavernier2014-02-03 10:10:35 +0000
commitcb3d0448af00d2e5b00f589519e88d58e87480b6 (patch)
tree3487c5be40d95e2fb0a0b544c2956598405be453
parent994ccc11a90a72c9c3cd6ea7c8acc6b50d8b414a (diff)
downloadorg.eclipse.papyrus-cb3d0448af00d2e5b00f589519e88d58e87480b6.tar.gz
org.eclipse.papyrus-cb3d0448af00d2e5b00f589519e88d58e87480b6.tar.xz
org.eclipse.papyrus-cb3d0448af00d2e5b00f589519e88d58e87480b6.zip
417396: [CSS] The CSS Engine shall support label visibility & mask
https://bugs.eclipse.org/bugs/show_bug.cgi?id=417396 - Move Property- and OperationLabelEditPolicy to uml.diagram.common - Adapt LifelineLabelEditPolicy to the new API
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/PortLabelEditPolicy.java (renamed from plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/PortLabelEditPolicy.java)2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/StereotypedElementLabelHelper.java24
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/edit/policies/OperationLabelEditPolicy.java388
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/edit/policies/PortLabelEditPolicy.java31
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/edit/policies/PropertyLabelEditPolicy.java310
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/model/ComponentDiagram.gmfgen8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/OperationForInterfaceEditPart.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/PortNameEditPart.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/PropertyForInterfaceEditPart.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/PropertyPartNameEditPartCN.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/PropertyLabelEditPolicy.java251
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/model/compositediagram.gmfgen2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/edit/parts/PortNameEditPart.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/edit/parts/PropertyPartNameEditPartCN.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineLabelEditPolicy.java61
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/preferences/CustomLifelinePreferencePage.java182
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineLabelHelper.java86
17 files changed, 57 insertions, 1300 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/PortLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/PortLabelEditPolicy.java
index 0118d3e17b3..f0f82beafe6 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/PortLabelEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/PortLabelEditPolicy.java
@@ -1,4 +1,4 @@
-package org.eclipse.papyrus.uml.diagram.composite.custom.edit.policies;
+package org.eclipse.papyrus.uml.diagram.common.editpolicies;
import java.util.Collection;
import java.util.List;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/StereotypedElementLabelHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/StereotypedElementLabelHelper.java
index 5d13b4de7ff..1e08a8c66c3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/StereotypedElementLabelHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/helper/StereotypedElementLabelHelper.java
@@ -22,7 +22,6 @@ import java.util.StringTokenizer;
import org.eclipse.draw2d.IFigure;
import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
import org.eclipse.gef.GraphicalEditPart;
@@ -36,6 +35,7 @@ import org.eclipse.papyrus.uml.appearance.helper.AppliedStereotypeHelper;
import org.eclipse.papyrus.uml.appearance.helper.UMLVisualInformationPapyrusConstant;
import org.eclipse.papyrus.uml.diagram.common.Activator;
import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.swt.graphics.Image;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.NamedElement;
@@ -50,17 +50,13 @@ public abstract class StereotypedElementLabelHelper {
* {@inheritDoc}
*/
public Element getUMLElement(GraphicalEditPart editPart) {
- EObject element = ((View)editPart.getModel()).getElement();
- if(element instanceof Element) {
- return (Element)element;
- }
- return null;
+ return UMLUtil.resolveUMLElement(editPart);
}
/**
* Parses the string containing the complete definition of properties to be
* displayed, and generates a map.
- *
+ *
* @param editPart
* the edit part for which the label is edited
* @param stereotypesToDisplay
@@ -89,7 +85,7 @@ public abstract class StereotypedElementLabelHelper {
/**
* Returns the image to be displayed for the applied stereotypes.
- *
+ *
* @return the image that represents the first applied stereotype or <code>null</code> if no image has to be displayed
*/
public Collection<Image> stereotypeIconsToDisplay(GraphicalEditPart editPart) {
@@ -114,7 +110,7 @@ public abstract class StereotypedElementLabelHelper {
/**
* Returns a String that displays stereotypes (using their simple name or
* their qualified name) and their properties
- *
+ *
* @param editPart
* the edit part for which the label is edited
* @param separator
@@ -201,7 +197,7 @@ public abstract class StereotypedElementLabelHelper {
/**
* get the list of stereotype to display from the eannotation
- *
+ *
* @return the list of stereotypes to display
*/
public String stereotypesToDisplay(GraphicalEditPart editPart) {
@@ -245,7 +241,7 @@ public abstract class StereotypedElementLabelHelper {
/**
* Computes the string that displays the stereotypes for the current element
- *
+ *
* @param separator
* the separator used to split the string representing the
* stereotypes.
@@ -320,7 +316,7 @@ public abstract class StereotypedElementLabelHelper {
/**
* Refreshes the label of the figure associated to the specified edit part
- *
+ *
* @param editPart
* the edit part managing the refreshed figure
*/
@@ -371,7 +367,7 @@ public abstract class StereotypedElementLabelHelper {
/**
* Computes the label corresponding to the semantic element
- *
+ *
* @param editPart
* the graphical part managing the semantic element
* @return the string corresponding to the display of the semantic element
@@ -380,7 +376,7 @@ public abstract class StereotypedElementLabelHelper {
/**
* Returns the image for the element
- *
+ *
* @param editPart
* the edit part that displays the element
* @return the image
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/edit/policies/OperationLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/edit/policies/OperationLabelEditPolicy.java
deleted file mode 100644
index 18b0b3e540b..00000000000
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/edit/policies/OperationLabelEditPolicy.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 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:
- * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
- * Nizar GUEDIDI (CEA LIST) - Update getUMLElement()
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.component.custom.edit.policies;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.helper.OperationLabelHelper;
-import org.eclipse.papyrus.uml.tools.utils.ICustomAppearence;
-import org.eclipse.uml2.uml.Operation;
-import org.eclipse.uml2.uml.Parameter;
-import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * Specific edit policy for label displaying stereotypes and their properties for edges representing
- * UML elements.
- */
-public class OperationLabelEditPolicy extends AbstractMaskManagedEditPolicy {
-
- /**
- * Creates a new PropertyLabelEditPolicy
- */
- public OperationLabelEditPolicy() {
- super();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addAdditionalListeners() {
- super.addAdditionalListeners();
- Operation operation = getUMLElement();
- // check host semantic element is not null
- if(operation == null) {
- return;
- }
- // adds a listener to the element itself, and to linked elements, like Type
- for(Parameter parameter : operation.getOwnedParameters()) {
- getDiagramEventBroker().addNotificationListener(parameter, this);
- // should also add this element as a listener of parameter type
- if(parameter.getType() != null) {
- getDiagramEventBroker().addNotificationListener(parameter.getType(), this);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getDefaultDisplayValue() {
- return ICustomAppearence.DEFAULT_UML_OPERATION;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getMaskLabel(int value) {
- return OperationLabelHelper.getInstance().getMaskLabel(value);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Collection<String> getMaskLabels() {
- return OperationLabelHelper.getInstance().getMaskLabels();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Map<Integer, String> getMasks() {
- return OperationLabelHelper.getInstance().getMasks();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Collection<Integer> getMaskValues() {
- return OperationLabelHelper.getInstance().getMaskValues();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPreferencePageID() {
- return "org.eclipse.papyrus.uml.diagram.clazz.custom.preferences.OperationPreferencePage";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Operation getUMLElement() {
- if(hostSemanticElement instanceof Operation) {
- return (Operation)hostSemanticElement;
- }
- return null;
- }
-
- /**
- * {@inheritedDoc}
- */
- @Override
- public void notifyChanged(Notification notification) {
- super.notifyChanged(notification);
- // change the label of the figure managed by the host edit part (managed by the parent edit
- // part in general...)
- // it must be changed only if:
- // - the annotation corresponding to the display of the stereotype changes
- // - the stereotype application list has changed
- Object object = notification.getNotifier();
- Operation operation = getUMLElement();
- if(object == null) {
- return;
- }
- if(object.equals(operation)) {
- notifyOperationChanged(operation, notification);
- } else if(isParameter(object)) {
- notifyParameterChanged(notification);
- } else if(isParameterType(object)) {
- notifyParameterTypeChanged(notification);
- }
- if(isMaskManagedAnnotation(object)) {
- refreshDisplay();
- }
- if(isRemovedMaskManagedLabelAnnotation(object, notification)) {
- refreshDisplay();
- }
- }
-
- /**
- * Checks if the given object is one of the parameter type of the operation
- *
- * @param object
- * the object to test
- * @return <code>true</code> if the object corresponds to the type of a parameter of the
- * operation
- */
- protected boolean isParameterType(Object object) {
- if(!(object instanceof Type)) {
- return false;
- }
- for(Parameter parameter : getUMLElement().getOwnedParameters()) {
- if(object.equals(parameter.getType())) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Checks if the given object is one of the parameter of the operation
- *
- * @param object
- * the object to test
- * @return <code>true</code> if the object is a parameter of the operation
- */
- protected boolean isParameter(Object object) {
- if(!(object instanceof Parameter)) {
- return false;
- }
- return getUMLElement().getOwnedParameters().contains(object);
- }
-
- /**
- * notifies that a parameter of the operation has changed.
- *
- * @param parameter
- * the {@link Parameter} that has changed
- * @param notification
- * the notification send when the element has been changed
- */
- protected void notifyParameterChanged(Notification notification) {
- switch(notification.getFeatureID(Parameter.class)) {
- case UMLPackage.PARAMETER__NAME:
- case UMLPackage.PARAMETER__DEFAULT_VALUE:
- case UMLPackage.PARAMETER__DIRECTION:
- case UMLPackage.PARAMETER__IS_STREAM:
- case UMLPackage.PARAMETER__IS_ORDERED:
- case UMLPackage.PARAMETER__LOWER:
- case UMLPackage.PARAMETER__UPPER:
- case UMLPackage.PARAMETER__LOWER_VALUE:
- case UMLPackage.PARAMETER__UPPER_VALUE:
- refreshDisplay();
- break;
- case UMLPackage.PARAMETER__TYPE:
- switch(notification.getEventType()) {
- // if it is added => adds listener to the type element
- case Notification.ADD:
- getDiagramEventBroker().addNotificationListener((EObject)notification.getNewValue(), this);
- refreshDisplay();
- // if it is removed => removes listener from the type element
- break;
- case Notification.ADD_MANY: // should never happen
- if(notification.getNewValue() instanceof List<?>) {
- List<?> addedElements = (List<?>)notification.getNewValue();
- for(Object addedElement : addedElements) {
- if(addedElement instanceof EObject) {
- getDiagramEventBroker().addNotificationListener((EObject)addedElement, this);
- }
- }
- }
- refreshDisplay();
- break;
- case Notification.REMOVE:
- getDiagramEventBroker().removeNotificationListener((EObject)notification.getOldValue(), this);
- refreshDisplay();
- break;
- case Notification.REMOVE_MANY: // should never happen
- if(notification.getOldValue() instanceof List<?>) {
- List<?> removedElements = (List<?>)notification.getOldValue();
- for(Object removedElement : removedElements) {
- if(removedElement instanceof EObject) {
- getDiagramEventBroker().removeNotificationListener((EObject)removedElement, this);
- }
- }
- }
- refreshDisplay();
- break;
- // if it is set, remove the old one and adds the new one. this is the method use when
- // the type is set or removed...
- case Notification.SET:
- if(notification.getNewValue() != null) {
- getDiagramEventBroker().addNotificationListener((EObject)notification.getNewValue(), this);
- }
- if(notification.getOldValue() != null) {
- getDiagramEventBroker().removeNotificationListener((EObject)notification.getOldValue(), this);
- }
- refreshDisplay();
- default:
- break;
- }
- break;
- default:
- // does nothing in other cases
- break;
- }
- }
-
- /**
- * notifies that a parameter of the operation has changed.
- *
- * @param parameter
- * the {@link Parameter} that has changed
- * @param notification
- * the notification send when the element has been changed
- */
- protected void notifyParameterTypeChanged(Notification notification) {
- // should be type.class, but seems to be a bug if this is put instead.
- switch(notification.getFeatureID(notification.getNotifier().getClass())) {
- case UMLPackage.TYPE__NAME:
- case UMLPackage.TYPE__TEMPLATE_PARAMETER:
- case UMLPackage.TYPE__VISIBILITY:
- refreshDisplay();
- break;
- default:
- // does nothing in other cases
- break;
- }
- }
-
- /**
- * notifies that the the property has changed.
- *
- * @param operation
- * the operation that has changed
- * @param notification
- * the notification send when the element has been changed
- */
- protected void notifyOperationChanged(Operation operation, Notification notification) {
- switch(notification.getFeatureID(Operation.class)) {
- case UMLPackage.OPERATION__NAME:
- case UMLPackage.OPERATION__VISIBILITY:
- case UMLPackage.OPERATION__IS_UNIQUE:
- case UMLPackage.OPERATION__REDEFINED_OPERATION:
- case UMLPackage.OPERATION__IS_ORDERED:
- case UMLPackage.OPERATION__LOWER:
- case UMLPackage.OPERATION__UPPER:
- case UMLPackage.OPERATION__IS_STATIC:
- refreshDisplay();
- break;
- case UMLPackage.OPERATION__OWNED_PARAMETER:
- switch(notification.getEventType()) {
- // if it is added => adds listener to the type element
- case Notification.ADD:
- getDiagramEventBroker().addNotificationListener((EObject)notification.getNewValue(), this);
- refreshDisplay();
- // if it is removed => removes listener from the type element
- break;
- case Notification.ADD_MANY: // should never happen
- if(notification.getNewValue() instanceof List<?>) {
- List<?> addedElements = (List<?>)notification.getNewValue();
- for(Object addedElement : addedElements) {
- if(addedElement instanceof EObject) {
- getDiagramEventBroker().addNotificationListener((EObject)addedElement, this);
- }
- }
- }
- refreshDisplay();
- break;
- case Notification.REMOVE:
- getDiagramEventBroker().removeNotificationListener((EObject)notification.getOldValue(), this);
- refreshDisplay();
- break;
- case Notification.REMOVE_MANY: // should never happen
- if(notification.getOldValue() instanceof List<?>) {
- List<?> removedElements = (List<?>)notification.getOldValue();
- for(Object removedElement : removedElements) {
- if(removedElement instanceof EObject) {
- getDiagramEventBroker().removeNotificationListener((EObject)removedElement, this);
- }
- }
- }
- refreshDisplay();
- break;
- // if it is set, remove the old one and adds the new one. this is the method use when
- // the type is set or removed...
- case Notification.SET:
- if(notification.getNewValue() != null) {
- getDiagramEventBroker().addNotificationListener((EObject)notification.getNewValue(), this);
- }
- if(notification.getOldValue() != null) {
- getDiagramEventBroker().removeNotificationListener((EObject)notification.getOldValue(), this);
- }
- refreshDisplay();
- default:
- break;
- }
- break;
- default:
- // does nothing in other cases
- break;
- }
- }
-
- /**
- * Refreshes the display of the edit part
- */
- @Override
- public void refreshDisplay() {
- // calls the helper for this edit Part
- OperationLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart)getHost());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void removeAdditionalListeners() {
- super.removeAdditionalListeners();
- Operation operation = getUMLElement();
- // check host semantic element is not null
- if(operation == null) {
- return;
- }
- for(Parameter parameter : operation.getOwnedParameters()) {
- getDiagramEventBroker().removeNotificationListener(parameter, this);
- // remove parameter type listener
- if(parameter.getType() != null) {
- getDiagramEventBroker().removeNotificationListener(parameter.getType(), this);
- }
- }
- }
-}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/edit/policies/PortLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/edit/policies/PortLabelEditPolicy.java
deleted file mode 100644
index 0dcbe365cd2..00000000000
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/edit/policies/PortLabelEditPolicy.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 - 2010 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:
- * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.component.custom.edit.policies;
-
-import org.eclipse.papyrus.uml.tools.utils.ICustomAppearence;
-
-/**
- * Specific edit policy for label displaying stereotypes and their properties for edges representing
- * UML elements.
- */
-public class PortLabelEditPolicy extends PropertyLabelEditPolicy{
-
- /**
- * Gets the default display value.
- *
- * @return the default display value {@inheritDoc}
- */
- public int getDefaultDisplayValue() {
- return ICustomAppearence.DISP_NAME;
- }
-}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/edit/policies/PropertyLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/edit/policies/PropertyLabelEditPolicy.java
deleted file mode 100644
index 820fd7f3d1e..00000000000
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/edit/policies/PropertyLabelEditPolicy.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 - 2010 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:
- * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.component.custom.edit.policies;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.helper.PropertyLabelHelper;
-import org.eclipse.papyrus.uml.diagram.component.custom.preferences.PropertyPreferencePage;
-import org.eclipse.papyrus.uml.tools.utils.ICustomAppearence;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.UMLPackage;
-
-// TODO: Auto-generated Javadoc
-/**
- * Specific edit policy for label displaying stereotypes and their properties for edges representing
- * UML elements.
- */
-public class PropertyLabelEditPolicy extends AbstractMaskManagedEditPolicy {
-
- /**
- * Adds the additional listeners.
- *
- * {@inheritDoc}
- */
- @Override
- public void addAdditionalListeners() {
- super.addAdditionalListeners();
- Property property = getUMLElement();
- // check host semantic element is not null
- if(property == null) {
- return;
- }
-
- // adds a listener to the element itself, and to linked elements, like Type
- if(property.getType() != null) {
- getDiagramEventBroker().addNotificationListener(property.getType(), this);
-
- }
- getDiagramEventBroker().addNotificationListener(property.getUpperValue(), this);
- getDiagramEventBroker().addNotificationListener(property.getLowerValue(), this);
- }
-
- /**
- * Gets the default display value.
- *
- * @return the default display value {@inheritDoc}
- */
- @Override
- public int getDefaultDisplayValue() {
- return ICustomAppearence.DEFAULT_UML_PROPERTY;
- }
-
- /**
- * Gets the mask label.
- *
- * @param value
- * the value
- * @return the mask label {@inheritDoc}
- */
- @Override
- public String getMaskLabel(int value) {
- return PropertyLabelHelper.getInstance().getMaskLabel(value);
- }
-
- /**
- * Gets the mask labels.
- *
- * @return the mask labels {@inheritDoc}
- */
- @Override
- public Collection<String> getMaskLabels() {
- return PropertyLabelHelper.getInstance().getMaskLabels();
- }
-
- /**
- * Gets the masks.
- *
- * @return the masks {@inheritDoc}
- */
- @Override
- public Map<Integer, String> getMasks() {
- return PropertyLabelHelper.getInstance().getMasks();
- }
-
- /**
- * Gets the mask values.
- *
- * @return the mask values {@inheritDoc}
- */
- @Override
- public Collection<Integer> getMaskValues() {
- return PropertyLabelHelper.getInstance().getMaskValues();
- }
-
- /**
- * Gets the preference page id.
- *
- * @return the preference page id
- * @see org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy#getPreferencePageID()
- */
-
- @Override
- public String getPreferencePageID() {
- return PropertyPreferencePage.ID;
- }
-
- /**
- * Gets the uML element.
- *
- * @return the uML element {@inheritDoc}
- */
- @Override
- public Property getUMLElement() {
- return (Property)super.getUMLElement();
- }
-
- /**
- * Notify changed.
- *
- * @param notification
- * the notification {@inheritedDoc}
- */
- @Override
- public void notifyChanged(Notification notification) {
- super.notifyChanged(notification);
- // change the label of the figure managed by the host edit part (managed by the parent edit
- // part in general...)
- // it must be changed only if:
- // - the annotation corresponding to the display of the stereotype changes
- // - the stereotype application list has changed
- Object object = notification.getNotifier();
- Property property = (Property)hostSemanticElement;
-
- if((object == null) || (hostSemanticElement == null)) {
- return;
- }
-
- if(notification.getFeature().equals(UMLPackage.eINSTANCE.getLiteralInteger_Value())) {
- refreshDisplay();
- } else if(notification.getFeature().equals(UMLPackage.eINSTANCE.getLiteralUnlimitedNatural_Value())) {
- refreshDisplay();
- }
-
- if(object.equals(property)) {
- notifyPropertyChanged(property, notification);
- } else if(object.equals(property.getType())) {
- notifyPropertyTypeChanged(property.getType(), notification);
- }
-
- if(isMaskManagedAnnotation(object)) {
- refreshDisplay();
- }
-
- if(isRemovedMaskManagedLabelAnnotation(object, notification)) {
- refreshDisplay();
- }
-
- }
-
- /**
- * notifies that the the property has changed.
- *
- * @param property
- * the property that has changed
- * @param notification
- * the notification send when the element has been changed
- */
- protected void notifyPropertyChanged(Property property, Notification notification) {
- switch(notification.getFeatureID(Property.class)) {
- case UMLPackage.PROPERTY__NAME:
- case UMLPackage.PROPERTY__VISIBILITY:
- case UMLPackage.PROPERTY__IS_DERIVED:
- case UMLPackage.PROPERTY__DEFAULT_VALUE:
- case UMLPackage.PROPERTY__SUBSETTED_PROPERTY:
- case UMLPackage.PROPERTY__REDEFINED_PROPERTY:
- case UMLPackage.PROPERTY__IS_ORDERED:
- case UMLPackage.PROPERTY__IS_UNIQUE:
- case UMLPackage.PROPERTY__IS_READ_ONLY:
- refreshDisplay();
- break;
- case UMLPackage.PROPERTY__TYPE:
- case UMLPackage.PROPERTY__LOWER:
- case UMLPackage.PROPERTY__LOWER_VALUE:
- case UMLPackage.PROPERTY__UPPER:
- case UMLPackage.PROPERTY__UPPER_VALUE:
-
- switch(notification.getEventType()) {
- // if it is added => adds listener to the type element
- case Notification.ADD:
- getDiagramEventBroker().addNotificationListener((EObject)notification.getNewValue(), this);
- refreshDisplay();
- // if it is removed => removes listener from the type element
- break;
- case Notification.ADD_MANY: // should never happen
- if(notification.getNewValue() instanceof List<?>) {
- List<?> addedElements = (List<?>)notification.getNewValue();
- for(Object addedElement : addedElements) {
- if(addedElement instanceof EObject) {
- getDiagramEventBroker().addNotificationListener((EObject)addedElement, this);
- }
- }
- }
- refreshDisplay();
- break;
- case Notification.REMOVE:
- getDiagramEventBroker().removeNotificationListener((EObject)notification.getOldValue(), this);
- refreshDisplay();
- break;
- case Notification.REMOVE_MANY: // should never happen
- if(notification.getOldValue() instanceof List<?>) {
- List<?> removedElements = (List<?>)notification.getOldValue();
- for(Object removedElement : removedElements) {
- if(removedElement instanceof EObject) {
- getDiagramEventBroker().removeNotificationListener((EObject)removedElement, this);
- }
- }
- }
- refreshDisplay();
- break;
- // if it is set, remove the old one and adds the new one. this is the method use when
- // the type is set or removed...
- case Notification.SET:
- if(notification.getOldValue() != null) {
- getDiagramEventBroker().removeNotificationListener((EObject)notification.getOldValue(), this);
- }
- if(notification.getNewValue() != null) {
- getDiagramEventBroker().addNotificationListener((EObject)notification.getNewValue(), this);
- }
- refreshDisplay();
-
- default:
- break;
-
- }
-
- break;
- default:
- // does nothing in other cases
- break;
- }
- }
-
- /**
- * notifies that the type of the property has changed.
- *
- * @param type
- * the type of the property that has changed
- * @param notification
- * the notification send when the element has been changed
- */
- protected void notifyPropertyTypeChanged(Type type, Notification notification) {
- switch(notification.getFeatureID(Property.class)) {
- case UMLPackage.TYPE__NAME:
- refreshDisplay(); // type name has changed => refresh the property display
- break;
- default:
- // does nothing by default
- break;
- }
- }
-
- /**
- * Refreshes the display of the edit part.
- */
- @Override
- public void refreshDisplay() {
- // calls the helper for this edit Part
- PropertyLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart)getHost());
- }
-
- /**
- * Removes the additional listeners.
- *
- * {@inheritDoc}
- */
- @Override
- protected void removeAdditionalListeners() {
- super.removeAdditionalListeners();
- Property property = getUMLElement();
- if(property == null) {
- // check semantic element is not null and this is really an instance of Property
- return;
- }
-
- if(property.getType() != null) {
- getDiagramEventBroker().removeNotificationListener(property.getType(), this);
- }
-
- getDiagramEventBroker().removeNotificationListener(property.getUpperValue(), this);
- getDiagramEventBroker().removeNotificationListener(property.getLowerValue(), this);
- }
-
-}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/model/ComponentDiagram.gmfgen b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/model/ComponentDiagram.gmfgen
index 2ace1f129ac..2dce7a75f3e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/model/ComponentDiagram.gmfgen
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/model/ComponentDiagram.gmfgen
@@ -127,7 +127,7 @@
<behaviour
xsi:type="gmfgen:CustomBehaviour"
key="org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY"
- editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.component.custom.edit.policies.PortLabelEditPolicy"/>
+ editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.PortLabelEditPolicy"/>
<modelFacet
xsi:type="gmfgen:FeatureLabelModelFacet"
parser="/0/@labelParsers/@implementations.0">
@@ -798,7 +798,7 @@
<behaviour
xsi:type="gmfgen:CustomBehaviour"
key="org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY"
- editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.component.custom.edit.policies.PropertyLabelEditPolicy"/>
+ editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.PropertyLabelEditPolicy"/>
<modelFacet>
<metaClass
href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Property"/>
@@ -850,7 +850,7 @@
<behaviour
xsi:type="gmfgen:CustomBehaviour"
key="org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY"
- editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.component.custom.edit.policies.OperationLabelEditPolicy"/>
+ editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.OperationLabelEditPolicy"/>
<modelFacet>
<metaClass
href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Operation"/>
@@ -1070,7 +1070,7 @@
<behaviour
xsi:type="gmfgen:CustomBehaviour"
key="org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY"
- editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.component.custom.edit.policies.PropertyLabelEditPolicy"/>
+ editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.PropertyLabelEditPolicy"/>
<modelFacet
xsi:type="gmfgen:FeatureLabelModelFacet"
parser="/0/@labelParsers/@implementations.0"
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/OperationForInterfaceEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/OperationForInterfaceEditPart.java
index 53c0e3f40c8..f3b43534835 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/OperationForInterfaceEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/OperationForInterfaceEditPart.java
@@ -70,9 +70,9 @@ import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEdi
import org.eclipse.papyrus.uml.diagram.common.editparts.UMLCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.OperationLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
import org.eclipse.papyrus.uml.diagram.component.custom.edit.policies.AppliedStereotypePropertyDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.component.custom.edit.policies.OperationLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.component.edit.policies.OperationForInterfaceItemSemanticEditPolicy;
import org.eclipse.papyrus.uml.diagram.component.edit.policies.UMLTextNonResizableEditPolicy;
import org.eclipse.papyrus.uml.diagram.component.edit.policies.UMLTextSelectionEditPolicy;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/PortNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/PortNameEditPart.java
index 714ac91f712..44256b9d4ec 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/PortNameEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/PortNameEditPart.java
@@ -66,8 +66,8 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEd
import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PortLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
-import org.eclipse.papyrus.uml.diagram.component.custom.edit.policies.PortLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.component.edit.policies.UMLTextSelectionEditPolicy;
import org.eclipse.papyrus.uml.diagram.component.part.UMLVisualIDRegistry;
import org.eclipse.papyrus.uml.diagram.component.providers.UMLElementTypes;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/PropertyForInterfaceEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/PropertyForInterfaceEditPart.java
index 23043ae73a6..65655065051 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/PropertyForInterfaceEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/PropertyForInterfaceEditPart.java
@@ -70,9 +70,9 @@ import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEdi
import org.eclipse.papyrus.uml.diagram.common.editparts.UMLCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractAppliedStereotypeDisplayEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PropertyLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
import org.eclipse.papyrus.uml.diagram.component.custom.edit.policies.AppliedStereotypePropertyDisplayEditPolicy;
-import org.eclipse.papyrus.uml.diagram.component.custom.edit.policies.PropertyLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.component.edit.policies.PropertyForInterfaceItemSemanticEditPolicy;
import org.eclipse.papyrus.uml.diagram.component.edit.policies.UMLTextNonResizableEditPolicy;
import org.eclipse.papyrus.uml.diagram.component.edit.policies.UMLTextSelectionEditPolicy;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/PropertyPartNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/PropertyPartNameEditPartCN.java
index 3353d90c10f..42aef685c8e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/PropertyPartNameEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/edit/parts/PropertyPartNameEditPartCN.java
@@ -66,9 +66,9 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditP
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PropertyLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil;
-import org.eclipse.papyrus.uml.diagram.component.custom.edit.policies.PropertyLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.component.edit.policies.UMLTextSelectionEditPolicy;
import org.eclipse.papyrus.uml.diagram.component.part.UMLVisualIDRegistry;
import org.eclipse.papyrus.uml.diagram.component.providers.UMLElementTypes;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/PropertyLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/PropertyLabelEditPolicy.java
deleted file mode 100644
index f8e2ea59371..00000000000
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/PropertyLabelEditPolicy.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009 - 2010 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:
- * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.composite.custom.edit.policies;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy;
-import org.eclipse.papyrus.uml.diagram.common.helper.PropertyLabelHelper;
-import org.eclipse.papyrus.uml.tools.utils.ICustomAppearence;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- * Specific edit policy for label displaying stereotypes and their properties for edges representing
- * UML elements.
- */
-public class PropertyLabelEditPolicy extends AbstractMaskManagedEditPolicy {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addAdditionalListeners() {
- super.addAdditionalListeners();
- Property property = getUMLElement();
- // check host semantic element is not null
- if(property == null) {
- return;
- }
-
- // adds a listener to the element itself, and to linked elements, like Type
- if(property.getType() != null) {
- getDiagramEventBroker().addNotificationListener(property.getType(), this);
-
- }
- getDiagramEventBroker().addNotificationListener(property.getUpperValue(), this);
- getDiagramEventBroker().addNotificationListener(property.getLowerValue(), this);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Collection<String> getDefaultDisplayValue() {
- return ICustomAppearence.DEFAULT_UML_PROPERTY;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Map<String, String> getMasks() {
- return PropertyLabelHelper.getInstance().getMasks();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Property getUMLElement() {
- return (Property)super.getUMLElement();
- }
-
- /**
- * {@inheritedDoc}
- */
- @Override
- public void notifyChanged(Notification notification) {
- super.notifyChanged(notification);
- // change the label of the figure managed by the host edit part (managed by the parent edit
- // part in general...)
- // it must be changed only if:
- // - the annotation corresponding to the display of the stereotype changes
- // - the stereotype application list has changed
- Object object = notification.getNotifier();
- Property property = (Property)hostSemanticElement;
-
- if((object == null) || (hostSemanticElement == null)) {
- return;
- }
-
- if(notification.getFeature().equals(UMLPackage.eINSTANCE.getLiteralInteger_Value())) {
- refreshDisplay();
- } else if(notification.getFeature().equals(UMLPackage.eINSTANCE.getLiteralUnlimitedNatural_Value())) {
- refreshDisplay();
- }
-
- if(object.equals(property)) {
- notifyPropertyChanged(property, notification);
- } else if(object.equals(property.getType())) {
- notifyPropertyTypeChanged(property.getType(), notification);
- }
-
- if(isMaskManagedAnnotation(object)) {
- refreshDisplay();
- }
-
- if(isRemovedMaskManagedLabelAnnotation(object, notification)) {
- refreshDisplay();
- }
-
- }
-
- /**
- * notifies that the the property has changed.
- *
- * @param property
- * the property that has changed
- * @param notification
- * the notification send when the element has been changed
- */
- protected void notifyPropertyChanged(Property property, Notification notification) {
- switch(notification.getFeatureID(Property.class)) {
- case UMLPackage.PROPERTY__NAME:
- case UMLPackage.PROPERTY__VISIBILITY:
- case UMLPackage.PROPERTY__IS_DERIVED:
- case UMLPackage.PROPERTY__DEFAULT_VALUE:
- case UMLPackage.PROPERTY__SUBSETTED_PROPERTY:
- case UMLPackage.PROPERTY__REDEFINED_PROPERTY:
- case UMLPackage.PROPERTY__IS_ORDERED:
- case UMLPackage.PROPERTY__IS_UNIQUE:
- case UMLPackage.PROPERTY__IS_READ_ONLY:
- refreshDisplay();
- break;
- case UMLPackage.PROPERTY__TYPE:
- case UMLPackage.PROPERTY__LOWER:
- case UMLPackage.PROPERTY__LOWER_VALUE:
- case UMLPackage.PROPERTY__UPPER:
- case UMLPackage.PROPERTY__UPPER_VALUE:
-
- switch(notification.getEventType()) {
- // if it is added => adds listener to the type element
- case Notification.ADD:
- getDiagramEventBroker().addNotificationListener((EObject)notification.getNewValue(), this);
- refreshDisplay();
- // if it is removed => removes listener from the type element
- break;
- case Notification.ADD_MANY: // should never happen
- if(notification.getNewValue() instanceof List<?>) {
- List<?> addedElements = (List<?>)notification.getNewValue();
- for(Object addedElement : addedElements) {
- if(addedElement instanceof EObject) {
- getDiagramEventBroker().addNotificationListener((EObject)addedElement, this);
- }
- }
- }
- refreshDisplay();
- break;
- case Notification.REMOVE:
- getDiagramEventBroker().removeNotificationListener((EObject)notification.getOldValue(), this);
- refreshDisplay();
- break;
- case Notification.REMOVE_MANY: // should never happen
- if(notification.getOldValue() instanceof List<?>) {
- List<?> removedElements = (List<?>)notification.getOldValue();
- for(Object removedElement : removedElements) {
- if(removedElement instanceof EObject) {
- getDiagramEventBroker().removeNotificationListener((EObject)removedElement, this);
- }
- }
- }
- refreshDisplay();
- break;
- // if it is set, remove the old one and adds the new one. this is the method use when
- // the type is set or removed...
- case Notification.SET:
- if(notification.getOldValue() != null) {
- getDiagramEventBroker().removeNotificationListener((EObject)notification.getOldValue(), this);
- }
- if(notification.getNewValue() != null) {
- getDiagramEventBroker().addNotificationListener((EObject)notification.getNewValue(), this);
- }
- refreshDisplay();
-
- default:
- break;
-
- }
-
- break;
- default:
- // does nothing in other cases
- break;
- }
- }
-
- /**
- * notifies that the type of the property has changed.
- *
- * @param type
- * the type of the property that has changed
- * @param notification
- * the notification send when the element has been changed
- */
- protected void notifyPropertyTypeChanged(Type type, Notification notification) {
- switch(notification.getFeatureID(Property.class)) {
- case UMLPackage.TYPE__NAME:
- refreshDisplay(); // type name has changed => refresh the property display
- break;
- default:
- // does nothing by default
- break;
- }
- }
-
- /**
- * Refreshes the display of the edit part
- */
- @Override
- public void refreshDisplay() {
- // calls the helper for this edit Part
- PropertyLabelHelper.getInstance().refreshEditPartDisplay((GraphicalEditPart)getHost());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void removeAdditionalListeners() {
- super.removeAdditionalListeners();
- Property property = getUMLElement();
- if(property == null) {
- // check semantic element is not null and this is really an instance of Property
- return;
- }
-
- if(property.getType() != null) {
- getDiagramEventBroker().removeNotificationListener(property.getType(), this);
- }
-
- getDiagramEventBroker().removeNotificationListener(property.getUpperValue(), this);
- getDiagramEventBroker().removeNotificationListener(property.getLowerValue(), this);
- }
-
-}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/model/compositediagram.gmfgen b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/model/compositediagram.gmfgen
index 22a3a1c3533..90ff2fde591 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/model/compositediagram.gmfgen
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/model/compositediagram.gmfgen
@@ -46,7 +46,7 @@
<viewmap xsi:type="gmfgen:FigureViewmap" figureQualifiedClassName="org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel">
<attributes xsi:type="gmfgen:LabelOffsetAttributes" x="25" y="3"/>
</viewmap>
- <behaviour xsi:type="gmfgen:CustomBehaviour" key="org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY" editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.composite.custom.edit.policies.PortLabelEditPolicy"/>
+ <behaviour xsi:type="gmfgen:CustomBehaviour" key="org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY" editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.PortLabelEditPolicy"/>
<modelFacet xsi:type="gmfgen:FeatureLabelModelFacet" parser="/0/@labelParsers/@implementations.0">
<metaFeatures href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/>
</modelFacet>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/edit/parts/PortNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/edit/parts/PortNameEditPart.java
index e0635ec2351..7adf20f03c3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/edit/parts/PortNameEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/edit/parts/PortNameEditPart.java
@@ -67,9 +67,9 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEd
import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PortLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil;
-import org.eclipse.papyrus.uml.diagram.composite.custom.edit.policies.PortLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.composite.edit.policies.UMLTextSelectionEditPolicy;
import org.eclipse.papyrus.uml.diagram.composite.part.UMLVisualIDRegistry;
import org.eclipse.papyrus.uml.diagram.composite.providers.UMLElementTypes;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/edit/parts/PropertyPartNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/edit/parts/PropertyPartNameEditPartCN.java
index 86cb00ce9b9..b704afda7b9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/edit/parts/PropertyPartNameEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/edit/parts/PropertyPartNameEditPartCN.java
@@ -66,9 +66,9 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditP
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.PropertyLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
import org.eclipse.papyrus.uml.diagram.common.util.DiagramEditPartsUtil;
-import org.eclipse.papyrus.uml.diagram.composite.custom.edit.policies.PropertyLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.composite.edit.policies.UMLTextSelectionEditPolicy;
import org.eclipse.papyrus.uml.diagram.composite.part.UMLVisualIDRegistry;
import org.eclipse.papyrus.uml.diagram.composite.providers.UMLElementTypes;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineLabelEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineLabelEditPolicy.java
index 81e3c87fa39..705575656b2 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineLabelEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineLabelEditPolicy.java
@@ -6,16 +6,10 @@ import java.util.Map;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.EditPart;
import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.AbstractMaskManagedEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineNameEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
-import org.eclipse.papyrus.uml.diagram.sequence.preferences.CustomLifelinePreferencePage;
import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineLabelHelper;
import org.eclipse.uml2.uml.ConnectableElement;
import org.eclipse.uml2.uml.Lifeline;
@@ -24,21 +18,10 @@ import org.eclipse.uml2.uml.UMLPackage;
public class LifelineLabelEditPolicy extends AbstractMaskManagedEditPolicy {
- private IPropertyChangeListener preferenceListener;
-
@Override
public void addAdditionalListeners() {
super.addAdditionalListeners();
- if(preferenceListener == null) {
- preferenceListener = new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- handlePreferenceChange(event);
- }
- };
- IPreferenceStore store = UMLDiagramEditorPlugin.getInstance().getPreferenceStore();
- store.addPropertyChangeListener(this.preferenceListener);
- }
Lifeline lifeline = getUMLElement();
// check host semantic element is not null
if(lifeline == null) {
@@ -55,17 +38,6 @@ public class LifelineLabelEditPolicy extends AbstractMaskManagedEditPolicy {
}
}
- protected void handlePreferenceChange(PropertyChangeEvent event) {
- EditPart part = getHost();
- if(part == null || part.getParent() == null) {
- return;
- }
- String key = event.getProperty();
- if(key.equals(CustomLifelinePreferencePage.LABEL_DISPLAY_PREFERENCE)) {
- refreshDisplay();
- }
- }
-
@Override
protected void removeAdditionalListeners() {
super.removeAdditionalListeners();
@@ -136,45 +108,22 @@ public class LifelineLabelEditPolicy extends AbstractMaskManagedEditPolicy {
}
}
- public int getDefaultDisplayValue() {
- return CustomLifelinePreferencePage.DEFAULT_LABEL_DISPLAY;
- }
-
- public String getMaskLabel(int value) {
- return LifelineLabelHelper.getInstance().getMaskLabel(value);
- }
-
- /**
- * {@inheritDoc}
- */
- public Collection<String> getMaskLabels() {
- return LifelineLabelHelper.getInstance().getMaskLabels();
+ @Override
+ public Collection<String> getDefaultDisplayValue() {
+ return LifelineLabelHelper.DEFAULT_LABEL_DISPLAY;
}
/**
* {@inheritDoc}
*/
- public Map<Integer, String> getMasks() {
+ @Override
+ public Map<String, String> getMasks() {
return LifelineLabelHelper.getInstance().getMasks();
}
/**
* {@inheritDoc}
*/
- public Collection<Integer> getMaskValues() {
- return LifelineLabelHelper.getInstance().getMaskValues();
- }
-
- /**
- * {@inheritDoc}
- */
- public String getPreferencePageID() {
- return "org.eclipse.papyrus.uml.diagram.sequence.preferences.LifelinePreferencePage";
- }
-
- /**
- * {@inheritDoc}
- */
@Override
public Lifeline getUMLElement() {
return (Lifeline)hostSemanticElement;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/preferences/CustomLifelinePreferencePage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/preferences/CustomLifelinePreferencePage.java
deleted file mode 100644
index 3ed373f0457..00000000000
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/preferences/CustomLifelinePreferencePage.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * 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:
- * Soyatec - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.preferences;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.PackageEditPart;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-
-/**
- * @author Jin Liu (jin.liu@soyatec.com)
- */
-public class CustomLifelinePreferencePage extends LifelinePreferencePage {
-
- public static final String LABEL_DISPLAY_PREFERENCE = PackageEditPart.MODEL_ID + "_Lifeline.label.display";
-
- public static final int SHOW_REPRESENT_NAME = 1 << 1;
-
- public static final int SHOW_REPRESENT_TYPE = 1 << 2;
-
- public static final int SHOW_UNDEFINED_TYPE = 1 << 3;
-
- public static final int SHOW_LIFELINE_NAME = 1 << 4;
-
- public static final int DEFAULT_LABEL_DISPLAY = SHOW_REPRESENT_NAME | SHOW_REPRESENT_TYPE;
-
- /**
- * @Override
- */
- public static void initDefaults(IPreferenceStore store) {
- String key = PackageEditPart.MODEL_ID + "_Lifeline";
- store.setDefault(PreferencesConstantsHelper.getElementConstant(key, PreferencesConstantsHelper.WIDTH), 100);
- store.setDefault(PreferencesConstantsHelper.getElementConstant(key, PreferencesConstantsHelper.HEIGHT), 250);
- store.setDefault(LABEL_DISPLAY_PREFERENCE, DEFAULT_LABEL_DISPLAY);
- }
-
- /** buttons to select the display kind for the label of the */
- protected Button showRepName, showRepType, showUndefined, showName;
-
- /** current operation display style */
- private int displayValue = getPreferenceStore().getInt(LABEL_DISPLAY_PREFERENCE);
-
- /**
- * Creates a button with the {@link SWT#CHECK} style.
- *
- * @param parent
- * the parent of the button
- * @param label
- * the label of the button
- * @param mask
- * the value controlled by the button
- * @return the button created
- */
- protected Button createCheckButton(Composite parent, String label, int mask) {
- Button button = new Button(parent, SWT.CHECK);
- button.setText(label);
- button.addSelectionListener(new AppearenceSelectionListener(mask));
- return button;
- }
-
- /**
- * Listeners for the check buttons that select the display of the label
- */
- private class AppearenceSelectionListener implements SelectionListener {
-
- /** the constant which refers the element to display or not */
- final private int style;
-
- /**
- * Default Constructor.
- *
- * @param style
- */
- public AppearenceSelectionListener(int style) {
- this.style = style;
- }
-
- /**
- * {@inheritDoc}
- */
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- /**
- * {@inheritDoc}
- */
- public void widgetSelected(SelectionEvent e) {
- // add or remove the flag to the display Operation value (invert the current value)
- displayValue = displayValue ^ style;
- // refresh buttons at the end
- refreshButtons();
- }
- }
-
- /**
- * Creates the group and check boxes to choose the kind of display
- *
- * @param parent
- * the parent composite that holds the group
- */
- protected void createLabelPreferencesButtons(Composite parent) {
- // create group that host the buttons
- Group group = new Group(parent, SWT.SHADOW_NONE);
- group.setText("Label Display");
- group.setLayout(new GridLayout(1, true));
- showRepName = createCheckButton(group, "Show represent name", SHOW_REPRESENT_NAME);
- showRepType = createCheckButton(group, "Show represent type", SHOW_REPRESENT_TYPE);
- showUndefined = createCheckButton(group, "Always show undefined type", SHOW_UNDEFINED_TYPE);
- showName = createCheckButton(group, "Always show lifeline name", SHOW_LIFELINE_NAME);
- }
-
- protected void createPageContents(Composite parent) {
- super.createPageContents(parent);
- // adds the label preferences checkboxes
- createLabelPreferencesButtons(parent);
- refreshButtons();
- }
-
- /**
- * Load the default preferences of the fields contained in this page
- */
- protected void loadDefaultPreferences() {
- displayValue = getPreferenceStore().getInt(LABEL_DISPLAY_PREFERENCE);
- refreshButtons();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void performDefaults() {
- loadDefaultPreferences();
- super.performDefaults();
- }
-
- @Override
- public boolean performOk() {
- storePreferences();
- return super.performOk();
- }
-
- protected void refreshButtons() {
- showRepName.setSelection(isCheck(displayValue, SHOW_REPRESENT_NAME));
- showRepType.setSelection(isCheck(displayValue, SHOW_REPRESENT_TYPE));
- showUndefined.setSelection(isCheck(displayValue, SHOW_UNDEFINED_TYPE));
- showName.setSelection(isCheck(displayValue, SHOW_LIFELINE_NAME));
- }
-
- private static boolean isCheck(int value, int mask) {
- return (value & mask) != 0;
- }
-
- /**
- * Stores the values of the fields contained in this page into the preference store.
- */
- protected void storePreferences() {
- super.storePreferences();
- IPreferenceStore store = getPreferenceStore();
- // checks the stored value and the actual one, so does not refresh diagram if it is not
- // needed
- if(displayValue != store.getInt(LABEL_DISPLAY_PREFERENCE)) {
- store.setValue(LABEL_DISPLAY_PREFERENCE, displayValue);
- }
- }
-}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineLabelHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineLabelHelper.java
index d104888d8e3..17da7c1ebce 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineLabelHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineLabelHelper.java
@@ -1,22 +1,32 @@
package org.eclipse.papyrus.uml.diagram.sequence.util;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.helper.StereotypedElementLabelHelper;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineNameEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.preferences.CustomLifelinePreferencePage;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.uml2.uml.ConnectableElement;
import org.eclipse.uml2.uml.Lifeline;
import org.eclipse.uml2.uml.Type;
public class LifelineLabelHelper extends StereotypedElementLabelHelper {
+ public static final String SHOW_REPRESENT_NAME = "representsName";
+
+ public static final String SHOW_REPRESENT_TYPE = "representsType";
+
+ public static final String SHOW_UNDEFINED_TYPE = "undefinedType";
+
+ public static final String SHOW_LIFELINE_NAME = "lifelineName";
+
+ public static final Collection<String> DEFAULT_LABEL_DISPLAY = Arrays.asList(SHOW_REPRESENT_NAME, SHOW_REPRESENT_TYPE);
+
/**
* singelton instance
*/
@@ -35,35 +45,17 @@ public class LifelineLabelHelper extends StereotypedElementLabelHelper {
}
/** Map for masks */
- protected final Map<Integer, String> masks = new HashMap<Integer, String>(7);
+ protected final Map<String, String> masks = new HashMap<String, String>();
/**
* Creates a new Operation label helper.
*/
protected LifelineLabelHelper() {
// initialize the map
- masks.put(CustomLifelinePreferencePage.SHOW_REPRESENT_NAME, "Show represent name");
- masks.put(CustomLifelinePreferencePage.SHOW_REPRESENT_TYPE, "Show represent type");
- masks.put(CustomLifelinePreferencePage.SHOW_UNDEFINED_TYPE, "Always show undefined type");
- masks.put(CustomLifelinePreferencePage.SHOW_LIFELINE_NAME, "Always show lifeline name");
- }
-
- /**
- * Returns the mask name given the value of the mask
- *
- * @return the mask name or <code>null</code> if no masks has been found
- */
- public String getMaskLabel(int value) {
- return masks.get(value);
- }
-
- /**
- * Returns the collection of mask names
- *
- * @return the collection of mask names
- */
- public Collection<String> getMaskLabels() {
- return masks.values();
+ masks.put(SHOW_REPRESENT_NAME, "Show represent name");
+ masks.put(SHOW_REPRESENT_TYPE, "Show represent type");
+ masks.put(SHOW_UNDEFINED_TYPE, "Always show undefined type");
+ masks.put(SHOW_LIFELINE_NAME, "Always show lifeline name");
}
/**
@@ -71,26 +63,16 @@ public class LifelineLabelHelper extends StereotypedElementLabelHelper {
*
* @return the map of masks used to display
*/
- @Override
- public Map<Integer, String> getMasks() {
+ public Map<String, String> getMasks() {
return masks;
}
/**
- * Returns the collection of mask values
- *
- * @return the collection of mask values
- */
- public Set<Integer> getMaskValues() {
- return masks.keySet();
- }
-
- /**
* {@inheritDoc}
*/
@Override
public Lifeline getUMLElement(GraphicalEditPart editPart) {
- return (Lifeline)((View)editPart.getModel()).getElement();
+ return (Lifeline)UMLUtil.resolveUMLElement(editPart);
}
@Override
@@ -98,7 +80,7 @@ public class LifelineLabelHelper extends StereotypedElementLabelHelper {
if(editPart instanceof LifelineNameEditPart) {
editPart = (GraphicalEditPart)editPart.getParent();
}
- int displayValue = CustomLifelinePreferencePage.DEFAULT_LABEL_DISPLAY;
+ Collection<String> displayValue = DEFAULT_LABEL_DISPLAY;
IMaskManagedLabelEditPolicy policy = (IMaskManagedLabelEditPolicy)editPart.getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY);
if(policy != null) {
displayValue = policy.getCurrentDisplayValue();
@@ -111,11 +93,11 @@ public class LifelineLabelHelper extends StereotypedElementLabelHelper {
private static final String UNDEFINED = "<Undefined>";
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=383722
- private String getCustomLabel(Lifeline lifeline, int displayValue) {
+ private String getCustomLabel(Lifeline lifeline, Collection<String> displayValue) {
StringBuilder sb = new StringBuilder();
appendName(lifeline, displayValue, sb);
- boolean displayType = isCheck(displayValue, CustomLifelinePreferencePage.SHOW_REPRESENT_TYPE);
- if(lifeline.getRepresents() == null || isCheck(displayValue, CustomLifelinePreferencePage.SHOW_LIFELINE_NAME)) {
+ boolean displayType = displayValue.contains(CustomLifelinePreferencePage.SHOW_REPRESENT_TYPE);
+ if(lifeline.getRepresents() == null || displayValue.contains(CustomLifelinePreferencePage.SHOW_LIFELINE_NAME)) {
displayType = false;
}
if(displayType) {
@@ -125,33 +107,33 @@ public class LifelineLabelHelper extends StereotypedElementLabelHelper {
return sb.toString();
}
- protected void appendName(Lifeline lifeline, int displayValue, StringBuilder sb) {
+ protected void appendName(Lifeline lifeline, Collection<String> displayValue, StringBuilder sb) {
ConnectableElement element = lifeline.getRepresents();
String lifelineName = lifeline.getName();
- if(element == null || isCheck(displayValue, CustomLifelinePreferencePage.SHOW_LIFELINE_NAME)) {
+ if(element == null || displayValue.contains(CustomLifelinePreferencePage.SHOW_LIFELINE_NAME)) {
appendString(sb, lifelineName, UNAMED);
return;
} else {
// represents is not null
- if(isCheck(displayValue, CustomLifelinePreferencePage.SHOW_REPRESENT_NAME)) {
+ if(displayValue.contains(CustomLifelinePreferencePage.SHOW_REPRESENT_NAME)) {
appendString(sb, element.getName(), UNAMED);
}
// if neither <1> or <2> are checked, show lifeline name (or <unnamed> when the lifeline has no name)
- else if(!isCheck(displayValue, CustomLifelinePreferencePage.SHOW_REPRESENT_TYPE)) {
+ else if(!displayValue.contains(CustomLifelinePreferencePage.SHOW_REPRESENT_TYPE)) {
appendString(sb, lifelineName, UNAMED);
}
}
}
- protected void appendType(Lifeline lifeline, int displayValue, StringBuilder sb) {
+ protected void appendType(Lifeline lifeline, Collection<String> displayValue, StringBuilder sb) {
ConnectableElement element = lifeline.getRepresents();
if(element == null) {
return;
}
Type type = element.getType();
- if(isCheck(displayValue, CustomLifelinePreferencePage.SHOW_REPRESENT_TYPE)) {
+ if(displayValue.contains(CustomLifelinePreferencePage.SHOW_REPRESENT_TYPE)) {
if(type == null) {
- if(isCheck(displayValue, CustomLifelinePreferencePage.SHOW_UNDEFINED_TYPE)) {
+ if(displayValue.contains(CustomLifelinePreferencePage.SHOW_UNDEFINED_TYPE)) {
sb.append(":").append(UNDEFINED);
}
} else {
@@ -160,10 +142,6 @@ public class LifelineLabelHelper extends StereotypedElementLabelHelper {
}
}
- private static boolean isCheck(int value, int mask) {
- return (value & mask) != 0;
- }
-
private void appendString(StringBuilder sb, String str, String defaultValue) {
if(str != null) {
sb.append(str);
@@ -172,8 +150,4 @@ public class LifelineLabelHelper extends StereotypedElementLabelHelper {
}
}
- @Override
- public int getDefaultValue() {
- return CustomLifelinePreferencePage.DEFAULT_LABEL_DISPLAY;
- }
}

Back to the top