Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonrad Kolosowski2003-08-25 19:37:14 +0000
committerKonrad Kolosowski2003-08-25 19:37:14 +0000
commitc280e9ffc6e8a427789a90fe2fcf13741e3a4a44 (patch)
treec57cf9765c09a6f1f60f75ae7d11aca2b586ccd6 /org.eclipse.help.base/src/org/eclipse/help/internal/search/LazyProgressMonitor.java
parent0fec3f388e537182b1c92a0534bb042e1a3356b1 (diff)
downloadeclipse.platform.ua-c280e9ffc6e8a427789a90fe2fcf13741e3a4a44.tar.gz
eclipse.platform.ua-c280e9ffc6e8a427789a90fe2fcf13741e3a4a44.tar.xz
eclipse.platform.ua-c280e9ffc6e8a427789a90fe2fcf13741e3a4a44.zip
RCP work 1
Diffstat (limited to 'org.eclipse.help.base/src/org/eclipse/help/internal/search/LazyProgressMonitor.java')
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/LazyProgressMonitor.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/LazyProgressMonitor.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/LazyProgressMonitor.java
new file mode 100644
index 000000000..8e277db13
--- /dev/null
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/LazyProgressMonitor.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.internal.search;
+import org.eclipse.core.runtime.IProgressMonitor;
+import java.lang.String;
+import org.eclipse.core.runtime.ProgressMonitorWrapper;
+/**
+ * Progress Monitor, that accumulates work without
+ * communicating it immidiately to the underlying monitor.
+ * The work is sent in larger chunks for performance reasons.
+ */
+class LazyProgressMonitor extends ProgressMonitorWrapper {
+ // maximum number of times worked() should be called
+ // on underlying progress monitor
+ private static final int MAX_STEPS = 100;
+ private final IProgressMonitor monitor;
+ private int totalWork;
+ private int work;
+ private int lastWorked;
+ private int treshold;
+ protected LazyProgressMonitor(IProgressMonitor monitor) {
+ super(monitor);
+ this.monitor = monitor;
+ }
+ /**
+ * @see IProgressMonitor#beginTask
+ */
+ public void beginTask(String name, int totalWork) {
+ if (totalWork > 0) {
+ this.totalWork = totalWork;
+ }
+ monitor.beginTask(name, totalWork);
+ work = 0;
+ lastWorked = 0;
+ treshold = 1 + totalWork / MAX_STEPS;
+ }
+ /**
+ * @see IProgressMonitor#worked
+ */
+ public void worked(int newWork) {
+ this.work += newWork;
+ if (work >= treshold) {
+ monitor.worked(work - lastWorked);
+ lastWorked = work;
+ treshold = work + 1 + totalWork / MAX_STEPS;
+ }
+
+ }
+}

Back to the top