Skip to content

Commit

Permalink
Initial work on more resource calendars.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemmermann committed Sep 15, 2022
1 parent 6c03db2 commit 07e4410
Show file tree
Hide file tree
Showing 15 changed files with 408 additions and 244 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,21 @@
import com.calendarfx.demo.CalendarFXDateControlSample;
import com.calendarfx.model.Calendar.Style;
import com.calendarfx.view.DateControl;
import com.calendarfx.view.resources.DetailedResourcesDayView;
import com.calendarfx.view.resources.ResourcesView;
import com.calendarfx.view.resources.Resource;
import javafx.scene.Node;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.ToggleButton;
import javafx.scene.layout.VBox;

public class HelloDetailedResourcesDayView extends CalendarFXDateControlSample {
public class HelloResourcesView extends CalendarFXDateControlSample {

private DetailedResourcesDayView detailedResouresDayView;
private ResourcesView resourcesView;

@Override
public String getSampleName() {
return "Detailed Resources Day View";
return "ResourcesView";
}

@Override
Expand All @@ -41,23 +44,32 @@ public String getSampleDescription() {

@Override
protected Class<?> getJavaDocClass() {
return DetailedResourcesDayView.class;
return ResourcesView.class;
}

@Override
public Node getControlPanel() {
ToggleButton availabilityButton = new ToggleButton("Edit Schedule");
availabilityButton.selectedProperty().bindBidirectional(detailedResouresDayView.editAvailabilityProperty());
return availabilityButton;
availabilityButton.selectedProperty().bindBidirectional(resourcesView.editAvailabilityProperty());

DatePicker datePicker = new DatePicker();
datePicker.valueProperty().bindBidirectional(resourcesView.dateProperty());

ChoiceBox<Integer> daysBox = new ChoiceBox<>();
daysBox.getItems().setAll(1, 2, 3, 4, 5, 7, 10, 14);
daysBox.setValue(resourcesView.getNumberOfDays());
daysBox.valueProperty().addListener(it -> resourcesView.setNumberOfDays(daysBox.getValue()));

return new VBox(10, availabilityButton, datePicker, daysBox);
}

@Override
protected DateControl createControl() {
detailedResouresDayView = new DetailedResourcesDayView();
detailedResouresDayView.setPrefHeight(800);
detailedResouresDayView.setPrefWidth(700);
detailedResouresDayView.getResources().addAll(create("Dirk", Style.STYLE1), create("Katja", Style.STYLE2), create("Philip", Style.STYLE3), create("Jule", Style.STYLE4), create("Armin", Style.STYLE5));
return detailedResouresDayView;
resourcesView = new ResourcesView();
resourcesView.setPrefHeight(800);
resourcesView.setPrefWidth(700);
resourcesView.getResources().addAll(create("Dirk", Style.STYLE1), create("Katja", Style.STYLE2), create("Philip", Style.STYLE3), create("Jule", Style.STYLE4), create("Armin", Style.STYLE5));
return resourcesView;
}

private Resource<String> create(String name, Style style) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,8 @@ private void doEditEntry(Entry<?> entry) {
if (entryView != null) {
entryView.bounce();

System.out.println(entryView.getLayoutBounds());
Point2D location = entryView.localToScreen(0, 0);

System.out.println(location);
Callback<EntryDetailsParameter, Boolean> callback = getEntryDetailsCallback();
EntryDetailsParameter param = new EntryDetailsParameter(null, this, entry, entryView, location.getX(), location.getY());
callback.call(param);
Expand Down Expand Up @@ -2636,6 +2634,7 @@ public final void bind(DateControl otherControl, boolean bindDate) {
Bindings.bindBidirectional(otherControl.enableTimeZoneSupportProperty(), enableTimeZoneSupportProperty());
Bindings.bindBidirectional(otherControl.showDetailsUponCreationProperty(), showDetailsUponCreationProperty());
Bindings.bindBidirectional(otherControl.showNoonMarkerProperty(), showNoonMarkerProperty());
Bindings.bindBidirectional(otherControl.showTodayProperty(), showTodayProperty());

if (bindDate) {
Bindings.bindBidirectional(otherControl.dateProperty(), dateProperty());
Expand Down Expand Up @@ -2705,6 +2704,7 @@ public final void unbind(DateControl otherControl) {
Bindings.unbindBidirectional(otherControl.availabilityFillProperty(), availabilityFillProperty());
Bindings.unbindBidirectional(otherControl.showDetailsUponCreationProperty(), showDetailsUponCreationProperty());
Bindings.unbindBidirectional(otherControl.showNoonMarkerProperty(), showNoonMarkerProperty());
Bindings.unbindBidirectional(otherControl.showTodayProperty(), showTodayProperty());

// unbind callbacks
Bindings.unbindBidirectional(otherControl.entryDetailsCallbackProperty(), entryDetailsCallbackProperty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ public DayViewBase() {
trimTimeBoundsProperty().addListener(trimListener);

installDefaultLassoFinishedBehaviour();

setMinWidth(0); // important, so that multi day views apply same width for all day views
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ private void bindVisibility() {
if (getLayer() != null) {
binding = binding.and(Bindings.createBooleanBinding(this::isAssignedLayerVisible, dateControl.visibleLayersProperty()));
}
if (dateControl instanceof DayViewBase) {
binding = binding.and(dateControl.editAvailabilityProperty().not());
}
// if (dateControl instanceof DayViewBase) {
// binding = binding.and(dateControl.editAvailabilityProperty().not());
// }

visibleProperty().bind(binding);
}
Expand Down

This file was deleted.

Loading

0 comments on commit 07e4410

Please sign in to comment.