added disabled state to reveal button in unlock success

This commit is contained in:
Tobias Hagemann
2019-09-06 13:29:22 +02:00
parent 9eee7883c5
commit df8fbe6440
2 changed files with 15 additions and 1 deletions

View File

@@ -1,7 +1,9 @@
package org.cryptomator.ui.unlock;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.control.ContentDisplay;
import javafx.stage.Stage;
@@ -24,6 +26,7 @@ public class UnlockSuccessController implements FxController {
private final Vault vault;
private final ExecutorService executor;
private final ObjectProperty<ContentDisplay> revealButtonState;
private final BooleanProperty revealButtonDisabled;
@Inject
public UnlockSuccessController(@UnlockWindow Stage window, @UnlockWindow Vault vault, ExecutorService executor) {
@@ -31,6 +34,7 @@ public class UnlockSuccessController implements FxController {
this.vault = vault;
this.executor = executor;
this.revealButtonState = new SimpleObjectProperty<>(ContentDisplay.TEXT_ONLY);
this.revealButtonDisabled = new SimpleBooleanProperty();
}
@@ -42,6 +46,7 @@ public class UnlockSuccessController implements FxController {
public void revealAndClose() {
LOG.trace("UnlockSuccessController.revealAndClose()");
revealButtonState.set(ContentDisplay.LEFT);
revealButtonDisabled.set(true);
Tasks.create(() -> {
vault.reveal();
}).onSuccess(() -> {
@@ -51,6 +56,7 @@ public class UnlockSuccessController implements FxController {
LOG.warn("Reveal failed.", e);
}).andFinally(() -> {
revealButtonState.set(ContentDisplay.TEXT_ONLY);
revealButtonDisabled.set(false);
}).runOnce(executor);
}
@@ -68,4 +74,12 @@ public class UnlockSuccessController implements FxController {
return revealButtonState.get();
}
public BooleanProperty revealButtonDisabledProperty() {
return revealButtonDisabled;
}
public boolean isRevealButtonDisabled() {
return revealButtonDisabled.get();
}
}

View File

@@ -33,7 +33,7 @@
<ButtonBar buttonMinWidth="120" buttonOrder="+CI">
<buttons>
<Button text="%generic.button.done" ButtonBar.buttonData="CANCEL_CLOSE" cancelButton="true" onAction="#close"/>
<Button text="%unlock.success.revealBtn" ButtonBar.buttonData="FINISH" defaultButton="true" onAction="#revealAndClose" contentDisplay="${controller.revealButtonState}">
<Button text="%unlock.success.revealBtn" ButtonBar.buttonData="FINISH" defaultButton="true" onAction="#revealAndClose" contentDisplay="${controller.revealButtonState}" disable="${controller.revealButtonDisabled}">
<graphic>
<ProgressIndicator progress="-1" prefWidth="12" prefHeight="12"/>
</graphic>