[Schmitzm-commits] r1438 - in trunk/schmitzm-core/src: main/java/de/schmitzm/i18n main/java/de/schmitzm/swing test/java/de/schmitzm/i18n test/java/de/schmitzm/swing
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Jan 27 13:53:33 CET 2011
Author: alfonx
Date: 2011-01-27 13:53:32 +0100 (Thu, 27 Jan 2011)
New Revision: 1438
Added:
trunk/schmitzm-core/src/test/java/de/schmitzm/swing/CancelButtonTest.java
trunk/schmitzm-core/src/test/java/de/schmitzm/swing/OkButtonTest.java
Modified:
trunk/schmitzm-core/src/main/java/de/schmitzm/i18n/SwitchLanguageDialog.java
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/CancelButton.java
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/OkButton.java
trunk/schmitzm-core/src/test/java/de/schmitzm/i18n/SwitchLanguageDialogTest.java
Log:
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/i18n/SwitchLanguageDialog.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/i18n/SwitchLanguageDialog.java 2011-01-27 12:37:43 UTC (rev 1437)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/i18n/SwitchLanguageDialog.java 2011-01-27 12:53:32 UTC (rev 1438)
@@ -56,119 +56,121 @@
* @author Stefan A. Tzeggai
*/
public class SwitchLanguageDialog extends AtlasDialog {
- protected Logger LOGGER = Logger.getLogger(SwitchLanguageDialog.class);
+ protected Logger LOGGER = Logger.getLogger(SwitchLanguageDialog.class);
- private JPanel jContentPane = null;
+ final private ImageIcon flagImageIcon = new ImageIcon(
+ TranslationEditJPanel.class.getResource("/de/schmitzm/swing/resource/images/flags.jpg"));
- private JLabel jLabelFlagimage = null;
+ private JPanel jContentPane = null;
- private JPanel jPanel = null;
+ private JLabel jLabelFlagimage = null;
- private JLabel jLabel = null;
-
- private OkButton jButton = null;
+ private JPanel jPanel = null;
- private LanguagesComboBox jComboBox = null;
+ private JLabel jLabel = null;
- private final List<String> languages;
+ private OkButton jButton = null;
- /**
- * if <code>true</code>, the default locale will also be changed during a
- * language selection
- **/
- protected boolean setLocale;
+ private LanguagesComboBox jComboBox = null;
- /**
- * A dialog to select one of the available languages. If only one language
- * is available, select it directly. Creating this object automatically
- * makes it visible, unless there is only one language to choose from.. it
- * that case it disposes itself automatically.
- *
- * @param setLocale if <code>true</code>, the default locale will also be
- * changed during a language selection
- */
- public SwitchLanguageDialog(final Component owner,
- final List<String> languages, boolean setLocale) {
- super(owner);
- this.languages = languages;
- this.setLocale = setLocale;
+ private final List<String> languages;
- if (languages == null || languages.size() == 0) {
- // No language is available.
- return;
- }
+ /**
+ * if <code>true</code>, the default locale will also be changed during a
+ * language selection
+ **/
+ protected boolean setLocale;
- Translation.setActiveLang(languages.get(0), setLocale);
- if (languages.size() == 1) {
- // Only language one language is available. It has been selected
- // automatically.
- return;
- }
+ /**
+ * A dialog to select one of the available languages. If only one language
+ * is available, select it directly. Creating this object automatically
+ * makes it visible, unless there is only one language to choose from.. it
+ * that case it disposes itself automatically.
+ *
+ * @param setLocale
+ * if <code>true</code>, the default locale will also be changed
+ * during a language selection
+ */
+ public SwitchLanguageDialog(final Component owner,
+ final List<String> languages, boolean setLocale) {
+ super(owner);
+ this.languages = languages;
+ this.setLocale = setLocale;
- initialize();
- }
+ if (languages == null || languages.size() == 0) {
+ // No language is available.
+ return;
+ }
- @Override
- /**
- * This modal dialog will not appear if there is <= one language to select from.
- */
- public void setVisible(boolean b) {
- if (b == true && (languages == null || languages.size() <= 1)) {
- return;
- }
- super.setVisible(b);
- }
+ Translation.setActiveLang(languages.get(0), setLocale);
+ if (languages.size() == 1) {
+ // Only language one language is available. It has been selected
+ // automatically.
+ return;
+ }
- /**
- * This method initializes this
- *
- * @return void
- */
- private void initialize() {
- this.setContentPane(getJContentPane());
+ initialize();
+ }
- pack();
+ @Override
+ /**
+ * This modal dialog will not appear if there is <= one language to select from.
+ */
+ public void setVisible(boolean b) {
+ if (b == true && (languages == null || languages.size() <= 1)) {
+ return;
+ }
+ super.setVisible(b);
+ }
- SwingUtil.centerFrameOnScreenRandom(this);
- setModal(true);
- }
+ /**
+ * This method initializes this
+ *
+ * @return void
+ */
+ private void initialize() {
+ this.setContentPane(getJContentPane());
- public boolean close() {
- // Only close by ESC and window-close if a valid selection is made
- if (jComboBox.getSelectedIndex() == languages.size()
- || jComboBox.getSelectedIndex() == -1)
- return false;
- else
- return super.close();
- }
+ pack();
- /**
- * This method initializes jContentPane
- *
- * @return javax.swing.JPanel
- */
- private JPanel getJContentPane() {
- if (jContentPane == null) {
- jLabelFlagimage = new JLabel(new ImageIcon(
- TranslationEditJPanel.class
- .getResource("resource/flags.jpg")));
- jContentPane = new JPanel();
- MigLayout migLayout = new MigLayout("wrap 1", "[center]", "[]0[]");
- jContentPane.setLayout(migLayout);
- jContentPane.add(jLabelFlagimage, "north");
- jContentPane.add(getLanguageCombobox());
- jContentPane.add(getOkButton(),
- "right, w 50!, gaptop 5, gapright 5, gapbottom 5");
- }
- return jContentPane;
- }
-
- /**
+ SwingUtil.centerFrameOnScreenRandom(this);
+ setModal(true);
+ }
+
+ public boolean close() {
+ // Only close by ESC and window-close if a valid selection is made
+ if (jComboBox.getSelectedIndex() == languages.size()
+ || jComboBox.getSelectedIndex() == -1)
+ return false;
+ else
+ return super.close();
+ }
+
+ /**
+ * This method initializes jContentPane
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jLabelFlagimage = new JLabel(flagImageIcon);
+ jContentPane = new JPanel();
+ MigLayout migLayout = new MigLayout("wrap 1", "[center]", "[]0[]");
+ jContentPane.setLayout(migLayout);
+ jContentPane.add(jLabelFlagimage, "north");
+ jContentPane.add(getLanguageCombobox());
+ jContentPane.add(getOkButton(),
+ "right, w 50!, gaptop 5, gapright 5, gapbottom 5");
+ }
+ return jContentPane;
+ }
+
+ /**
* This method initializes the OkButton
*
* @return javax.swing.JButton
*/
- @Override
+ @Override
protected OkButton getOkButton() {
if (jButton == null) {
jButton = new OkButton();
@@ -184,62 +186,62 @@
}
return jButton;
}
-
+
/**
- * This method initializes the JPanel that carries the select language
- * combobox
- *
- * @return javax.swing.JPanel
- */
- private JPanel getLanguageCombobox() {
- if (jPanel == null) {
- jLabel = new JLabel();
- jLabel.setText("Select language: "); // i8n!?! Maybe replace with an
- // icon of an index finger
- jPanel = new JPanel();
- jPanel.add(jLabel);
- jPanel.add(getJComboBox());
- }
- return jPanel;
- }
+ * This method initializes the JPanel that carries the select language
+ * combobox
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getLanguageCombobox() {
+ if (jPanel == null) {
+ jLabel = new JLabel();
+ jLabel.setText("Select language: "); // i8n!?! Maybe replace with an
+ // icon of an index finger
+ jPanel = new JPanel();
+ jPanel.add(jLabel);
+ jPanel.add(getJComboBox());
+ }
+ return jPanel;
+ }
- /**
- * This method initializes the Select Language Combobox
- *
- * @return javax.swing.JComboBox
- */
- private JComboBox getJComboBox() {
- if (jComboBox == null) {
- ArrayList<String> languagesPlusOne = new ArrayList<String>(
- languages);
- languagesPlusOne.add("?");
+ /**
+ * This method initializes the Select Language Combobox
+ *
+ * @return javax.swing.JComboBox
+ */
+ private JComboBox getJComboBox() {
+ if (jComboBox == null) {
+ ArrayList<String> languagesPlusOne = new ArrayList<String>(
+ languages);
+ languagesPlusOne.add("?");
- jComboBox = new LanguagesComboBox(languages);
+ jComboBox = new LanguagesComboBox(languages);
- SwingUtil.addMouseWheelForCombobox(jComboBox);
- jComboBox.addActionListener(new ActionListener() {
+ SwingUtil.addMouseWheelForCombobox(jComboBox);
+ jComboBox.addActionListener(new ActionListener() {
- public void actionPerformed(final ActionEvent e) {
- if (jComboBox.getSelectedIndex() == languages.size()) {
- getOkButton().setEnabled(false);
- return;
- }
+ public void actionPerformed(final ActionEvent e) {
+ if (jComboBox.getSelectedIndex() == languages.size()) {
+ getOkButton().setEnabled(false);
+ return;
+ }
- String l = languages.get(jComboBox.getSelectedIndex());
- try {
- Translation.setActiveLang(l, setLocale);
+ String l = languages.get(jComboBox.getSelectedIndex());
+ try {
+ Translation.setActiveLang(l, setLocale);
- getOkButton().setEnabled(true);
- } catch (java.lang.IllegalArgumentException ee) {
- LOGGER.warn("The language " + l + " is not valid", ee);
- getOkButton().setEnabled(false);
- }
+ getOkButton().setEnabled(true);
+ } catch (java.lang.IllegalArgumentException ee) {
+ LOGGER.warn("The language " + l + " is not valid", ee);
+ getOkButton().setEnabled(false);
+ }
- }
+ }
- });
- }
- return jComboBox;
- }
+ });
+ }
+ return jComboBox;
+ }
}
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/CancelButton.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/CancelButton.java 2011-01-27 12:37:43 UTC (rev 1437)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/CancelButton.java 2011-01-27 12:53:32 UTC (rev 1438)
@@ -35,6 +35,7 @@
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
+
/**
* A Cancel {@link JButton} without text, but with an expressive {@link Icon}
* stat symbolizes CANCEL
@@ -43,10 +44,11 @@
*
*/
public class CancelButton extends JButton {
- public static final Icon ICON_CANCEL_SMALL = new ImageIcon( CancelButton.class.getResource("small/cancel.png") );
+ public static final Icon ICON_CANCEL_SMALL = new ImageIcon(
+ CancelButton.class.getResource("resource/icons/small/cancel.png"));
- private static final Dimension DIMENSION = new Dimension(35,25);
-
+ private static final Dimension DIMENSION = new Dimension(35, 25);
+
/**
* Creates a {@link JButton} with an icon that symbolizes OK
*/
@@ -64,5 +66,4 @@
setMaximumSize(DIMENSION);
}
-
}
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/OkButton.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/OkButton.java 2011-01-27 12:37:43 UTC (rev 1437)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/OkButton.java 2011-01-27 12:53:32 UTC (rev 1438)
@@ -45,7 +45,7 @@
public class OkButton extends JButton {
public static final Icon ICON_OK_SMALL = new ImageIcon(OkButton.class
- .getResource("small/ok.png"));
+ .getResource("resource/icons/small/ok.png"));
private static final Dimension DIMENSION = new Dimension(35, 25);
Modified: trunk/schmitzm-core/src/test/java/de/schmitzm/i18n/SwitchLanguageDialogTest.java
===================================================================
--- trunk/schmitzm-core/src/test/java/de/schmitzm/i18n/SwitchLanguageDialogTest.java 2011-01-27 12:37:43 UTC (rev 1437)
+++ trunk/schmitzm-core/src/test/java/de/schmitzm/i18n/SwitchLanguageDialogTest.java 2011-01-27 12:53:32 UTC (rev 1438)
@@ -40,10 +40,11 @@
public class SwitchLanguageDialogTest extends TestingClass {
+
@Test
public void testDialog() throws Throwable {
- if (!TestingUtil.isInteractive())
+ if (!isInteractive())
// Test needed here because following GUI creation would crash
// without X11 DISPLAY
return;
@@ -57,7 +58,7 @@
@Test
public void testDialogDoesntAppearIf0OrOneLangOnly() throws Throwable {
- if (!TestingUtil.isInteractive())
+ if (!isInteractive())
// Test needed here because following GUI creation would crash
// without X11 DISPLAY
return;
Added: trunk/schmitzm-core/src/test/java/de/schmitzm/swing/CancelButtonTest.java
===================================================================
--- trunk/schmitzm-core/src/test/java/de/schmitzm/swing/CancelButtonTest.java 2011-01-27 12:37:43 UTC (rev 1437)
+++ trunk/schmitzm-core/src/test/java/de/schmitzm/swing/CancelButtonTest.java 2011-01-27 12:53:32 UTC (rev 1438)
@@ -0,0 +1,13 @@
+package de.schmitzm.swing;
+
+
+import org.junit.Test;
+
+public class CancelButtonTest {
+
+ @Test
+ public void testIcon() {
+ CancelButton.ICON_CANCEL_SMALL.getIconHeight();
+ }
+
+}
Property changes on: trunk/schmitzm-core/src/test/java/de/schmitzm/swing/CancelButtonTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id URL
Name: svn:eol-style
+ native
Added: trunk/schmitzm-core/src/test/java/de/schmitzm/swing/OkButtonTest.java
===================================================================
--- trunk/schmitzm-core/src/test/java/de/schmitzm/swing/OkButtonTest.java 2011-01-27 12:37:43 UTC (rev 1437)
+++ trunk/schmitzm-core/src/test/java/de/schmitzm/swing/OkButtonTest.java 2011-01-27 12:53:32 UTC (rev 1438)
@@ -0,0 +1,12 @@
+package de.schmitzm.swing;
+
+import org.junit.Test;
+
+public class OkButtonTest {
+
+ @Test
+ public void testIcon() {
+ OkButton.ICON_OK_SMALL.getIconHeight();
+ }
+
+}
Property changes on: trunk/schmitzm-core/src/test/java/de/schmitzm/swing/OkButtonTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id URL
Name: svn:eol-style
+ native
More information about the Schmitzm-commits
mailing list