From 0a9564ab14c79bf9fb4e37dd11469e3c2e5e8183 Mon Sep 17 00:00:00 2001 From: mkpaz Date: Thu, 25 May 2023 20:35:08 +0400 Subject: [PATCH] Rename InlineDatePicker to Calendar --- CHANGELOG.md | 4 +++ .../{InlineDatePicker.java => Calendar.java} | 28 +++++++-------- ...kerBehavior.java => CalendarBehavior.java} | 4 +-- ...eDatePickerSkin.java => CalendarSkin.java} | 14 ++++---- .../sampler/page/components/CalendarPage.java | 34 +++++++++---------- .../sampler/page/components/PopoverPage.java | 12 +++---- .../assets/fxml/blueprints/calendar.fxml | 4 +-- styles/src/components/_date-picker.scss | 2 +- 8 files changed, 53 insertions(+), 49 deletions(-) rename base/src/main/java/atlantafx/base/controls/{InlineDatePicker.java => Calendar.java} (92%) rename base/src/main/java/atlantafx/base/controls/{InlineDatePickerBehavior.java => CalendarBehavior.java} (93%) rename base/src/main/java/atlantafx/base/controls/{InlineDatePickerSkin.java => CalendarSkin.java} (97%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87bc88e..26ad839 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Breaking changes + +* The `InlineDatePicker` control renamed to `Calendar`. + ### Features - (Base) New `DeckPane` component with swipe and slide transition support. diff --git a/base/src/main/java/atlantafx/base/controls/InlineDatePicker.java b/base/src/main/java/atlantafx/base/controls/Calendar.java similarity index 92% rename from base/src/main/java/atlantafx/base/controls/InlineDatePicker.java rename to base/src/main/java/atlantafx/base/controls/Calendar.java index f69c8ce..6001fd2 100755 --- a/base/src/main/java/atlantafx/base/controls/InlineDatePicker.java +++ b/base/src/main/java/atlantafx/base/controls/Calendar.java @@ -68,7 +68,7 @@ import javafx.util.Callback; * provided in the {@link java.time.chrono.Chronology} API to get or set the corresponding * {@link java.time.chrono.ChronoLocalDate} value. */ -public class InlineDatePicker extends Control { +public class Calendar extends Control { protected LocalDate lastValidDate = null; protected Chronology lastValidChronology = IsoChronology.INSTANCE; @@ -76,7 +76,7 @@ public class InlineDatePicker extends Control { /** * Creates a default DatePicker instance with a null date value set. */ - public InlineDatePicker() { + public Calendar() { this(null); valueProperty().addListener(obs -> { @@ -109,7 +109,7 @@ public class InlineDatePicker extends Control { * * @param localDate to be set as the currently selected date in the DatePicker. Can be null. */ - public InlineDatePicker(LocalDate localDate) { + public Calendar(LocalDate localDate) { setValue(localDate); getStyleClass().add(DEFAULT_STYLE_CLASS); } @@ -119,7 +119,7 @@ public class InlineDatePicker extends Control { */ @Override protected Skin createDefaultSkin() { - return new InlineDatePickerSkin(this); + return new CalendarSkin(this); } /////////////////////////////////////////////////////////////////////////// @@ -144,17 +144,17 @@ public class InlineDatePicker extends Control { * A custom cell factory can be provided to customize individual day cells * Refer to {@link DateCell} and {@link Cell} for more information on cell factories. */ - private ObjectProperty> dayCellFactory; + private ObjectProperty> dayCellFactory; - public final void setDayCellFactory(Callback value) { + public final void setDayCellFactory(Callback value) { dayCellFactoryProperty().set(value); } - public final Callback getDayCellFactory() { + public final Callback getDayCellFactory() { return (dayCellFactory != null) ? dayCellFactory.get() : null; } - public final ObjectProperty> dayCellFactoryProperty() { + public final ObjectProperty> dayCellFactoryProperty() { if (dayCellFactory == null) { dayCellFactory = new SimpleObjectProperty<>(this, "dayCellFactory"); } @@ -210,13 +210,13 @@ public class InlineDatePicker extends Control { if (showWeekNumbers == null) { showWeekNumbers = new StyleableBooleanProperty(false) { @Override - public CssMetaData getCssMetaData() { + public CssMetaData getCssMetaData() { return StyleableProperties.SHOW_WEEK_NUMBERS; } @Override public Object getBean() { - return InlineDatePicker.this; + return Calendar.this; } @Override @@ -270,22 +270,22 @@ public class InlineDatePicker extends Control { // Stylesheet Handling // /////////////////////////////////////////////////////////////////////////// - private static final String DEFAULT_STYLE_CLASS = "inline-date-picker"; + private static final String DEFAULT_STYLE_CLASS = "calendar"; private static class StyleableProperties { private static final List> STYLEABLES; - private static final CssMetaData SHOW_WEEK_NUMBERS = + private static final CssMetaData SHOW_WEEK_NUMBERS = new CssMetaData<>("-fx-show-week-numbers", BooleanConverter.getInstance(), false) { @Override - public boolean isSettable(InlineDatePicker n) { + public boolean isSettable(Calendar n) { return n.showWeekNumbers == null || !n.showWeekNumbers.isBound(); } @Override @SuppressWarnings("RedundantCast") - public StyleableProperty getStyleableProperty(InlineDatePicker n) { + public StyleableProperty getStyleableProperty(Calendar n) { return (StyleableProperty) (WritableValue) n.showWeekNumbersProperty(); } }; diff --git a/base/src/main/java/atlantafx/base/controls/InlineDatePickerBehavior.java b/base/src/main/java/atlantafx/base/controls/CalendarBehavior.java similarity index 93% rename from base/src/main/java/atlantafx/base/controls/InlineDatePickerBehavior.java rename to base/src/main/java/atlantafx/base/controls/CalendarBehavior.java index 5fc2d8c..6e793a6 100755 --- a/base/src/main/java/atlantafx/base/controls/InlineDatePickerBehavior.java +++ b/base/src/main/java/atlantafx/base/controls/CalendarBehavior.java @@ -12,9 +12,9 @@ import java.time.ZoneId; import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseEvent; -public class InlineDatePickerBehavior extends BehaviorBase { +public class CalendarBehavior extends BehaviorBase { - public InlineDatePickerBehavior(InlineDatePicker control, InlineDatePickerSkin skin) { + public CalendarBehavior(Calendar control, CalendarSkin skin) { super(control, skin); } diff --git a/base/src/main/java/atlantafx/base/controls/InlineDatePickerSkin.java b/base/src/main/java/atlantafx/base/controls/CalendarSkin.java similarity index 97% rename from base/src/main/java/atlantafx/base/controls/InlineDatePickerSkin.java rename to base/src/main/java/atlantafx/base/controls/CalendarSkin.java index 954bf0c..7cfa1e3 100755 --- a/base/src/main/java/atlantafx/base/controls/InlineDatePickerSkin.java +++ b/base/src/main/java/atlantafx/base/controls/CalendarSkin.java @@ -27,7 +27,7 @@ package atlantafx.base.controls; -import static atlantafx.base.controls.InlineDatePicker.isValidDate; +import static atlantafx.base.controls.Calendar.isValidDate; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoUnit.DAYS; @@ -73,7 +73,7 @@ import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.util.Callback; -public class InlineDatePickerSkin extends BehaviorSkinBase { +public class CalendarSkin extends BehaviorSkinBase { // formatters final DateTimeFormatter yearFormatter = DateTimeFormatter.ofPattern("y"); @@ -113,7 +113,7 @@ public class InlineDatePickerSkin extends BehaviorSkinBase factory = getControl().getDayCellFactory(); + Callback factory = getControl().getDayCellFactory(); return Objects.requireNonNullElseGet( factory != null ? factory.call(getControl()) : null, DateCell::new diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/CalendarPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/CalendarPage.java index edf4dd3..83eb23d 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/CalendarPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/CalendarPage.java @@ -2,7 +2,7 @@ package atlantafx.sampler.page.components; -import atlantafx.base.controls.InlineDatePicker; +import atlantafx.base.controls.Calendar; import atlantafx.base.theme.Styles; import atlantafx.base.util.BBCodeParser; import atlantafx.sampler.page.ExampleBox; @@ -47,18 +47,18 @@ public final class CalendarPage extends OutlinePage { within a popup window.""" ); addSection("Usage", usageExample()); - addSection("No past dates", noPastDatesExample()); - addSection("User slots", clockExample()); + addSection("No Past Dates", noPastDatesExample()); + addSection("User Slots", clockExample()); addSection("Style", styleExample()); } private ExampleBox usageExample() { //snippet_1:start - var dp = new InlineDatePicker(TODAY); - dp.setShowWeekNumbers(true); + var cal = new Calendar(TODAY); + cal.setShowWeekNumbers(true); //snippet_1:end - var box = new HBox(dp); + var box = new HBox(cal); var description = BBCodeParser.createFormattedText(""" In the default state, no date is selected. You can modify this behavior \ either by using the constructor or by utilizing the [font=monospace]setValue()[/font] \ @@ -78,11 +78,11 @@ public final class CalendarPage extends OutlinePage { } } - var dp = new InlineDatePicker(TODAY); - dp.setDayCellFactory(c -> new FutureDateCell()); + var cal = new Calendar(TODAY); + cal.setDayCellFactory(c -> new FutureDateCell()); //snippet_2:end - var box = new HBox(dp); + var box = new HBox(cal); var description = BBCodeParser.createFormattedText(""" This example demonstrates how you can disable past dates in the [i]Calendar[/i].""" ); @@ -131,12 +131,12 @@ public final class CalendarPage extends OutlinePage { } } - var dp = new InlineDatePicker(TODAY); - dp.setTopNode(new Clock()); - dp.setShowWeekNumbers(true); + var cal = new Calendar(TODAY); + cal.setTopNode(new Clock()); + cal.setShowWeekNumbers(true); //snippet_3:end - var box = new HBox(dp); + var box = new HBox(cal); var description = BBCodeParser.createFormattedText(""" The [i]Calendar[/i] comes equipped with two slots (top and bottom) where \ users can place their own content. For example, you can use these slots to \ @@ -154,16 +154,16 @@ public final class CalendarPage extends OutlinePage { -color-date-month-year-fg: -color-fg-emphasis; }"""; //snippet_4:start - var dp = new InlineDatePicker(TODAY); - dp.setShowWeekNumbers(true); + var cal = new Calendar(TODAY); + cal.setShowWeekNumbers(true); // -color-date-border: -color-accent-emphasis; // -color-date-month-year-bg: -color-accent-emphasis; // -color-date-month-year-fg: -color-fg-emphasis; - dp.getStylesheets().add(Styles.toDataURI(dataClass)); + cal.getStylesheets().add(Styles.toDataURI(dataClass)); //snippet_4:end - var box = new HBox(dp); + var box = new HBox(cal); var description = BBCodeParser.createFormattedText(""" You can alter the style of the [i]Calendar[/i] by using looked-up color variables.""" ); diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/PopoverPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/PopoverPage.java index b0d0832..372a52b 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/PopoverPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/PopoverPage.java @@ -2,7 +2,7 @@ package atlantafx.sampler.page.components; -import atlantafx.base.controls.InlineDatePicker; +import atlantafx.base.controls.Calendar; import atlantafx.base.controls.Popover; import atlantafx.base.controls.Popover.ArrowLocation; import atlantafx.base.theme.Styles; @@ -77,20 +77,20 @@ public final class PopoverPage extends OutlinePage { link1.setOnAction(e -> pop1.show(link1)); // ~ - var datePicker = new InlineDatePicker(); - datePicker.setValue(LocalDate.now(ZoneId.systemDefault())); + var cal = new Calendar(); + cal.setValue(LocalDate.now(ZoneId.systemDefault())); // -color-date-border: transparent; // -color-date-bg: transparent; // -color-date-day-bg: transparent; // -color-date-month-year-bg: transparent; // -color-date-day-bg-hover: -color-bg-subtle; - datePicker.getStylesheets().add(Styles.toDataURI(dataClass)); + cal.getStylesheets().add(Styles.toDataURI(dataClass)); - var pop2 = new Popover(datePicker); + var pop2 = new Popover(cal); pop2.setHeaderAlwaysVisible(false); pop2.setDetachable(true); - var link2 = new Hyperlink("DatePicker"); + var link2 = new Hyperlink("Calendar"); link2.setOnAction(e -> pop2.show(link2)); //snippet_1:end diff --git a/sampler/src/main/resources/atlantafx/sampler/assets/fxml/blueprints/calendar.fxml b/sampler/src/main/resources/atlantafx/sampler/assets/fxml/blueprints/calendar.fxml index 9164086..8f888de 100644 --- a/sampler/src/main/resources/atlantafx/sampler/assets/fxml/blueprints/calendar.fxml +++ b/sampler/src/main/resources/atlantafx/sampler/assets/fxml/blueprints/calendar.fxml @@ -1,6 +1,6 @@ - + @@ -57,7 +57,7 @@ - +