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 |
} |
16 |
|
17 |
/** |
18 |
* Will try to close all dialogs, but the user may decide whether she |
19 |
* wants to save anything first or abort the closing. |
20 |
*/ |
21 |
public boolean closeAllInstances() { |
22 |
for (DIALOG d : getAllInstances()) { |
23 |
if (!d.close()) |
24 |
return false; |
25 |
} |
26 |
return true; |
27 |
} |
28 |
|
29 |
/** |
30 |
* Tells the user that the dialog shall be closed. The user may save, cancel or abort the closing. |
31 |
* |
32 |
* @return <code>true</code> if there is no open instance or the instance has been disposed |
33 |
*/ |
34 |
public boolean close(KEY key) { |
35 |
if (isVisibleFor(key)) { |
36 |
return getInstanceFor(key, null).close(); |
37 |
} |
38 |
|
39 |
return true; |
40 |
} |
41 |
|
42 |
} |