mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-17 02:01:27 +00:00
cleanup and simplification
This commit is contained in:
@@ -46,6 +46,7 @@ public class UiModule {
|
||||
return executorService;
|
||||
}
|
||||
|
||||
// TODO @Binds abstract ExecutorService bindExecutorService(ScheduledExecutorService executor); ?
|
||||
@Provides
|
||||
@FxApplicationScoped
|
||||
ExecutorService provideExecutorService(@Named("shutdownTaskScheduler") Consumer<Runnable> shutdownTaskScheduler) {
|
||||
|
||||
@@ -9,16 +9,11 @@ import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import javafx.stage.Window;
|
||||
import org.cryptomator.ui.common.FXMLLoaderFactory;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.common.FxControllerKey;
|
||||
import org.cryptomator.ui.mainwindow.MainWindow;
|
||||
import org.cryptomator.ui.mainwindow.MainWindowController;
|
||||
import org.cryptomator.ui.mainwindow.VaultDetailController;
|
||||
import org.cryptomator.ui.mainwindow.VaultListController;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Provider;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package org.cryptomator.ui.mainwindow;
|
||||
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.binding.StringBinding;
|
||||
import javafx.beans.binding.Binding;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.model.Vault;
|
||||
import org.fxmisc.easybind.EasyBind;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -13,39 +13,34 @@ import javax.inject.Inject;
|
||||
public class VaultListCellController implements FxController {
|
||||
|
||||
private final ObjectProperty<Vault> vault = new SimpleObjectProperty<>();
|
||||
private final StringBinding glyph;
|
||||
private final Binding<String> glyph;
|
||||
|
||||
@Inject
|
||||
VaultListCellController() {
|
||||
this.glyph = Bindings.createStringBinding(this::getGlyphForVault, vault);
|
||||
this.glyph = EasyBind.select(vault).selectObject(Vault::stateProperty).map(this::getGlyphForVaultState).orElse("WARNING");
|
||||
}
|
||||
|
||||
private String getGlyphForVault() {
|
||||
Vault v = vault.get();
|
||||
if (v == null) {
|
||||
return "WARNING";
|
||||
} else {
|
||||
switch (v.getState()) {
|
||||
case LOCKED:
|
||||
return "LOCK";
|
||||
case UNLOCKED:
|
||||
return "UNLOCK";
|
||||
case PROCESSING:
|
||||
return "SPINNER";
|
||||
default:
|
||||
return "WARNING";
|
||||
}
|
||||
private String getGlyphForVaultState(Vault.State state) {
|
||||
switch (state) {
|
||||
case LOCKED:
|
||||
return "LOCK";
|
||||
case PROCESSING:
|
||||
return "SPINNER";
|
||||
case UNLOCKED:
|
||||
return "UNLOCK";
|
||||
default:
|
||||
return "WARNING";
|
||||
}
|
||||
}
|
||||
|
||||
/* Getter/Setter */
|
||||
|
||||
public StringBinding glyphProperty() {
|
||||
public Binding<String> glyphProperty() {
|
||||
return glyph;
|
||||
}
|
||||
|
||||
public String getGlyph() {
|
||||
return glyph.get();
|
||||
return glyph.getValue();
|
||||
}
|
||||
|
||||
public ObjectProperty<Vault> vaultProperty() {
|
||||
|
||||
Reference in New Issue
Block a user