package skrueger.swing; public abstract class CancellableDialogManager extends DialogManager { /** * Will force a dispose of all dialogs, but the user may decide whether she * wants to save anything first. */ public void forceCloseAllInstances() { for (DIALOG d : getAllInstances()) { d.forceClose(); } dialogCache.clear(); } /** * Will try to close all dialogs, but the user may decide whether she * wants to save anything first or abort the closing. */ public boolean closeAllInstances() { for (DIALOG d : getAllInstances()) { if (!d.close()) return false; } dialogCache.clear(); return true; } /** * Tells the user that the dialog shall be closed. The user may save, cancel or abort the closing. * * @return true if there is no open instance or the instance has been disposed */ public boolean close(KEY key) { if (isVisibleFor(key)) { boolean closeResult = getInstanceFor(key, null).close(); if (closeResult) dialogCache.remove(key); return closeResult; } dialogCache.remove(key); return true; } }