mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-14 08:41:28 +00:00
replaced setters and extended the constructor of SimpleDialogController
This commit is contained in:
@@ -4,8 +4,6 @@ import org.cryptomator.ui.common.FxmlFile;
|
||||
import org.cryptomator.ui.common.FxmlLoaderFactory;
|
||||
import org.cryptomator.ui.controls.FontAwesome5Icon;
|
||||
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
@@ -30,20 +28,16 @@ public class SimpleDialog {
|
||||
dialogStage.setTitle(resolveText(builder.titleKey, builder.titleArgs));
|
||||
dialogStage.setResizable(false);
|
||||
|
||||
FxmlLoaderFactory loaderFactory = FxmlLoaderFactory.forController(new SimpleDialogController(), Scene::new, builder.resourceBundle);
|
||||
FXMLLoader loader = loaderFactory.load(FxmlFile.SIMPLE_DIALOG.getRessourcePathString());
|
||||
SimpleDialogController controller = loader.getController();
|
||||
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.okAction.accept(dialogStage),
|
||||
() -> builder.cancelAction.accept(dialogStage)),
|
||||
Scene::new, builder.resourceBundle);
|
||||
|
||||
controller.setMessage(resolveText(builder.messageKey, null));
|
||||
controller.setDescription(resolveText(builder.descriptionKey, null));
|
||||
controller.setIcon(builder.icon);
|
||||
controller.setOkButtonText(resolveText(builder.okButtonKey, null));
|
||||
controller.setCancelButtonText(resolveText(builder.cancelButtonKey, null));
|
||||
|
||||
controller.setOkAction(() -> builder.okAction.accept(dialogStage));
|
||||
controller.setCancelAction(() -> builder.cancelAction.accept(dialogStage));
|
||||
|
||||
dialogStage.setScene(new Scene(loader.getRoot()));
|
||||
dialogStage.setScene(new Scene(loaderFactory.load(FxmlFile.SIMPLE_DIALOG.getRessourcePathString()).getRoot()));
|
||||
}
|
||||
|
||||
public void showAndWait() {
|
||||
|
||||
@@ -2,54 +2,47 @@ package org.cryptomator.ui.dialogs;
|
||||
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.controls.FontAwesome5Icon;
|
||||
import org.cryptomator.ui.controls.FontAwesome5IconView;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
|
||||
public class SimpleDialogController implements FxController {
|
||||
|
||||
@FXML
|
||||
private Label messageLabel;
|
||||
@FXML
|
||||
private Label descriptionLabel;
|
||||
@FXML
|
||||
private FontAwesome5IconView iconView;
|
||||
@FXML
|
||||
private Button okButton;
|
||||
@FXML
|
||||
private Button cancelButton;
|
||||
private final String message;
|
||||
private final String description;
|
||||
private final FontAwesome5Icon icon;
|
||||
private final String okButtonText;
|
||||
private final String cancelButtonText;
|
||||
private final Runnable okAction;
|
||||
private final Runnable cancelAction;
|
||||
|
||||
private Runnable okAction;
|
||||
private Runnable cancelAction;
|
||||
|
||||
public void setMessage(String message) {
|
||||
messageLabel.setText(message);
|
||||
public SimpleDialogController(String message, String description, FontAwesome5Icon icon, String okButtonText, String cancelButtonText, Runnable okAction, Runnable cancelAction) {
|
||||
this.message = message;
|
||||
this.description = description;
|
||||
this.icon = icon;
|
||||
this.okButtonText = okButtonText;
|
||||
this.cancelButtonText = cancelButtonText;
|
||||
this.okAction = okAction;
|
||||
this.cancelAction = cancelAction;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
descriptionLabel.setText(description);
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setIcon(FontAwesome5Icon icon) {
|
||||
iconView.setGlyph(icon);
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setOkButtonText(String text) {
|
||||
okButton.setText(text);
|
||||
public FontAwesome5Icon getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setCancelButtonText(String text) {
|
||||
cancelButton.setText(text);
|
||||
public String getOkButtonText() {
|
||||
return okButtonText;
|
||||
}
|
||||
|
||||
public void setOkAction(Runnable action) {
|
||||
this.okAction = action;
|
||||
}
|
||||
|
||||
public void setCancelAction(Runnable action) {
|
||||
this.cancelAction = action;
|
||||
public String getCancelButtonText() {
|
||||
return cancelButtonText;
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
||||
@@ -28,21 +28,21 @@
|
||||
<Insets topRightBottomLeft="6"/>
|
||||
</padding>
|
||||
<Circle styleClass="glyph-icon-primary" radius="24"/>
|
||||
<FontAwesome5IconView fx:id="iconView" styleClass="glyph-icon-white" glyph="QUESTION" glyphSize="24"/>
|
||||
<FontAwesome5IconView glyph="${controller.icon}" styleClass="glyph-icon-white" glyphSize="24"/>
|
||||
</StackPane>
|
||||
</Group>
|
||||
<VBox HBox.hgrow="ALWAYS">
|
||||
<Label fx:id="messageLabel" styleClass="label-large" wrapText="true">
|
||||
<Label text="${controller.message}" styleClass="label-large" wrapText="true">
|
||||
<padding>
|
||||
<Insets bottom="6" top="6"/>
|
||||
</padding>
|
||||
</Label>
|
||||
<Label fx:id="descriptionLabel" wrapText="true"/>
|
||||
<Label text="${controller.description}" wrapText="true"/>
|
||||
<Region VBox.vgrow="ALWAYS" minHeight="18"/>
|
||||
<ButtonBar buttonMinWidth="120" buttonOrder="+CI">
|
||||
<buttons>
|
||||
<Button fx:id="cancelButton" ButtonBar.buttonData="CANCEL_CLOSE" cancelButton="true" onAction="#handleCancel"/>
|
||||
<Button fx:id="okButton" ButtonBar.buttonData="FINISH" defaultButton="true" onAction="#handleOk"/>
|
||||
<Button text="${controller.cancelButtonText}" ButtonBar.buttonData="CANCEL_CLOSE" cancelButton="true" onAction="#handleCancel"/>
|
||||
<Button text="${controller.okButtonText}" ButtonBar.buttonData="FINISH" defaultButton="true" onAction="#handleOk"/>
|
||||
</buttons>
|
||||
</ButtonBar>
|
||||
</VBox>
|
||||
|
||||
Reference in New Issue
Block a user