Refactored DayPane;

This commit is contained in:
Marc Beyer 2022-01-31 21:16:01 +01:00
parent 31dbeec55a
commit d980edeaad
2 changed files with 27 additions and 30 deletions

View File

@ -137,27 +137,30 @@ public class MainController {
private void createWeek() { private void createWeek() {
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
DayPane dayPane = new DayPane(dayNames[i]); DayPane dayPane = new DayPane();
this.dayLabel[i] = dayPane.getDayLabel(); this.dayLabel[i] = dayPane.getDayLabel();
calendarGrid.add(dayPane.getDayLabel(), i, 0); calendarGrid.add(dayPane.getDayLabel(), i, 0);
dayVBoxes[i] = dayPane.getDayVBox(); dayVBoxes[i] = dayPane.getDayVBox();
calendarGrid.add(dayPane.getScrollPane(), i, 1); calendarGrid.add(dayPane, i, 1);
} }
} }
private void addEvent(Event event) { private void addEvent(Event event) {
EventPane eventPane = new EventPane(event); EventPane eventPane = new EventPane(event);
eventPane.getEditBtn().setOnAction(event1 -> MainApplication.loadScene( eventPane.getEditBtn().setOnAction(event1 -> {
"Termin bearbeiten", MainApplication.loadScene(
"edit-event.fxml", "Termin bearbeiten",
"create-event.css", "edit-event.fxml",
650, "create-event.css",
650, 650,
fxmlLoader -> { 650,
EditEventController editEventController = fxmlLoader.getController(); fxmlLoader -> {
editEventController.setCurrentEvent(event); EditEventController editEventController = fxmlLoader.getController();
} editEventController.setCurrentEvent(event);
)); }
);
updateEvents();
});
eventPane.getDeleteBtn().setOnAction(e -> { eventPane.getDeleteBtn().setOnAction(e -> {
DataController dataController = new DataController(); DataController dataController = new DataController();

View File

@ -4,30 +4,28 @@ import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane; import javafx.scene.control.ScrollPane;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
public class DayPane { public class DayPane extends ScrollPane {
private Label dayLabel; private final Label dayLabel;
private VBox dayVBox; private final VBox dayVBox;
private ScrollPane scrollPane;
public DayPane(String name) { public DayPane() {
dayLabel = new Label(); dayLabel = new Label();
dayLabel.setText(name);
dayLabel.setMaxHeight(Double.MAX_VALUE); dayLabel.setMaxHeight(Double.MAX_VALUE);
dayLabel.setMaxWidth(Double.MAX_VALUE); dayLabel.setMaxWidth(Double.MAX_VALUE);
dayLabel.getStyleClass().add("labelDays"); dayLabel.getStyleClass().add("labelDays");
scrollPane = new ScrollPane();
dayVBox = new VBox(); dayVBox = new VBox();
dayVBox.getStyleClass().add("vBoxDays"); dayVBox.getStyleClass().add("vBoxDays");
dayVBox.setSpacing(10); dayVBox.setSpacing(10);
scrollPane.setContent(dayVBox);
scrollPane.setFitToWidth(true); setContent(dayVBox);
scrollPane.setFitToHeight(true); setFitToWidth(true);
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); setFitToHeight(true);
scrollPane.getStyleClass().add("scrollDays"); setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
getStyleClass().add("scrollDays");
getStyleClass().add("scrollDays");
} }
public Label getDayLabel() { public Label getDayLabel() {
@ -37,8 +35,4 @@ public class DayPane {
public VBox getDayVBox() { public VBox getDayVBox() {
return dayVBox; return dayVBox;
} }
public ScrollPane getScrollPane() {
return scrollPane;
}
} }