From 91b91777dea1bcbb1f39a8a8d21604fe17d71cee Mon Sep 17 00:00:00 2001 From: gered Date: Sat, 16 Jan 2016 12:49:43 -0500 Subject: [PATCH] rename window autosize property and remove hardcoded text strings --- .../java/org/fenix/llanfair/Language.java | 4 +++ .../java/org/fenix/llanfair/Llanfair.java | 12 ++++----- .../org/fenix/llanfair/config/Settings.java | 4 +-- .../org/fenix/llanfair/dialog/TabGeneral.java | 26 +++++++++---------- .../java/org/fenix/llanfair/gui/Core.java | 2 +- .../java/org/fenix/llanfair/gui/Footer.java | 2 +- .../java/org/fenix/llanfair/gui/Graph.java | 2 +- .../java/org/fenix/llanfair/gui/History.java | 2 +- .../java/org/fenix/llanfair/gui/RunPane.java | 2 +- src/main/resources/language.properties | 4 +++ 10 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/fenix/llanfair/Language.java b/src/main/java/org/fenix/llanfair/Language.java index f8d40b7..db6c793 100644 --- a/src/main/java/org/fenix/llanfair/Language.java +++ b/src/main/java/org/fenix/llanfair/Language.java @@ -28,6 +28,8 @@ public enum Language { setting_accuracy, setting_locked, setting_warnOnReset, + setting_windowUserResizable, + setting_windowWidth, // Settings > Color setting_color_background, @@ -139,6 +141,7 @@ public enum Language { error_read_file, error_write_file, error_import_run, + error_window_width, // Actions action_accept, @@ -248,6 +251,7 @@ public enum Language { TIME, UNTITLED, WARNING, + WINDOW_SIZE, /* * 1.4 diff --git a/src/main/java/org/fenix/llanfair/Llanfair.java b/src/main/java/org/fenix/llanfair/Llanfair.java index 7177ab9..fbea250 100644 --- a/src/main/java/org/fenix/llanfair/Llanfair.java +++ b/src/main/java/org/fenix/llanfair/Llanfair.java @@ -73,7 +73,7 @@ public class Llanfair extends BorderlessFrame implements TableModelListener, RESOURCES = new Resources(); registerFonts(); - setResizable(Settings.windowAutoSize.get()); + setResizable(Settings.windowUserResizable.get()); setLookAndFeel(); addComponentListener(this); @@ -351,11 +351,11 @@ public class Llanfair extends BorderlessFrame implements TableModelListener, || Settings.footerShowDeltaLabels.equals(property) || Settings.footerVerbose.equals(property) || Settings.footerMultiline.equals(property) - || Settings.windowAutoSize.equals(property) + || Settings.windowUserResizable.equals(property) || Settings.windowWidth.equals(property) || Run.NAME_PROPERTY.equals(property)) { - setResizable(Settings.windowAutoSize.get()); - MenuItem.enableResizeOptions(Settings.windowAutoSize.get()); + setResizable(Settings.windowUserResizable.get()); + MenuItem.enableResizeOptions(Settings.windowUserResizable.get()); forceResize(); } } @@ -434,7 +434,7 @@ public class Llanfair extends BorderlessFrame implements TableModelListener, public void componentResized(ComponentEvent e) { // we may have to override the width, but allow the height to grow as needed // don't have to change anything if autosizing - if (!Settings.windowAutoSize.get()) + if (!Settings.windowUserResizable.get()) setSize(new Dimension(Settings.windowWidth.get(), getHeight())); } @@ -522,7 +522,7 @@ public class Llanfair extends BorderlessFrame implements TableModelListener, private void forceResize() { Dimension newSize = new Dimension(); newSize.height = getHeight(); - if (Settings.windowAutoSize.get()) + if (Settings.windowUserResizable.get()) newSize.width = getWidth(); else newSize.width = Settings.windowWidth.get(); diff --git a/src/main/java/org/fenix/llanfair/config/Settings.java b/src/main/java/org/fenix/llanfair/config/Settings.java index bcd8cb2..b82d090 100644 --- a/src/main/java/org/fenix/llanfair/config/Settings.java +++ b/src/main/java/org/fenix/llanfair/config/Settings.java @@ -37,7 +37,7 @@ public class Settings { public static final Property compareMethod = new Property<>( "compareMethod" ); public static final Property accuracy = new Property<>( "accuracy" ); public static final Property warnOnReset = new Property<>( "warnOnReset" ); - public static final Property windowAutoSize = new Property<>( "windowAutoSize" ); + public static final Property windowUserResizable = new Property<>( "windowUserResizable" ); public static final Property windowWidth = new Property<>( "windowWidth" ); /* COLOR properties */ @@ -213,7 +213,7 @@ public class Settings { global.put( compareMethod.key, Compare.BEST_OVERALL_RUN ); global.put( accuracy.key, Accuracy.TENTH ); global.put( warnOnReset.key, true ); - global.put( windowAutoSize.key, true ); + global.put( windowUserResizable.key, true ); global.put( windowWidth.key, null ); global.put( colorBackground.key, Color.decode("0x000000") ); diff --git a/src/main/java/org/fenix/llanfair/dialog/TabGeneral.java b/src/main/java/org/fenix/llanfair/dialog/TabGeneral.java index 7d35521..c2cd838 100644 --- a/src/main/java/org/fenix/llanfair/dialog/TabGeneral.java +++ b/src/main/java/org/fenix/llanfair/dialog/TabGeneral.java @@ -42,7 +42,7 @@ public class TabGeneral extends SettingsTab implements ActionListener { private JLabel windowSizeLabel; - private JCheckBox windowAutoSize; + private JCheckBox windowUserResizable; private JTextField windowSize; @@ -83,20 +83,20 @@ public class TabGeneral extends SettingsTab implements ActionListener { warnOnReset.setSelected(Settings.warnOnReset.get()); warnOnReset.addActionListener(this); - windowSizeLabel = new JLabel("Window Width"); + windowSizeLabel = new JLabel("" + Language.WINDOW_SIZE); - windowAutoSize = new JCheckBox("Autosize"); - windowAutoSize.setSelected(Settings.windowAutoSize.get()); - windowAutoSize.addActionListener(this); + windowUserResizable = new JCheckBox("" + Language.setting_windowUserResizable); + windowUserResizable.setSelected(Settings.windowUserResizable.get()); + windowUserResizable.addActionListener(this); String windowWidthText = ""; if (Settings.windowWidth.get() != null) windowWidthText = "" + Settings.windowWidth.get(); windowSize = new JTextField(windowWidthText, 4); - windowSize.setEnabled(!windowAutoSize.isSelected()); + windowSize.setEnabled(!windowUserResizable.isSelected()); windowSize.addActionListener(this); - windowSizeUnitsText = new JLabel("pixels"); + windowSizeUnitsText = new JLabel("" + Language.setting_windowWidth); languageText = new JLabel("" + Language.setting_language); alwaysOnTopText = new JLabel("" + Language.APPLICATION); @@ -123,8 +123,8 @@ public class TabGeneral extends SettingsTab implements ActionListener { } } else if (source.equals(warnOnReset)) { Settings.warnOnReset.set(warnOnReset.isSelected()); - } else if (source.equals(windowAutoSize)) { - windowSize.setEnabled(!windowAutoSize.isSelected()); + } else if (source.equals(windowUserResizable)) { + windowSize.setEnabled(!windowUserResizable.isSelected()); } } @@ -133,15 +133,15 @@ public class TabGeneral extends SettingsTab implements ActionListener { void doDelayedSettingChange() throws InvalidSettingException { Settings.alwaysOnTop.set(alwaysOnTop.isSelected()); - Settings.windowAutoSize.set(windowAutoSize.isSelected()); + Settings.windowUserResizable.set(windowUserResizable.isSelected()); - if (!windowAutoSize.isSelected()) { + if (!windowUserResizable.isSelected()) { int windowWidth; try { windowWidth = Integer.parseInt(windowSize.getText().trim()); } catch (Exception ex) { - throw new InvalidSettingException(this, windowSize, "Window Width must be a positive integer."); + throw new InvalidSettingException(this, windowSize, "" + Language.error_window_width); } Settings.windowWidth.set(windowWidth); @@ -191,7 +191,7 @@ public class TabGeneral extends SettingsTab implements ActionListener { add(accuracyPanel, GBC.grid(1, 4).fill(GBC.H).insets(10, 0)); add(windowSizeLabel, GBC.grid(0, 5).anchor(GBC.LE).insets(5, 10)); - add(windowAutoSize, GBC.grid(1, 5).anchor(GBC.LS)); + add(windowUserResizable, GBC.grid(1, 5).anchor(GBC.LS)); JPanel windowSizeContainer = new JPanel(); windowSizeContainer.add(windowSize); windowSizeContainer.add(windowSizeUnitsText); diff --git a/src/main/java/org/fenix/llanfair/gui/Core.java b/src/main/java/org/fenix/llanfair/gui/Core.java index 23a6793..69a3d7f 100644 --- a/src/main/java/org/fenix/llanfair/gui/Core.java +++ b/src/main/java/org/fenix/llanfair/gui/Core.java @@ -410,7 +410,7 @@ class Core extends JPanel implements ActionListener { } else if (Settings.coreOtherTimeFont.equals(property)) { updateFonts(TIME); forceResize(); - } else if (Settings.windowAutoSize.equals(property) || Settings.windowWidth.equals(property)) { + } else if (Settings.windowUserResizable.equals(property) || Settings.windowWidth.equals(property)) { updateSize(); forceResize(); } diff --git a/src/main/java/org/fenix/llanfair/gui/Footer.java b/src/main/java/org/fenix/llanfair/gui/Footer.java index 278ca3d..145013f 100644 --- a/src/main/java/org/fenix/llanfair/gui/Footer.java +++ b/src/main/java/org/fenix/llanfair/gui/Footer.java @@ -224,7 +224,7 @@ class Footer extends JPanel { } else if (Settings.coreOtherTimeFont.equals(property)) { updateFonts(TIME | DELTA); forceResize(); - } else if (Settings.windowAutoSize.equals(property) || Settings.windowWidth.equals(property)) { + } else if (Settings.windowUserResizable.equals(property) || Settings.windowWidth.equals(property)) { updateSize(); forceResize(); } diff --git a/src/main/java/org/fenix/llanfair/gui/Graph.java b/src/main/java/org/fenix/llanfair/gui/Graph.java index 8af9387..64c4a77 100644 --- a/src/main/java/org/fenix/llanfair/gui/Graph.java +++ b/src/main/java/org/fenix/llanfair/gui/Graph.java @@ -172,7 +172,7 @@ class Graph extends JPanel { } } else if (Settings.coreFont.equals(property)) { updateFonts(ALL); - } else if (Settings.windowAutoSize.equals(property) || Settings.windowWidth.equals(property)) { + } else if (Settings.windowUserResizable.equals(property) || Settings.windowWidth.equals(property)) { updateSize(); forceResize(); } diff --git a/src/main/java/org/fenix/llanfair/gui/History.java b/src/main/java/org/fenix/llanfair/gui/History.java index 00ec7a5..bb90005 100644 --- a/src/main/java/org/fenix/llanfair/gui/History.java +++ b/src/main/java/org/fenix/llanfair/gui/History.java @@ -281,7 +281,7 @@ public class History extends JPanel { updateValues(TIME | LIVE); updateColors(TIME); forceResize(); - } else if (Settings.windowAutoSize.equals(property) || Settings.windowWidth.equals(property)) { + } else if (Settings.windowUserResizable.equals(property) || Settings.windowWidth.equals(property)) { updateSize(); forceResize(); } diff --git a/src/main/java/org/fenix/llanfair/gui/RunPane.java b/src/main/java/org/fenix/llanfair/gui/RunPane.java index 2abb9cc..e490001 100644 --- a/src/main/java/org/fenix/llanfair/gui/RunPane.java +++ b/src/main/java/org/fenix/llanfair/gui/RunPane.java @@ -248,7 +248,7 @@ public class RunPane extends JPanel { updateFonts(TITLE); } else if (Settings.coreFont.equals(property)) { updateFonts(ALL & ~TITLE); - } else if (Settings.windowAutoSize.equals(property) || Settings.windowWidth.equals(property)) { + } else if (Settings.windowUserResizable.equals(property) || Settings.windowWidth.equals(property)) { updateSize(); } } diff --git a/src/main/resources/language.properties b/src/main/resources/language.properties index e159cc4..6f7bb38 100644 --- a/src/main/resources/language.properties +++ b/src/main/resources/language.properties @@ -9,6 +9,8 @@ setting_compareMethod = Compare Method setting_accuracy = Accuracy setting_locked = setting_warnOnReset = Warn on Reset if better times +setting_windowUserResizable = User Resizable +setting_windowWidth = Fixed Width (Pixels) # Settings > Color setting_color_background = Background @@ -120,6 +122,7 @@ menuItem_exit = Exit error_read_file = "{0}" isn't a valid Llanfair run or you do not have permission to read it. error_write_file = You do not have permission to write in that folder. error_import_run = "{0}" isn't a recognized run file. +error_window_width = Window Width must be a positive integer. # Actions action_accept = @@ -222,6 +225,7 @@ SPLIT = Split: TIME = Time (Split) UNTITLED = WARNING = Warning +WINDOW_SIZE = Window Size # 1.4 INCREMENT =