Compare commits
No commits in common. "646da71e8a5527352b02f5f4225284d01c666876" and "f933690ba0604b030d082b274ec9ccc4856ef814" have entirely different histories.
646da71e8a
...
f933690ba0
@ -1,8 +0,0 @@
|
||||
package customUI;
|
||||
|
||||
public class Button extends javafx.scene.control.Button {
|
||||
|
||||
public void setTextValue(String text){
|
||||
super.setText(Converter.CONVERT_STR(text));
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package customUI;
|
||||
|
||||
public class Converter {
|
||||
/*
|
||||
Ä, ä \u00c4, \u00e4
|
||||
Ö, ö \u00d6, \u00f6
|
||||
Ü, ü \u00dc, \u00fc
|
||||
ß \u00df
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public static String CONVERT_STR(String str){
|
||||
return str
|
||||
.replace("ä", "\u00e4")
|
||||
.replace("Ä", "\u00c4")
|
||||
.replace("ö", "\u00f6")
|
||||
.replace("Ö", "\u00d6")
|
||||
.replace("ü", "\u00fc")
|
||||
.replace("Ü", "\u00dc")
|
||||
.replace("ß", "\u00df");
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
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));
|
||||
}
|
||||
}
|
@ -1,11 +1,13 @@
|
||||
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 customUI.Button;
|
||||
import customUI.Label;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
@ -28,7 +30,7 @@ public class MainController {
|
||||
private GridPane calendarGrid;
|
||||
|
||||
@FXML
|
||||
private javafx.scene.control.Label LabelMonth;
|
||||
private Label LabelMonth;
|
||||
|
||||
private final String[] dayNames = {"Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"};
|
||||
private final Label[] dayLabel = new Label[7];
|
||||
@ -108,7 +110,7 @@ public class MainController {
|
||||
private void createWeek() {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
Label label = new Label();
|
||||
label.setTextValue(dayNames[i]);
|
||||
label.setText(dayNames[i]);
|
||||
label.setMaxHeight(Double.MAX_VALUE);
|
||||
label.setMaxWidth(Double.MAX_VALUE);
|
||||
label.getStyleClass().add("labelDays");
|
||||
@ -140,14 +142,31 @@ public class MainController {
|
||||
HBox btnHBox = new HBox();
|
||||
btnHBox.setAlignment(Pos.BOTTOM_RIGHT);
|
||||
Button deleteBtn = new Button();
|
||||
deleteBtn.setTextValue(" X ");
|
||||
deleteBtn.setText(" X ");
|
||||
deleteBtn.setOnAction(e -> {
|
||||
DataController dataController = new DataController();
|
||||
dataController.deleteEvent(event.getId());
|
||||
updateEvents();
|
||||
});
|
||||
Button editBtn = new Button();
|
||||
editBtn.setTextValue("edit");
|
||||
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);
|
||||
@ -165,6 +184,12 @@ public class MainController {
|
||||
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);
|
||||
|
||||
@ -203,7 +228,7 @@ public class MainController {
|
||||
weekStartDateTime = now.plusDays(weekOffset * 7L - dayOfWeek + 1);
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
dayLabel[i].setTextValue(dayFormatter.format(weekStartDateTime.plusDays(i)));
|
||||
dayLabel[i].setText(dayFormatter.format(weekStartDateTime.plusDays(i)));
|
||||
}
|
||||
|
||||
LabelMonth.setText(dateFormatter.format(weekStartDateTime));
|
||||
|
@ -34,8 +34,7 @@ public class DataController {
|
||||
USER_ID = Long.parseLong(httpRequest.sendPostRequest(
|
||||
LOGIN_ENDPOINT,
|
||||
"login=" + username
|
||||
+ "&password=" + password,
|
||||
false
|
||||
+ "&password=" + password
|
||||
));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -46,7 +45,7 @@ public class DataController {
|
||||
|
||||
public void createEvent(Event event) {
|
||||
try {
|
||||
System.out.println(httpRequest.sendPostRequest(ADD_EVENT_ENDPOINT, event.getAsUrlParam(), true));
|
||||
System.out.println(httpRequest.sendPostRequest(ADD_EVENT_ENDPOINT, event.getAsUrlParam()));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Es konnte keine Verbindung mit dem Server hergestellt werden.");
|
||||
}
|
||||
@ -54,7 +53,7 @@ public class DataController {
|
||||
|
||||
public void deleteEvent(int eventId) {
|
||||
try {
|
||||
System.out.println(httpRequest.sendPostRequest(DELETE_EVENT_ENDPOINT, "eventId=" + eventId, true));
|
||||
System.out.println(httpRequest.sendPostRequest(DELETE_EVENT_ENDPOINT, "eventId=" + eventId));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -64,7 +63,7 @@ public class DataController {
|
||||
ArrayList<Event> eventList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
String jsonResponse = httpRequest.sendPostRequest(ALL_EVENTS_ENDPOINT, "userId=" + USER_ID, true);
|
||||
String jsonResponse = httpRequest.sendPostRequest(ALL_EVENTS_ENDPOINT, "userId=" + USER_ID);
|
||||
System.out.println(jsonResponse);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
@ -2,7 +2,6 @@ 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;
|
||||
@ -71,30 +70,10 @@ 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ÄÖÜäöü0-9 =!?+*/$%€.:,;_<>()-]*");
|
||||
Matcher matcher = pattern.matcher(name);
|
||||
if(!matcher.matches()){
|
||||
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 =!?+*/$.:,;_ <>()-");
|
||||
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.");
|
||||
@ -127,7 +106,7 @@ public class Event {
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = convertToASCII(name);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
@ -213,9 +192,4 @@ public class Event {
|
||||
"&isFullDay=" + isFullDay() +
|
||||
"&isPrivate=" + isPrivate();
|
||||
}
|
||||
|
||||
private String convertToASCII(String s){
|
||||
byte[] germanBytes = s.getBytes();
|
||||
return new String(germanBytes, StandardCharsets.US_ASCII);
|
||||
}
|
||||
}
|
||||
|
@ -9,23 +9,10 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class HttpRequest {
|
||||
public String sendPostRequest(String urlString, String urlParameters, boolean sendAuth) throws Exception {
|
||||
public String sendPostRequest(String urlString, String urlParameters) 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();
|
||||
|
||||
@ -36,12 +23,6 @@ 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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user