diff options
Diffstat (limited to 'src/de/fhswf/in/inf/se/projektthemenvergabe/view/KommentarHinzufuegenController.java')
| -rw-r--r-- | src/de/fhswf/in/inf/se/projektthemenvergabe/view/KommentarHinzufuegenController.java | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/de/fhswf/in/inf/se/projektthemenvergabe/view/KommentarHinzufuegenController.java b/src/de/fhswf/in/inf/se/projektthemenvergabe/view/KommentarHinzufuegenController.java new file mode 100644 index 0000000..a88a6af --- /dev/null +++ b/src/de/fhswf/in/inf/se/projektthemenvergabe/view/KommentarHinzufuegenController.java @@ -0,0 +1,70 @@ +package de.fhswf.in.inf.se.projektthemenvergabe.view; + +import java.io.IOException; + +import javafx.application.Platform; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.control.ButtonType; +import javafx.scene.control.Dialog; +import javafx.scene.control.TextArea; +import javafx.scene.layout.AnchorPane; + +public class KommentarHinzufuegenController extends Dialog<String> +{ + @FXML + private TextArea kommentarTextArea; + + /** + * Create a {@link Dialog} with an empty {@link TextArea}. + * + */ + public KommentarHinzufuegenController() + { + this(""); + } + + /** + * Create a {@link Dialog} with a {@link TextArea} and initialValue as + * text. + * + */ + public KommentarHinzufuegenController(String initialValue) + { + setTitle("Projektkommentar hinzufügen"); + setHeaderText("Geben Sie einen Kommentar zu dem Projekt ein."); + + FXMLLoader fxmlLoader = new FXMLLoader( + getClass().getResource("KommentarHinzufuegen.fxml")); + fxmlLoader.setController(this); + + try + { + getDialogPane().setContent((AnchorPane) fxmlLoader.load()); + } + catch (IOException e) + { + // Ignoriert, da die FXML Datei immer da sein sollte :-P + e.printStackTrace(); + } + + kommentarTextArea.setText(initialValue); + + // Setze die Button Typen für den Dialog + getDialogPane().getButtonTypes().addAll(ButtonType.OK, + ButtonType.CANCEL); + + // Setze Focus auf TextArea + Platform.runLater(() -> kommentarTextArea.requestFocus()); + + // Wenn OK gedrückt wurde, gib ein den Kommentar zurück + setResultConverter(dialogButton -> { + if (dialogButton == ButtonType.OK) + { + return kommentarTextArea.getText(); + } + + return null; + }); + } +} |
