KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > core > Policy


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.core;
12
13 import org.eclipse.core.runtime.*;
14
15 public class Policy {
16
17     //debug constants
18
public static boolean DEBUG_STREAMS = false;
19     public static boolean DEBUG_REFRESH_JOB = true;
20     public static boolean DEBUG_BACKGROUND_EVENTS = false;
21     public static boolean DEBUG_THREADING = false;
22
23     static {
24         //init debug options
25
if (TeamPlugin.getPlugin().isDebugging()) {
26             DEBUG_STREAMS = "true".equalsIgnoreCase(Platform.getDebugOption(TeamPlugin.ID + "/streams"));//$NON-NLS-1$ //$NON-NLS-2$
27
DEBUG_REFRESH_JOB = "true".equalsIgnoreCase(Platform.getDebugOption(TeamPlugin.ID + "/refreshjob"));//$NON-NLS-1$ //$NON-NLS-2$
28
DEBUG_BACKGROUND_EVENTS = "true".equalsIgnoreCase(Platform.getDebugOption(TeamPlugin.ID + "/backgroundevents"));//$NON-NLS-1$ //$NON-NLS-2$
29
DEBUG_THREADING = "true".equalsIgnoreCase(Platform.getDebugOption(TeamPlugin.ID + "/threading"));//$NON-NLS-1$ //$NON-NLS-2$
30
}
31     }
32     
33     /**
34      * Progress monitor helpers
35      */

36     public static void checkCanceled(IProgressMonitor monitor) {
37         if (monitor != null && monitor.isCanceled())
38             throw new OperationCanceledException();
39     }
40     public static IProgressMonitor monitorFor(IProgressMonitor monitor) {
41         if (monitor == null)
42             return new NullProgressMonitor();
43         return monitor;
44     }
45     
46     public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) {
47         if (monitor == null)
48             return new NullProgressMonitor();
49         if (monitor instanceof NullProgressMonitor)
50             return monitor;
51         return new SubProgressMonitor(monitor, ticks);
52     }
53     
54     public static IProgressMonitor infiniteSubMonitorFor(IProgressMonitor monitor, int ticks) {
55         if (monitor == null)
56             return new NullProgressMonitor();
57         if (monitor instanceof NullProgressMonitor)
58             return monitor;
59         return new InfiniteSubProgressMonitor(monitor, ticks);
60     }
61 }
62
Popular Tags