1 11 package org.eclipse.team.internal.ccvs.ui; 12 13 14 import java.util.ResourceBundle ; 15 16 import org.eclipse.core.runtime.IProgressMonitor; 17 import org.eclipse.core.runtime.NullProgressMonitor; 18 import org.eclipse.core.runtime.OperationCanceledException; 19 import org.eclipse.core.runtime.Platform; 20 import org.eclipse.core.runtime.SubProgressMonitor; 21 import org.eclipse.team.internal.core.InfiniteSubProgressMonitor; 22 23 public class Policy { 24 25 private static String ACTION_BUNDLE = "org.eclipse.team.internal.ccvs.ui.actions.actions"; private static ResourceBundle actionBundle = null; 27 28 public static boolean DEBUG_CONSOLE_BUFFERING = false; 29 30 static { 31 if (CVSUIPlugin.getPlugin().isDebugging()) { 33 DEBUG_CONSOLE_BUFFERING = "true".equalsIgnoreCase(Platform.getDebugOption(CVSUIPlugin.ID + "/consolebuffering")); } 35 } 36 37 40 public static void checkCanceled(IProgressMonitor monitor) { 41 if (monitor.isCanceled()) 42 cancelOperation(); 43 } 44 public static void cancelOperation() { 45 throw new OperationCanceledException(); 46 } 47 public static IProgressMonitor monitorFor(IProgressMonitor monitor) { 48 if (monitor == null) 49 return new NullProgressMonitor(); 50 return monitor; 51 } 52 public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) { 53 if (monitor == null) 54 return new NullProgressMonitor(); 55 if (monitor instanceof NullProgressMonitor) 56 return monitor; 57 return new SubProgressMonitor(monitor, ticks); 58 } 59 60 public static IProgressMonitor infiniteSubMonitorFor(IProgressMonitor monitor, int ticks) { 61 if (monitor == null) 62 return new NullProgressMonitor(); 63 if (monitor instanceof NullProgressMonitor) 64 return monitor; 65 return new InfiniteSubProgressMonitor(monitor, ticks); 66 } 67 68 public static ResourceBundle getActionBundle() { 69 ResourceBundle tmpBundle = actionBundle; 70 if (tmpBundle != null) 71 return tmpBundle; 72 return actionBundle = ResourceBundle.getBundle(ACTION_BUNDLE); 73 } 74 } 75 | Popular Tags |