final File propertiesFile = getPropertiesFile();
if (!propertiesFile.exists()) {
initDefaultConfiguration();
- saveConfigFile();
} else
loadConfigFile(propertiesFile);
}
- private void loadConfigFile(File propertiesFile) throws FileNotFoundException, com.esotericsoftware.yamlbeans.YamlException {
+ private void loadConfigFile(File propertiesFile) throws IOException {
YamlReader reader = new YamlReader(new FileReader(propertiesFile));
configuration = reader.read(Configuration.class);
- if (configuration == null) {
- configuration = new Configuration();
- configuration.fileAssociations = new HashSet<>();
- }
+ if (configuration == null)
+ initDefaultConfiguration();
}
private void saveConfigFile() throws IOException {
configuration.fileAssociations.add(association);
}
- private void initDefaultConfiguration() {
+ private void initDefaultConfiguration() throws IOException {
+ configuration = new Configuration();
+ configuration.fileAssociations = new HashSet<>();
+
configuration.navigationRootPath = System.getProperty("user.home") + "/";
configuration.directoryOpenCommand = "nautilus -w {file}";
registerFileAssociation(".*\\.avi$", "vlc {file}");
registerFileAssociation(".*\\.mp4$", "vlc {file}");
registerFileAssociation(".*\\.mkv$", "vlc {file}");
+
+ saveConfigFile();
}
}