Refactor
This commit is contained in:
@@ -20,23 +20,23 @@ import java.util.Locale;
|
||||
public class CreateEventController {
|
||||
|
||||
@FXML
|
||||
public GridPane mainGrid;
|
||||
private GridPane mainGrid;
|
||||
@FXML
|
||||
public JFXDatePicker datePickerDate;
|
||||
protected JFXDatePicker datePickerDate;
|
||||
@FXML
|
||||
public JFXTextField textName;
|
||||
protected JFXTextField textName;
|
||||
@FXML
|
||||
public JFXComboBox<String> ComboBoxPriotity;
|
||||
protected JFXComboBox<String> comboBoxPriority;
|
||||
@FXML
|
||||
public JFXToggleButton toggleBtnIsFullDay;
|
||||
private JFXToggleButton toggleBtnIsFullDay;
|
||||
@FXML
|
||||
public JFXToggleButton toggleBtnIsPrivate;
|
||||
private JFXToggleButton toggleBtnIsPrivate;
|
||||
@FXML
|
||||
public Label labelError;
|
||||
private Label labelError;
|
||||
@FXML
|
||||
public JFXTimePicker timeStart;
|
||||
private JFXTimePicker timeStart;
|
||||
@FXML
|
||||
public JFXTimePicker timeEnd;
|
||||
private JFXTimePicker timeEnd;
|
||||
|
||||
|
||||
public CreateEventController() {
|
||||
@@ -64,7 +64,7 @@ public class CreateEventController {
|
||||
|
||||
Event event = new Event(
|
||||
textName.getText(),
|
||||
ComboBoxPriotity.getSelectionModel().getSelectedIndex(),
|
||||
comboBoxPriority.getSelectionModel().getSelectedIndex(),
|
||||
toggleBtnIsFullDay.isSelected(),
|
||||
toggleBtnIsPrivate.isSelected(),
|
||||
timeStart.getValue(),
|
||||
|
@@ -17,7 +17,7 @@ public class EditEventController extends CreateEventController{
|
||||
|
||||
textName.setText(currentEvent.getName());
|
||||
datePickerDate.setValue(currentEvent.getDate().toLocalDate());
|
||||
ComboBoxPriotity.getSelectionModel().select(currentEvent.getPriority());
|
||||
comboBoxPriority.getSelectionModel().select(currentEvent.getPriority());
|
||||
|
||||
//timeEnd.setValue(currentEvent.getEnd());
|
||||
}
|
||||
|
@@ -2,16 +2,13 @@ package main;
|
||||
|
||||
import config.Config;
|
||||
import config.ConfigLoader;
|
||||
import helper.Tuple;
|
||||
import container.DataController;
|
||||
import container.HttpRequest;
|
||||
import javafx.application.Application;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import container.DataController;
|
||||
import container.HttpRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
@@ -41,6 +38,9 @@ public class MainApplication extends Application {
|
||||
config.setToken(HttpRequest.TOKEN);
|
||||
ConfigLoader.save(config);
|
||||
}
|
||||
|
||||
DataController.SERVER_URL = config.toServerUrl();
|
||||
|
||||
// Load main-scene
|
||||
loadMainScene(stage);
|
||||
|
||||
@@ -60,22 +60,30 @@ public class MainApplication extends Application {
|
||||
stage.show();
|
||||
}
|
||||
|
||||
private void loadLoginScene() throws IOException {
|
||||
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()
|
||||
private void loadLoginScene() {
|
||||
loadScene(
|
||||
"Anmelden",
|
||||
"../users/login.fxml",
|
||||
"../users/login.css",
|
||||
650,
|
||||
500
|
||||
);
|
||||
Stage stageLogin = new Stage();
|
||||
stageLogin.setTitle("Anmelden");
|
||||
stageLogin.setScene(sceneLogin);
|
||||
stageLogin.showAndWait();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch();
|
||||
}
|
||||
|
||||
public static void loadScene(
|
||||
String title,
|
||||
String fxml,
|
||||
String css,
|
||||
int width,
|
||||
int height
|
||||
) {
|
||||
loadScene(title, fxml, css, width, height, null);
|
||||
}
|
||||
|
||||
public static void loadScene(
|
||||
String title,
|
||||
String fxml,
|
||||
|
@@ -2,45 +2,40 @@ package main;
|
||||
|
||||
import config.Config;
|
||||
import config.ConfigLoader;
|
||||
import container.DataController;
|
||||
import container.Event;
|
||||
import container.HttpRequest;
|
||||
import events.EditEventController;
|
||||
import ui.DayPane;
|
||||
import ui.EventPane;
|
||||
import ui.SvgBtnCreator;
|
||||
import helper.HttpRequestException;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import container.DataController;
|
||||
import container.Event;
|
||||
import ui.DayPane;
|
||||
import ui.EventPane;
|
||||
import ui.SvgBtnCreator;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import container.HttpRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MainController {
|
||||
|
||||
@FXML
|
||||
public VBox leftNav;
|
||||
private VBox leftNav;
|
||||
@FXML
|
||||
public GridPane mainGridPane;
|
||||
private GridPane mainGridPane;
|
||||
@FXML
|
||||
public HBox buttonBox;
|
||||
private HBox buttonBox;
|
||||
@FXML
|
||||
private GridPane calendarGrid;
|
||||
|
||||
@FXML
|
||||
private javafx.scene.control.Label LabelMonth;
|
||||
|
||||
@@ -110,8 +105,7 @@ public class MainController {
|
||||
"create-event.fxml",
|
||||
"create-event.css",
|
||||
650,
|
||||
650,
|
||||
null
|
||||
650
|
||||
);
|
||||
updateEvents();
|
||||
}
|
||||
@@ -122,8 +116,7 @@ public class MainController {
|
||||
"option-view.fxml",
|
||||
"option-view.css",
|
||||
650,
|
||||
600,
|
||||
null
|
||||
600
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -27,17 +27,17 @@ import java.util.Optional;
|
||||
public class OptionController {
|
||||
|
||||
@FXML
|
||||
public JFXButton updateUserBtn;
|
||||
private JFXButton updateUserBtn;
|
||||
@FXML
|
||||
public JFXButton deleteUserBtn;
|
||||
private JFXButton deleteUserBtn;
|
||||
@FXML
|
||||
public JFXButton createUserBtn;
|
||||
private JFXButton createUserBtn;
|
||||
@FXML
|
||||
public JFXToggleButton saveLoginTBtn;
|
||||
private JFXToggleButton saveLoginTBtn;
|
||||
@FXML
|
||||
public Label labelError;
|
||||
private Label labelError;
|
||||
@FXML
|
||||
public GridPane mainGrid;
|
||||
private GridPane mainGrid;
|
||||
|
||||
private JFXComboBox<String> comboBox;
|
||||
private DataController dataController;
|
||||
@@ -79,8 +79,7 @@ public class OptionController {
|
||||
"../users/create-user.fxml",
|
||||
"../users/create-user.css",
|
||||
800,
|
||||
650,
|
||||
null
|
||||
650
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -1,26 +1,12 @@
|
||||
package ui;
|
||||
|
||||
import container.DataController;
|
||||
import container.Event;
|
||||
import events.EditEventController;
|
||||
import helper.HttpRequestException;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import main.MainApplication;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
public class EventPane extends VBox {
|
||||
|
||||
|
@@ -16,40 +16,24 @@ import java.util.Objects;
|
||||
|
||||
public class CreateUserController {
|
||||
|
||||
public TextField textName;
|
||||
public PasswordField textPassword;
|
||||
public PasswordField textPasswordSecond;
|
||||
public ToggleButton checkButtonIsAdmin;
|
||||
public TextField textLogin;
|
||||
public TextField textForename;
|
||||
public Label labelError;
|
||||
@FXML
|
||||
protected TextField textName;
|
||||
@FXML
|
||||
protected PasswordField textPassword;
|
||||
@FXML
|
||||
protected PasswordField textPasswordSecond;
|
||||
@FXML
|
||||
protected ToggleButton checkButtonIsAdmin;
|
||||
@FXML
|
||||
protected TextField textLogin;
|
||||
@FXML
|
||||
protected TextField textForename;
|
||||
@FXML
|
||||
protected Label labelError;
|
||||
|
||||
@FXML
|
||||
protected void createUser(ActionEvent event) {
|
||||
if (textLogin.getText().trim().isEmpty()){
|
||||
labelError.setText("Bitte Login Namen angeben");
|
||||
return;
|
||||
}
|
||||
if (textForename.getText().trim().isEmpty()) {
|
||||
labelError.setText("Bitte Vornamen eingeben!");
|
||||
return;
|
||||
}
|
||||
if (textName.getText().trim().isEmpty()) {
|
||||
labelError.setText("Bitte Nachnamen eingeben!");
|
||||
return;
|
||||
}
|
||||
if (textPassword.getText().trim().isEmpty()) {
|
||||
labelError.setText("Bitte Passwort eingeben!");
|
||||
return;
|
||||
}
|
||||
if (textPassword.getText().trim().length() < 8) {
|
||||
labelError.setText("Das Passwort muss mindestens 8 Zeichen lang sein!");
|
||||
return;
|
||||
}
|
||||
if (!Objects.equals(textPassword.getText(), textPasswordSecond.getText())){
|
||||
labelError.setText("Passwörter stimmen nicht überein!");
|
||||
return;
|
||||
}
|
||||
if (validateNameAndLogin() || validatePassword()) return;
|
||||
|
||||
User user = new User();
|
||||
user.setLogin(textLogin.getText().trim());
|
||||
@@ -69,6 +53,38 @@ public class CreateUserController {
|
||||
stage.close();
|
||||
}
|
||||
|
||||
protected boolean validatePassword() {
|
||||
if (textPassword.getText().trim().isEmpty()) {
|
||||
labelError.setText("Bitte Passwort eingeben!");
|
||||
return true;
|
||||
}
|
||||
if (textPassword.getText().trim().length() < 8) {
|
||||
labelError.setText("Das Passwort muss mindestens 8 Zeichen lang sein!");
|
||||
return true;
|
||||
}
|
||||
if (!Objects.equals(textPassword.getText(), textPasswordSecond.getText())){
|
||||
labelError.setText("Passwörter stimmen nicht überein!");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean validateNameAndLogin() {
|
||||
if (textLogin.getText().trim().isEmpty()){
|
||||
labelError.setText("Bitte Login Namen angeben");
|
||||
return true;
|
||||
}
|
||||
if (textForename.getText().trim().isEmpty()) {
|
||||
labelError.setText("Bitte Vornamen eingeben!");
|
||||
return true;
|
||||
}
|
||||
if (textName.getText().trim().isEmpty()) {
|
||||
labelError.setText("Bitte Nachnamen eingeben!");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void sendHttpRequest(User user) throws HttpRequestException {
|
||||
DataController dataController = new DataController();
|
||||
dataController.createUser(user);
|
||||
|
@@ -8,8 +8,6 @@ import javafx.scene.Node;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class EditUserController extends CreateUserController{
|
||||
private User currentUser;
|
||||
|
||||
@@ -28,34 +26,12 @@ public class EditUserController extends CreateUserController{
|
||||
|
||||
@Override
|
||||
protected void createUser(ActionEvent event){
|
||||
if (textLogin.getText().trim().isEmpty()){
|
||||
labelError.setText("Bitte Login Namen angeben");
|
||||
return;
|
||||
}
|
||||
if (textForename.getText().trim().isEmpty()) {
|
||||
labelError.setText("Bitte Vornamen eingeben!");
|
||||
return;
|
||||
}
|
||||
if (textName.getText().trim().isEmpty()) {
|
||||
labelError.setText("Bitte Nachnamen eingeben!");
|
||||
return;
|
||||
}
|
||||
if (validateNameAndLogin()) return;
|
||||
|
||||
User user = new User();
|
||||
|
||||
if(!textPassword.getText().trim().isEmpty() || !textPasswordSecond.getText().trim().isEmpty()){
|
||||
if (textPassword.getText().trim().isEmpty()) {
|
||||
labelError.setText("Bitte Passwort eingeben!");
|
||||
return;
|
||||
}
|
||||
if (textPassword.getText().trim().length() < 8) {
|
||||
labelError.setText("Das Passwort muss mindestens 8 Zeichen lang sein!");
|
||||
return;
|
||||
}
|
||||
if (!Objects.equals(textPassword.getText(), textPasswordSecond.getText())){
|
||||
labelError.setText("Passwörter stimmen nicht überein!");
|
||||
return;
|
||||
}
|
||||
if (validatePassword()) return;
|
||||
user.setPassword(textPassword.getText().trim());
|
||||
}
|
||||
|
||||
|
@@ -10,13 +10,13 @@ import container.DataController;
|
||||
|
||||
public class LoginController {
|
||||
@FXML
|
||||
public JFXTextField userField;
|
||||
private JFXTextField userField;
|
||||
@FXML
|
||||
public JFXPasswordField passField;
|
||||
private JFXPasswordField passField;
|
||||
@FXML
|
||||
public Label userErrLabel;
|
||||
private Label userErrLabel;
|
||||
@FXML
|
||||
public Label passErrLabel;
|
||||
private Label passErrLabel;
|
||||
|
||||
@FXML
|
||||
protected void login(ActionEvent event) {
|
||||
|
@@ -43,7 +43,7 @@
|
||||
<JFXTimePicker styleClass="timePicker" fx:id="timeStart" GridPane.columnIndex="1" GridPane.rowIndex="3" maxWidth="200" minWidth="200"/>
|
||||
<JFXTimePicker styleClass="timePicker" fx:id="timeEnd" GridPane.columnIndex="1" GridPane.rowIndex="4" maxWidth="200" minWidth="200"/>
|
||||
|
||||
<JFXComboBox fx:id="ComboBoxPriotity" styleClass="comboBox" GridPane.columnIndex="1" GridPane.rowIndex="5" maxWidth="200" minWidth="200">
|
||||
<JFXComboBox fx:id="comboBoxPriority" styleClass="comboBox" GridPane.columnIndex="1" GridPane.rowIndex="5" maxWidth="200" minWidth="200">
|
||||
<items>
|
||||
<FXCollections fx:factory="observableArrayList">
|
||||
<String fx:value="gering"/>
|
||||
|
@@ -43,7 +43,7 @@
|
||||
<JFXTimePicker styleClass="timePicker" fx:id="timeStart" GridPane.columnIndex="1" GridPane.rowIndex="3" maxWidth="200" minWidth="200"/>
|
||||
<JFXTimePicker styleClass="timePicker" fx:id="timeEnd" GridPane.columnIndex="1" GridPane.rowIndex="4" maxWidth="200" minWidth="200"/>
|
||||
|
||||
<JFXComboBox fx:id="ComboBoxPriotity" styleClass="comboBox" GridPane.columnIndex="1" GridPane.rowIndex="5" maxWidth="200" minWidth="200">
|
||||
<JFXComboBox fx:id="comboBoxPriority" styleClass="comboBox" GridPane.columnIndex="1" GridPane.rowIndex="5" maxWidth="200" minWidth="200">
|
||||
<items>
|
||||
<FXCollections fx:factory="observableArrayList">
|
||||
<String fx:value="gering"/>
|
||||
|
Reference in New Issue
Block a user