[Schmitzm-commits] r422 - in branches/1.0-gt2-2.6/src: schmitzm/geotools/gui skrueger/geotools skrueger/swing
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Oct 2 02:47:50 CEST 2009
Author: alfonx
Date: 2009-10-02 02:47:48 +0200 (Fri, 02 Oct 2009)
New Revision: 422
Added:
branches/1.0-gt2-2.6/src/skrueger/swing/CancellableDialogManager.java
Modified:
branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java
branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFS.java
branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFeatureCollection.java
branches/1.0-gt2-2.6/src/skrueger/geotools/StyledRasterPyramidInterface.java
branches/1.0-gt2-2.6/src/skrueger/swing/CancellableDialogAdapter.java
branches/1.0-gt2-2.6/src/skrueger/swing/DialogManager.java
branches/1.0-gt2-2.6/src/skrueger/swing/TranslationAskJDialog.java
Log:
* GP-Feature: Improved/unified dialog management moved further.
* GP-Feature: popup menu in MenuTree allows to edit DpEntries and Maps
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java 2009-10-01 21:06:37 UTC (rev 421)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java 2009-10-02 00:47:48 UTC (rev 422)
@@ -64,8 +64,6 @@
import org.geotools.data.memory.MemoryFeatureCollection;
import org.geotools.factory.GeoTools;
import org.geotools.feature.FeatureCollection;
-import org.geotools.feature.FeatureIterator;
-import org.geotools.feature.NameImpl;
import org.geotools.filter.AbstractFilter;
import org.geotools.filter.GeometryFilterImpl;
import org.geotools.filter.spatial.DWithinImpl;
Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFS.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFS.java 2009-10-01 21:06:37 UTC (rev 421)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFS.java 2009-10-02 00:47:48 UTC (rev 422)
@@ -34,7 +34,6 @@
import java.io.IOException;
import java.net.URL;
import java.util.Date;
-import java.util.HashMap;
import java.util.Random;
import javax.swing.ImageIcon;
Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFeatureCollection.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFeatureCollection.java 2009-10-01 21:06:37 UTC (rev 421)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFeatureCollection.java 2009-10-02 00:47:48 UTC (rev 422)
@@ -31,8 +31,6 @@
import java.io.IOException;
import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
import javax.swing.ImageIcon;
Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/StyledRasterPyramidInterface.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/StyledRasterPyramidInterface.java 2009-10-01 21:06:37 UTC (rev 421)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/StyledRasterPyramidInterface.java 2009-10-02 00:47:48 UTC (rev 422)
@@ -31,9 +31,7 @@
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
-import skrueger.geotools.StyledRasterInterface;
-
public interface StyledRasterPyramidInterface extends
StyledRasterInterface<FeatureCollection<SimpleFeatureType, SimpleFeature>> {
};
Modified: branches/1.0-gt2-2.6/src/skrueger/swing/CancellableDialogAdapter.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/swing/CancellableDialogAdapter.java 2009-10-01 21:06:37 UTC (rev 421)
+++ branches/1.0-gt2-2.6/src/skrueger/swing/CancellableDialogAdapter.java 2009-10-02 00:47:48 UTC (rev 422)
@@ -1,12 +1,21 @@
package skrueger.swing;
-import java.awt.Window;
+import java.awt.Component;
+import java.awt.Dialog;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
+import schmitzm.swing.SwingUtil;
+
+/**
+ * An abstract {@link JDialog} that implements a basic structure of how
+ * cancellable {@link JDialog}s work. The {@link JDialog} is designed to work on
+ * the real object and restore it's state when the user cancels the
+ * {@link JDialog}.
+ */
public abstract class CancellableDialogAdapter extends JDialog implements
CancellableDialog {
@@ -17,11 +26,15 @@
return cancelled;
}
- public CancellableDialogAdapter(final Window parentWindow) {
- super(parentWindow);
+ public CancellableDialogAdapter(final Component parentWindow, String title) {
+ super(SwingUtil.getParentWindow(parentWindow), title);
initDialog();
}
+ public CancellableDialogAdapter(final Component parentWindow) {
+ this(parentWindow, null);
+ }
+
private void initDialog() {
setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
@@ -30,26 +43,56 @@
@Override
public void windowClosing(WindowEvent e) {
- setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
-
- int showConfirmDialog = JOptionPane.showConfirmDialog(
- CancellableDialogAdapter.this, "Speichern?",
- "Änderungen speichern?", JOptionPane.YES_NO_CANCEL_OPTION); // i8n
-
- if (showConfirmDialog == JOptionPane.YES_OPTION)
- okClose();
- else if (showConfirmDialog == JOptionPane.NO_OPTION)
- cancelClose();
+ close();
}
});
}
- public CancellableDialogAdapter(final Window parentWindow, String title) {
- super(parentWindow, title);
- initDialog();
+ /**
+ * Allows to close the {@link JDialog} from "outside". The user will be
+ * asked and she may cancel the close process.
+ */
+ public boolean close() {
+ int showConfirmDialog = JOptionPane.showConfirmDialog(
+ CancellableDialogAdapter.this, "Speichern?",
+ "Änderungen speichern?", JOptionPane.YES_NO_CANCEL_OPTION); // i8n
+
+ if (showConfirmDialog == JOptionPane.YES_OPTION) {
+ return okClose();
+ }
+ else if (showConfirmDialog == JOptionPane.NO_OPTION) {
+ cancelClose();
+ return true;
+ }
+
+ return false;
}
+
+ /**
+ * This method can be called from "outside" to force a close of this
+ * {@link Dialog}. The user can't cancel the process. He may only decide to
+ * save possible changes.
+ */
+ public void forceClose() {
+
+ int res = JOptionPane.showConfirmDialog(
+ CancellableDialogAdapter.this, "Speichern?",
+ "Der Dialog muss nu gesclossen werden. Änderungen speichern?", JOptionPane.YES_NO_OPTION); // i8n
+
+ if (res == JOptionPane.YES_OPTION) {
+ okClose();
+ } else {
+ cancelClose();
+ }
+ }
+
+
+ /**
+ * Default implementation that calls {@link #cancel()} and
+ * {@link #dispose()}.
+ */
@Override
public void cancelClose() {
cancel();
@@ -62,9 +105,13 @@
/**
* This method is called when the dialog is closed and not canceled. Can be
* overwritten to do anything when the dialog has been accepted. For example
- * cheking for any {@link Checkable} components. Returns false, if the ok
- * has been vetoed.
+ * checking for any {@link Checkable} components. <br/>
+ *
+ * @Return <code>false</code>, if the ok has been vetoed.
*/
- public abstract boolean okClose();
+ public boolean okClose() {
+ dispose();
+ return true;
+ }
}
Added: branches/1.0-gt2-2.6/src/skrueger/swing/CancellableDialogManager.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/swing/CancellableDialogManager.java 2009-10-01 21:06:37 UTC (rev 421)
+++ branches/1.0-gt2-2.6/src/skrueger/swing/CancellableDialogManager.java 2009-10-02 00:47:48 UTC (rev 422)
@@ -0,0 +1,42 @@
+package skrueger.swing;
+
+
+public abstract class CancellableDialogManager<KEY, DIALOG extends CancellableDialogAdapter>
+ extends DialogManager<KEY, DIALOG> {
+
+ /**
+ * 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();
+ }
+ }
+
+ /**
+ * 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;
+ }
+ return true;
+ }
+
+ /**
+ * Tells the suer that the dialog shall be closed. The user may save, cancel or abort the closing.
+ *
+ * @return <code>true</code> if there is no open instance or the instance has been disposed
+ */
+ public boolean close(KEY key) {
+ if (isVisibleFor(key)) {
+ return getInstanceFor(key, null).close();
+ }
+
+ return true;
+ }
+
+}
Property changes on: branches/1.0-gt2-2.6/src/skrueger/swing/CancellableDialogManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id URL
Name: svn:eol-style
+ native
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 21:06:37 UTC (rev 421)
+++ branches/1.0-gt2-2.6/src/skrueger/swing/DialogManager.java 2009-10-02 00:47:48 UTC (rev 422)
@@ -3,6 +3,7 @@
import java.awt.Component;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -19,7 +20,7 @@
}
- private HashMap<KEY, DIALOG> dialogCache = new HashMap<KEY, DIALOG>();
+ protected HashMap<KEY, DIALOG> dialogCache = new HashMap<KEY, DIALOG>();
/**
* A {@link DialogManager} instance can be created for any extension of
@@ -136,4 +137,12 @@
return atLeastOne;
}
+ /**
+ * @return All instances of DIALOG as they are cached.
+ */
+ public Collection<DIALOG> getAllInstances() {
+ return dialogCache.values();
+ }
+
+
}
Modified: branches/1.0-gt2-2.6/src/skrueger/swing/TranslationAskJDialog.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/swing/TranslationAskJDialog.java 2009-10-01 21:06:37 UTC (rev 421)
+++ branches/1.0-gt2-2.6/src/skrueger/swing/TranslationAskJDialog.java 2009-10-02 00:47:48 UTC (rev 422)
@@ -44,7 +44,6 @@
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
-import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.KeyStroke;
More information about the Schmitzm-commits
mailing list