From d34d09aa2be7257aad20aaa758b66020e7d50b81 Mon Sep 17 00:00:00 2001 From: Marc Beyer Date: Mon, 10 Jan 2022 13:22:59 +0100 Subject: [PATCH 01/20] Changed REST-endpoints --- client/data/src/main/java/res/DataController.java | 13 +++++++------ client/data/src/main/java/res/Event.java | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/client/data/src/main/java/res/DataController.java b/client/data/src/main/java/res/DataController.java index 88566b6..52cac15 100644 --- a/client/data/src/main/java/res/DataController.java +++ b/client/data/src/main/java/res/DataController.java @@ -16,11 +16,12 @@ public class DataController { public static long USER_ID = -1; - private static final String ALL_EVENTS_ENDPOINT = "http://localhost:8080/vpr/all-events"; - private static final String ALL_USERS_ENDPOINT = "http://localhost:8080/vpr/all-users"; - private static final String ADD_EVENT_ENDPOINT = "http://localhost:8080/vpr/add-event"; - private static final String DELETE_EVENT_ENDPOINT = "http://localhost:8080/vpr/del-event"; - private static final String LOGIN_ENDPOINT = "http://localhost:8080/vpr/login"; + private static final String ALL_EVENTS_ENDPOINT = "http://localhost:8080/event/all"; + private static final String ADD_EVENT_ENDPOINT = "http://localhost:8080/event/add"; + private static final String DELETE_EVENT_ENDPOINT = "http://localhost:8080/event/del"; + + private static final String LOGIN_ENDPOINT = "http://localhost:8080/user/login"; + private static final String ALL_USERS_ENDPOINT = "http://localhost:8080/user/all"; private final HttpRequest httpRequest; @@ -110,4 +111,4 @@ public class DataController { return objectMapper.readValue(jsonString, Event[].class); } -} +} \ No newline at end of file diff --git a/client/data/src/main/java/res/Event.java b/client/data/src/main/java/res/Event.java index be598c2..5a6e585 100644 --- a/client/data/src/main/java/res/Event.java +++ b/client/data/src/main/java/res/Event.java @@ -73,7 +73,7 @@ public class Event { Pattern pattern = Pattern.compile("[A-Za-zÄÖÜäöü0-9 =!?+*/$%€.:,;_<>()-]*"); Matcher matcher = pattern.matcher(name); if(!matcher.matches()){ - throw new IllegalArgumentException("Der Name Darf nur aus Zahlen, Buchstaben und folgenden Sonderzeichen bestehen: =!?+*/$%€.:,;_ <>()-"); + throw new IllegalArgumentException("Der Name darf nur aus Zahlen, Buchstaben und folgenden Sonderzeichen bestehen: =!?+*/$%€.:,;_ <>()-"); } if(priority < 0){ throw new IllegalArgumentException("Bitte eine Priorit\u00e4t w\u00e4hlen."); From f933690ba0604b030d082b274ec9ccc4856ef814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20K=C3=BChn?= Date: Tue, 11 Jan 2022 07:46:39 +0100 Subject: [PATCH 02/20] Added UI to edit events --- .../src/main/java/main/MainController.java | 17 +++++ .../src/main/resources/main/edit-event.css | 46 ++++++++++++++ .../src/main/resources/main/edit-event.fxml | 63 +++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 client/app/src/main/resources/main/edit-event.css create mode 100644 client/app/src/main/resources/main/edit-event.fxml diff --git a/client/app/src/main/java/main/MainController.java b/client/app/src/main/java/main/MainController.java index c7092a7..b2d8d80 100644 --- a/client/app/src/main/java/main/MainController.java +++ b/client/app/src/main/java/main/MainController.java @@ -150,6 +150,23 @@ public class MainController { }); Button editBtn = new Button(); editBtn.setText("edit"); + editBtn.setOnAction(event1 -> { + try { + FXMLLoader fxmlLoader = new FXMLLoader( + MainApplication.class.getResource("edit-event.fxml")); + Scene scene = new Scene(fxmlLoader.load(), 650, 650); + scene.getStylesheets().add(Objects.requireNonNull( + MainApplication.class.getResource("edit-event.css")).toExternalForm()); + Stage stage = new Stage(); + stage.setTitle("Termin bearbeiten"); + stage.setScene(scene); + stage.initModality(Modality.APPLICATION_MODAL); + stage.setResizable(false); + stage.showAndWait(); + } catch (IOException e) { + e.printStackTrace(); + } + }); btnHBox.getChildren().add(editBtn); btnHBox.getChildren().add(deleteBtn); vBox.getChildren().add(btnHBox); diff --git a/client/app/src/main/resources/main/edit-event.css b/client/app/src/main/resources/main/edit-event.css new file mode 100644 index 0000000..442c669 --- /dev/null +++ b/client/app/src/main/resources/main/edit-event.css @@ -0,0 +1,46 @@ +GridPane{ + -fx-background-color: #3E415F; + -fx-padding: 20px; + -fx-font-size: 20px; + -fx-font-family: Segoe UI; + + -fx-border-insets: 1; + -fx-border-color: #B0B0B0; + -fx-border-style: solid; + -fx-border-width: 2; + -fx-effect: dropshadow(three-pass-box, rgba(100, 100, 100, 1), 24, 0.5, 0, 0); +} + +Label{ + -fx-text-fill: white; + -fx-max-width: 150px; + -fx-min-width: 150px; +} + +.mainLabel{ + -fx-background-color: #8D99AE; + -fx-padding: 10px; + -fx-max-width: 200px; + -fx-min-width: 200px; + -fx-font-weight: bold; + -fx-alignment: center; +} + +.inputField{ + -fx-padding: 10px; +} + +.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/edit-event.fxml b/client/app/src/main/resources/main/edit-event.fxml new file mode 100644 index 0000000..029d566 --- /dev/null +++ b/client/app/src/main/resources/main/edit-event.fxml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From eb55d5c6509edea368dc5db493e04fab721ac9a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20K=C3=BChn?= Date: Tue, 11 Jan 2022 12:13:24 +0100 Subject: [PATCH 03/20] Implementet JFoenix --- client/app/build.gradle.kts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/app/build.gradle.kts b/client/app/build.gradle.kts index 6a5a8cf..9661289 100644 --- a/client/app/build.gradle.kts +++ b/client/app/build.gradle.kts @@ -16,7 +16,12 @@ application { mainClassName = "client.MainApplication" } +repositories { + mavenCentral() +} + dependencies { + implementation("com.jfoenix:jfoenix:9.0.10") implementation(project(":data")) } From ea6420e2347f23996f45212a529745437c80c98f Mon Sep 17 00:00:00 2001 From: Marc Beyer Date: Tue, 11 Jan 2022 17:12:37 +0100 Subject: [PATCH 04/20] Added Auth-Header --- .../src/main/java/res/DataController.java | 9 ++++---- .../data/src/main/java/res/HttpRequest.java | 21 ++++++++++++++++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/client/data/src/main/java/res/DataController.java b/client/data/src/main/java/res/DataController.java index bd00842..1ac15b5 100644 --- a/client/data/src/main/java/res/DataController.java +++ b/client/data/src/main/java/res/DataController.java @@ -34,7 +34,8 @@ public class DataController { USER_ID = Long.parseLong(httpRequest.sendPostRequest( LOGIN_ENDPOINT, "login=" + username - + "&password=" + password + + "&password=" + password, + false )); } catch (Exception e) { e.printStackTrace(); @@ -45,7 +46,7 @@ public class DataController { public void createEvent(Event event) { try { - System.out.println(httpRequest.sendPostRequest(ADD_EVENT_ENDPOINT, event.getAsUrlParam())); + System.out.println(httpRequest.sendPostRequest(ADD_EVENT_ENDPOINT, event.getAsUrlParam(), true)); } catch (Exception e) { throw new RuntimeException("Es konnte keine Verbindung mit dem Server hergestellt werden."); } @@ -53,7 +54,7 @@ public class DataController { public void deleteEvent(int eventId) { try { - System.out.println(httpRequest.sendPostRequest(DELETE_EVENT_ENDPOINT, "eventId=" + eventId)); + System.out.println(httpRequest.sendPostRequest(DELETE_EVENT_ENDPOINT, "eventId=" + eventId, true)); } catch (Exception e) { e.printStackTrace(); } @@ -63,7 +64,7 @@ public class DataController { ArrayList eventList = new ArrayList<>(); try { - String jsonResponse = httpRequest.sendPostRequest(ALL_EVENTS_ENDPOINT, "userId=" + USER_ID); + String jsonResponse = httpRequest.sendPostRequest(ALL_EVENTS_ENDPOINT, "userId=" + USER_ID, true); System.out.println(jsonResponse); ObjectMapper objectMapper = new ObjectMapper(); diff --git a/client/data/src/main/java/res/HttpRequest.java b/client/data/src/main/java/res/HttpRequest.java index c565e31..398f157 100644 --- a/client/data/src/main/java/res/HttpRequest.java +++ b/client/data/src/main/java/res/HttpRequest.java @@ -9,10 +9,23 @@ import java.nio.charset.StandardCharsets; import java.util.Arrays; public class HttpRequest { - public String sendPostRequest(String urlString, String urlParameters) throws Exception { + public String sendPostRequest(String urlString, String urlParameters, boolean sendAuth) throws Exception { byte[] postData = urlParameters.getBytes(StandardCharsets.UTF_8); int postDataLength = postData.length; + /* + URL url = new URL("http://test.de:8080/event/add"); + HttpURLConnection http = (HttpURLConnection)url.openConnection(); + http.setRequestMethod("POST"); + http.setDoOutput(true); + http.setRequestProperty("Accept", "application/json"); + http.setRequestProperty("Authorization", "Bearer {token}"); + http.setRequestProperty("Content-Type", ""); + http.setRequestProperty("Content-Length", "0"); + + System.out.println(http.getResponseCode() + " " + http.getResponseMessage()); + http.disconnect(); + */ URL url = new URL(urlString); HttpURLConnection con = (HttpURLConnection) url.openConnection(); @@ -23,6 +36,12 @@ public class HttpRequest { con.setRequestProperty("charset", "utf-8"); con.setRequestProperty("Content-Length", Integer.toString(postDataLength)); con.setUseCaches(false); + + if(sendAuth){ + con.setRequestProperty("Accept", "application/json"); + con.setRequestProperty("Authorization", "Bearer {token}"); + } + try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) { wr.write(postData); } From 0ef383aa7fe413a56604daa801dde7d845469863 Mon Sep 17 00:00:00 2001 From: Marc Beyer Date: Tue, 11 Jan 2022 17:14:30 +0100 Subject: [PATCH 05/20] Fixed String encoding --- .../src/main/java/main/MainController.java | 2 +- client/data/src/main/java/res/Event.java | 32 +++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/client/app/src/main/java/main/MainController.java b/client/app/src/main/java/main/MainController.java index c7092a7..728c051 100644 --- a/client/app/src/main/java/main/MainController.java +++ b/client/app/src/main/java/main/MainController.java @@ -164,7 +164,7 @@ public class MainController { vBox.getChildren().add(timeLabel); } - Label typeLabel = new Label("Wer: " + event.getOwnerName()); + Label typeLabel = new Label("Wer: " + event.getOwnerName().replace("ü", "\u00fc")); vBox.getChildren().add(typeLabel); /* diff --git a/client/data/src/main/java/res/Event.java b/client/data/src/main/java/res/Event.java index 5a6e585..a730659 100644 --- a/client/data/src/main/java/res/Event.java +++ b/client/data/src/main/java/res/Event.java @@ -2,6 +2,7 @@ package res; import com.sun.jdi.event.StepEvent; +import java.nio.charset.StandardCharsets; import java.time.Duration; import java.time.LocalDate; import java.time.LocalDateTime; @@ -70,10 +71,30 @@ public class Event { if(name.length() < 3){ throw new IllegalArgumentException("Der Name muss eine L\u00e4nge von 3 haben."); } - Pattern pattern = Pattern.compile("[A-Za-zÄÖÜäöü0-9 =!?+*/$%€.:,;_<>()-]*"); + Pattern pattern = Pattern.compile("[A-Za-z\u00e4\u00f6\u00fc\u00c4\u00d6\u00dc\u00df0-9 =!?+*/$%.:,;_<>()-]*"); Matcher matcher = pattern.matcher(name); if(!matcher.matches()){ - throw new IllegalArgumentException("Der Name darf nur aus Zahlen, Buchstaben und folgenden Sonderzeichen bestehen: =!?+*/$%€.:,;_ <>()-"); + System.out.println(name); + + byte[] bytes = name.getBytes(StandardCharsets.UTF_16); + + String utf8EncodedString = new String(bytes, StandardCharsets.UTF_16); + System.out.println(utf8EncodedString); + + for (char c : (name).toCharArray()) { + System.out.print(c + " " + (int)c + ", "); + } + System.out.println(); + for (char c : (name).toCharArray()) { + System.out.print(c + " " + (int)c + ", "); + } + System.out.println(); + for (char c : ("TäöüÄÖÜ").toCharArray()) { + System.out.print(c + " " + (int)c + ", "); + } + System.out.println(); + + throw new IllegalArgumentException("Der Name darf nur aus Zahlen, Buchstaben und folgenden Sonderzeichen bestehen: \u00e4\u00f6\u00fc \u00c4\u00d6\u00dc \u00df =!?+*/$%.:,;_ <>()-"); } if(priority < 0){ throw new IllegalArgumentException("Bitte eine Priorit\u00e4t w\u00e4hlen."); @@ -106,7 +127,7 @@ public class Event { } public void setName(String name) { - this.name = name; + this.name = convertToASCII(name); } public int getPriority() { @@ -192,4 +213,9 @@ public class Event { "&isFullDay=" + isFullDay() + "&isPrivate=" + isPrivate(); } + + private String convertToASCII(String s){ + byte[] germanBytes = s.getBytes(); + return new String(germanBytes, StandardCharsets.US_ASCII); + } } From b205c96f85d347c746051770e079c042819b79b4 Mon Sep 17 00:00:00 2001 From: Marc Beyer Date: Thu, 13 Jan 2022 07:57:10 +0100 Subject: [PATCH 06/20] Fixed String encoding --- client/app/src/main/java/customUI/Button.java | 8 +++++++ .../app/src/main/java/customUI/Converter.java | 20 ++++++++++++++++ client/app/src/main/java/customUI/Label.java | 15 ++++++++++++ .../src/main/java/main/MainController.java | 24 +++++++------------ client/data/src/main/java/res/Event.java | 4 ++-- 5 files changed, 53 insertions(+), 18 deletions(-) create mode 100644 client/app/src/main/java/customUI/Button.java create mode 100644 client/app/src/main/java/customUI/Converter.java create mode 100644 client/app/src/main/java/customUI/Label.java diff --git a/client/app/src/main/java/customUI/Button.java b/client/app/src/main/java/customUI/Button.java new file mode 100644 index 0000000..3d4d4bf --- /dev/null +++ b/client/app/src/main/java/customUI/Button.java @@ -0,0 +1,8 @@ +package customUI; + +public class Button extends javafx.scene.control.Button { + + public void setTextValue(String text){ + super.setText(Converter.CONVERT_STR(text)); + } +} diff --git a/client/app/src/main/java/customUI/Converter.java b/client/app/src/main/java/customUI/Converter.java new file mode 100644 index 0000000..3e0493f --- /dev/null +++ b/client/app/src/main/java/customUI/Converter.java @@ -0,0 +1,20 @@ +package customUI; + +public class Converter { + /* + Ä, ä \u00c4, \u00e4 + Ö, ö \u00d6, \u00f6 + Ü, ü \u00dc, \u00fc + ß \u00df + */ + public static String CONVERT_STR(String str){ + return str + .replace("ä", "\u00e4") + .replace("Ä", "\u00c4") + .replace("ö", "\u00f6") + .replace("Ö", "\u00d6") + .replace("ü", "\u00fc") + .replace("Ü", "\u00dc") + .replace("ß", "\u00df"); + } +} diff --git a/client/app/src/main/java/customUI/Label.java b/client/app/src/main/java/customUI/Label.java new file mode 100644 index 0000000..8ba0ce2 --- /dev/null +++ b/client/app/src/main/java/customUI/Label.java @@ -0,0 +1,15 @@ +package customUI; + +public class Label extends javafx.scene.control.Label { + public Label(String content){ + super(Converter.CONVERT_STR(content)); + } + + public Label(){ + super(); + } + + public void setTextValue(String text){ + super.setText(Converter.CONVERT_STR(text)); + } +} diff --git a/client/app/src/main/java/main/MainController.java b/client/app/src/main/java/main/MainController.java index 728c051..f9b9a51 100644 --- a/client/app/src/main/java/main/MainController.java +++ b/client/app/src/main/java/main/MainController.java @@ -1,13 +1,11 @@ package main; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.geometry.Pos; import javafx.scene.Scene; -import javafx.scene.control.Button; -import javafx.scene.control.Label; +import customUI.Button; +import customUI.Label; import javafx.scene.control.ScrollPane; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; @@ -30,7 +28,7 @@ public class MainController { private GridPane calendarGrid; @FXML - private Label LabelMonth; + private javafx.scene.control.Label LabelMonth; private final String[] dayNames = {"Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"}; private final Label[] dayLabel = new Label[7]; @@ -110,7 +108,7 @@ public class MainController { private void createWeek() { for (int i = 0; i < 7; i++) { Label label = new Label(); - label.setText(dayNames[i]); + label.setTextValue(dayNames[i]); label.setMaxHeight(Double.MAX_VALUE); label.setMaxWidth(Double.MAX_VALUE); label.getStyleClass().add("labelDays"); @@ -142,14 +140,14 @@ public class MainController { HBox btnHBox = new HBox(); btnHBox.setAlignment(Pos.BOTTOM_RIGHT); Button deleteBtn = new Button(); - deleteBtn.setText(" X "); + deleteBtn.setTextValue(" X "); deleteBtn.setOnAction(e -> { DataController dataController = new DataController(); dataController.deleteEvent(event.getId()); updateEvents(); }); Button editBtn = new Button(); - editBtn.setText("edit"); + editBtn.setTextValue("edit"); btnHBox.getChildren().add(editBtn); btnHBox.getChildren().add(deleteBtn); vBox.getChildren().add(btnHBox); @@ -164,15 +162,9 @@ public class MainController { vBox.getChildren().add(timeLabel); } - Label typeLabel = new Label("Wer: " + event.getOwnerName().replace("ü", "\u00fc")); + Label typeLabel = new Label("Wer: " + event.getOwnerName()); vBox.getChildren().add(typeLabel); - /* - Ä, ä \u00c4, \u00e4 - Ö, ö \u00d6, \u00f6 - Ü, ü \u00dc, \u00fc - ß \u00df - */ Label prioLabel = new Label("Priorit\u00e4t: " + event.getPriority()); vBox.getChildren().add(prioLabel); @@ -211,7 +203,7 @@ public class MainController { weekStartDateTime = now.plusDays(weekOffset * 7L - dayOfWeek + 1); for (int i = 0; i < 7; i++) { - dayLabel[i].setText(dayFormatter.format(weekStartDateTime.plusDays(i))); + dayLabel[i].setTextValue(dayFormatter.format(weekStartDateTime.plusDays(i))); } LabelMonth.setText(dateFormatter.format(weekStartDateTime)); diff --git a/client/data/src/main/java/res/Event.java b/client/data/src/main/java/res/Event.java index a730659..90e9d41 100644 --- a/client/data/src/main/java/res/Event.java +++ b/client/data/src/main/java/res/Event.java @@ -71,7 +71,7 @@ public class Event { if(name.length() < 3){ throw new IllegalArgumentException("Der Name muss eine L\u00e4nge von 3 haben."); } - Pattern pattern = Pattern.compile("[A-Za-z\u00e4\u00f6\u00fc\u00c4\u00d6\u00dc\u00df0-9 =!?+*/$%.:,;_<>()-]*"); + Pattern pattern = Pattern.compile("[A-Za-z\u00e4\u00f6\u00fc\u00c4\u00d6\u00dc\u00df0-9 =!?+*/$.:,;_<>()-]*"); Matcher matcher = pattern.matcher(name); if(!matcher.matches()){ System.out.println(name); @@ -94,7 +94,7 @@ public class Event { } System.out.println(); - throw new IllegalArgumentException("Der Name darf nur aus Zahlen, Buchstaben und folgenden Sonderzeichen bestehen: \u00e4\u00f6\u00fc \u00c4\u00d6\u00dc \u00df =!?+*/$%.:,;_ <>()-"); + throw new IllegalArgumentException("Der Name darf nur aus Zahlen, Buchstaben und folgenden Sonderzeichen bestehen: \u00e4\u00f6\u00fc \u00c4\u00d6\u00dc \u00df =!?+*/$.:,;_ <>()-"); } if(priority < 0){ throw new IllegalArgumentException("Bitte eine Priorit\u00e4t w\u00e4hlen."); From 46606a5afc8712241511038262828417f94b7bfd Mon Sep 17 00:00:00 2001 From: Marc Beyer Date: Thu, 13 Jan 2022 08:26:51 +0100 Subject: [PATCH 07/20] Suppress warnings --- client/app/src/main/java/customUI/Converter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/client/app/src/main/java/customUI/Converter.java b/client/app/src/main/java/customUI/Converter.java index 3e0493f..bf0c895 100644 --- a/client/app/src/main/java/customUI/Converter.java +++ b/client/app/src/main/java/customUI/Converter.java @@ -7,6 +7,7 @@ public class Converter { Ü, ü \u00dc, \u00fc ß \u00df */ + @SuppressWarnings("all") public static String CONVERT_STR(String str){ return str .replace("ä", "\u00e4") From 0d105be15c91111e3d1f89e4f32417505e231d74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20K=C3=BChn?= Date: Thu, 13 Jan 2022 08:30:56 +0100 Subject: [PATCH 08/20] Created TimePicker and tried to add to grid --- .../main/java/main/CreateEventController.java | 25 ++++++++++++++----- .../src/main/java/main/MainController.java | 2 -- .../src/main/resources/main/edit-event.fxml | 6 ++--- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/client/app/src/main/java/main/CreateEventController.java b/client/app/src/main/java/main/CreateEventController.java index d77c407..64c6e2b 100644 --- a/client/app/src/main/java/main/CreateEventController.java +++ b/client/app/src/main/java/main/CreateEventController.java @@ -1,24 +1,24 @@ package main; +import com.jfoenix.controls.JFXTimePicker; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Node; import javafx.scene.control.*; +import javafx.scene.layout.GridPane; import javafx.stage.Stage; import res.DataController; import res.Event; public class CreateEventController { + @FXML + public GridPane grid; @FXML public DatePicker datePickerDate; @FXML public TextField textName; @FXML - public TextField textStart; - @FXML - public TextField textEnd; - @FXML public ComboBox ComboBoxTyp; @FXML public ComboBox ComboBoxPriotity; @@ -28,6 +28,10 @@ public class CreateEventController { public CheckBox checkBoxIsPrivate; @FXML public Label labelError; + @FXML + public JFXTimePicker timeStart; + @FXML + public JFXTimePicker timeEnd; public CreateEventController() { @@ -35,6 +39,15 @@ public class CreateEventController { @FXML public void initialize() { + JFXTimePicker timePickerStart = new JFXTimePicker(); + timeStart = timePickerStart; + timePickerStart.set24HourView(true); + grid.add(timePickerStart, 1 , 3); + + JFXTimePicker timePickerEnd = new JFXTimePicker(); + timeEnd = timePickerEnd; + timePickerEnd.set24HourView(true); + grid.add(timePickerEnd, 1 , 4); } @@ -50,8 +63,8 @@ public class CreateEventController { ComboBoxPriotity.getSelectionModel().getSelectedIndex(), checkBoxIsFullDay.isSelected(), checkBoxIsPrivate.isSelected(), - textStart.getText(), - textEnd.getText(), + timeStart.toString(), + timeEnd.toString(), datePickerDate.getValue().atStartOfDay(), (int) DataController.USER_ID ); diff --git a/client/app/src/main/java/main/MainController.java b/client/app/src/main/java/main/MainController.java index b2d8d80..5354d3a 100644 --- a/client/app/src/main/java/main/MainController.java +++ b/client/app/src/main/java/main/MainController.java @@ -1,7 +1,5 @@ package main; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.geometry.Pos; diff --git a/client/app/src/main/resources/main/edit-event.fxml b/client/app/src/main/resources/main/edit-event.fxml index 029d566..b3e3021 100644 --- a/client/app/src/main/resources/main/edit-event.fxml +++ b/client/app/src/main/resources/main/edit-event.fxml @@ -2,10 +2,10 @@ - - @@ -39,8 +39,6 @@ - - From f0405b5d8601071ea75f50dae4e246a95da8cfa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20K=C3=BChn?= Date: Thu, 13 Jan 2022 10:11:09 +0100 Subject: [PATCH 09/20] Added timePicker to mainGrid --- client/app/src/main/java/main/CreateEventController.java | 8 +++++--- client/app/src/main/resources/main/create-event.fxml | 4 +--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/app/src/main/java/main/CreateEventController.java b/client/app/src/main/java/main/CreateEventController.java index 64c6e2b..f98ffd7 100644 --- a/client/app/src/main/java/main/CreateEventController.java +++ b/client/app/src/main/java/main/CreateEventController.java @@ -13,7 +13,7 @@ import res.Event; public class CreateEventController { @FXML - public GridPane grid; + public GridPane mainGrid; @FXML public DatePicker datePickerDate; @FXML @@ -42,12 +42,14 @@ public class CreateEventController { JFXTimePicker timePickerStart = new JFXTimePicker(); timeStart = timePickerStart; timePickerStart.set24HourView(true); - grid.add(timePickerStart, 1 , 3); + timePickerStart.getStyleClass().add("timePicker"); + mainGrid.add(timePickerStart, 1 , 3); JFXTimePicker timePickerEnd = new JFXTimePicker(); timeEnd = timePickerEnd; timePickerEnd.set24HourView(true); - grid.add(timePickerEnd, 1 , 4); + timePickerEnd.getStyleClass().add("timePicker"); + mainGrid.add(timePickerEnd, 1 , 4); } diff --git a/client/app/src/main/resources/main/create-event.fxml b/client/app/src/main/resources/main/create-event.fxml index c56066c..e25fcdd 100644 --- a/client/app/src/main/resources/main/create-event.fxml +++ b/client/app/src/main/resources/main/create-event.fxml @@ -5,7 +5,7 @@ - @@ -39,8 +39,6 @@ - - From ce309581edac8817aab957b6bc8db3e101a869d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20K=C3=BChn?= Date: Thu, 13 Jan 2022 11:02:49 +0100 Subject: [PATCH 10/20] Added TimePicker to edit event, time is used --- .../main/java/main/CreateEventController.java | 10 +++- .../src/main/java/main/MainController.java | 2 +- .../src/main/resources/main/create-event.css | 5 ++ .../src/main/resources/main/edit-event.css | 46 ------------------- .../src/main/resources/main/edit-event.fxml | 2 +- 5 files changed, 15 insertions(+), 50 deletions(-) delete mode 100644 client/app/src/main/resources/main/edit-event.css diff --git a/client/app/src/main/java/main/CreateEventController.java b/client/app/src/main/java/main/CreateEventController.java index f98ffd7..132d8af 100644 --- a/client/app/src/main/java/main/CreateEventController.java +++ b/client/app/src/main/java/main/CreateEventController.java @@ -7,9 +7,15 @@ import javafx.scene.Node; import javafx.scene.control.*; import javafx.scene.layout.GridPane; import javafx.stage.Stage; +import javafx.util.StringConverter; +import javafx.util.converter.LocalTimeStringConverter; import res.DataController; import res.Event; +import java.time.LocalTime; +import java.time.format.FormatStyle; +import java.util.Locale; + public class CreateEventController { @FXML @@ -65,8 +71,8 @@ public class CreateEventController { ComboBoxPriotity.getSelectionModel().getSelectedIndex(), checkBoxIsFullDay.isSelected(), checkBoxIsPrivate.isSelected(), - timeStart.toString(), - timeEnd.toString(), + timeStart.getValue().toString(), + timeEnd.getValue().toString(), datePickerDate.getValue().atStartOfDay(), (int) DataController.USER_ID ); diff --git a/client/app/src/main/java/main/MainController.java b/client/app/src/main/java/main/MainController.java index 5354d3a..0b2649d 100644 --- a/client/app/src/main/java/main/MainController.java +++ b/client/app/src/main/java/main/MainController.java @@ -154,7 +154,7 @@ public class MainController { MainApplication.class.getResource("edit-event.fxml")); Scene scene = new Scene(fxmlLoader.load(), 650, 650); scene.getStylesheets().add(Objects.requireNonNull( - MainApplication.class.getResource("edit-event.css")).toExternalForm()); + MainApplication.class.getResource("create-event.css")).toExternalForm()); Stage stage = new Stage(); stage.setTitle("Termin bearbeiten"); stage.setScene(scene); diff --git a/client/app/src/main/resources/main/create-event.css b/client/app/src/main/resources/main/create-event.css index 442c669..0b7b085 100644 --- a/client/app/src/main/resources/main/create-event.css +++ b/client/app/src/main/resources/main/create-event.css @@ -43,4 +43,9 @@ Label{ -fx-max-height: 400px; -fx-wrap-text: true; -fx-font-size: 16px; +} + +.timePicker{ + -fx-background-color: white; + -fx-max-width: 150px; } \ No newline at end of file diff --git a/client/app/src/main/resources/main/edit-event.css b/client/app/src/main/resources/main/edit-event.css deleted file mode 100644 index 442c669..0000000 --- a/client/app/src/main/resources/main/edit-event.css +++ /dev/null @@ -1,46 +0,0 @@ -GridPane{ - -fx-background-color: #3E415F; - -fx-padding: 20px; - -fx-font-size: 20px; - -fx-font-family: Segoe UI; - - -fx-border-insets: 1; - -fx-border-color: #B0B0B0; - -fx-border-style: solid; - -fx-border-width: 2; - -fx-effect: dropshadow(three-pass-box, rgba(100, 100, 100, 1), 24, 0.5, 0, 0); -} - -Label{ - -fx-text-fill: white; - -fx-max-width: 150px; - -fx-min-width: 150px; -} - -.mainLabel{ - -fx-background-color: #8D99AE; - -fx-padding: 10px; - -fx-max-width: 200px; - -fx-min-width: 200px; - -fx-font-weight: bold; - -fx-alignment: center; -} - -.inputField{ - -fx-padding: 10px; -} - -.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/edit-event.fxml b/client/app/src/main/resources/main/edit-event.fxml index b3e3021..1d56f3d 100644 --- a/client/app/src/main/resources/main/edit-event.fxml +++ b/client/app/src/main/resources/main/edit-event.fxml @@ -5,7 +5,7 @@ - From baeed584ab9795c9f7f5d8ec2608e97ff0210921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20K=C3=BChn?= Date: Fri, 14 Jan 2022 10:14:17 +0100 Subject: [PATCH 11/20] TimPicker now uses 24h time format --- client/app/src/main/java/main/CreateEventController.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/app/src/main/java/main/CreateEventController.java b/client/app/src/main/java/main/CreateEventController.java index 132d8af..f3359c8 100644 --- a/client/app/src/main/java/main/CreateEventController.java +++ b/client/app/src/main/java/main/CreateEventController.java @@ -45,15 +45,20 @@ public class CreateEventController { @FXML public void initialize() { + + StringConverter defaultConverter = new LocalTimeStringConverter(FormatStyle.SHORT, Locale.GERMANY); + JFXTimePicker timePickerStart = new JFXTimePicker(); timeStart = timePickerStart; timePickerStart.set24HourView(true); + timePickerStart.setConverter(defaultConverter); timePickerStart.getStyleClass().add("timePicker"); mainGrid.add(timePickerStart, 1 , 3); JFXTimePicker timePickerEnd = new JFXTimePicker(); timeEnd = timePickerEnd; timePickerEnd.set24HourView(true); + timePickerEnd.setConverter(defaultConverter); timePickerEnd.getStyleClass().add("timePicker"); mainGrid.add(timePickerEnd, 1 , 4); } From 3fe16186e29dab34a9bece5fac0ac72afd99b084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20K=C3=BChn?= Date: Fri, 14 Jan 2022 11:11:05 +0100 Subject: [PATCH 12/20] Improved layout, removed typ --- .../main/java/main/CreateEventController.java | 2 -- .../src/main/resources/main/create-event.css | 2 +- .../src/main/resources/main/create-event.fxml | 29 +++++++++---------- .../src/main/resources/main/edit-event.fxml | 29 +++++++++---------- 4 files changed, 29 insertions(+), 33 deletions(-) diff --git a/client/app/src/main/java/main/CreateEventController.java b/client/app/src/main/java/main/CreateEventController.java index f3359c8..645c4e9 100644 --- a/client/app/src/main/java/main/CreateEventController.java +++ b/client/app/src/main/java/main/CreateEventController.java @@ -25,8 +25,6 @@ public class CreateEventController { @FXML public TextField textName; @FXML - public ComboBox ComboBoxTyp; - @FXML public ComboBox ComboBoxPriotity; @FXML public CheckBox checkBoxIsFullDay; diff --git a/client/app/src/main/resources/main/create-event.css b/client/app/src/main/resources/main/create-event.css index 0b7b085..323051a 100644 --- a/client/app/src/main/resources/main/create-event.css +++ b/client/app/src/main/resources/main/create-event.css @@ -47,5 +47,5 @@ Label{ .timePicker{ -fx-background-color: white; - -fx-max-width: 150px; + -fx-max-width: 200px; } \ 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 e25fcdd..d60b89c 100644 --- a/client/app/src/main/resources/main/create-event.fxml +++ b/client/app/src/main/resources/main/create-event.fxml @@ -23,24 +23,23 @@ - - - + + - - - - - - - - + + + + + + + + @@ -49,11 +48,11 @@ - - -