2021-11-29 15:44:55 +01:00
|
|
|
package main;
|
|
|
|
|
2022-01-14 21:22:50 +01:00
|
|
|
import com.jfoenix.controls.JFXTextField;
|
2022-01-13 08:30:56 +01:00
|
|
|
import com.jfoenix.controls.JFXTimePicker;
|
2021-11-29 15:44:55 +01:00
|
|
|
import javafx.event.ActionEvent;
|
|
|
|
import javafx.fxml.FXML;
|
|
|
|
import javafx.scene.Node;
|
2021-12-20 12:57:18 +01:00
|
|
|
import javafx.scene.control.*;
|
2022-01-13 08:30:56 +01:00
|
|
|
import javafx.scene.layout.GridPane;
|
2021-11-29 15:44:55 +01:00
|
|
|
import javafx.stage.Stage;
|
2022-01-13 11:02:49 +01:00
|
|
|
import javafx.util.StringConverter;
|
|
|
|
import javafx.util.converter.LocalTimeStringConverter;
|
2021-11-29 15:44:55 +01:00
|
|
|
import res.DataController;
|
|
|
|
import res.Event;
|
|
|
|
|
2022-01-13 11:02:49 +01:00
|
|
|
import java.time.LocalTime;
|
|
|
|
import java.time.format.FormatStyle;
|
|
|
|
import java.util.Locale;
|
|
|
|
|
2021-11-29 15:44:55 +01:00
|
|
|
public class CreateEventController {
|
|
|
|
|
2022-01-13 08:30:56 +01:00
|
|
|
@FXML
|
2022-01-13 10:11:09 +01:00
|
|
|
public GridPane mainGrid;
|
2021-11-29 15:44:55 +01:00
|
|
|
@FXML
|
|
|
|
public DatePicker datePickerDate;
|
|
|
|
@FXML
|
2022-01-14 21:22:50 +01:00
|
|
|
public JFXTextField textName;
|
2021-11-29 15:44:55 +01:00
|
|
|
@FXML
|
|
|
|
public ComboBox<String> ComboBoxPriotity;
|
|
|
|
@FXML
|
|
|
|
public CheckBox checkBoxIsFullDay;
|
|
|
|
@FXML
|
|
|
|
public CheckBox checkBoxIsPrivate;
|
2021-12-20 12:57:18 +01:00
|
|
|
@FXML
|
|
|
|
public Label labelError;
|
2022-01-13 08:30:56 +01:00
|
|
|
@FXML
|
|
|
|
public JFXTimePicker timeStart;
|
|
|
|
@FXML
|
|
|
|
public JFXTimePicker timeEnd;
|
2021-12-20 12:57:18 +01:00
|
|
|
|
2021-11-29 15:44:55 +01:00
|
|
|
|
2021-12-20 12:57:18 +01:00
|
|
|
public CreateEventController() {
|
|
|
|
}
|
2021-11-29 15:44:55 +01:00
|
|
|
|
|
|
|
@FXML
|
2021-12-20 12:57:18 +01:00
|
|
|
public void initialize() {
|
2022-01-14 10:14:17 +01:00
|
|
|
|
|
|
|
StringConverter<LocalTime> defaultConverter = new LocalTimeStringConverter(FormatStyle.SHORT, Locale.GERMANY);
|
|
|
|
|
2022-01-13 08:30:56 +01:00
|
|
|
JFXTimePicker timePickerStart = new JFXTimePicker();
|
|
|
|
timeStart = timePickerStart;
|
|
|
|
timePickerStart.set24HourView(true);
|
2022-01-14 10:14:17 +01:00
|
|
|
timePickerStart.setConverter(defaultConverter);
|
2022-01-13 10:11:09 +01:00
|
|
|
timePickerStart.getStyleClass().add("timePicker");
|
|
|
|
mainGrid.add(timePickerStart, 1 , 3);
|
2022-01-13 08:30:56 +01:00
|
|
|
|
|
|
|
JFXTimePicker timePickerEnd = new JFXTimePicker();
|
|
|
|
timeEnd = timePickerEnd;
|
|
|
|
timePickerEnd.set24HourView(true);
|
2022-01-14 10:14:17 +01:00
|
|
|
timePickerEnd.setConverter(defaultConverter);
|
2022-01-13 10:11:09 +01:00
|
|
|
timePickerEnd.getStyleClass().add("timePicker");
|
|
|
|
mainGrid.add(timePickerEnd, 1 , 4);
|
2021-12-20 12:57:18 +01:00
|
|
|
}
|
2021-11-29 15:44:55 +01:00
|
|
|
|
|
|
|
|
|
|
|
@FXML
|
2021-12-20 12:57:18 +01:00
|
|
|
protected void createBtnClick(ActionEvent actionEvent) {
|
|
|
|
try {
|
2021-12-22 15:04:15 +01:00
|
|
|
if (datePickerDate.getValue() == null) {
|
2021-12-20 12:57:18 +01:00
|
|
|
throw new IllegalArgumentException("Bitte w\u00e4hle ein Datum aus");
|
|
|
|
}
|
2021-11-29 15:44:55 +01:00
|
|
|
|
2021-12-20 12:57:18 +01:00
|
|
|
Event event = new Event(
|
|
|
|
textName.getText(),
|
|
|
|
ComboBoxPriotity.getSelectionModel().getSelectedIndex(),
|
|
|
|
checkBoxIsFullDay.isSelected(),
|
|
|
|
checkBoxIsPrivate.isSelected(),
|
2022-01-13 11:02:49 +01:00
|
|
|
timeStart.getValue().toString(),
|
|
|
|
timeEnd.getValue().toString(),
|
2021-12-20 12:57:18 +01:00
|
|
|
datePickerDate.getValue().atStartOfDay(),
|
2021-12-22 15:04:15 +01:00
|
|
|
(int) DataController.USER_ID
|
2021-12-20 12:57:18 +01:00
|
|
|
);
|
2021-11-29 15:44:55 +01:00
|
|
|
|
2021-12-20 12:57:18 +01:00
|
|
|
System.out.println(event.getAsUrlParam());
|
2021-11-29 15:44:55 +01:00
|
|
|
|
2021-12-20 12:57:18 +01:00
|
|
|
DataController dataController = new DataController();
|
|
|
|
dataController.createEvent(event);
|
2021-11-29 15:44:55 +01:00
|
|
|
|
2021-12-20 12:57:18 +01:00
|
|
|
Stage stage = (Stage) ((Node) actionEvent.getSource()).getScene().getWindow();
|
|
|
|
stage.close();
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
labelError.setText(e.getMessage());
|
|
|
|
}
|
2021-11-29 15:44:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@FXML
|
2021-12-20 12:57:18 +01:00
|
|
|
protected void abortBtnClick(ActionEvent event) {
|
2021-11-29 15:44:55 +01:00
|
|
|
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
|
|
|
|
stage.close();
|
|
|
|
}
|
|
|
|
}
|