1 11 package org.eclipse.team.internal.core; 12 13 14 import org.eclipse.core.runtime.IProgressMonitor; 15 import org.eclipse.core.runtime.SubProgressMonitor; 16 17 28 public class InfiniteSubProgressMonitor extends SubProgressMonitor { 29 30 int totalWork; 31 int halfWay; 32 int currentIncrement; 33 int nextProgress; 34 int worked; 35 36 41 public InfiniteSubProgressMonitor(IProgressMonitor monitor, int ticks) { 42 this(monitor, ticks, 0); 43 } 44 45 51 public InfiniteSubProgressMonitor(IProgressMonitor monitor, int ticks, int style) { 52 super(monitor, ticks, style); 53 } 54 55 public void beginTask(String name, int totalWork) { 56 super.beginTask(name, totalWork); 57 this.totalWork = totalWork; 58 this.halfWay = totalWork / 2; 59 this.currentIncrement = 1; 60 this.nextProgress = currentIncrement; 61 this.worked = 0; 62 } 63 64 public void worked(int work) { 65 if (worked >= totalWork) return; 66 if (--nextProgress <= 0) { 67 super.worked(1); 68 worked++; 69 if (worked >= halfWay) { 70 currentIncrement *= 2; 73 halfWay += (totalWork - halfWay) / 2; 74 } 75 nextProgress = currentIncrement; 77 } 78 } 79 80 86 public void subTask(String name) { 87 if(name != null && ! name.equals("")) { super.subTask(name); 89 } 90 } 91 } 92 | Popular Tags |