Last change
on this file since 6340 was 5170, checked in by Don-vip, 12 years ago |
cleanup svn:mime-type properties preventing Java sources from being viewed as such on Trac
|
-
Property svn:eol-style
set to
native
|
File size:
909 bytes
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.progress;
|
---|
3 |
|
---|
4 | import java.util.ArrayList;
|
---|
5 | import java.util.List;
|
---|
6 |
|
---|
7 | import org.openstreetmap.josm.gui.progress.ProgressMonitor.CancelListener;
|
---|
8 |
|
---|
9 | public class CancelHandler {
|
---|
10 |
|
---|
11 | private boolean isCanceled;
|
---|
12 | private List<CancelListener> listeners = new ArrayList<CancelListener>();
|
---|
13 |
|
---|
14 | public synchronized void cancel() {
|
---|
15 | if (!isCanceled) {
|
---|
16 | isCanceled = true;
|
---|
17 | for (CancelListener listener:listeners) {
|
---|
18 | listener.operationCanceled();
|
---|
19 | }
|
---|
20 | }
|
---|
21 | }
|
---|
22 |
|
---|
23 | public synchronized boolean isCanceled() {
|
---|
24 | return isCanceled;
|
---|
25 | }
|
---|
26 |
|
---|
27 | public synchronized void addCancelListener(CancelListener listener) {
|
---|
28 | listeners.add(listener);
|
---|
29 | }
|
---|
30 |
|
---|
31 | public synchronized void removeCancelListener(CancelListener listener) {
|
---|
32 | listeners.remove(listener);
|
---|
33 | }
|
---|
34 |
|
---|
35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.