KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.ui;
12
13
14
15 import java.util.ResourceBundle JavaDoc;
16
17 import org.eclipse.core.runtime.*;
18
19 /**
20  * Policy implements NLS convenience methods for the plugin and
21  * makes progress monitor policy decisions
22  */

23 public class Policy {
24     //debug constants
25
public static boolean DEBUG_SYNC_MODELS = false;
26     
27     private static String JavaDoc ACTION_BUNDLE = "org.eclipse.team.internal.ui.actions.actions"; //$NON-NLS-1$
28
private static ResourceBundle JavaDoc actionBundle = null;
29
30     /*
31      * Returns a resource bundle, creating one if it none is available.
32      */

33     public static ResourceBundle JavaDoc getActionBundle() {
34         // thread safety
35
ResourceBundle JavaDoc tmpBundle = actionBundle;
36         if (tmpBundle != null)
37             return tmpBundle;
38         return actionBundle = ResourceBundle.getBundle(ACTION_BUNDLE);
39     }
40     
41     static {
42         //init debug options
43
if (TeamUIPlugin.getPlugin().isDebugging()) {
44             DEBUG_SYNC_MODELS = "true".equalsIgnoreCase(Platform.getDebugOption(TeamUIPlugin.ID + "/syncmodels"));//$NON-NLS-1$ //$NON-NLS-2$
45
}
46     }
47     
48     /**
49      * Checks if the progress monitor is canceled.
50      *
51      * @param monitor the onitor to check for cancellation
52      * @throws OperationCanceledException if the monitor is canceled
53      */

54     public static void checkCanceled(IProgressMonitor monitor) {
55         if (monitor.isCanceled()) {
56             throw new OperationCanceledException();
57         }
58     }
59     
60     public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) {
61         if (monitor == null)
62             return new NullProgressMonitor();
63         if (monitor instanceof NullProgressMonitor)
64             return monitor;
65         return new SubProgressMonitor(monitor, ticks);
66     }
67
68     public static IProgressMonitor monitorFor(IProgressMonitor monitor) {
69         if (monitor == null)
70             return new NullProgressMonitor();
71         return monitor;
72     }
73 }
74
Popular Tags