1 |
alfonx |
422 |
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 |
alfonx |
615 |
dialogCache.clear(); |
16 |
alfonx |
422 |
} |
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 |
alfonx |
615 |
|
28 |
|
|
dialogCache.clear(); |
29 |
alfonx |
422 |
return true; |
30 |
|
|
} |
31 |
|
|
|
32 |
|
|
/** |
33 |
alfonx |
509 |
* Tells the user that the dialog shall be closed. The user may save, cancel or abort the closing. |
34 |
alfonx |
422 |
* |
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 |
alfonx |
615 |
boolean closeResult = getInstanceFor(key, null).close(); |
40 |
|
|
if (closeResult) dialogCache.remove(key); |
41 |
|
|
return closeResult; |
42 |
alfonx |
422 |
} |
43 |
alfonx |
615 |
dialogCache.remove(key); |
44 |
alfonx |
422 |
return true; |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
} |