Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-03-02 15:55:35 +0000
committercletavernie2012-03-02 15:55:35 +0000
commit7d3e4604b1d0fb8b8108bc28dbf6eea84aa486e1 (patch)
treea0e391183264cba6ff81435fa989907885ab5309
parent701daeca6f87e427f00bbb873e900149b8d364c2 (diff)
downloadorg.eclipse.papyrus-7d3e4604b1d0fb8b8108bc28dbf6eea84aa486e1.tar.gz
org.eclipse.papyrus-7d3e4604b1d0fb8b8108bc28dbf6eea84aa486e1.tar.xz
org.eclipse.papyrus-7d3e4604b1d0fb8b8108bc28dbf6eea84aa486e1.zip
370797: [Theme] Papyrus should provide a support for CSS files on its diagrams
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370797
-rw-r--r--incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/.project6
-rw-r--r--incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/META-INF/MANIFEST.MF8
-rw-r--r--incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/Model/StyleSheets.facetSet12
-rw-r--r--incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/Model/StyleSheets.querySet12
-rw-r--r--incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/plugin.xml16
-rw-r--r--incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/src/org/eclipse/papyrus/infra/gmfdiag/css/model/queries/GetStyleSheets.java44
-rw-r--r--incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/src/org/eclipse/papyrus/infra/gmfdiag/css/model/queries/IsStyleSheetContainer.java20
7 files changed, 109 insertions, 9 deletions
diff --git a/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/.project b/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/.project
index 1c5d4a73430..e15ced466a0 100644
--- a/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/.project
+++ b/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/.project
@@ -20,9 +20,15 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.emf.facet.common.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.emf.facet.common.ProjectNature</nature>
</natures>
</projectDescription>
diff --git a/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/META-INF/MANIFEST.MF b/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/META-INF/MANIFEST.MF
index 104f7afb766..d8e090800a4 100644
--- a/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/META-INF/MANIFEST.MF
+++ b/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/META-INF/MANIFEST.MF
@@ -13,6 +13,10 @@ Export-Package: org.eclipse.papyrus.infra.gmfdiag.css.model,
org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.util
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.ecore;visibility:=reexport,
- org.eclipse.papyrus.infra.core.log;bundle-version="0.9.0",
- org.eclipse.ui;bundle-version="3.102.0"
+ org.eclipse.ui,
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.9",
+ org.eclipse.emf.facet.infra.query;bundle-version="0.1.1",
+ org.eclipse.emf.facet.infra.query.core;bundle-version="0.1.1",
+ org.eclipse.emf.facet.infra.facet;bundle-version="0.1.1",
+ org.eclipse.emf.facet.infra.facet.core;bundle-version="0.1.1"
Bundle-ActivationPolicy: lazy
diff --git a/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/Model/StyleSheets.facetSet b/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/Model/StyleSheets.facetSet
new file mode 100644
index 00000000000..ced4b7d93a1
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/Model/StyleSheets.facetSet
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="ASCII"?>
+<facet:FacetSet xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:facet="http://www.eclipse.org/EmfFacet/infra/facet/0.8.incubation" xmlns:query="http://www.eclipse.org/EmfFacet/infra/query/0.8.incubation" name="StyleSheets" nsURI="http://www.eclipse.org/papyrus/infra/gmfdiag/css/facets" nsPrefix="cssFacets">
+ <eClassifiers xsi:type="facet:Facet" name="StyleSheetsContainer" abstract="true">
+ <eSuperTypes href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ <eStructuralFeatures xsi:type="facet:FacetReference" name="styleSheets" lowerBound="1" upperBound="-1" volatile="true" unsettable="true">
+ <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ <valueQuery xsi:type="query:JavaModelQuery" href="StyleSheets.querySet#GetStyleSheets"/>
+ </eStructuralFeatures>
+ <conditionQuery xsi:type="query:JavaModelQuery" href="StyleSheets.querySet#IsStyleSheetContainer"/>
+ </eClassifiers>
+ <extendedPackage href="http://www.eclipse.org/emf/2002/Ecore#/"/>
+</facet:FacetSet>
diff --git a/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/Model/StyleSheets.querySet b/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/Model/StyleSheets.querySet
new file mode 100644
index 00000000000..fc130647332
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/Model/StyleSheets.querySet
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="ASCII"?>
+<query:ModelQuerySet xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:query="http://www.eclipse.org/EmfFacet/infra/query/0.8.incubation" name="StyleSheets" description="">
+ <associatedMetamodels href="http://www.eclipse.org/emf/2002/Ecore#/"/>
+ <queries xsi:type="query:JavaModelQuery" name="IsStyleSheetContainer" description="Tests whether the context is a StyleSheet container or not" lowerBound="1" implementationClassName="org.eclipse.papyrus.infra.gmfdiag.css.model.queries.IsStyleSheetContainer">
+ <returnType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
+ <scope href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ </queries>
+ <queries xsi:type="query:JavaModelQuery" name="GetStyleSheets" description="Returns all the stylesheets contained in the given stylesheet container" upperBound="-1" lowerBound="1" implementationClassName="org.eclipse.papyrus.infra.gmfdiag.css.model.queries.GetStyleSheets">
+ <returnType xsi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ <scope href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ </queries>
+</query:ModelQuerySet>
diff --git a/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/plugin.xml b/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/plugin.xml
index 05d78e59164..4d5f832c6ea 100644
--- a/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/plugin.xml
+++ b/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/plugin.xml
@@ -1,16 +1,18 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse version="3.0"?>
-<!--
+<!--
-->
-
<plugin>
<extension point="org.eclipse.emf.ecore.generated_package">
- <package
- uri="http://www.eclipse.org/papyrus/infra/gmfdiag/css"
- class="org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StylesheetsPackage"
- genModel="Model/StyleSheets.genmodel"/>
+ <package class="org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StylesheetsPackage" genModel="Model/StyleSheets.genmodel" uri="http://www.eclipse.org/papyrus/infra/gmfdiag/css"/>
</extension>
+ <extension point="org.eclipse.emf.facet.infra.facet.registration">
+ <facetset file="Model/StyleSheets.facetSet"/>
+ </extension>
+ <extension point="org.eclipse.emf.facet.infra.query.registration">
+ <modelqueryset file="Model/StyleSheets.querySet"/>
+ </extension>
</plugin>
diff --git a/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/src/org/eclipse/papyrus/infra/gmfdiag/css/model/queries/GetStyleSheets.java b/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/src/org/eclipse/papyrus/infra/gmfdiag/css/model/queries/GetStyleSheets.java
new file mode 100644
index 00000000000..ffb60b5ee97
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/src/org/eclipse/papyrus/infra/gmfdiag/css/model/queries/GetStyleSheets.java
@@ -0,0 +1,44 @@
+package org.eclipse.papyrus.infra.gmfdiag.css.model.queries;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException;
+import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery;
+import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList;
+import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheet;
+
+public class GetStyleSheets implements
+ IJavaModelQuery<EObject, Collection<EObject>> {
+
+ public Collection<EObject> evaluate(EObject context,
+ ParameterValueList args) throws ModelQueryExecutionException {
+ ResourceSet resourceSet = context.eResource().getResourceSet();
+ if (resourceSet == null) {
+ return findStyleSheets(context.eResource());
+ }
+
+ List<EObject> result = new LinkedList<EObject>();
+ for (Resource resource : context.eResource().getResourceSet()
+ .getResources()) {
+ result.addAll(findStyleSheets(resource));
+ }
+
+ return result;
+ }
+
+ private Collection<EObject> findStyleSheets(Resource eResource) {
+ List<EObject> result = new LinkedList<EObject>();
+ for (EObject rootElement : eResource.getContents()){
+ if (rootElement instanceof StyleSheet){
+ result.add(rootElement);
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/src/org/eclipse/papyrus/infra/gmfdiag/css/model/queries/IsStyleSheetContainer.java b/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/src/org/eclipse/papyrus/infra/gmfdiag/css/model/queries/IsStyleSheetContainer.java
new file mode 100644
index 00000000000..854d06c3e98
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.infra.gmfdiag.css.model/src/org/eclipse/papyrus/infra/gmfdiag/css/model/queries/IsStyleSheetContainer.java
@@ -0,0 +1,20 @@
+package org.eclipse.papyrus.infra.gmfdiag.css.model.queries;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException;
+import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery;
+import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList;
+
+public class IsStyleSheetContainer implements IJavaModelQuery<EObject, Boolean> {
+
+ public Boolean evaluate(EObject context, ParameterValueList args)
+ throws ModelQueryExecutionException {
+ if (context.eResource() == null){
+ return false;
+ }
+
+ //Only the first root element is a StyleSheet container
+ return context.eResource().getContents().get(0) == context;
+ }
+
+}

Back to the top