mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-20 01:26:52 -04:00
created MountServiceConverter class
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package org.cryptomator.common.mount;
|
||||
|
||||
import org.cryptomator.integrations.mount.MountService;
|
||||
|
||||
import javafx.util.StringConverter;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class MountServiceConverter extends StringConverter<MountService> {
|
||||
|
||||
private final ResourceBundle resourceBundle;
|
||||
|
||||
public MountServiceConverter(ResourceBundle resourceBundle) {
|
||||
this.resourceBundle = resourceBundle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(MountService provider) {
|
||||
if (provider == null) {
|
||||
return resourceBundle.getString("preferences.volume.type.automatic");
|
||||
} else {
|
||||
return provider.displayName();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MountService fromString(String string) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package org.cryptomator.ui.preferences;
|
||||
|
||||
import dagger.Lazy;
|
||||
import org.cryptomator.common.ObservableUtil;
|
||||
import org.cryptomator.common.mount.MountServiceConverter;
|
||||
import org.cryptomator.common.settings.Settings;
|
||||
import org.cryptomator.common.vaults.VaultModule;
|
||||
import org.cryptomator.integrations.mount.MountCapability;
|
||||
@@ -70,7 +71,7 @@ public class VolumePreferencesController implements FxController {
|
||||
public void initialize() {
|
||||
volumeTypeChoiceBox.getItems().add(null);
|
||||
volumeTypeChoiceBox.getItems().addAll(mountProviders);
|
||||
volumeTypeChoiceBox.setConverter(new MountServiceConverter());
|
||||
volumeTypeChoiceBox.setConverter(new MountServiceConverter(resourceBundle));
|
||||
boolean autoSelected = settings.mountService.get() == null;
|
||||
volumeTypeChoiceBox.getSelectionModel().select(autoSelected ? null : selectedMountService.getValue());
|
||||
volumeTypeChoiceBox.valueProperty().addListener((observableValue, oldProvider, newProvider) -> {
|
||||
@@ -149,25 +150,6 @@ public class VolumePreferencesController implements FxController {
|
||||
return fuseRestartRequired.getValue();
|
||||
}
|
||||
|
||||
/* Helpers */
|
||||
|
||||
public class MountServiceConverter extends StringConverter<MountService> {
|
||||
|
||||
@Override
|
||||
public String toString(MountService provider) {
|
||||
if (provider == null) {
|
||||
return resourceBundle.getString("preferences.volume.type.automatic");
|
||||
} else {
|
||||
return provider.displayName();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MountService fromString(String string) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
public void openDocs() {
|
||||
application.get().getHostServices().showDocument(DOCS_MOUNTING_URL);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.cryptomator.ui.vaultoptions;
|
||||
import com.google.common.base.Strings;
|
||||
import dagger.Lazy;
|
||||
import org.cryptomator.common.ObservableUtil;
|
||||
import org.cryptomator.common.mount.MountServiceConverter;
|
||||
import org.cryptomator.common.mount.WindowsDriveLetters;
|
||||
import org.cryptomator.common.settings.VaultSettings;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
@@ -141,7 +142,7 @@ public class MountOptionsController implements FxController {
|
||||
|
||||
vaultVolumeTypeChoiceBox.getItems().add(null);
|
||||
vaultVolumeTypeChoiceBox.getItems().addAll(mountProviders);
|
||||
vaultVolumeTypeChoiceBox.setConverter(new MountServiceConverter());
|
||||
vaultVolumeTypeChoiceBox.setConverter(new MountServiceConverter(resourceBundle));
|
||||
boolean autoSelected = vaultSettings.mountService.get() == null;
|
||||
vaultVolumeTypeChoiceBox.getSelectionModel().select(autoSelected ? null : selectedMountService.getValue());
|
||||
vaultVolumeTypeChoiceBox.valueProperty().addListener((observableValue, oldProvider, newProvider) -> {
|
||||
@@ -353,23 +354,4 @@ public class MountOptionsController implements FxController {
|
||||
return loopbackPortSupported.get();
|
||||
}
|
||||
|
||||
//Helpers
|
||||
/* Helpers */
|
||||
|
||||
private class MountServiceConverter extends StringConverter<MountService> {
|
||||
|
||||
@Override
|
||||
public String toString(MountService provider) {
|
||||
if (provider == null) {
|
||||
return resourceBundle.getString("preferences.volume.type.automatic");
|
||||
} else {
|
||||
return provider.displayName();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MountService fromString(String string) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user