Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-04-06 16:20:24 +0000
committercletavernie2012-04-06 16:20:24 +0000
commitcaf53fac8c4cdef32e83f746d26e0ac8e8e70869 (patch)
tree7697453c66ce05098d0b795d3a975785fb48f83c /plugins/infra/gmfdiag/css
parentc4c789ea01b4f46f23438b7ab99a7fab9724e23d (diff)
downloadorg.eclipse.papyrus-caf53fac8c4cdef32e83f746d26e0ac8e8e70869.tar.gz
org.eclipse.papyrus-caf53fac8c4cdef32e83f746d26e0ac8e8e70869.tar.xz
org.eclipse.papyrus-caf53fac8c4cdef32e83f746d26e0ac8e8e70869.zip
370797: [Theme] Papyrus should provide a support for CSS files on its diagrams
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370797
Diffstat (limited to 'plugins/infra/gmfdiag/css')
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.xtext.ui/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/ui/color/CSSHighlightingConfiguration.java6
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/ui/color/CSSSemanticHighlightingCalculator.java26
3 files changed, 26 insertions, 9 deletions
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.xtext.ui/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.xtext.ui/META-INF/MANIFEST.MF
index 4696b653c83..eba11a6cbef 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.xtext.ui/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.xtext.ui/META-INF/MANIFEST.MF
@@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.papyrus.infra.gmfdiag.css.xtext,
org.eclipse.xtext.common.types.ui,
org.eclipse.xtext.ui.codetemplates.ui,
org.eclipse.compare,
- org.apache.log4j;bundle-version="1.2.15"
+ org.apache.log4j;bundle-version="1.2.15",
+ org.eclipse.e4.ui.css.core;bundle-version="0.10.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.eclipse.papyrus.infra.gmfdiag.ui.contentassist,
org.eclipse.papyrus.infra.gmfdiag.ui.contentassist.antlr,
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/ui/color/CSSHighlightingConfiguration.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/ui/color/CSSHighlightingConfiguration.java
index 3372c57aac7..832983762f6 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/ui/color/CSSHighlightingConfiguration.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/ui/color/CSSHighlightingConfiguration.java
@@ -1,5 +1,6 @@
package org.eclipse.papyrus.infra.gmfdiag.ui.color;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.xtext.ui.editor.syntaxcoloring.DefaultHighlightingConfiguration;
import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightingConfigurationAcceptor;
@@ -26,7 +27,7 @@ public class CSSHighlightingConfiguration extends DefaultHighlightingConfigurati
public TextStyle colorTextStyle() {
TextStyle textStyle = new TextStyle();
- textStyle.setColor(new RGB(0, 0, 0)); //TODO
+ textStyle.setColor(new RGB(255, 98, 176));
return textStyle;
}
@@ -68,7 +69,8 @@ public class CSSHighlightingConfiguration extends DefaultHighlightingConfigurati
public TextStyle fontTextStyle() {
TextStyle textStyle = new TextStyle();
- textStyle.setColor(new RGB(0, 0, 0)); //TODO
+ textStyle.setColor(new RGB(1, 1, 1));
+ textStyle.setStyle(SWT.ITALIC);
return textStyle;
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/ui/color/CSSSemanticHighlightingCalculator.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/ui/color/CSSSemanticHighlightingCalculator.java
index 396a670a65a..3574b5db693 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/ui/color/CSSSemanticHighlightingCalculator.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/ui/color/CSSSemanticHighlightingCalculator.java
@@ -1,8 +1,13 @@
package org.eclipse.papyrus.infra.gmfdiag.ui.color;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
+import org.eclipse.e4.ui.css.core.css2.CSS2ColorHelper;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.xtext.RuleCall;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.resource.XtextResource;
@@ -14,6 +19,8 @@ public class CSSSemanticHighlightingCalculator implements ISemanticHighlightingC
private final Map<String, String> ruleNameToID = new HashMap<String, String>();
+ private final Set<String> fontNames = new HashSet<String>();
+
public CSSSemanticHighlightingCalculator() {
ruleNameToID.put("CSSId", CSSHighlightingConfiguration.CSS_ID);
ruleNameToID.put("Class", CSSHighlightingConfiguration.CSS_CLASS);
@@ -40,6 +47,13 @@ public class CSSSemanticHighlightingCalculator implements ISemanticHighlightingC
ruleNameToID.put("Angle", CSSHighlightingConfiguration.NUMBER_ID);
ruleNameToID.put("Time", CSSHighlightingConfiguration.NUMBER_ID);
ruleNameToID.put("Number", CSSHighlightingConfiguration.NUMBER_ID);
+
+ //Available fonts
+
+ FontData[] fontData = Display.getCurrent().getFontList(null, true);
+ for(FontData data : fontData) {
+ fontNames.add(data.getName().toLowerCase());
+ }
}
public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor) {
@@ -52,14 +66,14 @@ public class CSSSemanticHighlightingCalculator implements ISemanticHighlightingC
if(node.getGrammarElement() instanceof RuleCall) {
RuleCall ruleCall = (RuleCall)node.getGrammarElement();
String name = ruleCall.getRule().getName();
- if("Name".equals(name)) {
+ if("Name".equals(name)) { //TODO: Strings should also be taken into account
//Check the known elements (fonts, colors, ...)
- String value = ""; //TODO
+ String value = node.getText();
if(isFont(value)) {
- acceptor.addPosition(node.getOffset(), node.getLength(), CSSHighlightingConfiguration.COLOR);
+ acceptor.addPosition(node.getOffset(), node.getLength(), CSSHighlightingConfiguration.FONT);
continue;
} else if(isColor(value)) {
- acceptor.addPosition(node.getOffset(), node.getLength(), CSSHighlightingConfiguration.FONT);
+ acceptor.addPosition(node.getOffset(), node.getLength(), CSSHighlightingConfiguration.COLOR);
continue;
}
}
@@ -72,10 +86,10 @@ public class CSSSemanticHighlightingCalculator implements ISemanticHighlightingC
}
public boolean isFont(String value) {
- return false; //TODO
+ return fontNames.contains(value.toLowerCase());
}
public boolean isColor(String value) {
- return false; //TODO
+ return CSS2ColorHelper.isColorName(value.toLowerCase());
}
}

Back to the top