add max recent files setting to the Settings > General dialog

This commit is contained in:
Gered 2017-01-28 11:53:04 -05:00
parent 6229197fba
commit 3f2ce3b810
3 changed files with 26 additions and 0 deletions

View file

@ -30,6 +30,7 @@ public enum Language {
setting_warnOnReset, setting_warnOnReset,
setting_windowUserResizable, setting_windowUserResizable,
setting_windowWidth, setting_windowWidth,
setting_maxRecentFiles,
// Settings > Color // Settings > Color
setting_color_background, setting_color_background,
@ -142,6 +143,7 @@ public enum Language {
error_write_file, error_write_file,
error_import_run, error_import_run,
error_window_width, error_window_width,
error_max_recent_files,
// Actions // Actions
action_accept, action_accept,

View file

@ -48,6 +48,10 @@ public class TabGeneral extends SettingsTab implements ActionListener {
private JLabel windowSizeUnitsText; private JLabel windowSizeUnitsText;
private JTextField maxRecentFiles;
private JLabel maxRecentFilesLabel;
// ----------------------------------------------------------- CONSTRUCTORS // ----------------------------------------------------------- CONSTRUCTORS
TabGeneral() { TabGeneral() {
@ -96,7 +100,11 @@ public class TabGeneral extends SettingsTab implements ActionListener {
windowSize.setEnabled(!windowUserResizable.isSelected()); windowSize.setEnabled(!windowUserResizable.isSelected());
windowSize.addActionListener(this); windowSize.addActionListener(this);
maxRecentFiles = new JTextField("" + Settings.maxRecentFiles.get(), 4);
maxRecentFiles.addActionListener(this);
windowSizeUnitsText = new JLabel("" + Language.setting_windowWidth); windowSizeUnitsText = new JLabel("" + Language.setting_windowWidth);
maxRecentFilesLabel = new JLabel("" + Language.setting_maxRecentFiles);
languageText = new JLabel("" + Language.setting_language); languageText = new JLabel("" + Language.setting_language);
alwaysOnTopText = new JLabel("" + Language.APPLICATION); alwaysOnTopText = new JLabel("" + Language.APPLICATION);
@ -146,6 +154,16 @@ public class TabGeneral extends SettingsTab implements ActionListener {
Settings.windowWidth.set(windowWidth); Settings.windowWidth.set(windowWidth);
} }
int numRecentFiles;
try {
numRecentFiles = Integer.parseInt(maxRecentFiles.getText().trim());
}
catch (Exception ex) {
throw new InvalidSettingException(this, maxRecentFiles, "" + Language.error_max_recent_files);
}
Settings.maxRecentFiles.set(numRecentFiles);
} }
/** /**
@ -196,6 +214,10 @@ public class TabGeneral extends SettingsTab implements ActionListener {
windowSizeContainer.add(windowSize); windowSizeContainer.add(windowSize);
windowSizeContainer.add(windowSizeUnitsText); windowSizeContainer.add(windowSizeUnitsText);
add(windowSizeContainer, GBC.grid(1, 6).anchor(GBC.LINE_START)); add(windowSizeContainer, GBC.grid(1, 6).anchor(GBC.LINE_START));
add(maxRecentFilesLabel, GBC.grid(0, 7).anchor(GBC.LINE_END).insets(5, 10));
add(maxRecentFiles, GBC.grid(1, 7).anchor(GBC.LINE_START).insets(0, 5));
} }
// --------------------------------------------------------- INTERNAL TYPES // --------------------------------------------------------- INTERNAL TYPES

View file

@ -11,6 +11,7 @@ setting_locked =
setting_warnOnReset = Warn on Reset if better times setting_warnOnReset = Warn on Reset if better times
setting_windowUserResizable = User Resizable setting_windowUserResizable = User Resizable
setting_windowWidth = Fixed Width (Pixels) setting_windowWidth = Fixed Width (Pixels)
setting_maxRecentFiles = Recent files limit
# Settings > Color # Settings > Color
setting_color_background = Background setting_color_background = Background
@ -123,6 +124,7 @@ error_read_file = "{0}" isn't a valid Llanfair run or you do not have permission
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. error_window_width = Window Width must be a positive integer.
error_max_recent_files = Recent files limit must be a positive integer.
# Actions # Actions
action_accept = action_accept =