Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2016-09-14 13:02:40 +0000
committerLars Vogel2016-10-31 16:07:26 +0000
commitc205f43de84fe3621879540bb35c41e76a7383c3 (patch)
treee11fe753eea275733d3ac6e153226765eec03ddf /bundles/org.eclipse.e4.tools.css.spy
parent357d2cf91e850ea1c3c8ededd7f777732b26b427 (diff)
downloadorg.eclipse.e4.tools-c205f43de84fe3621879540bb35c41e76a7383c3.tar.gz
org.eclipse.e4.tools-c205f43de84fe3621879540bb35c41e76a7383c3.tar.xz
org.eclipse.e4.tools-c205f43de84fe3621879540bb35c41e76a7383c3.zip
Bug 501418 - Replace SubProgressMonitor in CssSpyPart of the e4 tools
Change-Id: I396948176f3e98af93a7534df0727dee166c3d0b Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
Diffstat (limited to 'bundles/org.eclipse.e4.tools.css.spy')
-rw-r--r--bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CssSpyPart.java26
1 files changed, 7 insertions, 19 deletions
diff --git a/bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CssSpyPart.java b/bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CssSpyPart.java
index 451fef8d..05ed54c7 100644
--- a/bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CssSpyPart.java
+++ b/bundles/org.eclipse.e4.tools.css.spy/src/org/eclipse/e4/tools/css/spy/CssSpyPart.java
@@ -26,7 +26,7 @@ import javax.inject.Named;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.ui.css.core.dom.CSSStylableElement;
import org.eclipse.e4.ui.css.core.engine.CSSEngine;
@@ -877,12 +877,8 @@ public class CssSpyPart {
}
widgetTreeViewer.collapseAll();
Object[] roots = widgetTreeProvider.getElements(widgetTreeViewer.getInput());
- monitor.beginTask("Searching for \"" + text + "\"", roots.length * 10);
+ SubMonitor subMonitor = SubMonitor.convert(monitor, "Searching for \"" + text + "\"", roots.length * 10);
for (Object root : roots) {
- if (monitor.isCanceled()) {
- return;
- }
-
CSSStylableElement element = getCSSElement(root);
if (element == null) {
continue;
@@ -891,24 +887,20 @@ public class CssSpyPart {
CSSEngine engine = getCSSEngine(root);
try {
SelectorList selectors = engine.parseSelectors(text);
- monitor.worked(2);
- processCSSSearch(new SubProgressMonitor(monitor, 8), engine, selectors, element, null, results);
+ subMonitor.split(2);
+ processCSSSearch(subMonitor.split(8), engine, selectors, element, null, results);
} catch (CSSParseException e) {
System.out.println(e.toString());
} catch (IOException e) {
System.out.println(e.toString());
}
}
- monitor.done();
}
private void processCSSSearch(IProgressMonitor monitor, CSSEngine engine, SelectorList selectors,
CSSStylableElement element, String pseudo, Collection<Widget> results) {
- if (monitor.isCanceled()) {
- return;
- }
NodeList children = element.getChildNodes();
- monitor.beginTask("Searching", 5 + 5 * children.getLength());
+ SubMonitor subMonitor = SubMonitor.convert(monitor, "Searching", 5 + 5 * children.getLength());
boolean matched = false;
for (int i = 0; i < selectors.getLength(); i++) {
if (matched = engine.matches(selectors.item(i), element, pseudo)) {
@@ -918,15 +910,11 @@ public class CssSpyPart {
if (matched) {
results.add((Widget) element.getNativeWidget());
}
- monitor.worked(5);
+ subMonitor.split(5);
for (int i = 0; i < children.getLength(); i++) {
- if (monitor.isCanceled()) {
- return;
- }
- processCSSSearch(new SubProgressMonitor(monitor, 5), engine, selectors,
+ processCSSSearch(subMonitor.split(5), engine, selectors,
(CSSStylableElement) children.item(i), pseudo, results);
}
- monitor.done();
}
protected void dispose() {

Back to the top