Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2015-11-10 04:53:32 -0500
committerCamille Letavernier2015-11-10 04:55:33 -0500
commit17cef9291253fb9cba42bd7927661e71ca66e7d7 (patch)
treed7e068f0e2e77499af082450dd9695c91dc509ab
parent723215e77aaeda9e8acf6b6ca588db7dbd235a4c (diff)
downloadorg.eclipse.papyrus-17cef9291253fb9cba42bd7927661e71ca66e7d7.tar.gz
org.eclipse.papyrus-17cef9291253fb9cba42bd7927661e71ca66e7d7.tar.xz
org.eclipse.papyrus-17cef9291253fb9cba42bd7927661e71ca66e7d7.zip
478789: Papyrus Notation Model is used for non Papyrus Editors
https://bugs.eclipse.org/bugs/show_bug.cgi?id=478789 - Do not compute NamedStyles if the CSS Support is not enabled on the current resource - Add test Change-Id: Icf761fe2ec6885c11b102516e7a819e3ec3d4b7b Signed-off-by: Camille Letavernier <camille.letavernier@cea.fr>
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/style/impl/CSSViewDelegate.java5
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/build.properties3
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/plugin.xml18
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/namedStylesTest/model.di2
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/namedStylesTest/model.notation40
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/namedStylesTest/model.uml4
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/stylesheets/namedStyleTest.css3
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/AllTests.java3
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSNamedStyleTest.java80
10 files changed, 156 insertions, 4 deletions
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/style/impl/CSSViewDelegate.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/style/impl/CSSViewDelegate.java
index 6d25467378b..cab251a50a3 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/style/impl/CSSViewDelegate.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/style/impl/CSSViewDelegate.java
@@ -30,6 +30,7 @@ import org.eclipse.papyrus.infra.gmfdiag.css.Activator;
import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
import org.eclipse.papyrus.infra.gmfdiag.css.helper.ParserHelper;
import org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSStyles;
+import org.eclipse.papyrus.infra.gmfdiag.css.resource.CSSNotationResource;
import org.eclipse.papyrus.infra.gmfdiag.css.style.CSSView;
import org.w3c.dom.css.CSSValue;
@@ -59,7 +60,9 @@ public class CSSViewDelegate implements CSSView {
@Override
public NamedStyle getCSSNamedStyle(EClass eClass, String name) {
-
+ if (!CSSNotationResource.isCSSEnabled(view.eResource())) {
+ return null;
+ }
if (!NotationPackage.eINSTANCE.getNamedStyle().isSuperTypeOf(eClass)) {
return null;
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/META-INF/MANIFEST.MF
index 09be3b40a56..4e540186d4c 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/META-INF/MANIFEST.MF
@@ -28,5 +28,5 @@ Bundle-Version: 1.2.0.qualifier
Bundle-Name: CSS Tests
Bundle-ManifestVersion: 2
Bundle-Activator: org.eclipse.papyrus.infra.gmfdiag.css.tests.Activator
-Bundle-SymbolicName: org.eclipse.papyrus.infra.gmfdiag.css.tests
+Bundle-SymbolicName: org.eclipse.papyrus.infra.gmfdiag.css.tests;singleton:=true
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/build.properties b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/build.properties
index 130df98d220..c89f5eb10cb 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/build.properties
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/build.properties
@@ -3,5 +3,6 @@ output.. = bin/
bin.includes = META-INF/,\
.,\
resources/,\
- about.html
+ about.html,\
+ plugin.xml
src.includes = about.html
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/plugin.xml b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/plugin.xml
new file mode 100644
index 00000000000..d53c36f737c
--- /dev/null
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/plugin.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.infra.gmfdiag.css.theme">
+ <themeContribution
+ id="org.eclipse.papyrus.infra.gmfdiag.css.tests.namedStylesTest">
+ <stylesheet
+ stylesheetPath="resources/stylesheets/namedStyleTest.css">
+ </stylesheet>
+ </themeContribution>
+ <themeDefinition
+ id="org.eclipse.papyrus.infra.gmfdiag.css.tests.namedStylesTest"
+ label="NamedStyles Test">
+ </themeDefinition>
+ </extension>
+
+</plugin>
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/namedStylesTest/model.di b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/namedStylesTest/model.di
new file mode 100644
index 00000000000..8634d4c00e0
--- /dev/null
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/namedStylesTest/model.di
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/namedStylesTest/model.notation b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/namedStylesTest/model.notation
new file mode 100644
index 00000000000..e2afbef18fd
--- /dev/null
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/namedStylesTest/model.notation
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:css="http://www.eclipse.org/papyrus/infra/gmfdiag/css" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/papyrus/infra/viewpoints/policy/style" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML">
+ <notation:Diagram xmi:id="_w2EO8IeLEeWWuLbIMcUiMw" type="PapyrusUMLClassDiagram" name="Class Diagram" measurementUnit="Pixel">
+ <children xmi:type="notation:Shape" xmi:id="_xoz6gIeLEeWWuLbIMcUiMw" type="2008">
+ <children xmi:type="notation:DecorationNode" xmi:id="_xoz6goeLEeWWuLbIMcUiMw" type="5029"/>
+ <children xmi:type="notation:DecorationNode" xmi:id="_xoz6g4eLEeWWuLbIMcUiMw" type="8510">
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_xoz6hIeLEeWWuLbIMcUiMw" y="5"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_xoz6hYeLEeWWuLbIMcUiMw" type="7017">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_xoz6hoeLEeWWuLbIMcUiMw"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_xoz6h4eLEeWWuLbIMcUiMw"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_xoz6iIeLEeWWuLbIMcUiMw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_xoz6iYeLEeWWuLbIMcUiMw"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_xoz6ioeLEeWWuLbIMcUiMw" type="7018">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_xoz6i4eLEeWWuLbIMcUiMw"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_xoz6jIeLEeWWuLbIMcUiMw"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_xoz6jYeLEeWWuLbIMcUiMw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_xoz6joeLEeWWuLbIMcUiMw"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_xoz6j4eLEeWWuLbIMcUiMw" type="7019">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_xoz6kIeLEeWWuLbIMcUiMw"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_xoz6kYeLEeWWuLbIMcUiMw"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_xoz6koeLEeWWuLbIMcUiMw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_xoz6k4eLEeWWuLbIMcUiMw"/>
+ </children>
+ <styles xmi:type="notation:BooleanValueStyle" xmi:id="_16dV4IeLEeWWuLbIMcUiMw" name="shapeVisibility" booleanValue="true"/>
+ <element xmi:type="uml:Class" href="model.uml#_xoqJgIeLEeWWuLbIMcUiMw"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_xoz6gYeLEeWWuLbIMcUiMw" x="263" y="235"/>
+ </children>
+ <styles xmi:type="notation:StringValueStyle" xmi:id="_w2EO8YeLEeWWuLbIMcUiMw" name="diagram_compatibility_version" stringValue="1.1.0"/>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_w2EO8oeLEeWWuLbIMcUiMw"/>
+ <styles xmi:type="style:PapyrusViewStyle" xmi:id="_w2EO84eLEeWWuLbIMcUiMw">
+ <owner xmi:type="uml:Model" href="model.uml#_w0uLIIeLEeWWuLbIMcUiMw"/>
+ </styles>
+ <styles xmi:type="notation:EObjectListValueStyle" xmi:id="_R4g8MIeMEeWNLI4pV5eoIA" name="css_stylesheets" eObjectListValue="_jv3Q4IePEeWNLI4pV5eoIA"/>
+ <element xmi:type="uml:Model" href="model.uml#_w0uLIIeLEeWWuLbIMcUiMw"/>
+ </notation:Diagram>
+ <css:StyleSheetReference xmi:id="_jv3Q4IePEeWNLI4pV5eoIA" path="platform:/plugin/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/stylesheets/namedStyleTest.css"/>
+</xmi:XMI>
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/namedStylesTest/model.uml b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/namedStylesTest/model.uml
new file mode 100644
index 00000000000..9cf91a55465
--- /dev/null
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/model/namedStylesTest/model.uml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_w0uLIIeLEeWWuLbIMcUiMw" name="RootElement">
+ <packagedElement xmi:type="uml:Class" xmi:id="_xoqJgIeLEeWWuLbIMcUiMw" name="Class1"/>
+</uml:Model>
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/stylesheets/namedStyleTest.css b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/stylesheets/namedStyleTest.css
new file mode 100644
index 00000000000..c0eb6ec58d1
--- /dev/null
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/resources/stylesheets/namedStyleTest.css
@@ -0,0 +1,3 @@
+Class {
+ testNamedStyle: 18;
+}
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/AllTests.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/AllTests.java
index 05c7f2978bc..b1b4446cf38 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/AllTests.java
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/AllTests.java
@@ -12,8 +12,8 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css.tests.tests;
-import org.junit.runner.RunWith;
import org.eclipse.papyrus.junit.framework.classification.ClassificationSuite;
+import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@@ -22,6 +22,7 @@ import org.junit.runners.Suite.SuiteClasses;
CSSClassProviderTest.class,
CSSStylesheetTest.class,
CSSModelStylesheetTest.class,
+ CSSNamedStyleTest.class,
CSSCompartmentsTests.class,
CSSSupportTest.class,
CSSProjectStylesheetsTest.class,
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSNamedStyleTest.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSNamedStyleTest.java
new file mode 100644
index 00000000000..9efd74ba6f9
--- /dev/null
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.css.tests/src/org/eclipse/papyrus/infra/gmfdiag/css/tests/tests/CSSNamedStyleTest.java
@@ -0,0 +1,80 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.gmfdiag.css.tests.tests;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.IntValueStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.Shape;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.gmfdiag.css.engine.WorkspaceCSSEngine;
+import org.eclipse.papyrus.infra.gmfdiag.css.preferences.ThemePreferences;
+import org.eclipse.papyrus.infra.gmfdiag.css.tests.Activator;
+import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
+import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * @author Camille Letavernier
+ *
+ */
+public class CSSNamedStyleTest extends AbstractPapyrusTest {
+
+ @Rule
+ public final HouseKeeper houseKeeper = new HouseKeeper();
+
+ protected Diagram diagram;
+
+ private String previousTheme;
+
+ @Before
+ public void init() throws Exception {
+ IPreferenceStore cssThemePreferences = org.eclipse.papyrus.infra.gmfdiag.css.Activator.getDefault().getPreferenceStore();
+ previousTheme = cssThemePreferences.getString(ThemePreferences.CURRENT_THEME);
+ cssThemePreferences.setValue(ThemePreferences.CURRENT_THEME, "org.eclipse.papyrus.infra.gmfdiag.css.tests.namedStylesTest");
+ WorkspaceCSSEngine.instance.reset();
+
+ ResourceSet resourceSet = houseKeeper.createResourceSet();
+
+ URI modelURI = URI.createPlatformPluginURI(Activator.PLUGIN_ID + "/resources/model/namedStylesTest/model.notation", true);
+
+ diagram = (Diagram) EMFHelper.loadEMFModel(resourceSet, modelURI);
+ Assert.assertNotNull("Cannot find the model", diagram);
+ }
+
+ @After
+ public void dispose() throws Exception {
+ IPreferenceStore cssThemePreferences = org.eclipse.papyrus.infra.gmfdiag.css.Activator.getDefault().getPreferenceStore();
+ cssThemePreferences.setValue(ThemePreferences.CURRENT_THEME, previousTheme);
+ WorkspaceCSSEngine.instance.reset();
+ }
+
+ // Bug 478789: CSS NamedStyles are returned even if the CSS Support is not enabled
+ // Stylesheet is applied via a Test Theme
+ @Test
+ public void testStylesDisabled() {
+ Shape class1Shape = (Shape) diagram.getChildren().get(0);
+ IntValueStyle intStyle = (IntValueStyle) class1Shape.getNamedStyle(NotationPackage.eINSTANCE.getIntValueStyle(), "testNamedStyle");
+ Assert.assertNull("Dynamic IntValueStyle should not be returned, since CSS are not enabled", intStyle);
+ }
+
+}
+

Back to the top