diff --git a/client/app/src/main/java/main/CreateEventController.java b/client/app/src/main/java/main/CreateEventController.java index 14d52d3..e35e339 100644 --- a/client/app/src/main/java/main/CreateEventController.java +++ b/client/app/src/main/java/main/CreateEventController.java @@ -3,10 +3,7 @@ package main; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Node; -import javafx.scene.control.CheckBox; -import javafx.scene.control.ComboBox; -import javafx.scene.control.DatePicker; -import javafx.scene.control.TextField; +import javafx.scene.control.*; import javafx.stage.Stage; import res.DataController; import res.Event; @@ -29,39 +26,51 @@ public class CreateEventController { public CheckBox checkBoxIsFullDay; @FXML public CheckBox checkBoxIsPrivate; - - - public CreateEventController(){} - @FXML - public void initialize(){} + public Label labelError; - @FXML - protected void createBtnClick(ActionEvent actionEvent){ - Event event = new Event( - textName.getText(), - ComboBoxPriotity.getSelectionModel().getSelectedIndex(), - checkBoxIsFullDay.isSelected(), - checkBoxIsPrivate.isSelected(), - textStart.getText(), - textEnd.getText(), - datePickerDate.getValue().atStartOfDay(), - 1 - ); - - System.out.println(event.getAsUrlParam()); - - DataController dataController = new DataController(); - dataController.createEvent(event); - - Stage stage = (Stage) ((Node) actionEvent.getSource()).getScene().getWindow(); - stage.close(); + public CreateEventController() { } @FXML - protected void abortBtnClick(ActionEvent event){ + public void initialize() { + } + + + @FXML + protected void createBtnClick(ActionEvent actionEvent) { + try { + if(datePickerDate.getValue() == null){ + throw new IllegalArgumentException("Bitte w\u00e4hle ein Datum aus"); + } + + Event event = new Event( + textName.getText(), + ComboBoxPriotity.getSelectionModel().getSelectedIndex(), + checkBoxIsFullDay.isSelected(), + checkBoxIsPrivate.isSelected(), + textStart.getText(), + textEnd.getText(), + datePickerDate.getValue().atStartOfDay(), + 1 + ); + + System.out.println(event.getAsUrlParam()); + + DataController dataController = new DataController(); + dataController.createEvent(event); + + Stage stage = (Stage) ((Node) actionEvent.getSource()).getScene().getWindow(); + stage.close(); + } catch (RuntimeException e) { + labelError.setText(e.getMessage()); + } + } + + @FXML + protected void abortBtnClick(ActionEvent event) { Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); stage.close(); } diff --git a/client/app/src/main/java/main/MainController.java b/client/app/src/main/java/main/MainController.java index 36f3aed..984b955 100644 --- a/client/app/src/main/java/main/MainController.java +++ b/client/app/src/main/java/main/MainController.java @@ -69,7 +69,7 @@ public class MainController { protected void onAddBtnClick() { try { FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("create-event.fxml")); - Scene scene = new Scene(fxmlLoader.load(), 650, 500); + Scene scene = new Scene(fxmlLoader.load(), 650, 650); scene.getStylesheets().add(Objects.requireNonNull(MainApplication.class.getResource("create-event.css")).toExternalForm()); Stage stage = new Stage(); stage.setTitle("Termin erstellen"); diff --git a/client/app/src/main/resources/main/create-event.css b/client/app/src/main/resources/main/create-event.css index 59602e9..442c669 100644 --- a/client/app/src/main/resources/main/create-event.css +++ b/client/app/src/main/resources/main/create-event.css @@ -32,4 +32,15 @@ Label{ .mainButton{ -fx-font-weight: bold; +} + +#labelError{ + -fx-font-weight: bold; + -fx-max-width: 1000px; + -fx-text-fill: #ff5555; + -fx-padding: 16px; + -fx-min-height: 140px; + -fx-max-height: 400px; + -fx-wrap-text: true; + -fx-font-size: 16px; } \ No newline at end of file diff --git a/client/app/src/main/resources/main/create-event.fxml b/client/app/src/main/resources/main/create-event.fxml index 2ca5917..b3600c8 100644 --- a/client/app/src/main/resources/main/create-event.fxml +++ b/client/app/src/main/resources/main/create-event.fxml @@ -22,6 +22,7 @@ + @@ -51,8 +52,9 @@ +