1 11 package org.eclipse.update.internal.core; 12 13 14 import org.eclipse.core.runtime.IProgressMonitor; 15 import org.eclipse.core.runtime.NullProgressMonitor; 16 import org.eclipse.core.runtime.OperationCanceledException; 17 import org.eclipse.core.runtime.SubProgressMonitor; 18 19 public class Policy { 20 23 public static void checkCanceled(IProgressMonitor monitor) { 24 if (monitor.isCanceled()) 25 throw new OperationCanceledException(); 26 } 27 public static IProgressMonitor monitorFor(IProgressMonitor monitor) { 28 if (monitor == null) 29 return new NullProgressMonitor(); 30 return monitor; 31 } 32 33 public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) { 34 if (monitor == null) 35 return new NullProgressMonitor(); 36 if (monitor instanceof NullProgressMonitor) 37 return monitor; 38 return new SubProgressMonitor(monitor, ticks); 39 } 40 } 41 | Popular Tags |