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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Aug 17 14:45:49 CEST 2009


Author: alfonx
Date: 2009-08-17 14:45:48 +0200 (Mon, 17 Aug 2009)
New Revision: 302

Modified:
   trunk/src/skrueger/swing/TranslationAskJDialog.java
   trunk/src/skrueger/swing/TranslationJTextField.java
Log:
* GP-Feature: the EditSpEntry-GUI now also allows to define a charset to be used for the DBF file.

Modified: trunk/src/skrueger/swing/TranslationAskJDialog.java
===================================================================
--- trunk/src/skrueger/swing/TranslationAskJDialog.java	2009-08-15 17:28:39 UTC (rev 301)
+++ trunk/src/skrueger/swing/TranslationAskJDialog.java	2009-08-17 12:45:48 UTC (rev 302)
@@ -126,7 +126,7 @@
 	 * Using this constructor, you have to call setComponents afterwards.
 	 */
 	public TranslationAskJDialog(Component owner) {
-		this(owner, new JComponent[] {});
+		super(SwingUtil.getParentWindow(owner));
 	}
 
 	/**
@@ -143,6 +143,16 @@
 	public void setComponents(final JComponent... translationEditJPanels) {
 		this.translationEditJPanelsOrJustComponents = translationEditJPanels;
 
+		backup();
+
+		init();
+	}
+
+	/**
+	 * Stores the original values of all {@link TranslationEditJPanel}s so
+	 * cancel works.
+	 */
+	protected void backup() {
 		// Remember backups for all the TranslationEditJPanel
 		int count = 0;
 		for (JComponent component : translationEditJPanelsOrJustComponents) {
@@ -155,8 +165,6 @@
 				backup[count++] = orig.toOneLine();
 			}
 		}
-
-		init();
 	}
 
 	private void init() {
@@ -172,16 +180,16 @@
 		Box box = Box.createVerticalBox();
 		for (JComponent panel : translationEditJPanelsOrJustComponents) {
 			panel.setAlignmentX(java.awt.Component.LEFT_ALIGNMENT);
-			panel.setBorder( BorderFactory.createEmptyBorder(5, 6, 5, 6));
+			panel.setBorder(BorderFactory.createEmptyBorder(5, 6, 5, 6));
 			box.add(panel);
-			
+
 		}
 		JPanel cp = new JPanel(new BorderLayout());
 		cp.add(box, BorderLayout.WEST);
 		cp.add(getButtons(), BorderLayout.SOUTH);
 		setContentPane(cp);
-		
-		setTitle(SwingUtil.R("TranslationAskJDialog.Title")); 
+
+		setTitle(SwingUtil.R("TranslationAskJDialog.Title"));
 		setModal(true);
 		pack();
 	}
@@ -191,13 +199,20 @@
 		init();
 	}
 
+	/**
+	 * Called when the dilaog is closed using the cancel button.
+	 */
 	protected void cancel() {
+		restore();
 		firePropertyChange(PROPERTY_CANCEL_AND_CLOSE, null, null);
-		restore();
+		setCancelled(true);
 		setVisible(false);
 		dispose();
 	}
 
+	/**
+	 * Used to restore all the values when cancel has been pressed.
+	 */
 	protected void restore() {
 		int count = 0;
 		for (JComponent component : translationEditJPanelsOrJustComponents) {
@@ -229,9 +244,9 @@
 					putValue(Action.MNEMONIC_KEY, new Integer(
 							java.awt.event.KeyEvent.VK_E));
 
-					// Set tool tip text
-					putValue(Action.SHORT_DESCRIPTION,
-							"Accept the changes made to the translation.");
+					// // Set tool tip text
+					// putValue(Action.SHORT_DESCRIPTION,
+					// "Accept the changes made to the translation."); //i8n
 
 				}
 
@@ -242,8 +257,8 @@
 					if (!checkValidInputs())
 						return;
 
-					setVisible(false);
-					dispose();
+					okClose();
+
 				}
 
 			});
@@ -254,12 +269,13 @@
 		if (cancelButton == null) {
 			cancelButton = new CancelButton(new AbstractAction("") {
 				public void actionPerformed(ActionEvent evt) {
-					restore();
-					TranslationAskJDialog.this.firePropertyChange(
-							PROPERTY_CANCEL_AND_CLOSE, null, null);
-					setVisible(false);
-					setCancelled(true);
-					dispose();
+//					restore();
+//					TranslationAskJDialog.this.firePropertyChange(
+//							PROPERTY_CANCEL_AND_CLOSE, null, null);
+//					setVisible(false);
+//					setCancelled(true);
+//					dispose();
+					cancel();
 				}
 			});
 		}
@@ -269,6 +285,15 @@
 	}
 
 	/**
+	 * This method is only called when the dialog is closed and not cancelled.
+	 * Can be overwritten to do anything when the dialog has been accepted.
+	 */
+	protected void okClose() {
+		setVisible(false);
+		dispose();
+	}
+
+	/**
 	 * @return <code>true</code> if none of the translations contains illegal
 	 *         characters.
 	 */
@@ -283,7 +308,8 @@
 						JOptionPane
 								.showMessageDialog(
 										this,
-										SwingUtil.R("TranslationAskJDialog.ErrorMsg.InvalidCharacterInTranslation"));
+										SwingUtil
+												.R("TranslationAskJDialog.ErrorMsg.InvalidCharacterInTranslation"));
 						return false;
 					}
 				}

Modified: trunk/src/skrueger/swing/TranslationJTextField.java
===================================================================
--- trunk/src/skrueger/swing/TranslationJTextField.java	2009-08-15 17:28:39 UTC (rev 301)
+++ trunk/src/skrueger/swing/TranslationJTextField.java	2009-08-17 12:45:48 UTC (rev 302)
@@ -120,11 +120,12 @@
 
 			@Override
 			public void actionPerformed(ActionEvent e) {
-				LOGGER.debug("ActionListener called ");
+//				LOGGER.debug("ActionListener called ");
 
-				if (e.getSource() == trans
-						&& langCode.equals(e.getActionCommand())) {
-					LOGGER.debug(" and omittet!\n");
+				if (e.getSource() == trans) 
+//						&& langCode.equals(e.getActionCommand())) 
+						{
+//					LOGGER.debug(" and omittet!\n");
 					return;
 				}
 				LOGGER.debug(" and performed!\n");



More information about the Schmitzm-commits mailing list