Skip to content

Commit

Permalink
Configured upper left corner stone in ResourcesView to display the we…
Browse files Browse the repository at this point in the history
…ek of the year number.
  • Loading branch information
dlemmermann committed Sep 20, 2022
1 parent d9b72a3 commit e5de593
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.calendarfx.view.WeekDayHeaderView;
import com.calendarfx.view.WeekView;
import impl.com.calendarfx.view.resources.ResourcesViewSkin;
import javafx.beans.binding.Bindings;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ListProperty;
Expand All @@ -43,6 +44,7 @@
import javafx.scene.layout.Region;
import javafx.util.Callback;

import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.function.Consumer;

Expand Down Expand Up @@ -80,6 +82,13 @@ public ResourcesView() {
setVirtualGrid(grid);
setAvailabilityGrid(grid);
setGridLines(grid);

Label weekNumberLabel = new Label();
weekNumberLabel.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
weekNumberLabel.getStyleClass().add("week-number-label");
weekNumberLabel.setAlignment(Pos.CENTER);
weekNumberLabel.textProperty().bind(Bindings.createStringBinding(() -> DateTimeFormatter.ofPattern("w").format(getDate()), dateProperty()));
setUpperLeftCorner(weekNumberLabel);
}

private void maybeRunAndConsume(RequestEvent evt, Consumer<RequestEvent> consumer) {
Expand Down Expand Up @@ -348,7 +357,7 @@ public void setWeekViewFactory(Callback<T, WeekView> weekViewFactory) {
this.weekViewFactory.set(weekViewFactory);
}

private final ObjectProperty<Node> upperLeftCorner = new SimpleObjectProperty<>(this, "upperLeftCorner", new Region());
private final ObjectProperty<Node> upperLeftCorner = new SimpleObjectProperty<>(this, "upperLeftCorner");

public final Node getUpperLeftCorner() {
return upperLeftCorner.get();
Expand Down

0 comments on commit e5de593

Please sign in to comment.