Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2013-10-24 11:44:39 -0400
committerCamille Letavernier2013-10-24 12:00:55 -0400
commit3cb9670b51159491d948471560d972ed946e17c6 (patch)
tree0813f624577fee8dcc54764188fd2e13f03c41dc /plugins
parent417b9f1f20ad8bbbad59ca19dcd113db87ad374a (diff)
downloadorg.eclipse.papyrus-3cb9670b51159491d948471560d972ed946e17c6.tar.gz
org.eclipse.papyrus-3cb9670b51159491d948471560d972ed946e17c6.tar.xz
org.eclipse.papyrus-3cb9670b51159491d948471560d972ed946e17c6.zip
420297: [CSS - Properties] CSS Engine shall support custom properties
https://bugs.eclipse.org/bugs/show_bug.cgi?id=420297
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/CSSBasicCompartmentImpl.java20
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/CSSConnectorImpl.java22
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/CSSShapeImpl.java23
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/style/CSSView.java22
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/style/impl/CSSViewDelegate.java89
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSStyles.java16
7 files changed, 193 insertions, 2 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 627c2fedd06..7a3b970be55 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
@@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.infra.gmfdiag.css.model;bundle-version="0.10.1",
org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="0.10.1",
org.eclipse.papyrus.infra.core;bundle-version="0.10.1",
- org.eclipse.papyrus.infra.services.markerlistener;bundle-version="0.10.1"
+ org.eclipse.papyrus.infra.services.markerlistener;bundle-version="0.10.1",
+ org.eclipse.gmf.runtime.notation.edit;bundle-version="1.7.0"
Export-Package: org.eclipse.papyrus.infra.gmfdiag.css,
org.eclipse.papyrus.infra.gmfdiag.css.converters,
org.eclipse.papyrus.infra.gmfdiag.css.dom,
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/CSSBasicCompartmentImpl.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/CSSBasicCompartmentImpl.java
index 06c9ca62904..6e7618a238a 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/CSSBasicCompartmentImpl.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/CSSBasicCompartmentImpl.java
@@ -11,7 +11,9 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.notation.NamedStyle;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.impl.BasicCompartmentImpl;
import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
@@ -139,5 +141,23 @@ public class CSSBasicCompartmentImpl extends BasicCompartmentImpl implements CSS
ForceValueHelper.unsetValue(this, feature);
}
+ //////////////////////////////////
+ // Implements the getNamedStyle //
+ //////////////////////////////////
+
+ @Override
+ public NamedStyle getNamedStyle(EClass eClass, String name) {
+ return getCSSNamedStyle(eClass, name);
+ }
+
+ public NamedStyle getCSSNamedStyle(EClass eClass, String name) {
+ NamedStyle userStyle = super.getNamedStyle(eClass, name);
+ if(userStyle != null) {
+ return userStyle;
+ }
+
+ return getCSSView().getCSSNamedStyle(eClass, name);
+ }
+
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/CSSConnectorImpl.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/CSSConnectorImpl.java
index c885b2bf640..4b996849704 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/CSSConnectorImpl.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/CSSConnectorImpl.java
@@ -11,9 +11,11 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.gmf.runtime.notation.JumpLinkStatus;
import org.eclipse.gmf.runtime.notation.JumpLinkType;
+import org.eclipse.gmf.runtime.notation.NamedStyle;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.Routing;
import org.eclipse.gmf.runtime.notation.Smoothness;
@@ -26,7 +28,7 @@ import org.eclipse.papyrus.infra.gmfdiag.css.style.CSSView;
import org.eclipse.papyrus.infra.gmfdiag.css.style.impl.CSSConnectorStyleDelegate;
import org.eclipse.papyrus.infra.gmfdiag.css.style.impl.CSSViewDelegate;
-public class CSSConnectorImpl extends ConnectorImpl implements CSSConnectorStyle {
+public class CSSConnectorImpl extends ConnectorImpl implements CSSConnectorStyle, CSSView {
protected ExtendedCSSEngine engine;
@@ -359,5 +361,23 @@ public class CSSConnectorImpl extends ConnectorImpl implements CSSConnectorStyle
ForceValueHelper.unsetValue(this, feature);
}
+ //////////////////////////////////
+ // Implements the getNamedStyle //
+ //////////////////////////////////
+
+ @Override
+ public NamedStyle getNamedStyle(EClass eClass, String name) {
+ return getCSSNamedStyle(eClass, name);
+ }
+
+ public NamedStyle getCSSNamedStyle(EClass eClass, String name) {
+ NamedStyle userStyle = super.getNamedStyle(eClass, name);
+ if(userStyle != null) {
+ return userStyle;
+ }
+
+ return getCSSView().getCSSNamedStyle(eClass, name);
+ }
+
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/CSSShapeImpl.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/CSSShapeImpl.java
index 93b0491d429..377aabacc23 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/CSSShapeImpl.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/CSSShapeImpl.java
@@ -11,7 +11,9 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.notation.NamedStyle;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.impl.ShapeImpl;
import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
@@ -462,6 +464,10 @@ public class CSSShapeImpl extends ShapeImpl implements CSSShapeStyle, CustomStyl
}
}
+ ///////////////////////////////////
+ // Implements the custom styles //
+ ///////////////////////////////////
+
public boolean showElementIcon() {
return getCustomStyle().showElementIcon();
}
@@ -474,5 +480,22 @@ public class CSSShapeImpl extends ShapeImpl implements CSSShapeStyle, CustomStyl
return getCustomStyle().showShadow();
}
+ //////////////////////////////////
+ // Implements the getNamedStyle //
+ //////////////////////////////////
+
+ @Override
+ public NamedStyle getNamedStyle(EClass eClass, String name) {
+ return getCSSNamedStyle(eClass, name);
+ }
+
+ public NamedStyle getCSSNamedStyle(EClass eClass, String name) {
+ NamedStyle userStyle = super.getNamedStyle(eClass, name);
+ if(userStyle != null) {
+ return userStyle;
+ }
+
+ return getCSSView().getCSSNamedStyle(eClass, name);
+ }
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/style/CSSView.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/style/CSSView.java
index 623fd952284..7168abbbbd6 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/style/CSSView.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src-gen/org/eclipse/papyrus/infra/gmfdiag/css/style/CSSView.java
@@ -1,7 +1,29 @@
package org.eclipse.papyrus.infra.gmfdiag.css.style;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.gmf.runtime.notation.NamedStyle;
+import org.eclipse.gmf.runtime.notation.View;
+
public interface CSSView {
+ /**
+ * CSS Implementation of the isVisible() method
+ *
+ * @return
+ *
+ * @see View#isVisible()
+ */
public boolean isCSSVisible();
+
+ /**
+ * CSS Implementation of the getNamedStyle() method
+ *
+ * @param eClass
+ * @param name
+ * @return
+ *
+ * @see View#getNamedStyle(EClass, String)
+ */
+ public NamedStyle getCSSNamedStyle(EClass eClass, String name);
}
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 c32d507df81..9474d2fc45e 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
@@ -1,8 +1,17 @@
package org.eclipse.papyrus.infra.gmfdiag.css.style.impl;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.gmf.runtime.notation.BooleanValueStyle;
+import org.eclipse.gmf.runtime.notation.DoubleValueStyle;
+import org.eclipse.gmf.runtime.notation.IntValueStyle;
+import org.eclipse.gmf.runtime.notation.NamedStyle;
+import org.eclipse.gmf.runtime.notation.NotationFactory;
import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.StringValueStyle;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.css.Activator;
import org.eclipse.papyrus.infra.gmfdiag.css.engine.ExtendedCSSEngine;
+import org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSStyles;
import org.eclipse.papyrus.infra.gmfdiag.css.style.CSSView;
import org.w3c.dom.css.CSSValue;
@@ -27,4 +36,84 @@ public class CSSViewDelegate implements CSSView {
return (Boolean)engine.convert(cssValue, Boolean.class, null);
}
+ private boolean lookupStyle = false;
+
+ public NamedStyle getCSSNamedStyle(EClass eClass, String name) {
+
+ if(!NotationPackage.eINSTANCE.getNamedStyle().isSuperTypeOf(eClass)) {
+ return null;
+ }
+
+ ///////////////////////////////////////////////
+ //This method may call getNamedStyle() to retrieve the applied CSS Styles. Prevent overflow
+ if(CSSStyles.RESERVED_KEYWORDS.contains(name)) {
+ return null;
+ }
+
+ CSSValue cssValue;
+ synchronized(this) {
+ if(lookupStyle) {
+ return null;
+ }
+
+ try {
+ lookupStyle = true;
+ cssValue = engine.retrievePropertyValue(view, name);
+ if(cssValue == null) {
+ return null;
+ }
+ } finally {
+ lookupStyle = false;
+ }
+ }
+ ///////////////////////////////////////////////
+
+ try {
+ switch(eClass.getClassifierID()) {
+ case NotationPackage.BOOLEAN_VALUE_STYLE:
+
+ Boolean booleanValue = (Boolean)engine.convert(cssValue, Boolean.class, null);
+ BooleanValueStyle booleanStyle = NotationFactory.eINSTANCE.createBooleanValueStyle();
+
+ booleanStyle.setBooleanValue(booleanValue);
+ booleanStyle.setName(name);
+
+ return booleanStyle;
+
+ case NotationPackage.STRING_VALUE_STYLE:
+
+ String stringValue = (String)engine.convert(cssValue, String.class, null);
+ StringValueStyle stringStyle = NotationFactory.eINSTANCE.createStringValueStyle();
+
+ stringStyle.setName(name);
+ stringStyle.setStringValue(stringValue);
+
+ return stringStyle;
+
+ case NotationPackage.INT_VALUE_STYLE:
+
+ Integer intValue = (Integer)engine.convert(cssValue, Integer.class, null);
+ IntValueStyle intStyle = NotationFactory.eINSTANCE.createIntValueStyle();
+
+ intStyle.setName(name);
+ intStyle.setIntValue(intValue);
+
+ return intStyle;
+ case NotationPackage.DOUBLE_VALUE_STYLE:
+
+ Double doubleValue = (Double)engine.convert(cssValue, Double.class, null);
+ DoubleValueStyle doubleStyle = NotationFactory.eINSTANCE.createDoubleValueStyle();
+
+ doubleStyle.setName(name);
+ doubleStyle.setDoubleValue(doubleValue);
+
+ return doubleStyle;
+ default:
+ return null;
+ }
+ } catch (Exception ex) {
+ Activator.log.error(ex);
+ return null;
+ }
+ }
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSStyles.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSStyles.java
index 57beb64bceb..a82d04faac4 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSStyles.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/notation/CSSStyles.java
@@ -11,6 +11,10 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css.notation;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* Constants for the CSS-specific properties
*
@@ -38,4 +42,16 @@ public interface CSSStyles {
*/
public static final String CSS_DIAGRAM_STYLESHEETS_KEY = "css_stylesheets"; //$NON-NLS-1$
+ /**
+ * The list of reserved CSS Keywords used in GMF NamedStyle
+ *
+ * Note: In general, all values prefixed with css* are potentially reserved for the CSS Engine
+ */
+ public static final Set<String> RESERVED_KEYWORDS = new HashSet<String>(Arrays.asList(new String[]{
+ CSS_GMF_ID_KEY,
+ CSS_GMF_CLASS_KEY,
+ CSS_GMF_STYLE_KEY,
+ CSS_DIAGRAM_STYLESHEETS_KEY
+ }));
+
}

Back to the top