Statistics
| Revision:

gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / task / SimpleTaskStatus.java @ 3075

History | View | Annotate | Download (7.4 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.task;
25

    
26
import java.util.Date;
27
import org.gvsig.tools.observer.Observer;
28

    
29
public interface SimpleTaskStatus extends TaskStatus {
30

    
31
    public static SimpleTaskStatus FAKE_STATUS = new SimpleTaskStatus() {
32
        @Override
33
        public String getTitle() {
34
            return "";
35
        }
36

    
37
        @Override
38
        public void cancel() {
39
        }
40

    
41
        @Override
42
        public void setTitle(String title) {
43
        }
44

    
45
        @Override
46
        public void setTittle(String tittle) {
47
        }
48

    
49
        @Override
50
        public void message(String message) {
51
        }
52

    
53
        @Override
54
        public void setRangeOfValues(long min, long max) {
55
        }
56
        
57
        @Override
58
        public void setCurValue(long value) {
59
        }
60

    
61
        @Override
62
        public void incrementCurrentValue() {
63
        }
64

    
65
        @Override
66
        public void terminate() {
67
        }
68
        
69
        @Override
70
        public void setCancellable(boolean cancellable) {
71
        }
72

    
73
        @Override
74
        public void remove() {
75
        }
76

    
77
        @Override
78
        public void abort() {
79
        }
80
        
81
        @Override
82
        public void add() {
83
        }
84
        
85
        @Override
86
        public void restart() {
87
        }
88

    
89
        @Override
90
        public void pop() {
91
        }
92

    
93
        @Override
94
        public void setIndeterminate() {
95
        }
96

    
97
        @Override
98
        public boolean getAutoRemove() {
99
            return false;
100
        }
101

    
102
        @Override
103
        public void setAutoremove(boolean autoremove) {
104
        }
105
        
106
        @Override
107
        public void push() {
108
        }
109

    
110
        @Override
111
        public String getCode() {
112
            return null;
113
        }
114

    
115
        @Override
116
        public int getCompleted() {
117
            return 0;
118
        }
119

    
120
        @Override
121
        public String getLabel() {
122
            return "";
123
        }
124

    
125
        @Override
126
        public String getProgressLabel() {
127
            return "";
128
        }
129

    
130
        @Override
131
        public String getMessage() {
132
            return null;
133
        }
134

    
135
        @Override
136
        public boolean isCancelled() {
137
            return false;
138
        }
139

    
140
        @Override
141
        public boolean isAborted() {
142
            return false;
143
        }
144

    
145
        @Override
146
        public boolean isRunning() {
147
            return false;
148
        }
149

    
150
        @Override
151
        public Date getLastModification() {
152
            return new Date();
153
        }
154

    
155
        @Override
156
        public TaskStatusManager getManager() {
157
            return null;
158
        }
159

    
160
        @Override
161
        public boolean isIndeterminate() {
162
            return true;
163
        }
164

    
165
        @Override
166
        public boolean isCancellable() {
167
            return true;
168
        }
169

    
170
        @Override
171
        public boolean isCancellationRequested() {
172
            return false;
173
        }
174

    
175
        @Override
176
        public void cancelRequest() {
177
        }
178

    
179
        @Override
180
        public void addObserver(Observer o) {
181
        }
182

    
183
        @Override
184
        public void deleteObserver(Observer o) {
185
        }
186

    
187
        @Override
188
        public void deleteObservers() {
189
        }
190

    
191
        @Override
192
        public long getCurValue() {
193
            return 0;
194
        }
195
    };
196
    
197
    
198
    public static SimpleTaskStatus get(SimpleTaskStatus status) {
199
        if( status==null ) {
200
            return FAKE_STATUS;
201
        }
202
        return status;
203
    }
204
    
205
    /**
206
     * Used by the task to set the title associated to the task. It can't be
207
     * changed.
208
     *
209
     * @param tittle
210
     *
211
     * @deprecated @see {@link SimpleTaskStatus#setTitle(String)}
212
     */
213
    public void setTittle(String tittle);
214

    
215
    /**
216
     * Used by the task to set the title associated to the task. It can't be
217
     * changed.
218
     *
219
     * @param title
220
     */
221
    public void setTitle(String title);
222

    
223
    /**
224
     * Used by the task to set a message associated to the current action of the
225
     * task
226
     *
227
     * @param message
228
     */
229
    public void message(String message);
230

    
231
    /**
232
     * Used by the task to set the value for min and max steps of the task.
233
     * These are used with the "curvalue" to calculate the percentage of
234
     * completion.
235
     *
236
     * @param min
237
     * @param max
238
     */
239
    public void setRangeOfValues(long min, long max);
240

    
241
    /**
242
     * Used by the task to set the current step of the task.
243
     *
244
     * @param value
245
     * @see setRangeOfValues
246
     *
247
     */
248
    public void setCurValue(long value);
249

    
250
    public void incrementCurrentValue();
251
    
252
    /**
253
     * Used by the task to inform that it has terminated without errors.
254
     */
255
    public void terminate();
256

    
257
    /**
258
     * Used by the task to inform that it has terminated cancelled by the user
259
     * or another task.
260
     */
261
    public void cancel();
262

    
263
    /**
264
     * Used by the task to inform that it has terminated with errors.
265
     */
266
    public void abort();
267

    
268
    /**
269
     * Remove this TaskStatus from the TaskStatusManager
270
     */
271
    public void remove();
272

    
273
    /**
274
     * Add this TaskStatus to the TaskStatusManager. If TaskStatus already in
275
     * the manager this is updated.
276
     */
277
    public void add();
278

    
279
    /**
280
     * Used by the task to inform that this task es cacellable.
281
     *
282
     * @param cancellable
283
     */
284
    public void setCancellable(boolean cancellable);
285

    
286
    /**
287
     * Used by the task to inform that this TaskStatus is removed from the
288
     * manager automatically when the task is terminated and the manager need.
289
     *
290
     * @param autoremove
291
     */
292
    public void setAutoremove(boolean autoremove);
293

    
294
    /**
295
     * Return the autoremove value of this TaskStatus.
296
     *
297
     * @return
298
     */
299
    public boolean getAutoRemove();
300

    
301
    /**
302
     * Set the estatus of task to inteterminate. Reset values of range and
303
     * current value.
304
     */
305
    public void setIndeterminate();
306

    
307
    /**
308
     * Este metodo guarda los valores de progreso y el mensaje de la tarea para
309
     * ser restaurados posteriormente invocando al metodo {@link #pop()}.
310
     *
311
     * Los metodos {@link #push()} y {@link #pop()} estan pensado para gestionar
312
     * subtareas dentro de un tareas, de forma que las subtareas puedan tener su
313
     * propio progreso y mensaje mientras se estan ejecutando.
314
     *
315
     * @see {@link #pop()}
316
     */
317
    public void push();
318

    
319
    /**
320
     * Este metodo esta pensado para restaurar los ultimos valores de progreso y
321
     * mensaje que se guardaron invocando al metodo {@link #push()}.
322
     *
323
     * @see {@link #push()}
324
     */
325
    public void pop();
326

    
327
    public void restart();
328

    
329
    public long getCurValue();
330
}