rename window autosize property and remove hardcoded text strings

This commit is contained in:
Gered 2016-01-16 12:49:43 -05:00
parent 770f227637
commit 91b91777de
10 changed files with 34 additions and 26 deletions

View file

@ -28,6 +28,8 @@ public enum Language {
setting_accuracy, setting_accuracy,
setting_locked, setting_locked,
setting_warnOnReset, setting_warnOnReset,
setting_windowUserResizable,
setting_windowWidth,
// Settings > Color // Settings > Color
setting_color_background, setting_color_background,
@ -139,6 +141,7 @@ public enum Language {
error_read_file, error_read_file,
error_write_file, error_write_file,
error_import_run, error_import_run,
error_window_width,
// Actions // Actions
action_accept, action_accept,
@ -248,6 +251,7 @@ public enum Language {
TIME, TIME,
UNTITLED, UNTITLED,
WARNING, WARNING,
WINDOW_SIZE,
/* /*
* 1.4 * 1.4

View file

@ -73,7 +73,7 @@ public class Llanfair extends BorderlessFrame implements TableModelListener,
RESOURCES = new Resources(); RESOURCES = new Resources();
registerFonts(); registerFonts();
setResizable(Settings.windowAutoSize.get()); setResizable(Settings.windowUserResizable.get());
setLookAndFeel(); setLookAndFeel();
addComponentListener(this); addComponentListener(this);
@ -351,11 +351,11 @@ public class Llanfair extends BorderlessFrame implements TableModelListener,
|| Settings.footerShowDeltaLabels.equals(property) || Settings.footerShowDeltaLabels.equals(property)
|| Settings.footerVerbose.equals(property) || Settings.footerVerbose.equals(property)
|| Settings.footerMultiline.equals(property) || Settings.footerMultiline.equals(property)
|| Settings.windowAutoSize.equals(property) || Settings.windowUserResizable.equals(property)
|| Settings.windowWidth.equals(property) || Settings.windowWidth.equals(property)
|| Run.NAME_PROPERTY.equals(property)) { || Run.NAME_PROPERTY.equals(property)) {
setResizable(Settings.windowAutoSize.get()); setResizable(Settings.windowUserResizable.get());
MenuItem.enableResizeOptions(Settings.windowAutoSize.get()); MenuItem.enableResizeOptions(Settings.windowUserResizable.get());
forceResize(); forceResize();
} }
} }
@ -434,7 +434,7 @@ public class Llanfair extends BorderlessFrame implements TableModelListener,
public void componentResized(ComponentEvent e) { public void componentResized(ComponentEvent e) {
// we may have to override the width, but allow the height to grow as needed // we may have to override the width, but allow the height to grow as needed
// don't have to change anything if autosizing // don't have to change anything if autosizing
if (!Settings.windowAutoSize.get()) if (!Settings.windowUserResizable.get())
setSize(new Dimension(Settings.windowWidth.get(), getHeight())); setSize(new Dimension(Settings.windowWidth.get(), getHeight()));
} }
@ -522,7 +522,7 @@ public class Llanfair extends BorderlessFrame implements TableModelListener,
private void forceResize() { private void forceResize() {
Dimension newSize = new Dimension(); Dimension newSize = new Dimension();
newSize.height = getHeight(); newSize.height = getHeight();
if (Settings.windowAutoSize.get()) if (Settings.windowUserResizable.get())
newSize.width = getWidth(); newSize.width = getWidth();
else else
newSize.width = Settings.windowWidth.get(); newSize.width = Settings.windowWidth.get();

View file

@ -37,7 +37,7 @@ public class Settings {
public static final Property<Compare> compareMethod = new Property<>( "compareMethod" ); public static final Property<Compare> compareMethod = new Property<>( "compareMethod" );
public static final Property<Accuracy> accuracy = new Property<>( "accuracy" ); public static final Property<Accuracy> accuracy = new Property<>( "accuracy" );
public static final Property<Boolean> warnOnReset = new Property<>( "warnOnReset" ); public static final Property<Boolean> warnOnReset = new Property<>( "warnOnReset" );
public static final Property<Boolean> windowAutoSize = new Property<>( "windowAutoSize" ); public static final Property<Boolean> windowUserResizable = new Property<>( "windowUserResizable" );
public static final Property<Integer> windowWidth = new Property<>( "windowWidth" ); public static final Property<Integer> windowWidth = new Property<>( "windowWidth" );
/* COLOR properties */ /* COLOR properties */
@ -213,7 +213,7 @@ public class Settings {
global.put( compareMethod.key, Compare.BEST_OVERALL_RUN ); global.put( compareMethod.key, Compare.BEST_OVERALL_RUN );
global.put( accuracy.key, Accuracy.TENTH ); global.put( accuracy.key, Accuracy.TENTH );
global.put( warnOnReset.key, true ); global.put( warnOnReset.key, true );
global.put( windowAutoSize.key, true ); global.put( windowUserResizable.key, true );
global.put( windowWidth.key, null ); global.put( windowWidth.key, null );
global.put( colorBackground.key, Color.decode("0x000000") ); global.put( colorBackground.key, Color.decode("0x000000") );

View file

@ -42,7 +42,7 @@ public class TabGeneral extends SettingsTab implements ActionListener {
private JLabel windowSizeLabel; private JLabel windowSizeLabel;
private JCheckBox windowAutoSize; private JCheckBox windowUserResizable;
private JTextField windowSize; private JTextField windowSize;
@ -83,20 +83,20 @@ public class TabGeneral extends SettingsTab implements ActionListener {
warnOnReset.setSelected(Settings.warnOnReset.get()); warnOnReset.setSelected(Settings.warnOnReset.get());
warnOnReset.addActionListener(this); warnOnReset.addActionListener(this);
windowSizeLabel = new JLabel("Window Width"); windowSizeLabel = new JLabel("" + Language.WINDOW_SIZE);
windowAutoSize = new JCheckBox("Autosize"); windowUserResizable = new JCheckBox("" + Language.setting_windowUserResizable);
windowAutoSize.setSelected(Settings.windowAutoSize.get()); windowUserResizable.setSelected(Settings.windowUserResizable.get());
windowAutoSize.addActionListener(this); windowUserResizable.addActionListener(this);
String windowWidthText = ""; String windowWidthText = "";
if (Settings.windowWidth.get() != null) if (Settings.windowWidth.get() != null)
windowWidthText = "" + Settings.windowWidth.get(); windowWidthText = "" + Settings.windowWidth.get();
windowSize = new JTextField(windowWidthText, 4); windowSize = new JTextField(windowWidthText, 4);
windowSize.setEnabled(!windowAutoSize.isSelected()); windowSize.setEnabled(!windowUserResizable.isSelected());
windowSize.addActionListener(this); windowSize.addActionListener(this);
windowSizeUnitsText = new JLabel("pixels"); windowSizeUnitsText = new JLabel("" + Language.setting_windowWidth);
languageText = new JLabel("" + Language.setting_language); languageText = new JLabel("" + Language.setting_language);
alwaysOnTopText = new JLabel("" + Language.APPLICATION); alwaysOnTopText = new JLabel("" + Language.APPLICATION);
@ -123,8 +123,8 @@ public class TabGeneral extends SettingsTab implements ActionListener {
} }
} else if (source.equals(warnOnReset)) { } else if (source.equals(warnOnReset)) {
Settings.warnOnReset.set(warnOnReset.isSelected()); Settings.warnOnReset.set(warnOnReset.isSelected());
} else if (source.equals(windowAutoSize)) { } else if (source.equals(windowUserResizable)) {
windowSize.setEnabled(!windowAutoSize.isSelected()); windowSize.setEnabled(!windowUserResizable.isSelected());
} }
} }
@ -133,15 +133,15 @@ public class TabGeneral extends SettingsTab implements ActionListener {
void doDelayedSettingChange() throws InvalidSettingException { void doDelayedSettingChange() throws InvalidSettingException {
Settings.alwaysOnTop.set(alwaysOnTop.isSelected()); Settings.alwaysOnTop.set(alwaysOnTop.isSelected());
Settings.windowAutoSize.set(windowAutoSize.isSelected()); Settings.windowUserResizable.set(windowUserResizable.isSelected());
if (!windowAutoSize.isSelected()) { if (!windowUserResizable.isSelected()) {
int windowWidth; int windowWidth;
try { try {
windowWidth = Integer.parseInt(windowSize.getText().trim()); windowWidth = Integer.parseInt(windowSize.getText().trim());
} }
catch (Exception ex) { 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); 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(accuracyPanel, GBC.grid(1, 4).fill(GBC.H).insets(10, 0));
add(windowSizeLabel, GBC.grid(0, 5).anchor(GBC.LE).insets(5, 10)); 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(); JPanel windowSizeContainer = new JPanel();
windowSizeContainer.add(windowSize); windowSizeContainer.add(windowSize);
windowSizeContainer.add(windowSizeUnitsText); windowSizeContainer.add(windowSizeUnitsText);

View file

@ -410,7 +410,7 @@ class Core extends JPanel implements ActionListener {
} else if (Settings.coreOtherTimeFont.equals(property)) { } else if (Settings.coreOtherTimeFont.equals(property)) {
updateFonts(TIME); updateFonts(TIME);
forceResize(); forceResize();
} else if (Settings.windowAutoSize.equals(property) || Settings.windowWidth.equals(property)) { } else if (Settings.windowUserResizable.equals(property) || Settings.windowWidth.equals(property)) {
updateSize(); updateSize();
forceResize(); forceResize();
} }

View file

@ -224,7 +224,7 @@ class Footer extends JPanel {
} else if (Settings.coreOtherTimeFont.equals(property)) { } else if (Settings.coreOtherTimeFont.equals(property)) {
updateFonts(TIME | DELTA); updateFonts(TIME | DELTA);
forceResize(); forceResize();
} else if (Settings.windowAutoSize.equals(property) || Settings.windowWidth.equals(property)) { } else if (Settings.windowUserResizable.equals(property) || Settings.windowWidth.equals(property)) {
updateSize(); updateSize();
forceResize(); forceResize();
} }

View file

@ -172,7 +172,7 @@ class Graph extends JPanel {
} }
} else if (Settings.coreFont.equals(property)) { } else if (Settings.coreFont.equals(property)) {
updateFonts(ALL); updateFonts(ALL);
} else if (Settings.windowAutoSize.equals(property) || Settings.windowWidth.equals(property)) { } else if (Settings.windowUserResizable.equals(property) || Settings.windowWidth.equals(property)) {
updateSize(); updateSize();
forceResize(); forceResize();
} }

View file

@ -281,7 +281,7 @@ public class History extends JPanel {
updateValues(TIME | LIVE); updateValues(TIME | LIVE);
updateColors(TIME); updateColors(TIME);
forceResize(); forceResize();
} else if (Settings.windowAutoSize.equals(property) || Settings.windowWidth.equals(property)) { } else if (Settings.windowUserResizable.equals(property) || Settings.windowWidth.equals(property)) {
updateSize(); updateSize();
forceResize(); forceResize();
} }

