Changed encoding to utf-8

This commit is contained in:
Marc Beyer 2022-01-29 10:06:28 +01:00
parent 4e07b01b6a
commit 780ecbee0f
14 changed files with 135 additions and 95 deletions

View File

@ -5,13 +5,17 @@ plugins {
} }
javafx { javafx {
version = "11" version = "11.0.2"
modules( modules(
"javafx.controls", "javafx.controls",
"javafx.fxml" "javafx.fxml"
) )
} }
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
application { application {
mainClassName = "main.MainApplication" mainClassName = "main.MainApplication"
} }

View File

@ -1,8 +0,0 @@
package customUI;
public class Button extends javafx.scene.control.Button {
public void setTextValue(String text){
super.setText(Converter.convertString(text));
}
}

View File

@ -1,21 +0,0 @@
package customUI;
public class Converter {
/*
Ä, ä \u00c4, \u00e4
Ö, ö \u00d6, \u00f6
Ü, ü \u00dc, \u00fc
ß \u00df
*/
@SuppressWarnings("all")
public static String convertString(String str){
return str
.replace("ä", "\u00e4")
.replace("Ä", "\u00c4")
.replace("ö", "\u00f6")
.replace("Ö", "\u00d6")
.replace("ü", "\u00fc")
.replace("Ü", "\u00dc")
.replace("ß", "\u00df");
}
}

View File

@ -1,15 +0,0 @@
package customUI;
public class Label extends javafx.scene.control.Label {
public Label(String content){
super(Converter.convertString(content));
}
public Label(){
super();
}
public void setTextValue(String text){
super.setText(Converter.convertString(text));
}
}

View File

@ -1,9 +0,0 @@
package customUI;
public class Tooltip extends javafx.scene.control.Tooltip {
public Tooltip(String tollTipText){
super(Converter.convertString(tollTipText));
}
}

View File

