Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian de Alwis2011-12-06 16:44:33 -0500
committerBrian de Alwis2011-12-06 16:46:19 -0500
commit9154f180fc3b71dd06ec2e686487cc34318f5708 (patch)
tree37514b77246240a6351177fa635a0a3d0bd05651
parenta87a3a70c5233b5936ce4594b603a94593b7d4c8 (diff)
downloadorg.eclipse.e4.tools-9154f180fc3b71dd06ec2e686487cc34318f5708.tar.gz
org.eclipse.e4.tools-9154f180fc3b71dd06ec2e686487cc34318f5708.tar.xz
org.eclipse.e4.tools-9154f180fc3b71dd06ec2e686487cc34318f5708.zip
-rw-r--r--bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CSSPropertiesContentProvider.java5
-rw-r--r--bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CssSpyDialog.java26
2 files changed, 19 insertions, 12 deletions
diff --git a/bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CSSPropertiesContentProvider.java b/bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CSSPropertiesContentProvider.java
index 2803c9d5..8cc77280 100644
--- a/bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CSSPropertiesContentProvider.java
+++ b/bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CSSPropertiesContentProvider.java
@@ -18,7 +18,6 @@ import java.util.Map.Entry;
import org.eclipse.e4.ui.css.core.dom.CSSStylableElement;
import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler;
import org.eclipse.e4.ui.css.core.engine.CSSEngine;
-import org.eclipse.e4.ui.css.swt.dom.WidgetElement;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Widget;
@@ -36,9 +35,9 @@ public class CSSPropertiesContentProvider implements IStructuredContentProvider
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (newInput instanceof CSSStylableElement) {
this.input = (CSSStylableElement) newInput;
- this.cssEngine = WidgetElement.getEngine((Widget) input.getNativeWidget());
+ this.cssEngine = CssSpyDialog.getCSSEngine((Widget) input.getNativeWidget());
} else if (newInput instanceof Widget) {
- this.cssEngine = WidgetElement.getEngine((Widget) newInput);
+ this.cssEngine = CssSpyDialog.getCSSEngine((Widget) newInput);
this.input = (CSSStylableElement) cssEngine.getElement(newInput);
}
}
diff --git a/bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CssSpyDialog.java b/bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CssSpyDialog.java
index cff70893..fb59f096 100644
--- a/bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CssSpyDialog.java
+++ b/bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CssSpyDialog.java
@@ -17,6 +17,7 @@ import java.util.List;
import org.eclipse.e4.ui.css.core.dom.CSSStylableElement;
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.engine.CSSSWTEngineImpl;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -81,22 +82,29 @@ public class CssSpyDialog extends Dialog {
public static CSSStylableElement getCSSElement(Object o) {
if (o instanceof CSSStylableElement) {
return (CSSStylableElement) o;
- } else if (o instanceof Widget) {
- CSSEngine engine = WidgetElement.getEngine((Widget) o);
- return (CSSStylableElement) engine.getElement(o);
+ } else {
+ CSSEngine engine = getCSSEngine(o);
+ if (engine != null) {
+ return (CSSStylableElement) engine.getElement(o);
+ }
}
return null;
}
/** @return the CSS engine governing the argument, or null if none */
public static CSSEngine getCSSEngine(Object o) {
+ CSSEngine engine = null;
if (o instanceof CSSStylableElement) {
CSSStylableElement element = (CSSStylableElement) o;
- return WidgetElement.getEngine((Widget) element.getNativeWidget());
- } else if (o instanceof Widget) {
- return WidgetElement.getEngine((Widget) o);
+ engine = WidgetElement.getEngine((Widget) element.getNativeWidget());
+ }
+ if (engine == null && o instanceof Widget) {
+ engine = WidgetElement.getEngine((Widget) o);
+ }
+ if (engine == null && Display.getCurrent() != null) {
+ engine = new CSSSWTEngineImpl(Display.getCurrent());
}
- return null;
+ return engine;
}
private Display display;
@@ -173,7 +181,7 @@ public class CssSpyDialog extends Dialog {
}
shown = current;
- CSSEngine engine = WidgetElement.getEngine(shown);
+ CSSEngine engine = getCSSEngine(shown);
CSSStylableElement element = (CSSStylableElement) engine
.getElement(shown);
if (element == null) {
@@ -646,7 +654,7 @@ public class CssSpyDialog extends Dialog {
return;
}
- CSSEngine engine = WidgetElement.getEngine(shown);
+ CSSEngine engine = getCSSEngine(shown);
try {
SelectorList selectors = engine.parseSelectors(text);
processCSSSearch(text, null, engine, selectors, element);

Back to the top