1 |
package skrueger.swing; |
2 |
|
3 |
|
4 |
public abstract class CancellableDialogManager<KEY, DIALOG extends CancellableDialogAdapter> |
5 |
extends DialogManager<KEY, DIALOG> { |
6 |
|
7 |
/** |
8 |
* Will force a dispose of all dialogs, but the user may decide whether she |
9 |
* wants to save anything first. |
10 |
*/ |
11 |
public void forceCloseAllInstances() { |
12 |
for (DIALOG d : getAllInstances()) { |
13 |
d.forceClose(); |
14 |
} |
15 |
dialogCache.clear(); |
16 |
} |
17 |
|
18 |
/** |
19 |
* Will try to close all dialogs, but the user may decide whether she |
20 |
* wants to save anything first or abort the closing. |
21 |
*/ |
22 |
public boolean closeAllInstances() { |
23 |
for (DIALOG d : getAllInstances()) { |
24 |
if (!d.close()) |
25 |
return false; |
26 |
} |
27 |
|
28 |
dialogCache.clear(); |
29 |
return true; |
30 |
} |
31 |
|
32 |
/** |
33 |
* Tells the user that the dialog shall be closed. The user may save, cancel or abort the closing. |
34 |
* |
35 |
* @return <code>true</code> if there is no open instance or the instance has been disposed |
36 |
*/ |
37 |
public boolean close(KEY key) { |
38 |
if (isVisibleFor(key)) { |
39 |
boolean closeResult = getInstanceFor(key, null).close(); |
40 |
if (closeResult) dialogCache.remove(key); |
41 |
return closeResult; |
42 |
} |
43 |
dialogCache.remove(key); |
44 |
return true; |
45 |
} |
46 |
|
47 |
} |