Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2017-09-04 08:22:25 +0000
committervincent lorenzo2017-09-21 08:39:55 +0000
commitbcc1383b24cfe7cc8fc427aba8dde06de6b43e09 (patch)
tree70a0d44d3f679d98e2a0ca2783a4cab0bfc948d3 /plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org
parentdf51cda5b554fd28c2fb6859f96749a593b1d1c0 (diff)
downloadorg.eclipse.papyrus-bcc1383b24cfe7cc8fc427aba8dde06de6b43e09.tar.gz
org.eclipse.papyrus-bcc1383b24cfe7cc8fc427aba8dde06de6b43e09.tar.xz
org.eclipse.papyrus-bcc1383b24cfe7cc8fc427aba8dde06de6b43e09.zip
Bug 521754 - [Diagram] displayed label for custom connection decoration
should be different that its name. https://bugs.eclipse.org/bugs/show_bug.cgi?id=521754 Change-Id: I9dc52e104a79f197e5407e79871858453e04cff4 Signed-off-by: Mickael ADAM <mickael.adam@all4tec.net>
Diffstat (limited to 'plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/ConnectionDecorationStyleObservableValue.java31
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/AdvanceStyleModelElement.java39
2 files changed, 68 insertions, 2 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/ConnectionDecorationStyleObservableValue.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/ConnectionDecorationStyleObservableValue.java
index fd477383109..27579f3ed28 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/ConnectionDecorationStyleObservableValue.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/ConnectionDecorationStyleObservableValue.java
@@ -8,12 +8,14 @@
*
* Contributors:
* Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
+ * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 521754
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.properties.databinding;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomStringStyleObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.common.decoration.ConnectionDecorationRegistry;
/**
* The {@link CustomStringStyleObservableValue} used for connector decoration value.
@@ -51,4 +53,33 @@ public final class ConnectionDecorationStyleObservableValue extends CustomString
protected String getDefaultValue() {
return DEFAULT_VALUE;
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.AbstractCustomStyleObservableValue#doSetValue(java.lang.Object)
+ */
+ @Override
+ protected void doSetValue(final Object value) {
+ String name = null;
+ if (value instanceof String) {
+ name = ConnectionDecorationRegistry.getInstance().getName((String) value);
+ }
+ super.doSetValue(null != name ? name : value);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.AbstractCustomStyleObservableValue#doGetValue()
+ */
+ @Override
+ protected Object doGetValue() {
+ Object value = super.doGetValue();
+ if (value instanceof String) {
+ String label = ConnectionDecorationRegistry.getInstance().getLabel((String) value);
+ return null != label ? label : value;
+ }
+ return value;
+ }
} \ No newline at end of file
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/AdvanceStyleModelElement.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/AdvanceStyleModelElement.java
index 7da4b2b0da5..7c1a546b6b5 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/AdvanceStyleModelElement.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/AdvanceStyleModelElement.java
@@ -8,7 +8,7 @@
*
* Contributors:
* Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation - bug 465297
- * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 515661
+ * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 515661, 521754
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.properties.modelelement;
@@ -21,6 +21,8 @@ import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.draw2d.RotatableDecoration;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.papyrus.infra.gmfdiag.common.decoration.ConnectionDecorationRegistry;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.ConnectionEditPart;
import org.eclipse.papyrus.infra.gmfdiag.common.types.NotationTypesMap;
@@ -169,7 +171,7 @@ public class AdvanceStyleModelElement extends CustomStyleModelElement {
PortPositionEnum.OUTSIDE.toString() };
contentProvider = new StaticContentProvider(portPositions);
- }
+ } else
// case connector decorations
if (propertyPath.equals(ConnectionEditPart.TARGET_DECORATION)
@@ -183,4 +185,37 @@ public class AdvanceStyleModelElement extends CustomStyleModelElement {
return null != contentProvider ? contentProvider : super.getContentProvider(propertyPath);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.CustomStyleModelElement#getLabelProvider(java.lang.String)
+ */
+ @Override
+ public ILabelProvider getLabelProvider(final String propertyPath) {
+ ILabelProvider labelProvider = null;
+
+ // case connector decorations
+ if (propertyPath.equals(ConnectionEditPart.TARGET_DECORATION)
+ || propertyPath.equals(ConnectionEditPart.SOURCE_DECORATION)) {
+ Map<String, Class<? extends RotatableDecoration>> availableDecoration = ConnectionDecorationRegistry.getInstance().getAvailableDecoration();
+ List<String> decorations = new ArrayList<String>(availableDecoration.keySet());
+ decorations.addAll(Arrays.asList(ConnectionEditPart.DECORATION_VALUES));
+
+ labelProvider = new LabelProvider() {
+ @Override
+ public String getText(final Object element) {
+ if (element instanceof String) {
+ String label = ConnectionDecorationRegistry.getInstance().getLabel((String) element);
+ return null != label ? label : (String) element;
+ }
+ return null;
+ }
+ };
+ } else {
+ labelProvider = super.getLabelProvider(propertyPath);
+ }
+
+ return labelProvider;
+ }
+
}

Back to the top