diff options
author | Camille Letavernier | 2017-07-11 13:30:37 +0000 |
---|---|---|
committer | Camille Letavernier | 2017-07-24 11:52:04 +0000 |
commit | b3a6ce9d8d417cbfb888f01ca5333491438d4ccf (patch) | |
tree | 92c5dbb5be40b7dc909c39cdcf03691f621b1cee /plugins | |
parent | 52f22f02a375ad03cd1c0b81dd1de564ea2b1dfc (diff) | |
download | org.eclipse.papyrus-b3a6ce9d8d417cbfb888f01ca5333491438d4ccf.tar.gz org.eclipse.papyrus-b3a6ce9d8d417cbfb888f01ca5333491438d4ccf.tar.xz org.eclipse.papyrus-b3a6ce9d8d417cbfb888f01ca5333491438d4ccf.zip |
Bug 519412: Viewpoint Stylesheets have a very high priority
https://bugs.eclipse.org/bugs/show_bug.cgi?id=519412
Change-Id: I191d31e445fcc1736fe3b2f231a47886fa06a239
Signed-off-by: Camille Letavernier <cletavernier@eclipsesource.com>
(cherry picked from commit 01e46feb1c25062950a6ad2d8426714ee474eb2c)
Diffstat (limited to 'plugins')
5 files changed, 140 insertions, 37 deletions
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/META-INF/MANIFEST.MF index 1bc8d58e6bc..0c12103f9d3 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/META-INF/MANIFEST.MF +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/META-INF/MANIFEST.MF @@ -26,7 +26,7 @@ Require-Bundle: org.eclipse.e4.ui.css.core;bundle-version="[0.11.0,1.0.0)", org.eclipse.papyrus.infra.gmfdiag.representation;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy -Bundle-Version: 2.1.0.qualifier +Bundle-Version: 2.2.0.qualifier Bundle-Localization: plugin Bundle-Name: %pluginName Bundle-Activator: org.eclipse.papyrus.infra.gmfdiag.css.Activator diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/pom.xml b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/pom.xml index dad34a5ce59..ad4e497a33a 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/pom.xml +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/pom.xml @@ -7,6 +7,6 @@ <version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.infra.gmfdiag.css</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>2.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
\ No newline at end of file diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ExtendedCSSEngine.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ExtendedCSSEngine.java index c017eda985d..f342b1f58c8 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ExtendedCSSEngine.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ExtendedCSSEngine.java @@ -1,5 +1,5 @@ /*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
+ * Copyright (c) 2012, 2017 CEA LIST, EclipseSource and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@ *
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Camille Letavernier (EclipseSource) - Bug 519412
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css.engine;
@@ -107,10 +108,48 @@ public interface ExtendedCSSEngine extends LazyCSSEngine, CSSEngine { */
public CascadeScope getCascadeScope(StyleSheet stylesheet);
+ /**
+ * Scope of the CSSEngine, defining its priority level. Based on the W3C levels, with Papyrus-specific additions.
+ * Priority is: {@link #USER_AGENT} < {@link #USER} < {@link #VIEWPOINT} < {@link #AUTHOR}.
+ * Rules defined in a lower priority scope engine will always be overridden by rules from a higher priority scope engine.
+ * If the scope is equal, then the priority is based on the CSS Rule selector complexity, as defined by the W3C.
+ */
public enum CascadeScope {
+ /**
+ * The User Agent level, defining tool-specific rules (Mostly default values).
+ * This is the lowest priority level.
+ */
USER_AGENT(0),
+
+ /**
+ * The User level, defining general user-specific rules. This is used for e.g. Workspace-level Theme.
+ */
USER(1),
- AUTHOR(2);
+
+ /**
+ * The Viewpoint level, defining context-specific rules.
+ * This is used for Architecture Context/Viewpoint customization. The priority is higher
+ * than {@link #USER}, but lower than {@link #AUTHOR}
+ *
+ * @since 2.2
+ */
+ //Added in Bug 519412: Viewpoint Stylesheets have a very high priority
+ VIEWPOINT(2),
+
+ /**
+ * Project-, Model- or Diagram-specific rules. These rules have the highest priority
+ */
+ AUTHOR(3);
+
+ /**
+ * The integer priority level of this scope. Lower value means lower priority
+ *
+ * @return
+ * The priority
+ */
+ public int getOrder() {
+ return order;
+ }
private int order;
@@ -118,10 +157,6 @@ public interface ExtendedCSSEngine extends LazyCSSEngine, CSSEngine { this.order = order;
}
- public int getOrder() {
- return order;
- }
-
}
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ViewpointCSSEngine.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ViewpointCSSEngine.java new file mode 100644 index 00000000000..f6fb131bfa3 --- /dev/null +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/engine/ViewpointCSSEngine.java @@ -0,0 +1,88 @@ +/***************************************************************************** + * Copyright (c) 2017 EclipseSource 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: + * Camille Letavernier (EclipseSource) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.css.engine; + +import org.eclipse.papyrus.infra.architecture.representation.PapyrusRepresentationKind; +import org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSDiagram; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheet; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheetReference; +import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StylesheetsFactory; +import org.eclipse.papyrus.infra.gmfdiag.representation.PapyrusDiagram; +import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype; + +/** + * CSSEngine for stylesheets contributed via the architecture context ({@link PapyrusDiagram#getCustomStyle()}). + * + * Although it is manipulating the Diagram, it has a slightly lower priority than the {@link DiagramCSSEngine}, + * which contains user-defined stylesheets. + * + * @since 2.2 + */ +//Bug 519412: Viewpoint Stylesheets have a very high priority +public class ViewpointCSSEngine extends ExtendedCSSEngineImpl { + + private CSSDiagram diagram; + + /** + * Constructor. + * + * @param parent + * @param diagram + */ + public ViewpointCSSEngine(ExtendedCSSEngine parent, CSSDiagram diagram) { + super(parent); + this.diagram = diagram; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.css.engine.DiagramCSSEngine#reloadStyleSheets() + * + */ + @Override + protected void reloadStyleSheets() { + styleSheets.clear(); + StyleSheet css = getViewpointDefinedStylesheet(); + if (css != null) { + styleSheets.add(css); + } + } + + private StyleSheet getViewpointDefinedStylesheet() { + ViewPrototype proto = ViewPrototype.get(diagram); + if (proto == null) { + return null; + } + PapyrusRepresentationKind conf = proto.getRepresentationKind(); + if (conf == null || !(conf instanceof PapyrusDiagram)) { + return null; + } + String path = ((PapyrusDiagram) conf).getCustomStyle(); + if (path == null || path.isEmpty()) { + return null; + } + StyleSheetReference ref = StylesheetsFactory.eINSTANCE.createStyleSheetReference(); + ref.setPath(path); + return ref; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine#getCascadeScope() + * + * @return + */ + @Override + public CascadeScope getCascadeScope() { + return CascadeScope.VIEWPOINT; + } + +} diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSDiagramImpl.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSDiagramImpl.java index 060d78c96ad..7c188da46c6 100644 --- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSDiagramImpl.java +++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSDiagramImpl.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2012, 2016 CEA LIST, Christian W. Damus, and others. + * Copyright (c) 2012, 2017 CEA LIST, Christian W. Damus, and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -10,6 +10,7 @@ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation * Christian W. Damus (CEA) - support adapter instead of custom resource impl for CSS (CDO) * Christian W. Damus - bugs 433206, 464443, 436665 + * Camille Letavernier (EclipseSource) - Bug 519412 * *****************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.css.notation; @@ -24,17 +25,13 @@ import org.eclipse.gmf.runtime.notation.NamedStyle; import org.eclipse.gmf.runtime.notation.NotationPackage; import org.eclipse.gmf.runtime.notation.Style; import org.eclipse.gmf.runtime.notation.impl.DiagramImpl; -import org.eclipse.papyrus.infra.architecture.representation.PapyrusRepresentationKind; import org.eclipse.papyrus.infra.gmfdiag.css.engine.DiagramCSSEngine; import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine; +import org.eclipse.papyrus.infra.gmfdiag.css.engine.ViewpointCSSEngine; import org.eclipse.papyrus.infra.gmfdiag.css.resource.CSSNotationResource; import org.eclipse.papyrus.infra.gmfdiag.css.style.CSSView; import org.eclipse.papyrus.infra.gmfdiag.css.style.impl.CSSViewDelegate; import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheet; -import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StyleSheetReference; -import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.StylesheetsFactory; -import org.eclipse.papyrus.infra.gmfdiag.representation.PapyrusDiagram; -import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype; /** * Default implementation for CSSDiagram @@ -45,6 +42,7 @@ import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype; public class CSSDiagramImpl extends DiagramImpl implements CSSDiagram, CSSView.Internal { protected ExtendedCSSEngine engine; + private ExtendedCSSEngine viewpointEngine; private CSSView cssView; @@ -52,7 +50,8 @@ public class CSSDiagramImpl extends DiagramImpl implements CSSDiagram, CSSView.I public ExtendedCSSEngine getEngine() { if (engine == null) { ExtendedCSSEngine modelEngine = getModelEngine(); - engine = new DiagramCSSEngine(modelEngine, this); + viewpointEngine = new ViewpointCSSEngine(modelEngine, this); + engine = new DiagramCSSEngine(viewpointEngine, this); } return engine; } @@ -64,6 +63,8 @@ public class CSSDiagramImpl extends DiagramImpl implements CSSDiagram, CSSView.I engine.dispose(); engine = null; + viewpointEngine.dispose(); + viewpointEngine = null; // And walk our contents to make all views forget their engine eAllContents().forEachRemaining(o -> { @@ -116,31 +117,10 @@ public class CSSDiagramImpl extends DiagramImpl implements CSSDiagram, CSSView.I } } - StyleSheet s = getViewpointDefinedStylesheet(); - if (s != null) { - result.add(s); - } - return result; } - private StyleSheet getViewpointDefinedStylesheet() { - ViewPrototype proto = ViewPrototype.get(this); - if (proto == null) { - return null; - } - PapyrusRepresentationKind conf = proto.getRepresentationKind(); - if (conf == null || !(conf instanceof PapyrusDiagram)) { - return null; - } - String path = ((PapyrusDiagram) conf).getCustomStyle(); - if (path == null || path.isEmpty()) { - return null; - } - StyleSheetReference ref = StylesheetsFactory.eINSTANCE.createStyleSheetReference(); - ref.setPath(path); - return ref; - } + protected CSSView getCSSView() { if (cssView == null) { |