diff --git a/client/app/src/main/java/main/CreateEventController.java b/client/app/src/main/java/main/CreateEventController.java index 14d52d3..d77c407 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,50 @@ 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(), + (int) DataController.USER_ID + ); + + 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/Launcher.java b/client/app/src/main/java/main/Launcher.java index fd5d4c8..38c385d 100644 --- a/client/app/src/main/java/main/Launcher.java +++ b/client/app/src/main/java/main/Launcher.java @@ -1,7 +1,7 @@ package main; public class Launcher { - + public static void main(String[] args) { MainApplication.main(args); } diff --git a/client/app/src/main/java/main/MainApplication.java b/client/app/src/main/java/main/MainApplication.java index ac5f771..6efcaa1 100644 --- a/client/app/src/main/java/main/MainApplication.java +++ b/client/app/src/main/java/main/MainApplication.java @@ -4,6 +4,7 @@ import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.stage.Stage; +import res.DataController; import java.io.IOException; import java.util.Objects; @@ -14,19 +15,23 @@ public class MainApplication extends Application { FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("main-view.fxml")); Scene scene = new Scene(fxmlLoader.load(), 1200, 700); - scene.getStylesheets().add(Objects.requireNonNull(MainApplication.class.getResource("main-view.css")).toExternalForm()); + scene.getStylesheets().add(Objects.requireNonNull( + MainApplication.class.getResource("main-view.css")).toExternalForm()); stage.setTitle("SharePlaner"); stage.setScene(scene); - stage.show(); FXMLLoader fxmlLoaderLogin = new FXMLLoader(MainApplication.class.getResource("../users/login.fxml")); Scene sceneLogin = new Scene(fxmlLoaderLogin.load(), 650, 500); - sceneLogin.getStylesheets().add(Objects.requireNonNull(MainApplication.class.getResource("../users/login.css")).toExternalForm()); + sceneLogin.getStylesheets().add(Objects.requireNonNull( + MainApplication.class.getResource("../users/login.css")).toExternalForm()); Stage stageLogin = new Stage(); stageLogin.setTitle("Anmelden"); stageLogin.setScene(sceneLogin); - stageLogin.show(); + stageLogin.showAndWait(); + if (DataController.USER_ID >= 0) { + stage.show(); + } } public static void main(String[] args) { diff --git a/client/app/src/main/java/main/MainController.java b/client/app/src/main/java/main/MainController.java index 36f3aed..c7092a7 100644 --- a/client/app/src/main/java/main/MainController.java +++ b/client/app/src/main/java/main/MainController.java @@ -65,12 +65,35 @@ public class MainController { } } + @FXML + protected void onBackClick() { + weekOffset--; + setDates(); + updateEvents(); + } + + @FXML + protected void onTodayClick() { + weekOffset = 0; + setDates(); + updateEvents(); + } + + @FXML + protected void onNextClick() { + weekOffset++; + setDates(); + updateEvents(); + } + @FXML protected void onAddBtnClick() { try { - FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("create-event.fxml")); - Scene scene = new Scene(fxmlLoader.load(), 650, 500); - scene.getStylesheets().add(Objects.requireNonNull(MainApplication.class.getResource("create-event.css")).toExternalForm()); + FXMLLoader fxmlLoader = new FXMLLoader( + MainApplication.class.getResource("create-event.fxml")); + 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"); stage.setScene(scene); @@ -161,7 +184,8 @@ public class MainController { LocalDateTime eventDate = event.getDate(); - int day = (int) Duration.between(weekStartDateTime.toLocalDate().atStartOfDay(), eventDate.toLocalDate().atStartOfDay()).toDays(); + int day = (int) Duration.between( + weekStartDateTime.toLocalDate().atStartOfDay(), eventDate.toLocalDate().atStartOfDay()).toDays(); if (day >= 0 && day < 7) { dayVBoxes[day].getChildren().add(vBox); diff --git a/client/app/src/main/java/users/LoginControler.java b/client/app/src/main/java/users/LoginControler.java deleted file mode 100644 index df20ac2..0000000 --- a/client/app/src/main/java/users/LoginControler.java +++ /dev/null @@ -1,4 +0,0 @@ -package users; - -public class LoginControler { -} diff --git a/client/app/src/main/java/users/LoginController.java b/client/app/src/main/java/users/LoginController.java new file mode 100644 index 0000000..0350460 --- /dev/null +++ b/client/app/src/main/java/users/LoginController.java @@ -0,0 +1,50 @@ +package users; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.Node; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.stage.Stage; +import res.DataController; + +public class LoginController { + @FXML + public TextField userField; + @FXML + public TextField passField; + @FXML + public Label userErrLabel; + @FXML + public Label passErrLabel; + + @FXML + protected void login(ActionEvent event) { + if (userField.getText().trim().isEmpty()) { + userErrLabel.setText("Bitte Usernamen eingeben!"); + passErrLabel.setText(""); + return; + } + if (passField.getText().trim().isEmpty()) { + userErrLabel.setText(""); + passErrLabel.setText("Bitte Passwort eingeben!"); + return; + } + + DataController dataController = new DataController(); + if (!dataController.login(userField.getText(), passField.getText())) { + userErrLabel.setText("Name und Passwort passen nicht zueinander!"); + passErrLabel.setText("Name und Passwort passen nicht zueinander!"); + return; + } + + Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); + stage.close(); + } + + @FXML + protected void abortBtnClick(ActionEvent event) { + Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); + stage.close(); + } +} 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..c56066c 100644 --- a/client/app/src/main/resources/main/create-event.fxml +++ b/client/app/src/main/resources/main/create-event.fxml @@ -5,7 +5,8 @@ - + @@ -13,15 +14,16 @@ - - - - - - - - - + + + + + + + + + + @@ -43,17 +45,18 @@ - - - + + + +