Rename InlineDatePicker to Calendar
This commit is contained in:
parent
b7a753c8f9
commit
0a9564ab14
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Breaking changes
|
||||||
|
|
||||||
|
* The `InlineDatePicker` control renamed to `Calendar`.
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
- (Base) New `DeckPane` component with swipe and slide transition support.
|
- (Base) New `DeckPane` component with swipe and slide transition support.
|
||||||
|
@ -68,7 +68,7 @@ import javafx.util.Callback;
|
|||||||
* provided in the {@link java.time.chrono.Chronology} API to get or set the corresponding
|
* provided in the {@link java.time.chrono.Chronology} API to get or set the corresponding
|
||||||
* {@link java.time.chrono.ChronoLocalDate} value.
|
* {@link java.time.chrono.ChronoLocalDate} value.
|
||||||
*/
|
*/
|
||||||
public class InlineDatePicker extends Control {
|
public class Calendar extends Control {
|
||||||
|
|
||||||
protected LocalDate lastValidDate = null;
|
protected LocalDate lastValidDate = null;
|
||||||
protected Chronology lastValidChronology = IsoChronology.INSTANCE;
|
protected Chronology lastValidChronology = IsoChronology.INSTANCE;
|
||||||
@ -76,7 +76,7 @@ public class InlineDatePicker extends Control {
|
|||||||
/**
|
/**
|
||||||
* Creates a default DatePicker instance with a <code>null</code> date value set.
|
* Creates a default DatePicker instance with a <code>null</code> date value set.
|
||||||
*/
|
*/
|
||||||
public InlineDatePicker() {
|
public Calendar() {
|
||||||
this(null);
|
this(null);
|
||||||
|
|
||||||
valueProperty().addListener(obs -> {
|
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.
|
* @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);
|
setValue(localDate);
|
||||||
getStyleClass().add(DEFAULT_STYLE_CLASS);
|
getStyleClass().add(DEFAULT_STYLE_CLASS);
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ public class InlineDatePicker extends Control {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Skin<?> createDefaultSkin() {
|
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
|
* 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.
|
* Refer to {@link DateCell} and {@link Cell} for more information on cell factories.
|
||||||
*/
|
*/
|
||||||
private ObjectProperty<Callback<InlineDatePicker, DateCell>> dayCellFactory;
|
private ObjectProperty<Callback<Calendar, DateCell>> dayCellFactory;
|
||||||
|
|
||||||
public final void setDayCellFactory(Callback<InlineDatePicker, DateCell> value) {
|
public final void setDayCellFactory(Callback<Calendar, DateCell> value) {
|
||||||
dayCellFactoryProperty().set(value);
|
dayCellFactoryProperty().set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Callback<InlineDatePicker, DateCell> getDayCellFactory() {
|
public final Callback<Calendar, DateCell> getDayCellFactory() {
|
||||||
return (dayCellFactory != null) ? dayCellFactory.get() : null;
|
return (dayCellFactory != null) ? dayCellFactory.get() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ObjectProperty<Callback<InlineDatePicker, DateCell>> dayCellFactoryProperty() {
|
public final ObjectProperty<Callback<Calendar, DateCell>> dayCellFactoryProperty() {
|
||||||
if (dayCellFactory == null) {
|
if (dayCellFactory == null) {
|
||||||
dayCellFactory = new SimpleObjectProperty<>(this, "dayCellFactory");
|
dayCellFactory = new SimpleObjectProperty<>(this, "dayCellFactory");
|
||||||
}
|
}
|
||||||
@ -210,13 +210,13 @@ public class InlineDatePicker extends Control {
|
|||||||
if (showWeekNumbers == null) {
|
if (showWeekNumbers == null) {
|
||||||
showWeekNumbers = new StyleableBooleanProperty(false) {
|
showWeekNumbers = new StyleableBooleanProperty(false) {
|
||||||
@Override
|
@Override
|
||||||
public CssMetaData<InlineDatePicker, Boolean> getCssMetaData() {
|
public CssMetaData<Calendar, Boolean> getCssMetaData() {
|
||||||
return StyleableProperties.SHOW_WEEK_NUMBERS;
|
return StyleableProperties.SHOW_WEEK_NUMBERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getBean() {
|
public Object getBean() {
|
||||||
return InlineDatePicker.this;
|
return Calendar.this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -270,22 +270,22 @@ public class InlineDatePicker extends Control {
|
|||||||
// Stylesheet Handling //
|
// 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 class StyleableProperties {
|
||||||
|
|
||||||
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES;
|
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES;
|
||||||
|
|
||||||
private static final CssMetaData<InlineDatePicker, Boolean> SHOW_WEEK_NUMBERS =
|
private static final CssMetaData<Calendar, Boolean> SHOW_WEEK_NUMBERS =
|
||||||
new CssMetaData<>("-fx-show-week-numbers", BooleanConverter.getInstance(), false) {
|
new CssMetaData<>("-fx-show-week-numbers", BooleanConverter.getInstance(), false) {
|
||||||
@Override
|
@Override
|
||||||
public boolean isSettable(InlineDatePicker n) {
|
public boolean isSettable(Calendar n) {
|
||||||
return n.showWeekNumbers == null || !n.showWeekNumbers.isBound();
|
return n.showWeekNumbers == null || !n.showWeekNumbers.isBound();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("RedundantCast")
|
@SuppressWarnings("RedundantCast")
|
||||||
public StyleableProperty<Boolean> getStyleableProperty(InlineDatePicker n) {
|
public StyleableProperty<Boolean> getStyleableProperty(Calendar n) {
|
||||||
return (StyleableProperty<Boolean>) (WritableValue<Boolean>) n.showWeekNumbersProperty();
|
return (StyleableProperty<Boolean>) (WritableValue<Boolean>) n.showWeekNumbersProperty();
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -12,9 +12,9 @@ import java.time.ZoneId;
|
|||||||
import javafx.scene.input.KeyEvent;
|
import javafx.scene.input.KeyEvent;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
|
|
||||||
public class InlineDatePickerBehavior extends BehaviorBase<InlineDatePicker, InlineDatePickerSkin> {
|
public class CalendarBehavior extends BehaviorBase<Calendar, CalendarSkin> {
|
||||||
|
|
||||||
public InlineDatePickerBehavior(InlineDatePicker control, InlineDatePickerSkin skin) {
|
public CalendarBehavior(Calendar control, CalendarSkin skin) {
|
||||||
super(control, skin);
|
super(control, skin);
|
||||||
}
|
}
|
||||||
|
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
package atlantafx.base.controls;
|
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.DAY_OF_WEEK;
|
||||||
import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
|
import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
|
||||||
import static java.time.temporal.ChronoUnit.DAYS;
|
import static java.time.temporal.ChronoUnit.DAYS;
|
||||||
@ -73,7 +73,7 @@ import javafx.scene.layout.StackPane;
|
|||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.util.Callback;
|
import javafx.util.Callback;
|
||||||
|
|
||||||
public class InlineDatePickerSkin extends BehaviorSkinBase<InlineDatePicker, InlineDatePickerBehavior> {
|
public class CalendarSkin extends BehaviorSkinBase<Calendar, CalendarBehavior> {
|
||||||
|
|
||||||
// formatters
|
// formatters
|
||||||
final DateTimeFormatter yearFormatter = DateTimeFormatter.ofPattern("y");
|
final DateTimeFormatter yearFormatter = DateTimeFormatter.ofPattern("y");
|
||||||
@ -113,7 +113,7 @@ public class InlineDatePickerSkin extends BehaviorSkinBase<InlineDatePicker, Inl
|
|||||||
return firstDayOfMonth.get();
|
return firstDayOfMonth.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public InlineDatePickerSkin(InlineDatePicker datePicker) {
|
public CalendarSkin(Calendar datePicker) {
|
||||||
super(datePicker);
|
super(datePicker);
|
||||||
|
|
||||||
createUI();
|
createUI();
|
||||||
@ -158,8 +158,8 @@ public class InlineDatePickerSkin extends BehaviorSkinBase<InlineDatePicker, Inl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InlineDatePickerBehavior createDefaultBehavior() {
|
public CalendarBehavior createDefaultBehavior() {
|
||||||
return new InlineDatePickerBehavior(getControl(), this);
|
return new CalendarBehavior(getControl(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Locale getLocale() {
|
public Locale getLocale() {
|
||||||
@ -236,7 +236,7 @@ public class InlineDatePickerSkin extends BehaviorSkinBase<InlineDatePicker, Inl
|
|||||||
updateGrid();
|
updateGrid();
|
||||||
|
|
||||||
// preserve default class name for compatibility reasons
|
// preserve default class name for compatibility reasons
|
||||||
rootPane.getStyleClass().addAll("date-picker-popup", "inline-date-picker");
|
rootPane.getStyleClass().addAll("date-picker-popup", "calendar");
|
||||||
rootPane.getChildren().add(calendarGrid);
|
rootPane.getChildren().add(calendarGrid);
|
||||||
|
|
||||||
if (getControl().getBottomNode() != null) {
|
if (getControl().getBottomNode() != null) {
|
||||||
@ -576,7 +576,7 @@ public class InlineDatePickerSkin extends BehaviorSkinBase<InlineDatePicker, Inl
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected DateCell createDayCell() {
|
protected DateCell createDayCell() {
|
||||||
Callback<InlineDatePicker, DateCell> factory = getControl().getDayCellFactory();
|
Callback<Calendar, DateCell> factory = getControl().getDayCellFactory();
|
||||||
return Objects.requireNonNullElseGet(
|
return Objects.requireNonNullElseGet(
|
||||||
factory != null ? factory.call(getControl()) : null,
|
factory != null ? factory.call(getControl()) : null,
|
||||||
DateCell::new
|
DateCell::new
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
package atlantafx.sampler.page.components;
|
package atlantafx.sampler.page.components;
|
||||||
|
|
||||||
import atlantafx.base.controls.InlineDatePicker;
|
import atlantafx.base.controls.Calendar;
|
||||||
import atlantafx.base.theme.Styles;
|
import atlantafx.base.theme.Styles;
|
||||||
import atlantafx.base.util.BBCodeParser;
|
import atlantafx.base.util.BBCodeParser;
|
||||||
import atlantafx.sampler.page.ExampleBox;
|
import atlantafx.sampler.page.ExampleBox;
|
||||||
@ -47,18 +47,18 @@ public final class CalendarPage extends OutlinePage {
|
|||||||
within a popup window."""
|
within a popup window."""
|
||||||
);
|
);
|
||||||
addSection("Usage", usageExample());
|
addSection("Usage", usageExample());
|
||||||
addSection("No past dates", noPastDatesExample());
|
addSection("No Past Dates", noPastDatesExample());
|
||||||
addSection("User slots", clockExample());
|
addSection("User Slots", clockExample());
|
||||||
addSection("Style", styleExample());
|
addSection("Style", styleExample());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExampleBox usageExample() {
|
private ExampleBox usageExample() {
|
||||||
//snippet_1:start
|
//snippet_1:start
|
||||||
var dp = new InlineDatePicker(TODAY);
|
var cal = new Calendar(TODAY);
|
||||||
dp.setShowWeekNumbers(true);
|
cal.setShowWeekNumbers(true);
|
||||||
//snippet_1:end
|
//snippet_1:end
|
||||||
|
|
||||||
var box = new HBox(dp);
|
var box = new HBox(cal);
|
||||||
var description = BBCodeParser.createFormattedText("""
|
var description = BBCodeParser.createFormattedText("""
|
||||||
In the default state, no date is selected. You can modify this behavior \
|
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] \
|
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);
|
var cal = new Calendar(TODAY);
|
||||||
dp.setDayCellFactory(c -> new FutureDateCell());
|
cal.setDayCellFactory(c -> new FutureDateCell());
|
||||||
//snippet_2:end
|
//snippet_2:end
|
||||||
|
|
||||||
var box = new HBox(dp);
|
var box = new HBox(cal);
|
||||||
var description = BBCodeParser.createFormattedText("""
|
var description = BBCodeParser.createFormattedText("""
|
||||||
This example demonstrates how you can disable past dates in the [i]Calendar[/i]."""
|
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);
|
var cal = new Calendar(TODAY);
|
||||||
dp.setTopNode(new Clock());
|
cal.setTopNode(new Clock());
|
||||||
dp.setShowWeekNumbers(true);
|
cal.setShowWeekNumbers(true);
|
||||||
//snippet_3:end
|
//snippet_3:end
|
||||||
|
|
||||||
var box = new HBox(dp);
|
var box = new HBox(cal);
|
||||||
var description = BBCodeParser.createFormattedText("""
|
var description = BBCodeParser.createFormattedText("""
|
||||||
The [i]Calendar[/i] comes equipped with two slots (top and bottom) where \
|
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 \
|
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;
|
-color-date-month-year-fg: -color-fg-emphasis;
|
||||||
}""";
|
}""";
|
||||||
//snippet_4:start
|
//snippet_4:start
|
||||||
var dp = new InlineDatePicker(TODAY);
|
var cal = new Calendar(TODAY);
|
||||||
dp.setShowWeekNumbers(true);
|
cal.setShowWeekNumbers(true);
|
||||||
|
|
||||||
// -color-date-border: -color-accent-emphasis;
|
// -color-date-border: -color-accent-emphasis;
|
||||||
// -color-date-month-year-bg: -color-accent-emphasis;
|
// -color-date-month-year-bg: -color-accent-emphasis;
|
||||||
// -color-date-month-year-fg: -color-fg-emphasis;
|
// -color-date-month-year-fg: -color-fg-emphasis;
|
||||||
dp.getStylesheets().add(Styles.toDataURI(dataClass));
|
cal.getStylesheets().add(Styles.toDataURI(dataClass));
|
||||||
//snippet_4:end
|
//snippet_4:end
|
||||||
|
|
||||||
var box = new HBox(dp);
|
var box = new HBox(cal);
|
||||||
var description = BBCodeParser.createFormattedText("""
|
var description = BBCodeParser.createFormattedText("""
|
||||||
You can alter the style of the [i]Calendar[/i] by using looked-up color variables."""
|
You can alter the style of the [i]Calendar[/i] by using looked-up color variables."""
|
||||||
);
|
);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
package atlantafx.sampler.page.components;
|
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;
|
||||||
import atlantafx.base.controls.Popover.ArrowLocation;
|
import atlantafx.base.controls.Popover.ArrowLocation;
|
||||||
import atlantafx.base.theme.Styles;
|
import atlantafx.base.theme.Styles;
|
||||||
@ -77,20 +77,20 @@ public final class PopoverPage extends OutlinePage {
|
|||||||
link1.setOnAction(e -> pop1.show(link1));
|
link1.setOnAction(e -> pop1.show(link1));
|
||||||
|
|
||||||
// ~
|
// ~
|
||||||
var datePicker = new InlineDatePicker();
|
var cal = new Calendar();
|
||||||
datePicker.setValue(LocalDate.now(ZoneId.systemDefault()));
|
cal.setValue(LocalDate.now(ZoneId.systemDefault()));
|
||||||
// -color-date-border: transparent;
|
// -color-date-border: transparent;
|
||||||
// -color-date-bg: transparent;
|
// -color-date-bg: transparent;
|
||||||
// -color-date-day-bg: transparent;
|
// -color-date-day-bg: transparent;
|
||||||
// -color-date-month-year-bg: transparent;
|
// -color-date-month-year-bg: transparent;
|
||||||
// -color-date-day-bg-hover: -color-bg-subtle;
|
// -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.setHeaderAlwaysVisible(false);
|
||||||
pop2.setDetachable(true);
|
pop2.setDetachable(true);
|
||||||
|
|
||||||
var link2 = new Hyperlink("DatePicker");
|
var link2 = new Hyperlink("Calendar");
|
||||||
link2.setOnAction(e -> pop2.show(link2));
|
link2.setOnAction(e -> pop2.show(link2));
|
||||||
//snippet_1:end
|
//snippet_1:end
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import atlantafx.base.controls.InlineDatePicker?>
|
<?import atlantafx.base.controls.Calendar?>
|
||||||
<?import java.lang.String?>
|
<?import java.lang.String?>
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.Button?>
|
||||||
@ -57,7 +57,7 @@
|
|||||||
<Separator orientation="VERTICAL" prefHeight="200.0" styleClass="large" />
|
<Separator orientation="VERTICAL" prefHeight="200.0" styleClass="large" />
|
||||||
<VBox alignment="TOP_CENTER" spacing="10.0">
|
<VBox alignment="TOP_CENTER" spacing="10.0">
|
||||||
<children>
|
<children>
|
||||||
<InlineDatePicker prefWidth="400.0" showWeekNumbers="true" VBox.vgrow="NEVER" />
|
<Calendar prefWidth="400.0" showWeekNumbers="true" VBox.vgrow="NEVER" />
|
||||||
<Button contentDisplay="GRAPHIC_ONLY" mnemonicParsing="false" styleClass="flat">
|
<Button contentDisplay="GRAPHIC_ONLY" mnemonicParsing="false" styleClass="flat">
|
||||||
<graphic>
|
<graphic>
|
||||||
<Label maxWidth="1.7976931348623157E308" styleClass="danger" text="Remove due date" />
|
<Label maxWidth="1.7976931348623157E308" styleClass="danger" text="Remove due date" />
|
||||||
|
@ -197,7 +197,7 @@ $chrono-cell-padding: 0.083333em $cell-padding-x 0.083333em 0.333333em !default;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.inline-date-picker {
|
.calendar {
|
||||||
-fx-effect: none;
|
-fx-effect: none;
|
||||||
|
|
||||||
>.top-node,
|
>.top-node,
|
||||||
|
Loading…
Reference in New Issue
Block a user