Fixed String encoding

This commit is contained in:
Marc Beyer 2022-01-13 07:57:10 +01:00
parent 0ef383aa7f
commit b205c96f85
5 changed files with 53 additions and 18 deletions

View File

@ -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));
}
}

View File

@ -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");
}
}

View File

@ -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));
}
}

View File

@ -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));

View File

@ -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.");