Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2013-08-01 15:52:00 +0000
committerCamille Letavernier2013-08-01 15:52:00 +0000
commitb9dff725774c7ce19776d8ab660011b54e920c42 (patch)
tree1d07ad9ca5bdca452d84eb7af310ecda0caafce7
parent777e248da5a412e807be3c9ca04470d9ad345da6 (diff)
downloadorg.eclipse.papyrus-b9dff725774c7ce19776d8ab660011b54e920c42.tar.gz
org.eclipse.papyrus-b9dff725774c7ce19776d8ab660011b54e920c42.tar.xz
org.eclipse.papyrus-b9dff725774c7ce19776d8ab660011b54e920c42.zip
384571: [CSS - Selectors] Add new CSS selectors, to handle complex UML
cases https://bugs.eclipse.org/bugs/show_bug.cgi?id=384571 Add support for Stereotypes and Stereotype properties
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/plugin.xml1
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/schema/domElementAdapter.exsd109
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/GMFElementAdapter.java60
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/DiagramCSSEngine.java2
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ElementProviderWrapper.java100
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ICSSElementProviderFactory.java24
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/.classpath7
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/.project28
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/META-INF/MANIFEST.MF19
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/about.html28
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/build.properties7
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/plugin.xml12
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/Activator.java58
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/dom/GMFUMLElementAdapter.java135
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/dom/GMFUMLElementProvider.java36
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/dom/GMFUMLElementProviderFactory.java37
16 files changed, 629 insertions, 34 deletions
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/plugin.xml b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/plugin.xml
index 948168d4d72..b82a4ff395c 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/plugin.xml
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/plugin.xml
@@ -3,6 +3,7 @@
<plugin>
<extension-point id="theme" name="CSS Theme" schema="schema/theme.exsd"/>
<extension-point id="markertopseudoselectormappingprovider" name="MarkerToPseudoSelectorMappingProvider" schema="schema/markertopseudoselectormappingprovider.exsd"/>
+ <extension-point id="domElementAdapter" name="domElementAdapter" schema="schema/domElementAdapter.exsd"/>
<extension point="org.eclipse.emf.ecore.factory_override">
<factory
class="org.eclipse.papyrus.infra.gmfdiag.css.factory.CSSNotationFactory"
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/schema/domElementAdapter.exsd b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/schema/domElementAdapter.exsd
new file mode 100644
index 00000000000..b4d5e973c71
--- /dev/null
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/schema/domElementAdapter.exsd
@@ -0,0 +1,109 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.infra.gmfdiag.css" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.papyrus.infra.gmfdiag.css" id="domElementAdapter" name="domElementAdapter"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="factory" 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="factory">
+ <complexType>
+ <attribute name="order" type="string" use="default" value="50">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="factory" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.gmfdiag.css.engine.ICSSElementProviderFactory"/>
+ </appinfo>
+ </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/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/GMFElementAdapter.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/GMFElementAdapter.java
index 4659a2f3929..d3151e98ee3 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/GMFElementAdapter.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/dom/GMFElementAdapter.java
@@ -65,69 +65,46 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan
//TODO : Use an extension point for this map, or find another way to map Diagram ID to CSS Element name
public static final Map<String, String> diagramNameMappings = new HashMap<String, String>();
- static {
- //UML
- diagramNameMappings.put("CompositeStructure", "CompositeDiagram");
- diagramNameMappings.put("Package", "PackageDiagram");
- diagramNameMappings.put("PapyrusUMLActivityDiagram", "ActivityDiagram");
- diagramNameMappings.put("PapyrusUMLClassDiagram", "ClassDiagram");
- diagramNameMappings.put("PapyrusUMLCommunicationDiagram", "CommunicationDiagram");
- diagramNameMappings.put("PapyrusUMLComponentDiagram", "ComponentDiagram");
- diagramNameMappings.put("PapyrusUMLDeploymentDiagram", "DeploymentDiagram");
- diagramNameMappings.put("PapyrusUMLProfileDiagram", "ProfileDiagram");
- diagramNameMappings.put("PapyrusUMLSequenceDiagram", "SequenceDiagram");
- diagramNameMappings.put("PapyrusUMLStateMachineDiagram", "StateMachineDiagram");
- diagramNameMappings.put("UseCase", "UseCaseDiagram");
- diagramNameMappings.put("PapyrusUMLTimingDiagram", "TimingDiagram");
- diagramNameMappings.put("PapyrusUMLInteractionOverviewDiagram", "InteractionOverviewDiagram");
-
- //SysML
- diagramNameMappings.put("BlockDefinition", "BlockDiagram");
- diagramNameMappings.put("InternalBlock", "InternalBlockDiagram");
- diagramNameMappings.put("PapyrusSysMLRequirement", "RequirementDiagram");
- diagramNameMappings.put("Parametric", "ParametricDiagram");
- }
-
/**
* The Semantic Model Element associated to the current styled element
* Might also be a GMF Diagram
*/
- private EObject semanticElement;
+ protected EObject semanticElement;
/**
* The current GMF Element
*/
- private View notationElement;
+ protected View notationElement;
/**
* The namespace URI of the semanticElement
*/
- private String namespaceURI;
+ protected String namespaceURI;
/**
* The unqualified name of the semantic Element
*/
- private String localName;
+ protected String localName;
/**
* The list of child nodes for this element
*/
- private Node[] children;
+ protected Node[] children;
/**
* The parent node of this element
*/
- private Node parentNode;
+ protected Node parentNode;
/**
* A Listener for standard Style properties
*/
- private Adapter styleListener;
+ protected Adapter styleListener;
/**
* A Listener for custom Style properties
*/
- private CustomStyleListener cssStyleListener;
+ protected CustomStyleListener cssStyleListener;
/**
* Returns the CSS ID of the selected element.
@@ -368,7 +345,24 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan
* The attributes are the semantic's element features
*/
@Override
- public String getAttribute(String attr) {
+ public final String getAttribute(String attr) {
+ String value = doGetAttribute(attr);
+ if(value != null) {
+ return value;
+
+ }
+
+ return "";
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * The attributes are the semantic's element features
+ *
+ * Returns null if the attribute is not known
+ */
+ protected String doGetAttribute(String attr) {
EStructuralFeature feature = getSemanticElement().eClass().getEStructuralFeature(attr);
if(feature != null) {
Object value = semanticElement.eGet(feature);
@@ -377,7 +371,7 @@ public class GMFElementAdapter extends ElementAdapter implements NodeList, IChan
}
}
- return "";
+ return null;
}
/**
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/DiagramCSSEngine.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/DiagramCSSEngine.java
index ffae587eb03..09ae9180353 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/DiagramCSSEngine.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/DiagramCSSEngine.java
@@ -52,7 +52,7 @@ public class DiagramCSSEngine extends ExtendedCSSEngineImpl implements IChangeLi
super(parent);
this.diagram = diagram;
- setElementProvider(new GMFElementProvider());
+ setElementProvider(new ElementProviderWrapper(diagram));
}
@Override
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ElementProviderWrapper.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ElementProviderWrapper.java
new file mode 100644
index 00000000000..02e646efec5
--- /dev/null
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ElementProviderWrapper.java
@@ -0,0 +1,100 @@
+/*****************************************************************************
+ * 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.gmfdiag.css.engine;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.e4.ui.css.core.dom.IElementProvider;
+import org.eclipse.e4.ui.css.core.engine.CSSEngine;
+import org.eclipse.papyrus.infra.gmfdiag.css.Activator;
+import org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSDiagram;
+import org.w3c.dom.Element;
+
+/**
+ * Provides an Element for a GMF Notation object.
+ *
+ * @author Camille Letavernier
+ */
+@SuppressWarnings("restriction")
+public class ElementProviderWrapper implements IElementProvider {
+
+ public static final String EXTENSION_POINT = Activator.PLUGIN_ID + ".domElementAdapter";
+
+ private IElementProvider delegate;
+
+ public ElementProviderWrapper(CSSDiagram diagram) {
+ this.delegate = getElementProviderFor(diagram);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @param element
+ * A GMF View
+ * @param engine
+ * An ExtendedCSSEngine
+ */
+ public Element getElement(Object element, CSSEngine engine) {
+ return delegate.getElement(element, engine);
+ }
+
+ private List<ICSSElementProviderFactory> getCSSElementProviders() {
+ IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT);
+
+
+ //Ordered Factories (Map of Lists to allow equalities)
+ SortedMap<Integer, List<ICSSElementProviderFactory>> sortedFactories = new TreeMap<Integer, List<ICSSElementProviderFactory>>();
+
+ for(IConfigurationElement e : config) {
+ try {
+ final int order = Integer.parseInt(e.getAttribute("order")); //$NON-NLS-1$
+ final ICSSElementProviderFactory factory = (ICSSElementProviderFactory)e.createExecutableExtension("factory"); //$NON-NLS-1$
+
+ getFactories(sortedFactories, order).add(factory);
+ } catch (Exception ex) {
+ Activator.log.error(String.format("Plugin %s contributed an invalid CSS DOM Element Provider Factory", e.getContributor()), ex);
+ }
+ }
+
+ //SortedMap to List
+ List<ICSSElementProviderFactory> factories = new LinkedList<ICSSElementProviderFactory>();
+ for(List<ICSSElementProviderFactory> factoriesEntry : sortedFactories.values()) {
+ factories.addAll(factoriesEntry);
+ }
+
+ return factories;
+ }
+
+ private List<ICSSElementProviderFactory> getFactories(Map<Integer, List<ICSSElementProviderFactory>> sortedFactories, int order) {
+ if(!sortedFactories.containsKey(order)) {
+ sortedFactories.put(order, new LinkedList<ICSSElementProviderFactory>());
+ }
+ return sortedFactories.get(order);
+ }
+
+ private IElementProvider getElementProviderFor(CSSDiagram diagram) {
+ for(ICSSElementProviderFactory providerFactory : getCSSElementProviders()) {
+ if(providerFactory.isProviderFor(diagram)) {
+ return providerFactory.createProvider(diagram);
+ }
+ }
+
+ return new GMFElementProvider();
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ICSSElementProviderFactory.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ICSSElementProviderFactory.java
new file mode 100644
index 00000000000..2656ef38071
--- /dev/null
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ICSSElementProviderFactory.java
@@ -0,0 +1,24 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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.gmfdiag.css.engine;
+
+import org.eclipse.e4.ui.css.core.dom.IElementProvider;
+import org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSDiagram;
+
+
+@SuppressWarnings("restriction")
+public interface ICSSElementProviderFactory {
+
+ public boolean isProviderFor(CSSDiagram diagram);
+
+ public IElementProvider createProvider(CSSDiagram diagram);
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/.classpath b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/.project b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/.project
new file mode 100644
index 00000000000..19661f6acfa
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.uml.diagram.css</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..0f76c5c284e
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: UML-Specific CSS concepts (Incubation)
+Bundle-SymbolicName: org.eclipse.papyrus.uml.diagram.css;singleton:=true
+Bundle-Version: 0.10.1.qualifier
+Bundle-Activator: org.eclipse.papyrus.uml.diagram.css.Activator
+Bundle-Vendor: Eclipse Modeling Project
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.infra.gmfdiag.css;bundle-version="0.10.1",
+ org.eclipse.uml2.uml;bundle-version="4.1.100",
+ org.eclipse.papyrus.uml.tools;bundle-version="0.10.1",
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.10.1",
+ org.eclipse.gmf.runtime.notation;bundle-version="1.7.0",
+ org.eclipse.e4.ui.css.core;bundle-version="0.10.100",
+ org.eclipse.core.databinding;bundle-version="1.4.1",
+ org.eclipse.papyrus.infra.tools;bundle-version="0.10.1"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/about.html b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/about.html
new file mode 100644
index 00000000000..209103075a7
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>November 14, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/build.properties b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/build.properties
new file mode 100644
index 00000000000..e3693a3b66e
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ about.html,\
+ plugin.xml
+src.includes = about.html
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/plugin.xml
new file mode 100644
index 00000000000..e61f1ec5fa2
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/plugin.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.infra.gmfdiag.css.domElementAdapter">
+ <factory
+ factory="org.eclipse.papyrus.uml.diagram.css.dom.GMFUMLElementProviderFactory"
+ order="50">
+ </factory>
+ </extension>
+
+</plugin>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/Activator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/Activator.java
new file mode 100644
index 00000000000..fe488c3b204
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/Activator.java
@@ -0,0 +1,58 @@
+package org.eclipse.papyrus.uml.diagram.css;
+
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.uml.diagram.css"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ public static LogHelper log;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ log = new LogHelper(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/dom/GMFUMLElementAdapter.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/dom/GMFUMLElementAdapter.java
new file mode 100644
index 00000000000..0ec27c67272
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/dom/GMFUMLElementAdapter.java
@@ -0,0 +1,135 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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.uml.diagram.css.dom;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.css.dom.GMFElementAdapter;
+import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
+import org.eclipse.papyrus.infra.tools.util.ListHelper;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Stereotype;
+
+/**
+ * DOM Element Adapter for UML Elements
+ *
+ * Supports applied stereotypes and stereotype properties
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class GMFUMLElementAdapter extends GMFElementAdapter {
+
+ public static final String APPLIED_STEREOTYPES_PROPERTY = "appliedStereotypes"; //$NON-NLS-1$
+
+ /**
+ * The CSS Separator for qualifiers, when we must use CSS ID
+ * When we can use CSS String, we use the standard UML "::" qualifier separator
+ *
+ * NOTE: Separator "__" does not work
+ */
+ public static final String QUALIFIER_SEPARATOR = "--"; //$NON-NLS-1$
+
+ static {
+ //UML
+ diagramNameMappings.put("CompositeStructure", "CompositeDiagram"); //$NON-NLS-1$
+ diagramNameMappings.put("Package", "PackageDiagram"); //$NON-NLS-1$
+ diagramNameMappings.put("PapyrusUMLActivityDiagram", "ActivityDiagram"); //$NON-NLS-1$
+ diagramNameMappings.put("PapyrusUMLClassDiagram", "ClassDiagram"); //$NON-NLS-1$
+ diagramNameMappings.put("PapyrusUMLCommunicationDiagram", "CommunicationDiagram"); //$NON-NLS-1$
+ diagramNameMappings.put("PapyrusUMLComponentDiagram", "ComponentDiagram"); //$NON-NLS-1$
+ diagramNameMappings.put("PapyrusUMLDeploymentDiagram", "DeploymentDiagram"); //$NON-NLS-1$
+ diagramNameMappings.put("PapyrusUMLProfileDiagram", "ProfileDiagram"); //$NON-NLS-1$
+ diagramNameMappings.put("PapyrusUMLSequenceDiagram", "SequenceDiagram"); //$NON-NLS-1$
+ diagramNameMappings.put("PapyrusUMLStateMachineDiagram", "StateMachineDiagram"); //$NON-NLS-1$
+ diagramNameMappings.put("UseCase", "UseCaseDiagram"); //$NON-NLS-1$
+ diagramNameMappings.put("PapyrusUMLTimingDiagram", "TimingDiagram"); //$NON-NLS-1$
+ diagramNameMappings.put("PapyrusUMLInteractionOverviewDiagram", "InteractionOverviewDiagram"); //$NON-NLS-1$
+
+ //SysML
+ diagramNameMappings.put("BlockDefinition", "BlockDiagram");
+ diagramNameMappings.put("InternalBlock", "InternalBlockDiagram");
+ diagramNameMappings.put("PapyrusSysMLRequirement", "RequirementDiagram");
+ diagramNameMappings.put("Parametric", "ParametricDiagram");
+ }
+
+ public GMFUMLElementAdapter(View view, ExtendedCSSEngine engine) {
+ super(view, engine);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * Applied Stereotypes are manipulated as DOM Attributes
+ */
+ @Override
+ protected String doGetAttribute(String attr) {
+ //Semantic properties
+ String parentValue = super.doGetAttribute(attr);
+ if(parentValue != null) {
+ return parentValue;
+ }
+
+ if(semanticElement instanceof Element) {
+ //Applied stereotypes
+ Element currentElement = (Element)semanticElement;
+ if(APPLIED_STEREOTYPES_PROPERTY.equals(attr)) {
+ List<String> appliedStereotypes = new LinkedList<String>();
+ for(Stereotype stereotype : currentElement.getAppliedStereotypes()) {
+ appliedStereotypes.add(stereotype.getName());
+ appliedStereotypes.add(stereotype.getQualifiedName());
+ }
+ if(!appliedStereotypes.isEmpty()) {
+ return ListHelper.deepToString(appliedStereotypes, " ");
+ }
+ }
+
+ for(EObject stereotypeApplication : currentElement.getStereotypeApplications()) {
+ EStructuralFeature feature = stereotypeApplication.eClass().getEStructuralFeature(attr);
+ if(feature != null) {
+ Object value = stereotypeApplication.eGet(feature);
+ if(value != null) {
+ return value.toString();
+ }
+ }
+ }
+
+ if(attr.contains(QUALIFIER_SEPARATOR)) {
+ List<String> qualifiers = ListHelper.asList(attr.split(QUALIFIER_SEPARATOR)); //Writable list
+
+ String propertyName = qualifiers.remove(qualifiers.size() - 1); //Last element is the property name
+ //Remaining strings can be used to build the Stereotype's qualified name
+
+ String stereotypeName = ListHelper.deepToString(qualifiers, "::");
+
+ Stereotype appliedStereotype = currentElement.getAppliedStereotype(stereotypeName);
+
+ if(appliedStereotype != null) {
+ EObject stereotypeApplication = currentElement.getStereotypeApplication(appliedStereotype);
+ EStructuralFeature feature = stereotypeApplication.eClass().getEStructuralFeature(propertyName);
+ if(feature != null) {
+ Object value = stereotypeApplication.eGet(feature);
+ if(value != null) {
+ return value.toString();
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/dom/GMFUMLElementProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/dom/GMFUMLElementProvider.java
new file mode 100644
index 00000000000..39d81f0bdeb
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/dom/GMFUMLElementProvider.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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.uml.diagram.css.dom;
+
+import org.eclipse.e4.ui.css.core.dom.IElementProvider;
+import org.eclipse.e4.ui.css.core.engine.CSSEngine;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
+import org.w3c.dom.Element;
+
+
+public class GMFUMLElementProvider implements IElementProvider {
+
+ public Element getElement(Object element, CSSEngine engine) {
+
+ if(!(element instanceof View)) {
+ throw new IllegalArgumentException("Unknown element : " + element);
+ }
+
+ if(!(engine instanceof ExtendedCSSEngine)) {
+ throw new IllegalArgumentException("Invalid CSS Engine : " + engine);
+ }
+
+ return new GMFUMLElementAdapter((View)element, (ExtendedCSSEngine)engine);
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/dom/GMFUMLElementProviderFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/dom/GMFUMLElementProviderFactory.java
new file mode 100644
index 00000000000..54dd7f1cd41
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/src/org/eclipse/papyrus/uml/diagram/css/dom/GMFUMLElementProviderFactory.java
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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.uml.diagram.css.dom;
+
+import org.eclipse.e4.ui.css.core.dom.IElementProvider;
+import org.eclipse.papyrus.infra.gmfdiag.css.engine.ICSSElementProviderFactory;
+import org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSDiagram;
+import org.eclipse.uml2.uml.Element;
+
+
+/**
+ * IElementProvider Factory for Diagrams related to UML Elements
+ *
+ * @author Camille Letavernier
+ *
+ */
+@SuppressWarnings("restriction")
+public class GMFUMLElementProviderFactory implements ICSSElementProviderFactory {
+
+ public boolean isProviderFor(CSSDiagram diagram) {
+ return diagram.getElement() instanceof Element; //Provider for UML Elements
+ }
+
+ public IElementProvider createProvider(CSSDiagram diagram) {
+ return new GMFUMLElementProvider();
+ }
+
+}

Back to the top