KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > 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.update.internal.core;
12
13
14 import org.eclipse.core.runtime.IProgressMonitor;
15 import org.eclipse.core.runtime.NullProgressMonitor;
16 import org.eclipse.core.runtime.OperationCanceledException;
17 import org.eclipse.core.runtime.SubProgressMonitor;
18
19 public class Policy {
20     /**
21      * Progress monitor helpers
22      */

23     public static void checkCanceled(IProgressMonitor monitor) {
24         if (monitor.isCanceled())
25             throw new OperationCanceledException();
26     }
27     public static IProgressMonitor monitorFor(IProgressMonitor monitor) {
28         if (monitor == null)
29             return new NullProgressMonitor();
30         return monitor;
31     }
32     
33     public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) {
34         if (monitor == null)
35             return new NullProgressMonitor();
36         if (monitor instanceof NullProgressMonitor)
37             return monitor;
38         return new SubProgressMonitor(monitor, ticks);
39     }
40 }
41
Popular Tags