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
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>
-rw-r--r--plugins/doc/org.eclipse.papyrus.infra.gmfdiag.common.doc/resource/connectionDecorationCustomization.mediawiki1
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml13
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/schema/connectionDecoration.exsd244
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/decoration/ConnectionDecorationRegistry.java41
-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
6 files changed, 246 insertions, 123 deletions
diff --git a/plugins/doc/org.eclipse.papyrus.infra.gmfdiag.common.doc/resource/connectionDecorationCustomization.mediawiki b/plugins/doc/org.eclipse.papyrus.infra.gmfdiag.common.doc/resource/connectionDecorationCustomization.mediawiki
index 03e64cf77f7..a6a22b7d3f8 100644
--- a/plugins/doc/org.eclipse.papyrus.infra.gmfdiag.common.doc/resource/connectionDecorationCustomization.mediawiki
+++ b/plugins/doc/org.eclipse.papyrus.infra.gmfdiag.common.doc/resource/connectionDecorationCustomization.mediawiki
@@ -32,6 +32,7 @@ New decoration can be added through extension point:<br>
''org.eclipse.papyrus.infra.gmfdiag.common.connectionDecoration''<br><br>
Attributes:
*''name'': The name of the decoration, used for the decoration values.
+*''label'': The label of the decoration, used for the user interface (ie Properties view).
*''class'': The class of the decoration to instanciate. Must implement ''org.eclipse.draw2d.RotatableDecoration''.
Added decorations will be available in advance properties tab and in the CSS autocompletion.
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
index 9536d22734e..c45d6968703 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
@@ -496,6 +496,7 @@
point="org.eclipse.papyrus.infra.gmfdiag.common.connectionDecoration">
<decorationDeclaration
class="org.eclipse.papyrus.infra.gmfdiag.common.decoration.OpenArrowConnectionDecoration"
+ label="Open Arrow"
name="open_arrow">
</decorationDeclaration>
</extension>
@@ -503,6 +504,7 @@
point="org.eclipse.papyrus.infra.gmfdiag.common.connectionDecoration">
<decorationDeclaration
class="org.eclipse.papyrus.infra.gmfdiag.common.decoration.SolidDiamondFilledConnectionDecoration"
+ label="Solid Diamond Filled"
name="solid_diamond_filled">
</decorationDeclaration>
</extension>
@@ -510,21 +512,24 @@
point="org.eclipse.papyrus.infra.gmfdiag.common.connectionDecoration">
<decorationDeclaration
class="org.eclipse.papyrus.infra.gmfdiag.common.decoration.SolidDiamondEmptyConnectionDecoration"
+ label="Solid Diamond Empty"
name="solid_diamond_empty">
</decorationDeclaration>
</extension>
<extension
point="org.eclipse.papyrus.infra.gmfdiag.common.connectionDecoration">
<decorationDeclaration
- class="org.eclipse.papyrus.infra.gmfdiag.common.decoration.SolidArrowFilledConnectionDecoration"
- name="solid_arrow_filled">
+ class="org.eclipse.papyrus.infra.gmfdiag.common.decoration.SolidArrowFilledConnectionDecoration"
+ label="Solid Arrow Filled"
+ name="solid_arrow_filled">
</decorationDeclaration>
</extension>
<extension
point="org.eclipse.papyrus.infra.gmfdiag.common.connectionDecoration">
<decorationDeclaration
- class="org.eclipse.papyrus.infra.gmfdiag.common.decoration.SolidArrowEmptyConnectionDecoration"
- name="solid_arrow_empty">
+ class="org.eclipse.papyrus.infra.gmfdiag.common.decoration.SolidArrowEmptyConnectionDecoration"
+ label="Solid Arrow Empty"
+ name="solid_arrow_empty">
</decorationDeclaration>
</extension>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/schema/connectionDecoration.exsd b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/schema/connectionDecoration.exsd
index da5324bfe3a..1d4a36f8037 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/schema/connectionDecoration.exsd
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/schema/connectionDecoration.exsd
@@ -1,117 +1,127 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.papyrus.infra.gmfdiag.common" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.papyrus.infra.gmfdiag.common" id="connectionDecoration" name="Connection Decoration"/>
- </appInfo>
- <documentation>
- Extension point to define connection decoration. These decorations will be availlable with CSS attributes and namedStyles sourceDecoration and targetDecoration.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element />
- </appInfo>
- </annotation>
- <complexType>
- <sequence minOccurs="1" maxOccurs="unbounded">
- <element ref="decorationDeclaration"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="decorationDeclaration">
- <complexType>
- <attribute name="name" type="string" use="required">
- <annotation>
- <documentation>
- The name of the decoration. It will be available to be used as attribute in CSS.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.draw2d.RotatableDecoration"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 3.1
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiinfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) 2017 CEA LIST, ALL4TEC and others.
-
- All rights reserved. This program and the accompanying materials
- are made available under the terms of the Eclipse Public License v1.0
- which accompanies this distribution, and is available at
- http://www.eclipse.org/legal/epl-v10.html
-
- Contributors:
- Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.infra.gmfdiag.common" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.papyrus.infra.gmfdiag.common" id="connectionDecoration" name="Connection Decoration"/>
+ </appInfo>
+ <documentation>
+ Extension point to define connection decoration. These decorations will be availlable with CSS attributes and namedStyles sourceDecoration and targetDecoration.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="decorationDeclaration"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="decorationDeclaration">
+ <complexType>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+ The name of the decoration. It will be available to be used as attribute in CSS.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.draw2d.RotatableDecoration"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="label" type="string">
+ <annotation>
+ <documentation>
+ The label of the decoration. Used in properties view, Advance tab, Source and Target decoration combo list.
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 3.1
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2017 CEA LIST, ALL4TEC and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/decoration/ConnectionDecorationRegistry.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/decoration/ConnectionDecorationRegistry.java
index 9424b60c19d..fa3dfc1f784 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/decoration/ConnectionDecorationRegistry.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/decoration/ConnectionDecorationRegistry.java
@@ -8,6 +8,7 @@
*
* 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.common.decoration;
@@ -38,6 +39,9 @@ public class ConnectionDecorationRegistry {
/** The decoration map. */
protected Map<String, Class<? extends RotatableDecoration>> decorationMap = null;
+ /** The label map. */
+ protected Map<String, String> labelMap = null;
+
/**
* Constructor.
*/
@@ -61,14 +65,21 @@ public class ConnectionDecorationRegistry {
*/
protected void init() {
decorationMap = new HashMap<String, Class<? extends RotatableDecoration>>();
+ labelMap = new HashMap<String, String>();
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
for (IConfigurationElement element : elements) {
String decorationName = element.getAttribute("name"); //$NON-NLS-1$
+
String decorationClass = element.getAttribute("class"); //$NON-NLS-1$
Class<? extends RotatableDecoration> loadClass = ClassLoaderHelper.loadClass(decorationClass, RotatableDecoration.class);
if (null != loadClass) {
decorationMap.put(decorationName, loadClass);
}
+
+ String decorationlabel = element.getAttribute("label"); //$NON-NLS-1$
+ if (null != decorationlabel) {
+ labelMap.put(decorationName, decorationlabel);
+ }
}
}
@@ -94,4 +105,34 @@ public class ConnectionDecorationRegistry {
return decorationMap;
}
+ /**
+ * Gets the decoration label.
+ *
+ * @param decorationName
+ * the decoration name
+ * @return the decoration label (null if not found)
+ */
+ public String getLabel(final String decorationName) {
+ return labelMap.get(decorationName);
+ }
+
+ /**
+ * Gets the decoration name.
+ *
+ * @param decorationLabel
+ * the decoration label
+ * @return the decoration name (null if not found)
+ */
+ public String getName(final String decorationLabel) {
+ String name = null;
+ try {
+ name = labelMap.entrySet().stream()
+ .filter(e -> e.getValue().equals(decorationLabel))
+ .findFirst().get().getKey();
+ } catch (Exception NoSuchElementException) {
+ // Do nothing, return null if no element
+ }
+ return name;
+ }
+
}
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