KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > 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.ccvs.ui;
12
13
14 import java.util.ResourceBundle JavaDoc;
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 JavaDoc ACTION_BUNDLE = "org.eclipse.team.internal.ccvs.ui.actions.actions"; //$NON-NLS-1$
26
private static ResourceBundle JavaDoc actionBundle = null;
27     
28     public static boolean DEBUG_CONSOLE_BUFFERING = false;
29
30     static {
31         //init debug options
32
if (CVSUIPlugin.getPlugin().isDebugging()) {
33             DEBUG_CONSOLE_BUFFERING = "true".equalsIgnoreCase(Platform.getDebugOption(CVSUIPlugin.ID + "/consolebuffering")); //$NON-NLS-1$ //$NON-NLS-2$
34
}
35     }
36
37     /**
38      * Progress monitor helpers
39      */

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 JavaDoc getActionBundle() {
69         ResourceBundle JavaDoc tmpBundle = actionBundle;
70         if (tmpBundle != null)
71             return tmpBundle;
72         return actionBundle = ResourceBundle.getBundle(ACTION_BUNDLE);
73     }
74 }
75
Popular Tags