@ -2,9 +2,7 @@ package helper;
import javafx.geometry.Bounds; import javafx.geometry.Bounds;
import javafx.scene.Group; import javafx.scene.Group;
import customUI.Button; import javafx.scene.control.*;
import javafx.scene.control.ContentDisplay;
import customUI.Tooltip;
import javafx.scene.shape.SVGPath; import javafx.scene.shape.SVGPath;
public class SvgBtnCreator { public class SvgBtnCreator {

View File

@ -1,6 +1,5 @@
package main; package main;
import customUI.Converter;
import helper.HttpRequestException; import helper.HttpRequestException;
import res.DataController; import res.DataController;
import res.Event; import res.Event;
@ -16,7 +15,7 @@ public class EditEventController extends CreateEventController{
public void setCurrentEvent(Event currentEvent) { public void setCurrentEvent(Event currentEvent) {
this.currentEvent = currentEvent; this.currentEvent = currentEvent;
textName.setText(Converter.convertString(currentEvent.getName())); textName.setText(currentEvent.getName());
datePickerDate.setValue(currentEvent.getDate().toLocalDate()); datePickerDate.setValue(currentEvent.getDate().toLocalDate());
ComboBoxPriotity.getSelectionModel().select(currentEvent.getPriority()); ComboBoxPriotity.getSelectionModel().select(currentEvent.getPriority());

View File

@ -2,8 +2,6 @@ package main;
import config.Config; import config.Config;
import config.ConfigLoader; import config.ConfigLoader;
import customUI.Button;
import customUI.Label;
import helper.SvgBtnCreator; import helper.SvgBtnCreator;
import helper.HttpRequestException; import helper.HttpRequestException;
import javafx.fxml.FXML; import javafx.fxml.FXML;
@ -12,7 +10,7 @@ import javafx.geometry.Pos;
import javafx.scene.Group; import javafx.scene.Group;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.ScrollPane; import javafx.scene.control.*;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
@ -154,7 +152,7 @@ public class MainController {
private void createWeek() { private void createWeek() {
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
Label label = new Label(); Label label = new Label();
label.setTextValue(dayNames[i]); label.setText(dayNames[i]);
label.setMaxHeight(Double.MAX_VALUE); label.setMaxHeight(Double.MAX_VALUE);
label.setMaxWidth(Double.MAX_VALUE); label.setMaxWidth(Double.MAX_VALUE);
label.getStyleClass().add("labelDays"); label.getStyleClass().add("labelDays");
@ -248,7 +246,7 @@ public class MainController {
Label typeLabel = new Label("Wer: " + event.getOwnerName()); Label typeLabel = new Label("Wer: " + event.getOwnerName());
vBox.getChildren().add(typeLabel); vBox.getChildren().add(typeLabel);
Label prioLabel = new Label("Priorit\u00e4t: " + event.getPriority()); Label prioLabel = new Label("Priorität: " + event.getPriority());
vBox.getChildren().add(prioLabel); vBox.getChildren().add(prioLabel);
if (event.isFullDay()) { if (event.isFullDay()) {
@ -286,7 +284,7 @@ public class MainController {
weekStartDateTime = now.plusDays(weekOffset * 7L - dayOfWeek + 1); weekStartDateTime = now.plusDays(weekOffset * 7L - dayOfWeek + 1);
for (int i = 0; i < 7; i++) { 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)); LabelMonth.setText(dateFormatter.format(weekStartDateTime));

View File

@ -9,6 +9,8 @@ import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.stage.Modality; import javafx.stage.Modality;
@ -20,6 +22,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Optional;
public class OptionController { public class OptionController {
@ -36,10 +39,13 @@ public class OptionController {
@FXML @FXML
public GridPane mainGrid; public GridPane mainGrid;
private JFXComboBox<String> comboBox;
private DataController dataController;
private List<User> users;
@FXML @FXML
public void initialize(){ public void initialize(){
DataController dataController = new DataController(); dataController = new DataController();
List<User> users;
try{ try{
users = dataController.getAllUser(); users = dataController.getAllUser();
} catch (HttpRequestException e){ } catch (HttpRequestException e){
@ -50,7 +56,7 @@ public class OptionController {
for (User user: users) { for (User user: users) {
observableUserList.add(user.getLogin()); observableUserList.add(user.getLogin());
} }
JFXComboBox<String> comboBox = new JFXComboBox<>(observableUserList); comboBox = new JFXComboBox<>(observableUserList);
comboBox.getStyleClass().add("comboBox"); comboBox.getStyleClass().add("comboBox");
mainGrid.add(comboBox, 2,2); mainGrid.add(comboBox, 2,2);
@ -62,14 +68,36 @@ public class OptionController {
} }
public void onCreateBtnClick(ActionEvent actionEvent) { public void onCreateBtnClick(ActionEvent actionEvent) {
loadUserScene(actionEvent, "User erstellen", "../users/create-user.fxml");
}
public void onUpdateBtnClick(ActionEvent actionEvent) {
loadUserScene(actionEvent, "User bearbeiten", "../users/edit-user.fxml");
}
public void onDeleteBtnClick(ActionEvent actionEvent) {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Wirklich löschen?");
Optional<ButtonType> result = alert.showAndWait();
if(result.isPresent() && result.get() == ButtonType.OK){
try { try {
dataController.deleteUser(users.get(comboBox.getSelectionModel().getSelectedIndex()));
} catch (HttpRequestException e) {
Alert alert1 = new Alert(Alert.AlertType.ERROR, e.getMessage());
alert1.showAndWait();
}
}
}
private Scene loadUserScene(ActionEvent actionEvent, String title, String fxml) {
FXMLLoader fxmlLoader = new FXMLLoader( FXMLLoader fxmlLoader = new FXMLLoader(
MainApplication.class.getResource("../users/create-user.fxml")); MainApplication.class.getResource(fxml));
Scene scene = new Scene(fxmlLoader.load(), 800, 650); Scene scene = null;
try {
scene = new Scene(fxmlLoader.load(), 800, 650);
scene.getStylesheets().add(Objects.requireNonNull( scene.getStylesheets().add(Objects.requireNonNull(
MainApplication.class.getResource("../users/create-user.css")).toExternalForm()); MainApplication.class.getResource("../users/create-user.css")).toExternalForm());
Stage stage = new Stage(); Stage stage = new Stage();
stage.setTitle("User erstellen"); stage.setTitle(title);
stage.setScene(scene); stage.setScene(scene);
stage.initModality(Modality.APPLICATION_MODAL); stage.initModality(Modality.APPLICATION_MODAL);
stage.setResizable(false); stage.setResizable(false);
@ -79,11 +107,6 @@ public class OptionController {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} return scene;
public void onUpdateBtnClick(ActionEvent actionEvent) {
}
public void onDeleteBtnClick(ActionEvent actionEvent) {
} }
} }

View File

@ -0,0 +1,19 @@
package users;
import res.User;
public class EditUserController extends CreateUserController{
private User currentUser;
public User getCurrentUser() {
return currentUser;
}
public void setCurrentUser(User currentUser) {
this.currentUser = currentUser;
textForename.setText(currentUser.getForename());
textName.setText(currentUser.getName());
textLogin.setText(currentUser.getLogin());
}
}

View File

@ -3,6 +3,7 @@
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import com.jfoenix.controls.JFXToggleButton?>
<GridPane xmlns="http://javafx.com/javafx" <GridPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml" xmlns:fx="http://javafx.com/fxml"
fx:controller="users.CreateUserController"> fx:controller="users.CreateUserController">
@ -40,7 +41,7 @@
<PasswordField fx:id="textPassword" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="4" /> <PasswordField fx:id="textPassword" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="4" />
<PasswordField fx:id="textPasswordSecond" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="5" /> <PasswordField fx:id="textPasswordSecond" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="5" />
<ToggleButton fx:id="checkButtonIsAdmin" GridPane.columnIndex="2" GridPane.rowIndex="6"/> <JFXToggleButton fx:id="checkButtonIsAdmin" GridPane.columnIndex="2" GridPane.rowIndex="6"/>
<Label fx:id="labelError" styleClass="errorMessage" GridPane.columnIndex="2" GridPane.rowIndex="7"/> <Label fx:id="labelError" styleClass="errorMessage" GridPane.columnIndex="2" GridPane.rowIndex="7"/>
@ -49,7 +50,7 @@
<Insets right="100" left="100"/> <Insets right="100" left="100"/>
</HBox.margin> </HBox.margin>
<Button onAction="#abortBtnClick">Abbrechen</Button> <Button onAction="#abortBtnClick">Abbrechen</Button>
<Button onAction="#createUser" styleClass="btnLogin" >Anmelden</Button> <Button onAction="#createUser" styleClass="btnLogin" >Anlegen</Button>
</HBox> </HBox>
</GridPane> </GridPane>

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.geometry.Insets?>
<?import com.jfoenix.controls.JFXToggleButton?>
<GridPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="users.EditUserController">
<columnConstraints>
<ColumnConstraints minWidth="100"/>
<ColumnConstraints minWidth="100"/>
<ColumnConstraints minWidth="100"/>
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="ALWAYS" />
<RowConstraints vgrow="ALWAYS" />
<RowConstraints vgrow="ALWAYS" />
<RowConstraints vgrow="ALWAYS" />
<RowConstraints vgrow="ALWAYS" />
<RowConstraints vgrow="ALWAYS" />
<RowConstraints vgrow="ALWAYS" />
<RowConstraints vgrow="ALWAYS" />
<RowConstraints vgrow="ALWAYS" />
<RowConstraints vgrow="ALWAYS" />
</rowConstraints>
<Label styleClass="mainLabel" GridPane.columnIndex="2" >User bearbeiten</Label>
<Label styleClass="inputLabel" GridPane.rowIndex="1" GridPane.columnIndex="1">Login:</Label>
<Label styleClass="inputLabel" GridPane.rowIndex="2" GridPane.columnIndex="1">Vorname:</Label>
<Label styleClass="inputLabel" GridPane.rowIndex="3" GridPane.columnIndex="1">Nachname:</Label>
<Label styleClass="inputLabel" GridPane.rowIndex="4" GridPane.columnIndex="1">Passwort:</Label>
<Label styleClass="inputLabel" GridPane.rowIndex="5" GridPane.columnIndex="1">Passwort wiederholen:</Label>
<Label styleClass="inputLabelAdmin" GridPane.rowIndex="6" GridPane.columnIndex="1">Admin:</Label>
<TextField fx:id="textLogin" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="1" />
<TextField fx:id="textForename" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="2" />
<TextField fx:id="textName" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="3" />
<PasswordField fx:id="textPassword" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="4" />
<PasswordField fx:id="textPasswordSecond" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="5" />
<JFXToggleButton fx:id="checkButtonIsAdmin" GridPane.columnIndex="2" GridPane.rowIndex="6"/>
<Label fx:id="labelError" styleClass="errorMessage" GridPane.columnIndex="2" GridPane.rowIndex="7"/>
<HBox GridPane.columnIndex="2" GridPane.rowIndex="8" alignment="CENTER_RIGHT">
<HBox.margin>
<Insets right="100" left="100"/>
</HBox.margin>
<Button onAction="#abortBtnClick">Abbrechen</Button>
<Button onAction="#createUser" styleClass="btnLogin" >Bearbeiten</Button>
</HBox>
</GridPane>

View File

@ -2,6 +2,10 @@ plugins {
java java
} }
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
dependencies { dependencies {
val jacksonVersion = "2.13.0" val jacksonVersion = "2.13.0"
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion") implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")

View File

@ -1,19 +1,11 @@
package res; package res;
import com.sun.jdi.event.StepEvent;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.sql.SQLOutput;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
public class Event { public class Event {
@ -44,15 +36,15 @@ public class Event {
System.out.println("Create Event"); System.out.println("Create Event");
if (name.length() < 3) { if (name.length() < 3) {
throw new IllegalArgumentException("Der Name muss eine L\u00e4nge von 3 haben."); throw new IllegalArgumentException("Der Name muss eine Länge 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); Matcher matcher = pattern.matcher(name);
if (!matcher.matches()) { if (!matcher.matches()) {
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) { if (priority < 0) {
throw new IllegalArgumentException("Bitte eine Priorit\u00e4t w\u00e4hlen."); throw new IllegalArgumentException("Bitte eine Priorität wählen.");
} }
LocalDateTime today = LocalDateTime.now().toLocalDate().atStartOfDay(); LocalDateTime today = LocalDateTime.now().toLocalDate().atStartOfDay();
if (Duration.between(today, date).isNegative()) { if (Duration.between(today, date).isNegative()) {
@ -82,9 +74,7 @@ public class Event {
} }
public void setName(String name) { public void setName(String name) {
System.out.println(name);
this.name = name; this.name = name;
System.out.println(this.name);
} }
public int getPriority() { public int getPriority() {