-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work on more resource calendars.
- Loading branch information
1 parent
c9544cc
commit 6c03db2
Showing
23 changed files
with
781 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...pler/src/main/java/com/calendarfx/demo/views/resources/HelloDetailedResourcesDayView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (C) 2017 Dirk Lemmermann Software & Consulting (dlsc.com) | ||
* Copyright (C) 2006 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.calendarfx.demo.views.resources; | ||
|
||
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.Resource; | ||
import javafx.scene.Node; | ||
import javafx.scene.control.ToggleButton; | ||
|
||
public class HelloDetailedResourcesDayView extends CalendarFXDateControlSample { | ||
|
||
private DetailedResourcesDayView detailedResouresDayView; | ||
|
||
@Override | ||
public String getSampleName() { | ||
return "Detailed Resources Day View"; | ||
} | ||
|
||
@Override | ||
public String getSampleDescription() { | ||
return "The detailed day view aggregates a day view, an all day view, a calendar header (for swimlane layout), and a time scale."; | ||
} | ||
|
||
@Override | ||
protected Class<?> getJavaDocClass() { | ||
return DetailedResourcesDayView.class; | ||
} | ||
|
||
@Override | ||
public Node getControlPanel() { | ||
ToggleButton availabilityButton = new ToggleButton("Edit Schedule"); | ||
availabilityButton.selectedProperty().bindBidirectional(detailedResouresDayView.editAvailabilityProperty()); | ||
return availabilityButton; | ||
} | ||
|
||
@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; | ||
} | ||
|
||
private Resource<String> create(String name, Style style) { | ||
Resource<String> resource = new Resource(name); | ||
resource.getAvailabilityCalendar().setName("Availability of " + name); | ||
resource.getCalendar().setStyle(style); | ||
resource.getCalendar().addEventHandler(evt -> System.out.println(evt)); | ||
resource.getAvailabilityCalendar().addEventHandler(evt -> System.out.println(evt)); | ||
return resource; | ||
} | ||
|
||
public static void main(String[] args) { | ||
launch(args); | ||
} | ||
|
||
} |
102 changes: 102 additions & 0 deletions
102
...Sampler/src/main/java/com/calendarfx/demo/views/resources/HelloMultiDayViewContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright (C) 2017 Dirk Lemmermann Software & Consulting (dlsc.com) | ||
* Copyright (C) 2006 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.calendarfx.demo.views.resources; | ||
|
||
import com.calendarfx.demo.CalendarFXDateControlSample; | ||
import com.calendarfx.model.Calendar; | ||
import com.calendarfx.model.Entry; | ||
import com.calendarfx.view.DateControl; | ||
import com.calendarfx.view.resources.DetailedResourcesDayView; | ||
import com.calendarfx.view.resources.MultiResourceDayViewContainer; | ||
import com.calendarfx.view.resources.Resource; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalTime; | ||
|
||
public class HelloMultiDayViewContainer extends CalendarFXDateControlSample { | ||
|
||
private MultiResourceDayViewContainer<Resource<String>> multiDayViewContainer; | ||
|
||
@Override | ||
public String getSampleName() { | ||
return "Multi Day View Container"; | ||
} | ||
|
||
@Override | ||
public String getSampleDescription() { | ||
return "A specialized container for showing multiple DayView instances, one for each item added to it."; | ||
} | ||
|
||
@Override | ||
protected Class<?> getJavaDocClass() { | ||
return DetailedResourcesDayView.class; | ||
} | ||
|
||
@Override | ||
protected DateControl createControl() { | ||
multiDayViewContainer = new MultiResourceDayViewContainer<>(); | ||
multiDayViewContainer.getResources().addAll(create("Dirk"), create("Katja"), create("Philip"), create("Jule"), create("Armin")); | ||
multiDayViewContainer.setPrefHeight(800); | ||
return multiDayViewContainer; | ||
} | ||
|
||
private Resource<String> create(String name) { | ||
Resource<String> resource = new Resource(name); | ||
resource.getCalendar().addEventHandler(evt -> System.out.println(evt)); | ||
resource.getAvailabilityCalendar().addEventHandler(evt -> System.out.println(evt)); | ||
return resource; | ||
} | ||
|
||
class HelloCalendar extends Calendar { | ||
|
||
public HelloCalendar() { | ||
LocalDate date = LocalDate.now(); | ||
|
||
for (int i = 1; i < 3; i++) { | ||
|
||
Entry<?> entry = new Entry<>(); | ||
entry.changeStartDate(date); | ||
entry.changeEndDate(date); | ||
|
||
entry.setTitle("Entry " + i); | ||
|
||
int hour = (int) (Math.random() * 23); | ||
int durationInHours = Math.min(24 - hour, | ||
(int) (Math.random() * 4)); | ||
|
||
LocalTime startTime = LocalTime.of(hour, 0); | ||
LocalTime endTime = startTime.plusHours(durationInHours); | ||
|
||
entry.changeStartTime(startTime); | ||
entry.changeEndTime(endTime); | ||
|
||
if (Math.random() < .1) { | ||
entry.setFullDay(true); | ||
entry.setTitle("Full Day Entry"); | ||
} | ||
|
||
entry.setCalendar(this); | ||
} | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
launch(args); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.