From b0dbce48197310d9d72539de8c3bc6e9e8991fe8 Mon Sep 17 00:00:00 2001 From: ksm Date: Sat, 30 Aug 2014 20:38:07 +0200 Subject: [PATCH 1/2] Moved texts to resources, added resource for Polish language. --- .../java/org/ciscavate/cjwizard/WizardContainer.java | 11 +++++++---- src/main/java/org/ciscavate/cjwizard/WizardPage.java | 8 ++++---- src/main/java/org/ciscavate/cjwizard/WizardTest.java | 10 +++++----- src/main/java/org/ciscavate/cjwizard/WizardTest2.java | 10 +++++----- src/main/resources/i18n/cjwizard.properties | 4 ++++ src/main/resources/i18n/cjwizard_pl.properties | 4 ++++ 6 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 src/main/resources/i18n/cjwizard.properties create mode 100644 src/main/resources/i18n/cjwizard_pl.properties diff --git a/src/main/java/org/ciscavate/cjwizard/WizardContainer.java b/src/main/java/org/ciscavate/cjwizard/WizardContainer.java index c0b2edf..3f4bb1c 100644 --- a/src/main/java/org/ciscavate/cjwizard/WizardContainer.java +++ b/src/main/java/org/ciscavate/cjwizard/WizardContainer.java @@ -19,6 +19,7 @@ import java.awt.event.ActionEvent; import java.util.LinkedList; import java.util.List; +import java.util.ResourceBundle; import javax.swing.AbstractAction; import javax.swing.BorderFactory; @@ -47,6 +48,8 @@ public class WizardContainer extends JPanel implements WizardController { */ private static Logger log = LoggerFactory.getLogger(WizardContainer.class); + private static ResourceBundle msg = ResourceBundle.getBundle("i18n.cjwizard"); + /** * Storage for all the collected information. */ @@ -83,7 +86,7 @@ public class WizardContainer extends JPanel implements WizardController { */ private JPanel _extraButtonPanel; - private final AbstractAction _prevAction = new AbstractAction("< Prev"){ + private final AbstractAction _prevAction = new AbstractAction(msg.getString("PREVIOUS")){ { setEnabled(false); } @@ -93,14 +96,14 @@ public void actionPerformed(ActionEvent e) { } }; - private final AbstractAction _nextAction = new AbstractAction("Next >"){ + private final AbstractAction _nextAction = new AbstractAction(msg.getString("NEXT")){ @Override public void actionPerformed(ActionEvent e) { next(); } }; - private final AbstractAction _finishAction = new AbstractAction("Finish"){ + private final AbstractAction _finishAction = new AbstractAction(msg.getString("FINISH")){ { setEnabled(false); } @@ -110,7 +113,7 @@ public void actionPerformed(ActionEvent e) { } }; - private final AbstractAction _cancelAction = new AbstractAction("Cancel"){ + private final AbstractAction _cancelAction = new AbstractAction(msg.getString("CANCEL")){ @Override public void actionPerformed(ActionEvent e) { cancel(); diff --git a/src/main/java/org/ciscavate/cjwizard/WizardPage.java b/src/main/java/org/ciscavate/cjwizard/WizardPage.java index ec4acee..66ae40e 100644 --- a/src/main/java/org/ciscavate/cjwizard/WizardPage.java +++ b/src/main/java/org/ciscavate/cjwizard/WizardPage.java @@ -155,7 +155,7 @@ private Object getValue(Component c) { } else if (c instanceof JList){ val = ((JList) c).getSelectedValues(); } else { - log.warn("Unknown component: "+c); + log.warn("Unknown component: {}", c); } return val; @@ -197,7 +197,7 @@ private void setValue(Component c, Object o) { } list.setSelectedIndices(indices); } else { - log.warn("Unknown component: "+c); + log.warn("Unknown component: {}", c); } } @@ -283,7 +283,7 @@ private class WPContainerListener implements ContainerListener { */ @Override public void componentAdded(ContainerEvent e) { - log.trace("component added: "+e.getChild()); + log.trace("component added: {}", e.getChild()); Component newComp = e.getChild(); storeIfNamed(newComp); @@ -319,7 +319,7 @@ private void storeIfNamed(Component newComp) { */ @Override public void componentRemoved(ContainerEvent e) { - log.trace("component removed: "+e.getChild()); + log.trace("component removed: {}", e.getChild()); _namedComponents.remove(e.getChild()); } } diff --git a/src/main/java/org/ciscavate/cjwizard/WizardTest.java b/src/main/java/org/ciscavate/cjwizard/WizardTest.java index 3c61308..a471bf0 100644 --- a/src/main/java/org/ciscavate/cjwizard/WizardTest.java +++ b/src/main/java/org/ciscavate/cjwizard/WizardTest.java @@ -64,19 +64,19 @@ public WizardTest(){ wc.addWizardListener(new WizardListener(){ @Override public void onCanceled(List path, WizardSettings settings) { - log.debug("settings: "+wc.getSettings()); + log.debug("settings: {}", wc.getSettings()); WizardTest.this.dispose(); } @Override public void onFinished(List path, WizardSettings settings) { - log.debug("settings: "+wc.getSettings()); + log.debug("settings: {}", wc.getSettings()); WizardTest.this.dispose(); } @Override public void onPageChanged(WizardPage newPage, List path) { - log.debug("settings: "+wc.getSettings()); + log.debug("settings: {}", wc.getSettings()); // Set the dialog title to match the description of the new page: WizardTest.this.setTitle(newPage.getDescription()); } @@ -165,7 +165,7 @@ public void rendering(List path, WizardSettings settings) { @Override public WizardPage createPage(List path, WizardSettings settings) { - log.debug("creating page "+path.size()); + log.debug("creating page {}", path.size()); // Get the next page to display. The path is the list of all wizard // pages that the user has proceeded through from the start of the @@ -179,7 +179,7 @@ public WizardPage createPage(List path, // In fact, we can do arbitrarily complex computation to determine // the next wizard page. - log.debug("Returning page: "+page); + log.debug("Returning page: {}", page); return page; } diff --git a/src/main/java/org/ciscavate/cjwizard/WizardTest2.java b/src/main/java/org/ciscavate/cjwizard/WizardTest2.java index 8389f41..ad9205d 100644 --- a/src/main/java/org/ciscavate/cjwizard/WizardTest2.java +++ b/src/main/java/org/ciscavate/cjwizard/WizardTest2.java @@ -64,19 +64,19 @@ public WizardTest2(){ wc.addWizardListener(new WizardListener(){ @Override public void onCanceled(List path, WizardSettings settings) { - log.debug("settings: "+wc.getSettings()); + log.debug("settings: {}", wc.getSettings()); WizardTest2.this.dispose(); } @Override public void onFinished(List path, WizardSettings settings) { - log.debug("settings: "+wc.getSettings()); + log.debug("settings: {}", wc.getSettings()); WizardTest2.this.dispose(); } @Override public void onPageChanged(WizardPage newPage, List path) { - log.debug("settings: "+wc.getSettings()); + log.debug("settings: {}", wc.getSettings()); // Set the dialog title to match the description of the new page: WizardTest2.this.setTitle(newPage.getDescription()); } @@ -101,7 +101,7 @@ private class TestFactory implements PageFactory{ @Override public WizardPage createPage(List path, WizardSettings settings) { - log.debug("creating page "+path.size()); + log.debug("creating page {}", path.size()); // Get the next page to display. The path is the list of all wizard // pages that the user has proceeded through from the start of the @@ -116,7 +116,7 @@ public WizardPage createPage(List path, // In fact, we can do arbitrarily complex computation to determine // the next wizard page. - log.debug("Returning page: "+page); + log.debug("Returning page: {}", page); return page; } diff --git a/src/main/resources/i18n/cjwizard.properties b/src/main/resources/i18n/cjwizard.properties new file mode 100644 index 0000000..e113668 --- /dev/null +++ b/src/main/resources/i18n/cjwizard.properties @@ -0,0 +1,4 @@ +PREVIOUS=< Prev +NEXT=Next > +FINISH=Finish +CANCEL=Cancel \ No newline at end of file diff --git a/src/main/resources/i18n/cjwizard_pl.properties b/src/main/resources/i18n/cjwizard_pl.properties new file mode 100644 index 0000000..e85a499 --- /dev/null +++ b/src/main/resources/i18n/cjwizard_pl.properties @@ -0,0 +1,4 @@ +PREVIOUS=Wstecz +NEXT=Dalej +FINISH=Zako\u0144cz +CANCEL=Anuluj \ No newline at end of file From 450f6f811e5a337c28f1e8c23ddfefd18dc79da8 Mon Sep 17 00:00:00 2001 From: ksm Date: Sun, 31 Aug 2014 18:42:28 +0200 Subject: [PATCH 2/2] Make all buttons as wide as widest of them. --- .../org/ciscavate/cjwizard/WizardContainer.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/ciscavate/cjwizard/WizardContainer.java b/src/main/java/org/ciscavate/cjwizard/WizardContainer.java index 3f4bb1c..c7111a4 100644 --- a/src/main/java/org/ciscavate/cjwizard/WizardContainer.java +++ b/src/main/java/org/ciscavate/cjwizard/WizardContainer.java @@ -16,18 +16,17 @@ package org.ciscavate.cjwizard; import java.awt.BorderLayout; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.util.LinkedList; import java.util.List; import java.util.ResourceBundle; - import javax.swing.AbstractAction; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JPanel; - import org.ciscavate.cjwizard.pagetemplates.DefaultPageTemplate; import org.ciscavate.cjwizard.pagetemplates.PageTemplate; import org.ciscavate.utilities.ExceptionUtilities; @@ -152,6 +151,18 @@ private void initComponents() { final JButton finishBtn = new JButton(_finishAction); final JButton cancelBtn = new JButton(_cancelAction); + Dimension preferredMax = prevBtn.getPreferredSize(); + for (JButton b : new JButton[]{nextBtn, finishBtn, cancelBtn}) { + Dimension bp = b.getPreferredSize(); + preferredMax.setSize(Math.max(preferredMax.getWidth(), bp.getWidth()), + Math.max(preferredMax.getHeight(), bp.getHeight())); + } + + prevBtn.setPreferredSize(preferredMax); + nextBtn.setPreferredSize(preferredMax); + finishBtn.setPreferredSize(preferredMax); + cancelBtn.setPreferredSize(preferredMax); + _extraButtonPanel = new JPanel(); _extraButtonPanel.setLayout( new BoxLayout(_extraButtonPanel, BoxLayout.LINE_AXIS));