[Schmitzm-commits] r421 - branches/1.0-gt2-2.6/src/skrueger/swing
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Oct 1 23:06:37 CEST 2009
Author: alfonx
Date: 2009-10-01 23:06:37 +0200 (Thu, 01 Oct 2009)
New Revision: 421
Modified:
branches/1.0-gt2-2.6/src/skrueger/swing/DialogManager.java
Log:
* Last commit before I start changing the DesignAtlasMapViewDialog to extend CancellableDialogAdapter AND switch it's logic to always work on a copy/clone of the map.
Modified: branches/1.0-gt2-2.6/src/skrueger/swing/DialogManager.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/swing/DialogManager.java 2009-10-01 20:22:48 UTC (rev 420)
+++ branches/1.0-gt2-2.6/src/skrueger/swing/DialogManager.java 2009-10-01 21:06:37 UTC (rev 421)
@@ -10,8 +10,8 @@
import org.apache.log4j.Logger;
-public abstract class DialogManager<KEY, DIALOG extends JDialog> extends
- JDialog {
+public abstract class DialogManager<KEY, DIALOG extends JDialog> {
+ final static private Logger LOGGER = Logger.getLogger(DialogManager.class);
public abstract class FactoryInterface {
@@ -19,10 +19,13 @@
}
- final Logger LOGGER = Logger.getLogger(DialogManager.class);
-
private HashMap<KEY, DIALOG> dialogCache = new HashMap<KEY, DIALOG>();
+ /**
+ * A {@link DialogManager} instance can be created for any extension of
+ * {@link JDialog} that will implement the
+ * {@link #getInstanceFor(Object, Component, Object...)} method.
+ */
public DialogManager() {
}
@@ -74,9 +77,7 @@
final DIALOG dialog = dialogCache.get(chartId);
if (dialog != null) {
dialog.dispose();
- if (dialogCache.remove(chartId) == null) {
- LOGGER.warn("Hae?!?!"); //TODO cleanup
- }
+ dialogCache.remove(chartId);
return true;
}
return false;
@@ -88,11 +89,11 @@
* will create the instance by invoking the {@link FactoryInterface} #create
* method.
*
- * @param key
* @param factory
* {@link FactoryInterface} that creates the DIALOG
*
- * @return Always a visible and inFront instance for the given key.
+ * @return Always a visible and inFront instance of DIALOG for the given
+ * key.
*/
public DIALOG getInstanceFor(final KEY key, FactoryInterface factory) {
DIALOG dialog;
@@ -113,20 +114,18 @@
}
return dialog;
}
-
/**
- * Disposes all open instances.
+ * Disposes all open instances and removes them from the cache.
*
* @return <code>true</code> if at least one window has been disposed.
*/
public boolean disposeAll() {
-
+
boolean atLeastOne = false;
HashSet<KEY> tempKeys = new HashSet<KEY>(dialogCache.keySet());
for (KEY key : tempKeys) {
- DIALOG dialog = dialogCache
- .get(key);
+ DIALOG dialog = dialogCache.get(key);
if (dialog != null) {
dialog.dispose();
atLeastOne = true;
@@ -136,5 +135,5 @@
dialogCache.clear();
return atLeastOne;
}
-
+
}
More information about the Schmitzm-commits
mailing list