Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-02-23 08:08:20 -0500
committercletavernie2012-02-23 08:08:20 -0500
commit9c82937cd6d61a365736ff1b53e5129de729136e (patch)
tree79158156065ce4e031065361fe4c329f328e88f4 /plugins
parent547b02475bfff0f6af1c0d2cd20d802c7f0f8041 (diff)
downloadorg.eclipse.papyrus-9c82937cd6d61a365736ff1b53e5129de729136e.tar.gz
org.eclipse.papyrus-9c82937cd6d61a365736ff1b53e5129de729136e.tar.xz
org.eclipse.papyrus-9c82937cd6d61a365736ff1b53e5129de729136e.zip
370797: [Theme] Papyrus should provide a support for CSS files on its diagrams
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370797
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/META-INF/MANIFEST.MF5
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/build.properties3
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/plugin.xml6
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/schema/styleProvider.exsd109
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/AppearanceHelper.java61
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/NameLabelIconHelper.java36
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/QualifiedNameHelper.java37
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/ShadowFigureHelper.java39
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/style/AnnotationStyleProvider.java124
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/style/AppearanceStyleProvider.java24
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/AnnotationObservableValue.java144
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java22
12 files changed, 491 insertions, 119 deletions
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/META-INF/MANIFEST.MF b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/META-INF/MANIFEST.MF
index fe8b99f8b31..ee30a940f23 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/META-INF/MANIFEST.MF
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
-Bundle-SymbolicName: org.eclipse.papyrus.infra.emf.appearance
+Bundle-SymbolicName: org.eclipse.papyrus.infra.emf.appearance;singleton:=true
Bundle-Version: 0.9.0.qualifier
Bundle-Activator: org.eclipse.papyrus.infra.emf.appearance.Activator
Bundle-Vendor: %Bundle-Vendor
@@ -16,4 +16,5 @@ Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Export-Package: org.eclipse.papyrus.infra.emf.appearance,
org.eclipse.papyrus.infra.emf.appearance.commands,
- org.eclipse.papyrus.infra.emf.appearance.helper
+ org.eclipse.papyrus.infra.emf.appearance.helper,
+ org.eclipse.papyrus.infra.emf.appearance.style
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/build.properties b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/build.properties
index f4ae9701586..73a5119ed93 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/build.properties
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/build.properties
@@ -2,4 +2,5 @@ source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
- plugin.properties
+ plugin.properties,\
+ plugin.xml
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/plugin.xml b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/plugin.xml
new file mode 100644
index 00000000000..28883b23431
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/plugin.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension-point id="styleProvider" name="Style provider" schema="schema/styleProvider.exsd"/>
+
+</plugin>
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/schema/styleProvider.exsd b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/schema/styleProvider.exsd
new file mode 100644
index 00000000000..bcd654be728
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/schema/styleProvider.exsd
@@ -0,0 +1,109 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.infra.emf.appearance" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.papyrus.infra.emf.appearance" id="styleProvider" name="Style provider"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="styleprovider" minOccurs="1" maxOccurs="unbounded"/>
+ </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="styleprovider">
+ <complexType>
+ <attribute name="styleProvider" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.emf.appearance.style.AppearanceStyleProvider"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="priority" type="string" use="default" value="50">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </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="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/AppearanceHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/AppearanceHelper.java
new file mode 100644
index 00000000000..eab9de0f72f
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/AppearanceHelper.java
@@ -0,0 +1,61 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.appearance.helper;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EModelElement;
+import org.eclipse.papyrus.infra.emf.appearance.Activator;
+import org.eclipse.papyrus.infra.emf.appearance.style.AnnotationStyleProvider;
+import org.eclipse.papyrus.infra.emf.appearance.style.AppearanceStyleProvider;
+
+
+public class AppearanceHelper {
+
+ public static String EXTENSION_ID = Activator.PLUGIN_ID + ".styleProvider";
+
+ public static boolean showElementIcon(EModelElement modelElement) {
+ return styleProvider.showElementIcon(modelElement);
+ }
+
+ public static int getQualifiedNameDepth(EModelElement modelElement) {
+ return styleProvider.getQualifiedNameDepth(modelElement);
+ }
+
+ public static boolean showShadow(EModelElement modelElement) {
+ return styleProvider.showShadow(modelElement);
+ }
+
+ private static AppearanceStyleProvider findStyleProvider() {
+ //Default style provider
+ AppearanceStyleProvider provider = new AnnotationStyleProvider();
+
+ IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
+
+ int currentPriority = Integer.MAX_VALUE;
+ for(IConfigurationElement e : config) {
+ try {
+ int priority = Integer.parseInt(e.getAttribute("priority")); //$NON-NLS-1$
+ if(priority < currentPriority) {
+ provider = (AppearanceStyleProvider)e.createExecutableExtension("styleProvider"); //$NON-NLS-1$
+ currentPriority = priority;
+ }
+ } catch (Exception ex) {
+ Activator.log.error("The plugin " + e.getContributor() + " contributed an invalid extension for " + EXTENSION_ID, ex); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ }
+
+ return provider;
+ }
+
+ private static AppearanceStyleProvider styleProvider = findStyleProvider();
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/NameLabelIconHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/NameLabelIconHelper.java
index a79ce0b8a74..a6cbbd81d94 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/NameLabelIconHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/NameLabelIconHelper.java
@@ -13,13 +13,16 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.appearance.helper;
-import org.eclipse.emf.common.util.EMap;
-import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.papyrus.infra.emf.appearance.commands.SetNameLabelIconCommand;
+import org.eclipse.papyrus.infra.emf.appearance.style.AnnotationStyleProvider;
+/**
+ * @deprecated Use AppearanceHelper (For getters) or AnnotationStyleProvider
+ * (For Commands) instead.
+ */
+@Deprecated
public class NameLabelIconHelper {
/**
@@ -28,26 +31,9 @@ public class NameLabelIconHelper {
* @param modelElement
* the view where is attach the element
*/
+ @Deprecated
public static boolean showLabelIcon(EModelElement modelElement) {
- EAnnotation displayNameLabelIcon = modelElement.getEAnnotation(VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON);
- if(displayNameLabelIcon != null) {
- EMap<String, String> entries = displayNameLabelIcon.getDetails();
- if(entries != null) {
- String gradientvalueString = entries.get(VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON_VALUE);
- if(gradientvalueString != null) {
- Boolean display = new Boolean(gradientvalueString);
- if(display) {
- return true;
- }
- }
- }
- }
-
- //CSS Value (TODO : Remove this dependency ; add an extension point)
-
- // return UMLCustomStyle.getCSSElementIcon(modelElement);
-
- return false;
+ return AppearanceHelper.showElementIcon(modelElement);
}
/**
@@ -60,11 +46,11 @@ public class NameLabelIconHelper {
* @param nameLabelIconValue
* true to display the icon of the element in labelName
*
- * @return the command to set the gradient to true are false.
+ * @return the command to set the elementIcon to true are false.
*/
- // @unused
+ @Deprecated
public static RecordingCommand getNameLabelIconCommand(TransactionalEditingDomain domain, EModelElement view, boolean nameLabelIconValue) {
- return new SetNameLabelIconCommand(domain, view, nameLabelIconValue);
+ return AnnotationStyleProvider.getSetElementIconCommand(domain, view, nameLabelIconValue);
}
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/QualifiedNameHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/QualifiedNameHelper.java
index e3be8cf921d..3a17476c658 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/QualifiedNameHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/QualifiedNameHelper.java
@@ -13,13 +13,16 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.appearance.helper;
-import org.eclipse.emf.common.util.EMap;
-import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.papyrus.infra.emf.appearance.commands.SetQualifiedNameDepthCommand;
+import org.eclipse.papyrus.infra.emf.appearance.style.AnnotationStyleProvider;
+/**
+ * @deprecated Use AppearanceHelper (For getters) or AnnotationStyleProvider
+ * (For Commands) instead.
+ */
+@Deprecated
public class QualifiedNameHelper {
/**
@@ -29,27 +32,9 @@ public class QualifiedNameHelper {
* the view where is attach the element
* @return the depth
*/
+ @Deprecated
public static int getQualifiedNameDepth(EModelElement modelElement) {
- EAnnotation qualifiedNameAnnotation = modelElement.getEAnnotation(VisualInformationPapyrusConstants.QUALIFIED_NAME);
- if(qualifiedNameAnnotation != null) {
- EMap<String, String> entries = qualifiedNameAnnotation.getDetails();
-
- if(entries != null) {
- String depthString = entries.get(VisualInformationPapyrusConstants.QUALIFIED_NAME_DEPTH);
- if(depthString != null) {
- Integer i = new Integer(depthString);
- if(i != 1000) {
- return i.intValue();
- }
- }
- }
- }
-
- //CSS Value (TODO : Remove this dependency ; add an extension point)
-
- // return UMLCustomStyle.getCSSQualifiedNameDepth(modelElement);
-
- return 1000;
+ return AppearanceHelper.getQualifiedNameDepth(modelElement);
}
/**
@@ -62,11 +47,11 @@ public class QualifiedNameHelper {
* @param depth
* the depth
*
- * @return the sets the qualifed name depth command
+ * @return the set qualified name depth command
*/
- // @unused
+ @Deprecated
public static RecordingCommand getSetQualifedNameDepthCommand(TransactionalEditingDomain domain, EModelElement view, int depth) {
- return new SetQualifiedNameDepthCommand(domain, view, depth);
+ return AnnotationStyleProvider.getSetQualifiedNameDepthCommand(domain, view, depth);
}
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/ShadowFigureHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/ShadowFigureHelper.java
index 0934faac09d..e45c7f1b773 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/ShadowFigureHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/helper/ShadowFigureHelper.java
@@ -13,13 +13,16 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.appearance.helper;
-import org.eclipse.emf.common.util.EMap;
-import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.papyrus.infra.emf.appearance.commands.SetShadowFigureCommand;
+import org.eclipse.papyrus.infra.emf.appearance.style.AnnotationStyleProvider;
+/**
+ * @deprecated Use AppearanceHelper (For getters) or AnnotationStyleProvider
+ * (For Commands) instead.
+ */
+@Deprecated
public class ShadowFigureHelper {
/**
@@ -28,29 +31,9 @@ public class ShadowFigureHelper {
* @param modelElement
* the view where is attach the element
*/
+ @Deprecated
public static boolean getShadowFigureValue(EModelElement modelElement) {
- EAnnotation shadowAnnotation = modelElement.getEAnnotation(VisualInformationPapyrusConstants.SHADOWFIGURE);
- if(shadowAnnotation != null) {
- EMap<String, String> entries = shadowAnnotation.getDetails();
-
- if(entries != null) {
- String gradientvalueString = entries.get(VisualInformationPapyrusConstants.SHADOWFIGURE_VALUE);
- if(gradientvalueString != null) {
- Boolean b = new Boolean(gradientvalueString);
- if(b) {
- return true;
- }
- }
- }
- }
- //CSS Value (TODO : Remove this dependency ; add an extension point)
-
- // if(modelElement instanceof UMLCustomStyle) {
- // UMLCustomStyle cssElement = (UMLCustomStyle)modelElement;
- // return cssElement.getCSSShadow();
- // }
-
- return false;
+ return AppearanceHelper.showShadow(modelElement);
}
/**
@@ -63,11 +46,11 @@ public class ShadowFigureHelper {
* @param shadowFigureValue
* true to display the shadow on the figure
*
- * @return the command to set the gradient to true are false.
+ * @return the command to set the shadow to true or false.
*/
- // @unused
+ @Deprecated
public static RecordingCommand getShadowColorCommand(TransactionalEditingDomain domain, EModelElement view, boolean shadowFigureValue) {
- return new SetShadowFigureCommand(domain, view, shadowFigureValue);
+ return AnnotationStyleProvider.getSetShadowCommand(domain, view, shadowFigureValue);
}
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/style/AnnotationStyleProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/style/AnnotationStyleProvider.java
new file mode 100644
index 00000000000..df7856e1a72
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/style/AnnotationStyleProvider.java
@@ -0,0 +1,124 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.appearance.style;
+
+import org.eclipse.emf.common.util.EMap;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EModelElement;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.emf.appearance.commands.SetNameLabelIconCommand;
+import org.eclipse.papyrus.infra.emf.appearance.commands.SetQualifiedNameDepthCommand;
+import org.eclipse.papyrus.infra.emf.appearance.commands.SetShadowFigureCommand;
+import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants;
+
+
+public class AnnotationStyleProvider implements AppearanceStyleProvider {
+
+ public boolean showElementIcon(EModelElement modelElement) {
+ EAnnotation displayNameLabelIcon = modelElement.getEAnnotation(VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON);
+ if(displayNameLabelIcon != null) {
+ EMap<String, String> entries = displayNameLabelIcon.getDetails();
+ if(entries != null) {
+ String gradientvalueString = entries.get(VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON_VALUE);
+ if(gradientvalueString != null) {
+ return new Boolean(gradientvalueString);
+ }
+ }
+ }
+ return false;
+ }
+
+ //TODO: Improve this method. The annotation should be able to store either a String (FULL, NONE) or an Integer.
+ //The method should parse this string to the corresponding integer when called.
+ //Check whether this is compatible with the property view edition (Which already manipulates and parses "FULL" and "NONE")
+ public int getQualifiedNameDepth(EModelElement modelElement) {
+ EAnnotation qualifiedNameAnnotation = modelElement.getEAnnotation(VisualInformationPapyrusConstants.QUALIFIED_NAME);
+ if(qualifiedNameAnnotation != null) {
+ EMap<String, String> entries = qualifiedNameAnnotation.getDetails();
+
+ if(entries != null) {
+ String depthString = entries.get(VisualInformationPapyrusConstants.QUALIFIED_NAME_DEPTH);
+ if(depthString != null) {
+ return new Integer(depthString);
+ }
+ }
+ }
+
+ return 1000;
+ }
+
+ public boolean showShadow(EModelElement modelElement) {
+ EAnnotation shadowAnnotation = modelElement.getEAnnotation(VisualInformationPapyrusConstants.SHADOWFIGURE);
+ if(shadowAnnotation != null) {
+ EMap<String, String> entries = shadowAnnotation.getDetails();
+
+ if(entries != null) {
+ String gradientvalueString = entries.get(VisualInformationPapyrusConstants.SHADOWFIGURE_VALUE);
+ if(gradientvalueString != null) {
+ return new Boolean(gradientvalueString);
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Gets the command to set the gradient to true are false.
+ *
+ * @param domain
+ * the domain
+ * @param view
+ * the view
+ * @param nameLabelIconValue
+ * true to display the icon of the element in labelName
+ *
+ * @return the command to set the elementIcon to true are false.
+ */
+ public static RecordingCommand getSetElementIconCommand(TransactionalEditingDomain domain, EModelElement view, boolean nameLabelIconValue) {
+ return new SetNameLabelIconCommand(domain, view, nameLabelIconValue);
+ }
+
+ /**
+ * Gets the sets the qualifed name depth command.
+ *
+ * @param domain
+ * the domain
+ * @param view
+ * the view
+ * @param depth
+ * the depth
+ *
+ * @return the set qualified name depth command
+ */
+ public static RecordingCommand getSetQualifiedNameDepthCommand(TransactionalEditingDomain domain, EModelElement view, int depth) {
+ return new SetQualifiedNameDepthCommand(domain, view, depth);
+ }
+
+ /**
+ * Gets the command to set the shadow figure to true are false.
+ *
+ * @param domain
+ * the domain
+ * @param view
+ * the view
+ * @param shadowFigureValue
+ * true to display the shadow on the figure
+ *
+ * @return the command to set the shadow to true or false.
+ */
+ public static RecordingCommand getSetShadowCommand(TransactionalEditingDomain domain, EModelElement view, boolean shadowFigureValue) {
+ return new SetShadowFigureCommand(domain, view, shadowFigureValue);
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/style/AppearanceStyleProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/style/AppearanceStyleProvider.java
new file mode 100644
index 00000000000..2ce1e6cf127
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.appearance/src/org/eclipse/papyrus/infra/emf/appearance/style/AppearanceStyleProvider.java
@@ -0,0 +1,24 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.appearance.style;
+
+import org.eclipse.emf.ecore.EModelElement;
+
+
+public interface AppearanceStyleProvider {
+
+ public boolean showElementIcon(EModelElement modelElement);
+
+ public int getQualifiedNameDepth(EModelElement modelElement);
+
+ public boolean showShadow(EModelElement modelElement);
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/AnnotationObservableValue.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/AnnotationObservableValue.java
index d223c890198..1b5e9551fd7 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/AnnotationObservableValue.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/AnnotationObservableValue.java
@@ -11,13 +11,10 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.databinding;
-import java.util.Map.Entry;
-
import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
+import org.eclipse.emf.common.command.AbstractCommand;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.common.util.BasicEMap;
-import org.eclipse.emf.common.util.EMap;
import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.ecore.EcoreFactory;
@@ -53,6 +50,12 @@ public class AnnotationObservableValue extends AbstractObservableValue {
protected String key;
/**
+ * Whether the EAnnotation should be removed from the source when its last
+ * entry is removed (ie. value = null)
+ */
+ protected boolean deleteWithLastEntry;
+
+ /**
* Constructor.
*
* Creates an IObservableValue for the annotation. The annotation doesn't
@@ -68,10 +71,33 @@ public class AnnotationObservableValue extends AbstractObservableValue {
* The name of annotation's property to edit
*/
public AnnotationObservableValue(EModelElement source, EditingDomain domain, String annotationName, String key) {
+ this(source, domain, annotationName, key, false);
+ }
+
+ /**
+ * Constructor.
+ *
+ * Creates an IObservableValue for the annotation. The annotation doesn't
+ * need to be created beforehand
+ *
+ * @param source
+ * The EObject owning the annotation
+ * @param domain
+ * The editing domain on which the commands will be executed
+ * @param annotationName
+ * The name of the annotation
+ * @param key
+ * The name of annotation's property to edit
+ * @param deleteWithLastEntry
+ * Whether the EAnnotation should be removed from the source when its
+ * last entry is removed (ie. value = null)
+ */
+ public AnnotationObservableValue(EModelElement source, EditingDomain domain, String annotationName, String key, boolean deleteWithLastEntry) {
this.source = source;
this.domain = domain;
this.annotationName = annotationName;
this.key = key;
+ this.deleteWithLastEntry = deleteWithLastEntry;
}
/**
@@ -94,7 +120,6 @@ public class AnnotationObservableValue extends AbstractObservableValue {
return annotation.getDetails().get(key);
}
-
protected EAnnotation getEAnnotation() {
return source.getEAnnotation(annotationName);
}
@@ -114,7 +139,8 @@ public class AnnotationObservableValue extends AbstractObservableValue {
EAnnotation annotation = getEAnnotation();
if(value == null) {
- if(annotation == null) {
+ //No change : the key is not defined ; we cannot remove it
+ if(annotation == null || !annotation.getDetails().containsKey(key)) {
return null;
}
} else {
@@ -138,37 +164,103 @@ public class AnnotationObservableValue extends AbstractObservableValue {
if(annotation == null) {
annotation = EcoreFactory.eINSTANCE.createEAnnotation();
- SetCommand nameCommand = new SetCommand(domain, annotation, EcorePackage.eINSTANCE.getEAnnotation_Source(), annotationName);
- nameCommand.setLabel("Set name");
- emfCommand.append(nameCommand);
SetCommand attachToSourceCommand = new SetCommand(domain, annotation, EcorePackage.eINSTANCE.getEAnnotation_EModelElement(), source);
- nameCommand.setLabel("Attach to source");
+ attachToSourceCommand.setLabel("Attach to source");
emfCommand.append(attachToSourceCommand);
- }
- EMap<String, String> details = new BasicEMap<String, String>();
- for(Entry<String, String> entry : annotation.getDetails().entrySet()) {
- details.put(entry.getKey(), entry.getValue());
+ SetCommand nameCommand = new SetCommand(domain, annotation, EcorePackage.eINSTANCE.getEAnnotation_Source(), annotationName);
+ nameCommand.setLabel("Set name");
+ emfCommand.append(nameCommand);
}
if(value == null) {
- details.remove(key);
- if(details.isEmpty()) { //We removed the last key : delete the annotation
- SetCommand command = new SetCommand(domain, annotation, EcorePackage.eINSTANCE.getEAnnotation_EModelElement(), null);
- command.setLabel("Delete EAnnotation");
- emfCommand.append(command);
- annotation = null;
- return emfCommand;
+ if(annotation.getDetails().size() == 1 && annotation.getDetails().containsKey(key) && deleteWithLastEntry) {
+ //We removed the last key : delete the annotation
+ SetCommand deleteAnnotationCommand = new SetCommand(domain, annotation, EcorePackage.eINSTANCE.getEAnnotation_EModelElement(), null);
+ deleteAnnotationCommand.setLabel("Delete EAnnotation");
+ emfCommand.append(deleteAnnotationCommand);
+ } else {
+ Command removeEntryCommand = new RemoveEntryCommand(annotation, key);
+ emfCommand.append(removeEntryCommand);
}
} else {
- details.put(key, (String)value);
+ Command addEntryCommand = new AddEntryCommand(annotation, key, (String)value);
+ emfCommand.append(addEntryCommand);
}
- SetCommand command = new SetCommand(domain, annotation, EcorePackage.eINSTANCE.getEAnnotation_Details(), details);
- command.setLabel("Set details");
- emfCommand.append(command);
-
return emfCommand;
}
+
+ protected class RemoveEntryCommand extends AbstractCommand {
+
+ private EAnnotation annotation;
+
+ private String key;
+
+ private String previousValue;
+
+ private boolean undo = false;
+
+ public RemoveEntryCommand(EAnnotation annotation, String key) {
+ this.annotation = annotation;
+ this.key = key;
+ }
+
+ public void execute() {
+ if(undo = annotation.getDetails().containsKey(key)) {
+ previousValue = annotation.getDetails().get(key);
+ annotation.getDetails().remove(key);
+ }
+ }
+
+ public void redo() {
+ execute();
+ }
+
+ @Override
+ public boolean prepare() {
+ return true;
+ }
+
+ @Override
+ public void undo() {
+ if(undo) {
+ annotation.getDetails().put(key, previousValue);
+ }
+ }
+ }
+
+ protected class AddEntryCommand extends AbstractCommand {
+
+ private EAnnotation annotation;
+
+ private String key;
+
+ private String value;
+
+ public AddEntryCommand(EAnnotation annotation, String key, String value) {
+ this.annotation = annotation;
+ this.key = key;
+ this.value = value;
+ }
+
+ public void execute() {
+ annotation.getDetails().put(key, value);
+ }
+
+ public void redo() {
+ execute();
+ }
+
+ @Override
+ public void undo() {
+ annotation.getDetails().remove(key);
+ }
+
+ @Override
+ public boolean prepare() {
+ return true;
+ }
+ }
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java
index f59067695aa..a94c345801a 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java
@@ -251,40 +251,40 @@ public class EMFObservableList extends ObservableList implements ICommitListener
return result;
}
- protected Command getAddCommand(int index, Object value) {
+ public Command getAddCommand(int index, Object value) {
return AddCommand.create(editingDomain, source, feature, value, index);
}
- protected Command getAddCommand(Object value) {
+ public Command getAddCommand(Object value) {
return AddCommand.create(editingDomain, source, feature, value);
}
- protected Command getAddAllCommand(Collection<?> values) {
+ public Command getAddAllCommand(Collection<?> values) {
return AddCommand.create(editingDomain, source, feature, values);
}
- protected Command getAddAllCommand(int index, Collection<?> values) {
+ public Command getAddAllCommand(int index, Collection<?> values) {
return AddCommand.create(editingDomain, source, feature, values, index);
}
- protected Command getClearCommand() {
+ public Command getClearCommand() {
return getRemoveAllCommand(new LinkedList<Object>(wrappedList));
}
- protected Command getRemoveCommand(int index) {
+ public Command getRemoveCommand(int index) {
Object value = get(index);
return getRemoveCommand(value);
}
- protected Command getRemoveCommand(Object value) {
+ public Command getRemoveCommand(Object value) {
return RemoveCommand.create(editingDomain, source, feature, value);
}
- protected Command getRemoveAllCommand(Collection<?> values) {
+ public Command getRemoveAllCommand(Collection<?> values) {
return RemoveCommand.create(editingDomain, source, feature, values);
}
- protected List<Command> getMoveCommands(int oldIndex, int newIndex) {
+ public List<Command> getMoveCommands(int oldIndex, int newIndex) {
Object value = get(oldIndex);
List<Command> commands = new LinkedList<Command>();
commands.add(getRemoveCommand(value));
@@ -292,7 +292,7 @@ public class EMFObservableList extends ObservableList implements ICommitListener
return commands;
}
- protected Command getRetainAllCommand(Collection<?> values) {
+ public Command getRetainAllCommand(Collection<?> values) {
List<Object> objectsToRemove = new LinkedList<Object>();
for(Object object : values) {
if(!contains(object)) {
@@ -306,7 +306,7 @@ public class EMFObservableList extends ObservableList implements ICommitListener
}
}
- protected Command getSetCommand(int index, Object value) {
+ public Command getSetCommand(int index, Object value) {
return SetCommand.create(editingDomain, source, feature, value, index);
}

Back to the top