View file

@ -248,7 +248,7 @@ public class RunPane extends JPanel {
updateFonts(TITLE); updateFonts(TITLE);
} else if (Settings.coreFont.equals(property)) { } else if (Settings.coreFont.equals(property)) {
updateFonts(ALL & ~TITLE); updateFonts(ALL & ~TITLE);
} else if (Settings.windowAutoSize.equals(property) || Settings.windowWidth.equals(property)) { } else if (Settings.windowUserResizable.equals(property) || Settings.windowWidth.equals(property)) {
updateSize(); updateSize();
} }
} }

View file

@ -9,6 +9,8 @@ setting_compareMethod = Compare Method
setting_accuracy = Accuracy setting_accuracy = Accuracy
setting_locked = setting_locked =
setting_warnOnReset = Warn on Reset if better times setting_warnOnReset = Warn on Reset if better times
setting_windowUserResizable = User Resizable
setting_windowWidth = Fixed Width (Pixels)
# Settings > Color # Settings > Color
setting_color_background = Background 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_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_write_file = You do not have permission to write in that folder.
error_import_run = "{0}" isn't a recognized run file. error_import_run = "{0}" isn't a recognized run file.
error_window_width = Window Width must be a positive integer.
# Actions # Actions
action_accept = action_accept =
@ -222,6 +225,7 @@ SPLIT = Split:
TIME = Time (Split) TIME = Time (Split)
UNTITLED = <untitled> UNTITLED = <untitled>
WARNING = Warning WARNING = Warning
WINDOW_SIZE = Window Size
# 1.4 # 1.4
INCREMENT = INCREMENT =