[Schmitzm-commits] r1499 - trunk/schmitzm-core/src/main/java/de/schmitzm/swing

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Feb 10 02:21:13 CET 2011


Author: alfonx
Date: 2011-02-10 02:21:11 +0100 (Thu, 10 Feb 2011)
New Revision: 1499

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/TranslationAskJDialog.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/TranslationEditJPanel.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/TranslationsAskJPanel.java
Log:
* Changed the default font size.
* Improved the language defaults dialog.. with little success :-(

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/TranslationAskJDialog.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/TranslationAskJDialog.java	2011-02-10 00:30:02 UTC (rev 1498)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/TranslationAskJDialog.java	2011-02-10 01:21:11 UTC (rev 1499)
@@ -29,7 +29,6 @@
  ******************************************************************************/
 package de.schmitzm.swing;
 
-import java.awt.BorderLayout;
 import java.awt.Component;
 import java.awt.FlowLayout;
 import java.awt.event.ActionEvent;
@@ -47,8 +46,10 @@
 import javax.swing.JRootPane;
 import javax.swing.KeyStroke;
 
-public class TranslationAskJDialog extends CancellableDialogAdapter{
+import net.miginfocom.swing.MigLayout;
 
+public class TranslationAskJDialog extends CancellableDialogAdapter {
+
 	private OkButton okButton;
 	private CancelButton cancelButton;
 
@@ -132,23 +133,28 @@
 		this.translationEditJPanelsOrJustComponents = translationEditJPanels;
 
 		init();
+
 	}
 
-
 	private void init() {
 		setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
 		addWindowListener(new WindowAdapter() {
 
+			@Override
 			public void windowClosing(WindowEvent e) {
 				cancel();
 			}
 
 		});
-		
-		translationsAskPane = new TranslationsAskJPanel(translationEditJPanelsOrJustComponents);
-		JPanel cp = new JPanel(new BorderLayout());
-		cp.add(translationsAskPane, BorderLayout.WEST);
-		cp.add(getButtons(), BorderLayout.SOUTH);
+
+		translationsAskPane = new TranslationsAskJPanel(
+				translationEditJPanelsOrJustComponents);
+		JPanel cp = new JPanel(new MigLayout("wrap 1, insets 1, gap 0"));
+		cp.add(translationsAskPane, "");
+		cp.add(getButtons(), "bottom");
+		// JPanel cp = new JPanel(new BorderLayout());
+		// cp.add(translationsAskPane, BorderLayout.WEST);
+		// cp.add(getButtons(), BorderLayout.SOUTH);
 		setContentPane(cp);
 
 		setTitle(SwingUtil.R("TranslationAskJDialog.Title"));
@@ -176,7 +182,6 @@
 		dispose();
 	}
 
-
 	private JComponent getButtons() {
 		JPanel jPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
 
@@ -231,27 +236,26 @@
 	 * This method is only called when the dialog is closed and not canceled.
 	 * Can be overwritten to do anything when the dialog has been accepted.
 	 */
+	@Override
 	public boolean okClose() {
 
 		if (!translationsAskPane.checkValidInputs())
 			return false;
-		
-		
+
 		dispose();
-		
-		TranslationAskJDialog.this.firePropertyChange(
-				PROPERTY_APPLY_AND_CLOSE, null, null);
+
+		TranslationAskJDialog.this.firePropertyChange(PROPERTY_APPLY_AND_CLOSE,
+				null, null);
 		return true;
 	}
 
-
-
 	/**
 	 * After the modal dialog has been closed, this allows to find out, whether
 	 * the {@link Component} has been canceled.
 	 * 
 	 * @return <code>true</code> if the {@link JDialog} has been canceled.
 	 */
+	@Override
 	public boolean isCancelled() {
 		return hasBeenCanceled;
 	}

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/TranslationEditJPanel.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/TranslationEditJPanel.java	2011-02-10 00:30:02 UTC (rev 1498)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/TranslationEditJPanel.java	2011-02-10 01:21:11 UTC (rev 1499)
@@ -29,8 +29,8 @@
  ******************************************************************************/
 package de.schmitzm.swing;
 
-import java.awt.BorderLayout;
 import java.awt.Dimension;
+import java.awt.Font;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.util.HashMap;
@@ -44,6 +44,8 @@
 import javax.swing.SpringLayout;
 import javax.swing.SwingConstants;
 
+import net.miginfocom.swing.MigLayout;
+
 import org.apache.log4j.Logger;
 
 import de.schmitzm.i18n.Translation;
@@ -64,13 +66,13 @@
 
 	private final List<String> languages;
 	private JPanel translationGrid;
-	private Translation trans;
+	private final Translation trans;
 
 	/**
 	 * Remembers all {@link JTextField} that have been created.
 	 */
-	private HashMap<String, TranslationJTextField> langTextFields = new HashMap<String, TranslationJTextField>();
-	private WeakHashMap<ActionListener, ActionListener> actionListeners = new WeakHashMap<ActionListener, ActionListener>();
+	private final HashMap<String, TranslationJTextField> langTextFields = new HashMap<String, TranslationJTextField>();
+	private final WeakHashMap<ActionListener, ActionListener> actionListeners = new WeakHashMap<ActionListener, ActionListener>();
 
 	private final String question;
 
@@ -89,7 +91,7 @@
 	 */
 	public TranslationEditJPanel(String question, Translation trans,
 			List<String> languages_) {
-		super(new BorderLayout());
+		super(new MigLayout("wrap 2, gap 1, insets 1"));
 		this.question = question;
 
 		SwingUtil.setMinimumWidth(this, 400);
@@ -104,14 +106,39 @@
 	}
 
 	private void initGUI() {
-		add(getTranslationGrid(), BorderLayout.CENTER);
+		// add(getTranslationGrid(), BorderLayout.CENTER);
 
 		if (question != null) {
 			JLabel questionLable = new JLabel(question);
 			questionLable
-					.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
-			add(questionLable, BorderLayout.NORTH);
+					.setFont(questionLable.getFont().deriveFont(Font.BOLD));
+			// questionLable
+			// .setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
+			add(questionLable, "span 2, gap rel");
 		}
+
+		for (String langId : languages) {
+
+			// language code : entry field for translation
+			JLabel langDesc = new JLabel(langId.toUpperCase() + " :");
+			// langDesc.setHorizontalAlignment(SwingConstants.RIGHT);
+			// langDesc.setVerticalAlignment(SwingConstants.NORTH);
+
+			TranslationJTextField langTextField = langTextFields.get(langId);
+
+			if (langTextField == null) {
+				langTextField = new TranslationJTextField(trans, langId);
+				// Setting a size
+				langTextField.setPreferredSize(new Dimension(360, 22));
+				langDesc.setLabelFor(langTextField);
+			}
+
+			add(langDesc, "sgxk");
+			add(langTextField, "sgxv");
+
+			langTextFields.put(langId, langTextField);
+		}
+
 	}
 
 	/**
@@ -156,11 +183,12 @@
 				langTextFields.put(langId, langTextField);
 			}
 
-			// Lay out the panel.
-			SpringUtilities.makeCompactGrid(translationGrid, languages.size(), // rows,
-					2, // cols
-					6, 6, // initX, initY
-					6, 6); // xPad, yPad
+			// // Lay out the panel.
+			// SpringUtilities.makeCompactGrid(translationGrid,
+			// languages.size(), // rows,
+			// 2, // cols
+			// 6, 6, // initX, initY
+			// 6, 6); // xPad, yPad
 
 		}
 		return translationGrid;
@@ -206,5 +234,4 @@
 		}
 	}
 
-
 }

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/TranslationsAskJPanel.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/TranslationsAskJPanel.java	2011-02-10 00:30:02 UTC (rev 1498)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/TranslationsAskJPanel.java	2011-02-10 01:21:11 UTC (rev 1499)
@@ -1,15 +1,15 @@
 package de.schmitzm.swing;
 
-import javax.swing.BorderFactory;
 import javax.swing.JComponent;
 import javax.swing.JOptionPane;
 
 import net.miginfocom.swing.MigLayout;
 import de.schmitzm.i18n.Translation;
 
-public class TranslationsAskJPanel extends JPanel implements Cancellable, Checkable {
+public class TranslationsAskJPanel extends JPanel implements Cancellable,
+		Checkable {
 
-	private String[] backup = new String[50]; // Maximum 50 languages
+	private final String[] backup = new String[50]; // Maximum 50 languages
 	private final JComponent[] translationEditJPanelsOrJustComponents;
 
 	public TranslationsAskJPanel(
@@ -31,7 +31,7 @@
 
 		for (JComponent panel : translationEditJPanelsOrJustComponents) {
 			panel.setAlignmentX(java.awt.Component.LEFT_ALIGNMENT);
-			panel.setBorder(BorderFactory.createEmptyBorder(5, 6, 5, 6));
+			// panel.setBorder(BorderFactory.createEmptyBorder(2, 4, 3, 3));
 			add(panel);
 		}
 
@@ -69,7 +69,6 @@
 			}
 		}
 	}
-	
 
 	/**
 	 * @return <code>true</code> if none of the translations contains illegal
@@ -82,16 +81,16 @@
 				TranslationEditJPanel tep = (TranslationEditJPanel) component;
 
 				final Translation translationToCheck = tep.getTranslation();
-				
+
 				if (!Translation.checkValid(translationToCheck)) {
 					JOptionPane
-					.showMessageDialog(
-							this,
-							SwingUtil
-									.R("TranslationAskJDialog.ErrorMsg.InvalidCharacterInTranslation"));	
+							.showMessageDialog(
+									this,
+									SwingUtil
+											.R("TranslationAskJDialog.ErrorMsg.InvalidCharacterInTranslation"));
 					return false;
 				}
-				
+
 			}
 		}
 



More information about the Schmitzm-commits mailing list