Jan-Peter Klein 1 месяц назад
Родитель
Сommit
41a279da9d

+ 11 - 9
src/main/java/org/cryptomator/ui/dialogs/SimpleDialogController.java

@@ -16,7 +16,8 @@ public class SimpleDialogController implements FxController {
 	private final String cancelButtonText;
 	private final Runnable okAction;
 	private final Runnable cancelAction;
-	private final BooleanProperty dismissed = new SimpleBooleanProperty();
+	private final BooleanProperty cancelButtonVisible = new SimpleBooleanProperty(true);
+
 
 	public SimpleDialogController(String message, String description, FontAwesome5Icon icon, String okButtonText, String cancelButtonText, Runnable okAction, Runnable cancelAction) {
 		this.message = message;
@@ -26,12 +27,18 @@ public class SimpleDialogController implements FxController {
 		this.cancelButtonText = cancelButtonText;
 		this.okAction = okAction;
 		this.cancelAction = cancelAction;
+		this.cancelButtonVisible.set(cancelButtonText != null && !cancelButtonText.isEmpty());
+	}
+
+	public BooleanProperty cancelButtonVisibleProperty() {
+		return cancelButtonVisible;
 	}
-	
-	public void initialize() {
-		dismissed.set(cancelButtonText == null || cancelButtonText.isEmpty());
+
+	public boolean isCancelButtonVisible(){
+		return cancelButtonVisible.get();
 	}
 
+
 	public String getMessage() {
 		return message;
 	}
@@ -52,11 +59,6 @@ public class SimpleDialogController implements FxController {
 		return cancelButtonText;
 	}
 
-	@FXML
-	public boolean getDismissed() {
-		return dismissed.get();
-	}
-
 	@FXML
 	private void handleOk() {
 		if (okAction != null) {

+ 1 - 1
src/main/resources/fxml/simple_dialog.fxml

@@ -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" visible="${controller.dismissed}" managed="${controller.dismissed}"/>
+					<Button text="${controller.cancelButtonText}" ButtonBar.buttonData="CANCEL_CLOSE" cancelButton="true" onAction="#handleCancel" visible="${controller.cancelButtonVisible}" managed="${controller.cancelButtonVisible}"/>
 					<Button text="${controller.okButtonText}" ButtonBar.buttonData="FINISH" defaultButton="true" onAction="#handleOk"/>
 				</buttons>
 			</ButtonBar>