package org.eclipse.team.internal.core;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.osgi.service.debug.DebugOptionsListener;
public class Policy {
public static boolean DEBUG = false;
public static boolean DEBUG_STREAMS = false;
public static boolean DEBUG_REFRESH_JOB = true;
public static boolean DEBUG_BACKGROUND_EVENTS = false;
public static boolean DEBUG_THREADING = false;
static final DebugOptionsListener DEBUG_OPTIONS_LISTENER = options -> {
DEBUG = options.getBooleanOption(TeamPlugin.ID + "/debug", false);
DEBUG_STREAMS = DEBUG && options.getBooleanOption(TeamPlugin.ID + "/streams", false);
DEBUG_REFRESH_JOB = DEBUG && options.getBooleanOption(TeamPlugin.ID + "/refreshjob", false);
DEBUG_BACKGROUND_EVENTS = DEBUG && options.getBooleanOption(TeamPlugin.ID + "/backgroundevents", false);
DEBUG_THREADING = DEBUG && options.getBooleanOption(TeamPlugin.ID + "/threading", false);
};
public static void checkCanceled(IProgressMonitor monitor) {
if (monitor != null && monitor.isCanceled())
throw new OperationCanceledException();
}
public static IProgressMonitor monitorFor(IProgressMonitor monitor) {
if (monitor == null)
return new NullProgressMonitor();
return monitor;
}
public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) {
if (monitor == null)
return new NullProgressMonitor();
if (monitor instanceof NullProgressMonitor)
return monitor;
return SubMonitor.convert(monitor, ticks);
}
public static IProgressMonitor infiniteSubMonitorFor(IProgressMonitor monitor, int ticks) {
if (monitor == null)
return new NullProgressMonitor();
if (monitor instanceof NullProgressMonitor)
return monitor;
return new InfiniteSubProgressMonitor(monitor, ticks);
}
}