KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > retouche > editor > semantic > ScanningCancellableTask


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.retouche.editor.semantic;
20 import org.netbeans.api.gsf.CancellableTask;
21
22 /**
23  * This file is originally from Retouche, the Java Support
24  * infrastructure in NetBeans. I have modified the file as little
25  * as possible to make merging Retouche fixes back as simple as
26  * possible.
27  *
28  *
29  * @author Jan Lahoda
30  */

31 public abstract class ScanningCancellableTask<T> implements CancellableTask<T> {
32
33     private boolean canceled;
34
35     /** Creates a new instance of ScanningCancellableTask */
36     protected ScanningCancellableTask() {
37     }
38
39     public final synchronized void cancel() {
40         System.err.println("ScanningCancellableTask.cancel: Not yet implemented");
41 // canceled = true;
42
//
43
// if (pathScanner != null) {
44
// pathScanner.cancel();
45
// }
46
// if (scanner != null) {
47
// scanner.cancel();
48
// }
49
}
50
51     public abstract void run(T parameter) throws Exception JavaDoc;
52     
53     protected final synchronized boolean isCancelled() {
54         return canceled;
55     }
56     
57     protected final synchronized void resume() {
58         canceled = false;
59     }
60     
61 // private CancellableTreePathScanner pathScanner;
62
// private CancellableTreeScanner scanner;
63
//
64
// protected <R, P> R scan(CancellableTreePathScanner<R, P> scanner, Tree toScan, P p) {
65
// if (isCancelled())
66
// return null;
67
//
68
// try {
69
// synchronized (this) {
70
// this.pathScanner = scanner;
71
// }
72
//
73
// if (isCancelled())
74
// return null;
75
//
76
// return scanner.scan(toScan, p);
77
// } finally {
78
// synchronized (this) {
79
// this.pathScanner = null;
80
// }
81
// }
82
// }
83
//
84
// protected <R, P> R scan(CancellableTreeScanner<R, P> scanner, Tree toScan, P p) {
85
// if (isCancelled())
86
// return null;
87
//
88
// try {
89
// synchronized (this) {
90
// this.scanner = scanner;
91
// }
92
//
93
// if (isCancelled())
94
// return null;
95
//
96
// return scanner.scan(toScan, p);
97
// } finally {
98
// synchronized (this) {
99
// this.scanner = null;
100
// }
101
// }
102
// }
103
//
104
}
105
Popular Tags