removing defaultMountDir from the settings

This commit is contained in:
infeo
2018-02-19 23:14:28 +01:00
parent c957f93ce6
commit d0d83c6833
14 changed files with 65 additions and 136 deletions
@@ -30,8 +30,7 @@ public class Settings {
public static final int DEFAULT_NUM_TRAY_NOTIFICATIONS = 3;
public static final String DEFAULT_GVFS_SCHEME = "dav";
public static final boolean DEFAULT_DEBUG_MODE = false;
public static final String DEFAULT_DEFAULT_MOUNT_DIR = System.getProperty("user.home");
public static final String DEFAULT_NIO_ADAPTER = "webdav";
public static final String DEFAULT_NIO_ADAPTER = "WEBDAV";
private final ObservableList<VaultSettings> directories = FXCollections.observableArrayList(VaultSettings::observables);
private final BooleanProperty checkForUpdates = new SimpleBooleanProperty(DEFAULT_CHECK_FOR_UDPATES);
@@ -40,7 +39,6 @@ public class Settings {
private final StringProperty preferredGvfsScheme = new SimpleStringProperty(DEFAULT_GVFS_SCHEME);
private final BooleanProperty debugMode = new SimpleBooleanProperty(DEFAULT_DEBUG_MODE);
private final StringProperty nioAdapterImpl = new SimpleStringProperty(DEFAULT_NIO_ADAPTER);
private final StringProperty defaultMountDir = new SimpleStringProperty(DEFAULT_DEFAULT_MOUNT_DIR);
private Consumer<Settings> saveCmd;
@@ -55,7 +53,6 @@ public class Settings {
preferredGvfsScheme.addListener(this::somethingChanged);
debugMode.addListener(this::somethingChanged);
nioAdapterImpl.addListener(this::somethingChanged);
defaultMountDir.addListener(this::somethingChanged);
}
void setSaveCmd(Consumer<Settings> saveCmd) {
@@ -102,7 +99,4 @@ public class Settings {
return nioAdapterImpl;
}
public StringProperty defaultMountDir() {
return defaultMountDir;
}
}
@@ -34,7 +34,6 @@ public class SettingsJsonAdapter extends TypeAdapter<Settings> {
out.name("preferredGvfsScheme").value(value.preferredGvfsScheme().get());
out.name("debugMode").value(value.debugMode().get());
out.name("nioAdapterImpl").value(value.usedNioAdapterImpl().get());
out.name("defaultMountDir").value(value.defaultMountDir().get());
out.endObject();
}
@@ -54,33 +53,30 @@ public class SettingsJsonAdapter extends TypeAdapter<Settings> {
while (in.hasNext()) {
String name = in.nextName();
switch (name) {
case "directories":
settings.getDirectories().addAll(readVaultSettingsArray(in));
break;
case "checkForUpdatesEnabled":
settings.checkForUpdates().set(in.nextBoolean());
break;
case "port":
settings.port().set(in.nextInt());
break;
case "numTrayNotifications":
settings.numTrayNotifications().set(in.nextInt());
break;
case "preferredGvfsScheme":
settings.preferredGvfsScheme().set(in.nextString());
break;
case "debugMode":
settings.debugMode().set(in.nextBoolean());
break;
case "nioAdapterImpl":
settings.usedNioAdapterImpl().set(in.nextString());
break;
case "defaultMountDir":
settings.defaultMountDir().set(in.nextString());
break;
default:
LOG.warn("Unsupported vault setting found in JSON: " + name);
in.skipValue();
case "directories":
settings.getDirectories().addAll(readVaultSettingsArray(in));
break;
case "checkForUpdatesEnabled":
settings.checkForUpdates().set(in.nextBoolean());
break;
case "port":
settings.port().set(in.nextInt());
break;
case "numTrayNotifications":
settings.numTrayNotifications().set(in.nextInt());
break;
case "preferredGvfsScheme":
settings.preferredGvfsScheme().set(in.nextString());
break;
case "debugMode":
settings.debugMode().set(in.nextBoolean());
break;
case "nioAdapterImpl":
settings.usedNioAdapterImpl().set(in.nextString());
break;
default:
LOG.warn("Unsupported vault setting found in JSON: " + name);
in.skipValue();
}
}
in.endObject();
@@ -36,7 +36,7 @@ public class VaultSettings {
private final BooleanProperty unlockAfterStartup = new SimpleBooleanProperty(DEFAULT_UNLOCK_AFTER_STARTUP);
private final BooleanProperty mountAfterUnlock = new SimpleBooleanProperty(DEFAULT_MOUNT_AFTER_UNLOCK);
private final BooleanProperty revealAfterMount = new SimpleBooleanProperty(DEFAULT_REAVEAL_AFTER_MOUNT);
private final StringProperty mountPath = new SimpleStringProperty(Settings.DEFAULT_DEFAULT_MOUNT_DIR);
private final StringProperty mountPath = new SimpleStringProperty();
public VaultSettings(String id) {
this.id = Objects.requireNonNull(id);
@@ -45,7 +45,7 @@ public class VaultSettings {
}
Observable[] observables() {
return new Observable[] {path, mountName, winDriveLetter, unlockAfterStartup, mountAfterUnlock, revealAfterMount};
return new Observable[]{path, mountName, winDriveLetter, unlockAfterStartup, mountAfterUnlock, revealAfterMount};
}
private void deriveMountNameFromPath(Path path) {
@@ -35,7 +35,6 @@ public class SettingsJsonAdapterTest {
Assert.assertEquals(42, settings.numTrayNotifications().get());
Assert.assertEquals("dav", settings.preferredGvfsScheme().get());
Assert.assertEquals("webdav", settings.usedNioAdapterImpl().get());
Assert.assertEquals("/home/test/crypto", settings.defaultMountDir().get());
}
}