mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-17 10:11:27 +00:00
simple dialog without cancel button
This commit is contained in:
@@ -31,8 +31,9 @@ public class SimpleDialog {
|
||||
FxmlLoaderFactory loaderFactory = FxmlLoaderFactory.forController( //
|
||||
new SimpleDialogController(resolveText(builder.messageKey, null), //
|
||||
resolveText(builder.descriptionKey, null), //
|
||||
builder.icon, resolveText(builder.okButtonKey, null), //
|
||||
resolveText(builder.cancelButtonKey, null), //
|
||||
builder.icon, //
|
||||
resolveText(builder.okButtonKey, null), //
|
||||
builder.cancelButtonKey != null ? resolveText(builder.cancelButtonKey, null) : null, //
|
||||
() -> builder.okAction.accept(dialogStage), //
|
||||
() -> builder.cancelAction.accept(dialogStage)), //
|
||||
Scene::new, builder.resourceBundle);
|
||||
@@ -67,7 +68,6 @@ public class SimpleDialog {
|
||||
private String descriptionKey;
|
||||
private String okButtonKey;
|
||||
private String cancelButtonKey;
|
||||
|
||||
private FontAwesome5Icon icon;
|
||||
private Consumer<Stage> okAction = Stage::close;
|
||||
private Consumer<Stage> cancelAction = Stage::close;
|
||||
@@ -128,7 +128,6 @@ public class SimpleDialog {
|
||||
Objects.requireNonNull(messageKey, "SimpleDialog messageKey must be set.");
|
||||
Objects.requireNonNull(descriptionKey, "SimpleDialog descriptionKey must be set.");
|
||||
Objects.requireNonNull(okButtonKey, "SimpleDialog okButtonKey must be set.");
|
||||
Objects.requireNonNull(cancelButtonKey, "SimpleDialog cancelButtonKey must be set.");
|
||||
|
||||
try {
|
||||
return new SimpleDialog(this);
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.cryptomator.ui.dialogs;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.controls.FontAwesome5Icon;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.fxml.FXML;
|
||||
|
||||
public class SimpleDialogController implements FxController {
|
||||
@@ -14,6 +16,7 @@ public class SimpleDialogController implements FxController {
|
||||
private final String cancelButtonText;
|
||||
private final Runnable okAction;
|
||||
private final Runnable cancelAction;
|
||||
private final BooleanProperty dismissed = new SimpleBooleanProperty();
|
||||
|
||||
public SimpleDialogController(String message, String description, FontAwesome5Icon icon, String okButtonText, String cancelButtonText, Runnable okAction, Runnable cancelAction) {
|
||||
this.message = message;
|
||||
@@ -24,6 +27,10 @@ public class SimpleDialogController implements FxController {
|
||||
this.okAction = okAction;
|
||||
this.cancelAction = cancelAction;
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
dismissed.set(cancelButtonText == null || cancelButtonText.isEmpty());
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
@@ -45,6 +52,11 @@ public class SimpleDialogController implements FxController {
|
||||
return cancelButtonText;
|
||||
}
|
||||
|
||||
@FXML
|
||||
public boolean getDismissed() {
|
||||
return dismissed.get();
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void handleOk() {
|
||||
if (okAction != null) {
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<Region VBox.vgrow="ALWAYS" minHeight="18"/>
|
||||
<ButtonBar buttonMinWidth="120" buttonOrder="+CI">
|
||||
<buttons>
|
||||
<Button text="${controller.cancelButtonText}" ButtonBar.buttonData="CANCEL_CLOSE" cancelButton="true" onAction="#handleCancel"/>
|
||||
<Button text="${controller.cancelButtonText}" ButtonBar.buttonData="CANCEL_CLOSE" cancelButton="true" onAction="#handleCancel" visible="${controller.dismissed}" managed="${controller.dismissed}"/>
|
||||
<Button text="${controller.okButtonText}" ButtonBar.buttonData="FINISH" defaultButton="true" onAction="#handleOk"/>
|
||||
</buttons>
|
||||
</ButtonBar>
|
||||
|
||||
Reference in New Issue
Block a user