Project

General

Profile

Download (5.82 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.cdm.common.monitor;
2

    
3

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

    
15
/**
16
 * An abstract wrapper around a progress monitor which,
17
 * unless overridden, forwards <code>IProgressMonitor</code>
18
 * and <code>IProgressMonitorWithBlocking</code> methods to the wrapped progress monitor.
19
 * <p>
20
 * This class can be used without OSGi running.
21
 * </p><p>
22
 * Clients may subclass.
23
 * </p>
24
 */
25
public abstract class ProgressMonitorWrapper implements 
26
        IProgressMonitor /*, IProgressMonitorWithBlocking*/ {
27

    
28
    /** The wrapped progress monitor. */
29
    private IProgressMonitor progressMonitor;
30

    
31
    /** 
32
     * Creates a new wrapper around the given monitor.
33
     *
34
     * @param monitor the progress monitor to forward to
35
     */
36
    protected ProgressMonitorWrapper(IProgressMonitor monitor) {
37
//        Assert.isNotNull(monitor);
38
        progressMonitor = monitor;
39
    }
40

    
41
    /** 
42
     * This implementation of a <code>IProgressMonitor</code>
43
     * method forwards to the wrapped progress monitor.
44
     * Clients may override this method to do additional
45
     * processing.
46
     *
47
     * @see IProgressMonitor#beginTask(String, int)
48
     */
49
    public void beginTask(String name, int totalWork) {
50
        progressMonitor.beginTask(name, totalWork);
51
    }
52
//
53
//    /**
54
//     * This implementation of a <code>IProgressMonitorWithBlocking</code>
55
//     * method forwards to the wrapped progress monitor.
56
//     * Clients may override this method to do additional
57
//     * processing.
58
//     *
59
//     * @see IProgressMonitorWithBlocking#clearBlocked()
60
//     * @since 3.0
61
//     */
62
//    public void clearBlocked() {
63
//        if (progressMonitor instanceof  IProgressMonitorWithBlocking)
64
//            ((IProgressMonitorWithBlocking) progressMonitor)
65
//                    .clearBlocked();
66
//    }
67

    
68
    /**
69
     * This implementation of a <code>IProgressMonitor</code>
70
     * method forwards to the wrapped progress monitor.
71
     * Clients may override this method to do additional
72
     * processing.
73
     *
74
     * @see IProgressMonitor#done()
75
     */
76
    public void done() {
77
        progressMonitor.done();
78
    }
79

    
80
    /**
81
     * Returns the wrapped progress monitor.
82
     *
83
     * @return the wrapped progress monitor
84
     */
85
    public IProgressMonitor getWrappedProgressMonitor() {
86
        return progressMonitor;
87
    }
88

    
89
    /**
90
     * This implementation of a <code>IProgressMonitor</code>
91
     * method forwards to the wrapped progress monitor.
92
     * Clients may override this method to do additional
93
     * processing.<BR>
94
     * As the  {@link IProgressMonitor interface} documentation for 
95
     * {@link IProgressMonitor#internalWorked(double) this method} 
96
     * says the method must not be called by a client. 
97
     * Clients should always use the method </code>worked(int)</code>.
98
     *
99
     * @see IProgressMonitor#internalWorked(double)
100
     */
101
    public void internalWorked(double work) {
102
        progressMonitor.internalWorked(work);
103
    }
104

    
105
    /**
106
     * This implementation of a <code>IProgressMonitor</code>
107
     * method forwards to the wrapped progress monitor.
108
     * Clients may override this method to do additional
109
     * processing.
110
     *
111
     * @see IProgressMonitor#isCanceled()
112
     */
113
    public boolean isCanceled() {
114
        return progressMonitor.isCanceled();
115
    }
116

    
117
//    /**
118
//     * This implementation of a <code>IProgressMonitorWithBlocking</code>
119
//     * method forwards to the wrapped progress monitor.
120
//     * Clients may override this method to do additional
121
//     * processing.
122
//     *
123
//     * @see IProgressMonitorWithBlocking#setBlocked(IStatus)
124
//     * @since 3.0
125
//     */
126
//    public void setBlocked(IStatus reason) {
127
//        if (progressMonitor instanceof  IProgressMonitorWithBlocking)
128
//            ((IProgressMonitorWithBlocking) progressMonitor)
129
//                    .setBlocked(reason);
130
//    }
131

    
132
    /**
133
     * This implementation of a <code>IProgressMonitor</code>
134
     * method forwards to the wrapped progress monitor.
135
     * Clients may override this method to do additional
136
     * processing.
137
     *
138
     * @see IProgressMonitor#setCanceled(boolean)
139
     */
140
    public void setCanceled(boolean b) {
141
        progressMonitor.setCanceled(b);
142
    }
143

    
144
    /**
145
     * This implementation of a <code>IProgressMonitor</code>
146
     * method forwards to the wrapped progress monitor.
147
     * Clients may override this method to do additional
148
     * processing.
149
     *
150
     * @see IProgressMonitor#setTaskName(String)
151
     */
152
    public void setTaskName(String name) {
153
        progressMonitor.setTaskName(name);
154
    }
155

    
156
    /**
157
     * This implementation of a <code>IProgressMonitor</code>
158
     * method forwards to the wrapped progress monitor.
159
     * Clients may override this method to do additional
160
     * processing.
161
     *
162
     * @see IProgressMonitor#subTask(String)
163
     */
164
    public void subTask(String name) {
165
        progressMonitor.subTask(name);
166
    }
167

    
168
    /**
169
     * This implementation of a <code>IProgressMonitor</code>
170
     * method forwards to the wrapped progress monitor.
171
     * Clients may override this method to do additional
172
     * processing.
173
     *
174
     * @see IProgressMonitor#worked(int)
175
     */
176
    public void worked(int work) {
177
        progressMonitor.worked(work);
178
    }
179
}
(5-5/7)