add setting for specifying a custom default splits path
probably not terribly useful for most people, but for those like me who keep their splits in Dropbox, it is handy
This commit is contained in:
parent
1b1d8b2330
commit
25a2349715
|
@ -56,7 +56,7 @@ final class Actions {
|
||||||
master = owner;
|
master = owner;
|
||||||
|
|
||||||
file = null;
|
file = null;
|
||||||
fileChooser = new JFileChooser(UserSettings.getSplitsPath());
|
fileChooser = new JFileChooser(UserSettings.getSplitsPath(this.file));
|
||||||
fileChooser.setFileFilter(new FileNameExtensionFilter("" + Language.RUN_FILE_FILTER, "lfs"));
|
fileChooser.setFileFilter(new FileNameExtensionFilter("" + Language.RUN_FILE_FILTER, "lfs"));
|
||||||
|
|
||||||
lastUnsplit = 0L;
|
lastUnsplit = 0L;
|
||||||
|
@ -254,10 +254,7 @@ final class Actions {
|
||||||
private File selectFile(FILE_CHOOSER_TYPE dialogType) {
|
private File selectFile(FILE_CHOOSER_TYPE dialogType) {
|
||||||
int action = -1;
|
int action = -1;
|
||||||
|
|
||||||
if (this.file == null)
|
fileChooser.setCurrentDirectory(new File(UserSettings.getSplitsPath(this.file)));
|
||||||
fileChooser.setCurrentDirectory(new File(UserSettings.getSplitsPath()));
|
|
||||||
else
|
|
||||||
fileChooser.setCurrentDirectory(this.file);
|
|
||||||
|
|
||||||
if (dialogType == FILE_CHOOSER_TYPE.OPEN)
|
if (dialogType == FILE_CHOOSER_TYPE.OPEN)
|
||||||
action = fileChooser.showOpenDialog(master);
|
action = fileChooser.showOpenDialog(master);
|
||||||
|
|
|
@ -19,6 +19,8 @@ public enum Language {
|
||||||
|
|
||||||
// Settings > Generic
|
// Settings > Generic
|
||||||
setting_alwaysOnTop,
|
setting_alwaysOnTop,
|
||||||
|
setting_useDefaultSplitsPath,
|
||||||
|
setting_customSplitsPath,
|
||||||
setting_language,
|
setting_language,
|
||||||
setting_viewerLanguage,
|
setting_viewerLanguage,
|
||||||
setting_recentFiles,
|
setting_recentFiles,
|
||||||
|
@ -145,6 +147,7 @@ public enum Language {
|
||||||
error_import_run,
|
error_import_run,
|
||||||
error_window_width,
|
error_window_width,
|
||||||
error_max_recent_files,
|
error_max_recent_files,
|
||||||
|
error_splits_path,
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
action_accept,
|
action_accept,
|
||||||
|
@ -252,6 +255,7 @@ public enum Language {
|
||||||
RUN_FILE_FILTER,
|
RUN_FILE_FILTER,
|
||||||
SEGMENT,
|
SEGMENT,
|
||||||
SEGMENTS,
|
SEGMENTS,
|
||||||
|
SELECT_SPLITS_DIR,
|
||||||
SPLIT,
|
SPLIT,
|
||||||
TIME,
|
TIME,
|
||||||
UNTITLED,
|
UNTITLED,
|
||||||
|
|
|
@ -40,6 +40,8 @@ public class Settings {
|
||||||
public static final Property<Boolean> warnOnReset = new Property<>( "warnOnReset" );
|
public static final Property<Boolean> warnOnReset = new Property<>( "warnOnReset" );
|
||||||
public static final Property<Boolean> windowUserResizable = new Property<>( "windowUserResizable" );
|
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" );
|
||||||
|
public static final Property<Boolean> useDefaultSplitsPath = new Property<>( "useDefaultSplitsPath" );
|
||||||
|
public static final Property<String> customSplitsPath = new Property<>( "customSplitsPath" );
|
||||||
|
|
||||||
/* COLOR properties */
|
/* COLOR properties */
|
||||||
|
|
||||||
|
@ -222,6 +224,8 @@ public class Settings {
|
||||||
setDefault( warnOnReset.key, true, force );
|
setDefault( warnOnReset.key, true, force );
|
||||||
setDefault( windowUserResizable.key, true, force );
|
setDefault( windowUserResizable.key, true, force );
|
||||||
setDefault( windowWidth.key, null, force );
|
setDefault( windowWidth.key, null, force );
|
||||||
|
setDefault( useDefaultSplitsPath.key, true, force );
|
||||||
|
setDefault( customSplitsPath.key, null, force );
|
||||||
|
|
||||||
setDefault( colorBackground.key, Color.decode("0x000000"), force );
|
setDefault( colorBackground.key, Color.decode("0x000000"), force );
|
||||||
setDefault( colorForeground.key, Color.decode( "0xc0c0c0" ), force );
|
setDefault( colorForeground.key, Color.decode( "0xc0c0c0" ), force );
|
||||||
|
|
|
@ -5,12 +5,14 @@ import org.fenix.llanfair.Llanfair;
|
||||||
import org.fenix.llanfair.config.Accuracy;
|
import org.fenix.llanfair.config.Accuracy;
|
||||||
import org.fenix.llanfair.config.Compare;
|
import org.fenix.llanfair.config.Compare;
|
||||||
import org.fenix.llanfair.config.Settings;
|
import org.fenix.llanfair.config.Settings;
|
||||||
|
import org.fenix.utils.UserSettings;
|
||||||
import org.fenix.utils.gui.GBC;
|
import org.fenix.utils.gui.GBC;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.File;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -30,6 +32,12 @@ public class TabGeneral extends SettingsTab implements ActionListener {
|
||||||
|
|
||||||
private JLabel alwaysOnTopText;
|
private JLabel alwaysOnTopText;
|
||||||
|
|
||||||
|
private JCheckBox useDefaultSplitsPath;
|
||||||
|
|
||||||
|
private JTextField customSplitsPath;
|
||||||
|
|
||||||
|
private JButton selectCustomSplitsPath;
|
||||||
|
|
||||||
private ButtonGroup compare;
|
private ButtonGroup compare;
|
||||||
|
|
||||||
private JLabel compareText;
|
private JLabel compareText;
|
||||||
|
@ -63,6 +71,22 @@ public class TabGeneral extends SettingsTab implements ActionListener {
|
||||||
alwaysOnTop = new JCheckBox("" + Language.setting_alwaysOnTop);
|
alwaysOnTop = new JCheckBox("" + Language.setting_alwaysOnTop);
|
||||||
alwaysOnTop.setSelected(Settings.alwaysOnTop.get());
|
alwaysOnTop.setSelected(Settings.alwaysOnTop.get());
|
||||||
|
|
||||||
|
useDefaultSplitsPath = new JCheckBox("" + Language.setting_useDefaultSplitsPath);
|
||||||
|
useDefaultSplitsPath.setSelected(Settings.useDefaultSplitsPath.get());
|
||||||
|
useDefaultSplitsPath.addActionListener(this);
|
||||||
|
|
||||||
|
String path = UserSettings.getSplitsPath(null);
|
||||||
|
if (path == null)
|
||||||
|
path = "";
|
||||||
|
|
||||||
|
customSplitsPath = new JTextField(path);
|
||||||
|
customSplitsPath.setEnabled(!Settings.useDefaultSplitsPath.get());
|
||||||
|
customSplitsPath.setColumns(30);
|
||||||
|
|
||||||
|
selectCustomSplitsPath = new JButton("" + Language.SELECT_SPLITS_DIR);
|
||||||
|
selectCustomSplitsPath.addActionListener(this);
|
||||||
|
selectCustomSplitsPath.setEnabled(!Settings.useDefaultSplitsPath.get());
|
||||||
|
|
||||||
compare = new ButtonGroup();
|
compare = new ButtonGroup();
|
||||||
Compare setCmp = Settings.compareMethod.get();
|
Compare setCmp = Settings.compareMethod.get();
|
||||||
for (Compare method : Compare.values()) {
|
for (Compare method : Compare.values()) {
|
||||||
|
@ -133,6 +157,24 @@ public class TabGeneral extends SettingsTab implements ActionListener {
|
||||||
Settings.warnOnReset.set(warnOnReset.isSelected());
|
Settings.warnOnReset.set(warnOnReset.isSelected());
|
||||||
} else if (source.equals(windowUserResizable)) {
|
} else if (source.equals(windowUserResizable)) {
|
||||||
windowSize.setEnabled(!windowUserResizable.isSelected());
|
windowSize.setEnabled(!windowUserResizable.isSelected());
|
||||||
|
} else if (source.equals(useDefaultSplitsPath)) {
|
||||||
|
Settings.useDefaultSplitsPath.set(useDefaultSplitsPath.isSelected());
|
||||||
|
if (useDefaultSplitsPath.isEnabled())
|
||||||
|
Settings.customSplitsPath.set(null);
|
||||||
|
String path = UserSettings.getSplitsPath(null);
|
||||||
|
if (path == null)
|
||||||
|
path = "";
|
||||||
|
customSplitsPath.setText(path);
|
||||||
|
boolean enabled = !Settings.useDefaultSplitsPath.get();
|
||||||
|
customSplitsPath.setEnabled(enabled);
|
||||||
|
selectCustomSplitsPath.setEnabled(enabled);
|
||||||
|
} else if (source.equals(selectCustomSplitsPath)) {
|
||||||
|
JFileChooser chooser = new JFileChooser();
|
||||||
|
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||||
|
int action = chooser.showOpenDialog(this);
|
||||||
|
if (action == JFileChooser.APPROVE_OPTION) {
|
||||||
|
customSplitsPath.setText(chooser.getSelectedFile().toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +206,14 @@ public class TabGeneral extends SettingsTab implements ActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.maxRecentFiles.set(numRecentFiles);
|
Settings.maxRecentFiles.set(numRecentFiles);
|
||||||
|
|
||||||
|
if (!Settings.useDefaultSplitsPath.get()) {
|
||||||
|
String path = customSplitsPath.getText().trim();
|
||||||
|
if (!new File(path).exists()) {
|
||||||
|
throw new InvalidSettingException(this, customSplitsPath, "" + Language.error_splits_path);
|
||||||
|
}
|
||||||
|
Settings.customSplitsPath.set(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -187,6 +237,22 @@ public class TabGeneral extends SettingsTab implements ActionListener {
|
||||||
add(alwaysOnTop, GBC.grid(1, 0).anchor(GBC.LINE_START));
|
add(alwaysOnTop, GBC.grid(1, 0).anchor(GBC.LINE_START));
|
||||||
add(warnOnReset, GBC.grid(1, 1).anchor(GBC.LINE_START));
|
add(warnOnReset, GBC.grid(1, 1).anchor(GBC.LINE_START));
|
||||||
|
|
||||||
|
JPanel panelSplitsPath = new JPanel(new GridBagLayout()); {
|
||||||
|
panelSplitsPath.add(
|
||||||
|
useDefaultSplitsPath,
|
||||||
|
GBC.grid(0, 0, 2, 1).anchor(GBC.LINE_START)
|
||||||
|
);
|
||||||
|
panelSplitsPath.add(
|
||||||
|
customSplitsPath,
|
||||||
|
GBC.grid(0, 1).anchor(GBC.LINE_START).insets(0, 5)
|
||||||
|
);
|
||||||
|
panelSplitsPath.add(
|
||||||
|
selectCustomSplitsPath,
|
||||||
|
GBC.grid(1, 1).anchor(GBC.LINE_START)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
add(panelSplitsPath, GBC.grid(1, 2).anchor(GBC.LINE_START));
|
||||||
|
|
||||||
//add(languageText, GBC.grid(0, 2).anchor(GBC.LINE_END).insets(10, 10));
|
//add(languageText, GBC.grid(0, 2).anchor(GBC.LINE_END).insets(10, 10));
|
||||||
//add(language, GBC.grid(1, 2).fill(GBC.HORIZONTAL));
|
//add(language, GBC.grid(1, 2).fill(GBC.HORIZONTAL));
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.fenix.utils;
|
package org.fenix.utils;
|
||||||
|
|
||||||
|
import org.fenix.llanfair.config.Settings;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class UserSettings {
|
public class UserSettings {
|
||||||
|
@ -31,7 +33,19 @@ public class UserSettings {
|
||||||
* Returns the path to the location where splits can be saved in. This is
|
* Returns the path to the location where splits can be saved in. This is
|
||||||
* located as a subdirectory within the user settings directory.
|
* located as a subdirectory within the user settings directory.
|
||||||
*/
|
*/
|
||||||
public static String getSplitsPath() {
|
public static String getDefaultSplitsPath() {
|
||||||
return splitsPath.getPath();
|
return splitsPath.getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getSplitsPath(File selectedFile) {
|
||||||
|
if (selectedFile != null)
|
||||||
|
return selectedFile.toString();
|
||||||
|
else {
|
||||||
|
if (Settings.useDefaultSplitsPath.get())
|
||||||
|
return UserSettings.getDefaultSplitsPath();
|
||||||
|
else
|
||||||
|
return Settings.customSplitsPath.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Settings > Generic
|
# Settings > Generic
|
||||||
setting_alwaysOnTop = Always on Top
|
setting_alwaysOnTop = Always on Top
|
||||||
|
setting_useDefaultSplitsPath = Use Default Splits Directory
|
||||||
|
setting_customSplitsPath = Splits Directory
|
||||||
setting_language = Language
|
setting_language = Language
|
||||||
setting_viewerLanguage = Viewer's Language
|
setting_viewerLanguage = Viewer's Language
|
||||||
setting_recentFiles =
|
setting_recentFiles =
|
||||||
|
@ -126,6 +128,7 @@ 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.
|
error_max_recent_files = Recent files limit must be a positive integer.
|
||||||
|
error_splits_path = Splits Directory cannot be read or does not exist.
|
||||||
|
|
||||||
# Actions
|
# Actions
|
||||||
action_accept =
|
action_accept =
|
||||||
|
@ -226,6 +229,7 @@ RUN_TITLE = Run Title
|
||||||
RUN_FILE_FILTER = Llanfair Run Splits
|
RUN_FILE_FILTER = Llanfair Run Splits
|
||||||
SEGMENT = Time (Segment)
|
SEGMENT = Time (Segment)
|
||||||
SEGMENTS = Segments
|
SEGMENTS = Segments
|
||||||
|
SELECT_SPLITS_DIR = Choose ...
|
||||||
SPLIT = Split:
|
SPLIT = Split:
|
||||||
TIME = Time (Split)
|
TIME = Time (Split)
|
||||||
UNTITLED = <untitled>
|
UNTITLED = <untitled>
|
||||||
|
|
Reference in a new issue