Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian de Alwis2014-04-01 21:03:50 -0400
committerBrian de Alwis2014-04-02 11:24:37 -0400
commitcf711ec747778f9886bc1a33796157e69c91c7f0 (patch)
treea0fa17b55d97b68f2d0fc688fa7f5e125f145e25
parent9d90472feb963fd7e808cdceed0ed7242940816a (diff)
downloadorg.eclipse.e4.tools-cf711ec747778f9886bc1a33796157e69c91c7f0.tar.gz
org.eclipse.e4.tools-cf711ec747778f9886bc1a33796157e69c91c7f0.tar.xz
org.eclipse.e4.tools-cf711ec747778f9886bc1a33796157e69c91c7f0.zip
Bug 431744 - [CSS] Support using multiple CSS engines
Add style sheets for all CSS engines managed by the ThemeManager.
-rw-r--r--bundles/org.eclipse.e4.tools.css.spy/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CSSScratchPadWindow.java74
2 files changed, 44 insertions, 32 deletions
diff --git a/bundles/org.eclipse.e4.tools.css.spy/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.tools.css.spy/META-INF/MANIFEST.MF
index b029b8b8..13b3a386 100644
--- a/bundles/org.eclipse.e4.tools.css.spy/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.tools.css.spy/META-INF/MANIFEST.MF
@@ -11,7 +11,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.6.0",
org.eclipse.swt;bundle-version="3.6.0",
org.eclipse.jface;bundle-version="3.8.0",
org.eclipse.e4.ui.css.swt;bundle-version="0.10.0",
- org.eclipse.e4.ui.css.swt.theme;bundle-version="0.9.1",
+ org.eclipse.e4.ui.css.swt.theme;bundle-version="0.9.201",
org.eclipse.e4.ui.widgets;bundle-version="0.11.0",
org.eclipse.e4.ui.model.workbench;bundle-version="0.9.1"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CSSScratchPadWindow.java b/bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CSSScratchPadWindow.java
index d32157c8..f0c3c635 100644
--- a/bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CSSScratchPadWindow.java
+++ b/bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CSSScratchPadWindow.java
@@ -8,7 +8,6 @@ import java.util.List;
import org.eclipse.e4.ui.css.core.dom.ExtendedDocumentCSS;
import org.eclipse.e4.ui.css.core.engine.CSSEngine;
-import org.eclipse.e4.ui.css.swt.dom.WidgetElement;
import org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngine;
import org.eclipse.e4.ui.css.swt.theme.IThemeEngine;
import org.eclipse.jface.dialogs.Dialog;
@@ -93,41 +92,54 @@ public class CSSScratchPadWindow extends Dialog {
}
private void applyCSS() {
+ if (themeEngine == null) {
+ exceptions.setText("No theme engine available!");
+ return;
+ }
long start = System.nanoTime();
exceptions.setText("");
- CSSEngine engine = WidgetElement.getEngine(getShell().getDisplay());
- if (engine == null) {
- exceptions.setText("No CSS Engine available");
- }
- if (themeEngine != null) {
- // FIXME: expose this new protocol
- ((ThemeEngine) themeEngine).resetCurrentTheme();
- }
- ExtendedDocumentCSS doc = (ExtendedDocumentCSS) engine
- .getDocumentCSS();
- List<StyleSheet> sheets = new ArrayList<StyleSheet>();
- StyleSheetList list = doc.getStyleSheets();
- for (int i = 0; i < list.getLength(); i++) {
- sheets.add(list.item(i));
- }
- try {
- Reader reader = new StringReader(cssText.getText());
- sheets.add(0, engine.parseStyleSheet(reader));
- doc.removeAllStyleSheets();
- for (StyleSheet sheet : sheets) {
- doc.addStyleSheet(sheet);
+ StringBuilder sb = new StringBuilder();
+
+ // FIXME: expose these new protocols: resetCurrentTheme() and
+ // getCSSEngines()
+ ((ThemeEngine) themeEngine).resetCurrentTheme();
+
+ int count = 0;
+ for (CSSEngine engine : ((ThemeEngine) themeEngine).getCSSEngines()) {
+ if (count++ > 0) {
+ sb.append("\n\n");
+ }
+ sb.append("Engine[").append(engine.getClass().getSimpleName())
+ .append("]");
+ ExtendedDocumentCSS doc = (ExtendedDocumentCSS) engine
+ .getDocumentCSS();
+ List<StyleSheet> sheets = new ArrayList<StyleSheet>();
+ StyleSheetList list = doc.getStyleSheets();
+ for (int i = 0; i < list.getLength(); i++) {
+ sheets.add(list.item(i));
+ }
+
+ try {
+ Reader reader = new StringReader(cssText.getText());
+ sheets.add(0, engine.parseStyleSheet(reader));
+ doc.removeAllStyleSheets();
+ for (StyleSheet sheet : sheets) {
+ doc.addStyleSheet(sheet);
+ }
+ engine.reapply();
+
+ long nanoDiff = System.nanoTime() - start;
+ sb.append("\nTime: ").append(nanoDiff / 1000000).append("ms");
+ } catch (CSSParseException e) {
+ sb.append("\nError: line ").append(e.getLineNumber())
+ .append(" col ").append(e.getColumnNumber())
+ .append(": ").append(e.getLocalizedMessage());
+ } catch (IOException e) {
+ sb.append("\nError: ").append(e.getLocalizedMessage());
}
- engine.reapply();
-
- long nanoDiff = System.nanoTime() - start;
- exceptions.setText("Total time: " + (nanoDiff / 1000000) + "ms");
- } catch (CSSParseException e) {
- exceptions.setText("Error: line " + e.getLineNumber() + " col "
- + e.getColumnNumber() + ": " + e.getLocalizedMessage());
- } catch (IOException e) {
- exceptions.setText("Error: " + e.getLocalizedMessage());
}
+ exceptions.setText(sb.toString());
}
}

Back to the top