[Schmitzm-commits] r33 - trunk/src/skrueger/swing

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sat Mar 28 18:06:27 CET 2009


Author: alfonx
Date: 2009-03-28 18:06:27 +0100 (Sat, 28 Mar 2009)
New Revision: 33

Modified:
   trunk/src/skrueger/swing/TranslationAskJDialog.java
   trunk/src/skrueger/swing/TranslationEditJPanel.java
Log:
The cancel mechanism of these didn't work. Thanks to AR for reporting this.

Modified: trunk/src/skrueger/swing/TranslationAskJDialog.java
===================================================================
--- trunk/src/skrueger/swing/TranslationAskJDialog.java	2009-03-28 16:44:24 UTC (rev 32)
+++ trunk/src/skrueger/swing/TranslationAskJDialog.java	2009-03-28 17:06:27 UTC (rev 33)
@@ -88,14 +88,27 @@
 
 	/**
 	 * This class handles the cancel button itself. You may still want to listen
-	 * to PROPERTY_APPLY_AND_CLOSE events.
-	 * This dialog is modal. The dialog has to be set visible afterwards. 
+	 * to PROPERTY_APPLY_AND_CLOSE events. This dialog is modal. The dialog has
+	 * to be set visible afterwards.
 	 */
 	public TranslationAskJDialog(Window owner,
 			final JComponent... translationEditJPanels) {
 		super(owner);
 		this.translationEditJPanelsOrJustComponents = translationEditJPanels;
 		init();
+
+		// Rememebr backups for all the jtextpanels
+		int count = 0;
+		for (JComponent component : translationEditJPanelsOrJustComponents) {
+			if (component instanceof TranslationEditJPanel) {
+				TranslationEditJPanel tep = (TranslationEditJPanel) component;
+				Translation orig = tep.getTranslation();
+				// We dont' want to overwrite the Translation object on
+				// restore(). We just want to change its values.
+
+				backup[count++] = orig.toOneLine();
+			}
+		}
 	}
 
 	private void init() {
@@ -136,9 +149,8 @@
 		for (JComponent component : translationEditJPanelsOrJustComponents) {
 			if (component instanceof TranslationEditJPanel) {
 				TranslationEditJPanel tep = (TranslationEditJPanel) component;
-				tep.getTranslation().fromOneLine(backup[count]);
+				tep.getTranslation().fromOneLine(backup[count++]);
 			}
-			count++;
 		}
 	}
 
@@ -233,7 +245,9 @@
 	}
 
 	/**
-	 * After the modal dialog has been closed, this allows to find out, wether the dialog has been canceled.
+	 * After the modal dialog has been closed, this allows to find out, wether
+	 * the dialog has been canceled.
+	 * 
 	 * @return
 	 */
 	public boolean isHasBeenCanceled() {

Modified: trunk/src/skrueger/swing/TranslationEditJPanel.java
===================================================================
--- trunk/src/skrueger/swing/TranslationEditJPanel.java	2009-03-28 16:44:24 UTC (rev 32)
+++ trunk/src/skrueger/swing/TranslationEditJPanel.java	2009-03-28 17:06:27 UTC (rev 33)
@@ -28,7 +28,7 @@
 import skrueger.i8n.Translation;
 
 /**
- * A JPanel that asks the user for translation of several strings 
+ * A {@link JPanel} that asks the user for translation of several strings 
  * @author Stefan Alfons Krüger
  *
  */
@@ -198,6 +198,9 @@
 		return jPanel;
 	}
 	
+	/**
+	 * @return The {@link Translation} that this {@link TranslationEditJPanel} deals with.
+	 */
 	public Translation getTranslation() {
 		return trans;
 	}



More information about the Schmitzm-commits mailing list