simplifying bindings

This commit is contained in:
infeo
2019-07-31 12:49:21 +02:00
parent 4afb9d86c7
commit a7df100e56
2 changed files with 10 additions and 12 deletions

View File

@@ -1,20 +1,19 @@
package org.cryptomator.ui.addvaultwizard;
import dagger.Lazy;
import javafx.beans.property.BooleanProperty;
import javafx.beans.binding.BooleanBinding;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.Scene;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import org.cryptomator.common.settings.VaultSettings;
import org.cryptomator.common.vaults.Vault;
import org.cryptomator.common.vaults.VaultFactory;
import org.cryptomator.ui.common.FxController;
import org.cryptomator.ui.common.FxmlFile;
import org.cryptomator.ui.common.FxmlScene;
import org.cryptomator.common.vaults.Vault;
import org.cryptomator.common.vaults.VaultFactory;
import javax.inject.Inject;
import java.io.File;
@@ -28,7 +27,7 @@ public class ChooseExistingVaultController implements FxController {
private final Lazy<Scene> welcomeScene;
private final ObjectProperty<Path> vaultPath;
private final ObservableList<Vault> vaults;
private final BooleanProperty isVaultPathNull;
private final BooleanBinding vaultPathIsNull;
private final VaultFactory vaultFactory;
private final ResourceBundle resourceBundle;
@@ -40,8 +39,7 @@ public class ChooseExistingVaultController implements FxController {
this.vaults = vaults;
this.vaultFactory = vaultFactory;
this.resourceBundle = resourceBundle;
this.isVaultPathNull = new SimpleBooleanProperty();
isVaultPathNull.bind(vaultPath.isNull());
this.vaultPathIsNull = vaultPath.isNull();
}
@FXML
@@ -79,12 +77,12 @@ public class ChooseExistingVaultController implements FxController {
return vaultPath;
}
public boolean getIsVaultPathNull() {
return isVaultPathNull.get();
public boolean isVaultPathIsNull() {
return vaultPathIsNull.get();
}
public BooleanProperty isVaultPathNullProperty() {
return isVaultPathNull;
public BooleanBinding vaultPathIsNullProperty() {
return vaultPathIsNull;
}
}

View File

@@ -28,7 +28,7 @@
<ButtonBar buttonMinWidth="120" buttonOrder="B+I">
<buttons>
<Button text="TODO Back" ButtonBar.buttonData="BACK_PREVIOUS" onAction="#back"/>
<Button text="TODO Open" ButtonBar.buttonData="FINISH" onAction="#finish" defaultButton="true" disable="${controller.isVaultPathNull}"/>
<Button text="TODO Open" ButtonBar.buttonData="FINISH" onAction="#finish" defaultButton="true" disable="${controller.vaultPathIsNull}"/>
</buttons>
</ButtonBar>
</children>