Rename InlineDatePicker to Calendar
This commit is contained in:
parent
b7a753c8f9
commit
0a9564ab14
@ -2,6 +2,10 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* The `InlineDatePicker` control renamed to `Calendar`.
|
||||
|
||||
### Features
|
||||
|
||||
- (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
|
||||
* {@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 <code>null</code> 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<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);
|
||||
}
|
||||
|
||||
public final Callback<InlineDatePicker, DateCell> getDayCellFactory() {
|
||||
public final Callback<Calendar, DateCell> getDayCellFactory() {
|
||||
return (dayCellFactory != null) ? dayCellFactory.get() : null;
|
||||
}
|
||||
|
||||
public final ObjectProperty<Callback<InlineDatePicker, DateCell>> dayCellFactoryProperty() {
|
||||
public final ObjectProperty<Callback<Calendar, DateCell>> 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<InlineDatePicker, Boolean> getCssMetaData() {
|
||||
public CssMetaData<Calendar, Boolean> 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<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) {
|
||||
@Override
|
||||
public boolean isSettable(InlineDatePicker n) {
|
||||
public boolean isSettable(Calendar n) {
|
||||
return n.showWeekNumbers == null || !n.showWeekNumbers.isBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("RedundantCast")
|
||||
public StyleableProperty<Boolean> getStyleableProperty(InlineDatePicker n) {
|
||||
public StyleableProperty<Boolean> getStyleableProperty(Calendar n) {
|
||||
return (StyleableProperty<Boolean>) (WritableValue<Boolean>) n.showWeekNumbersProperty();
|
||||
}
|
||||
};
|
@ -12,9 +12,9 @@ import java.time.ZoneId;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
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);
|
||||
}
|
||||
|
@ -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<InlineDatePicker, InlineDatePickerBehavior> {
|
||||
public class CalendarSkin extends BehaviorSkinBase<Calendar, CalendarBehavior> {
|
||||
|
||||
// formatters
|
||||
final DateTimeFormatter yearFormatter = DateTimeFormatter.ofPattern("y");
|
||||
@ -113,7 +113,7 @@ public class InlineDatePickerSkin extends BehaviorSkinBase<InlineDatePicker, Inl
|
||||
return firstDayOfMonth.get();
|
||||
}
|
||||
|
||||
public InlineDatePickerSkin(InlineDatePicker datePicker) {
|
||||
public CalendarSkin(Calendar datePicker) {
|
||||
super(datePicker);
|
||||
|
||||
createUI();
|
||||
@ -158,8 +158,8 @@ public class InlineDatePickerSkin extends BehaviorSkinBase<InlineDatePicker, Inl
|
||||
}
|
||||
|
||||
@Override
|
||||
public InlineDatePickerBehavior createDefaultBehavior() {
|
||||
return new InlineDatePickerBehavior(getControl(), this);
|
||||
public CalendarBehavior createDefaultBehavior() {
|
||||
return new CalendarBehavior(getControl(), this);
|
||||
}
|
||||
|
||||
public Locale getLocale() {
|
||||
@ -236,7 +236,7 @@ public class InlineDatePickerSkin extends BehaviorSkinBase<InlineDatePicker, Inl
|
||||
updateGrid();
|
||||
|
||||
// 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);
|
||||
|
||||
if (getControl().getBottomNode() != null) {
|
||||
@ -576,7 +576,7 @@ public class InlineDatePickerSkin extends BehaviorSkinBase<InlineDatePicker, Inl
|
||||
}
|
||||
|
||||
protected DateCell createDayCell() {
|
||||
Callback<InlineDatePicker, DateCell> factory = getControl().getDayCellFactory();
|
||||
Callback<Calendar, DateCell> factory = getControl().getDayCellFactory();
|
||||
return Objects.requireNonNullElseGet(
|
||||
factory != null ? factory.call(getControl()) : null,
|
||||
DateCell::new
|
@ -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."""
|
||||
);
|
||||
|
@ -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
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import atlantafx.base.controls.InlineDatePicker?>
|
||||
<?import atlantafx.base.controls.Calendar?>
|
||||
<?import java.lang.String?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
@ -57,7 +57,7 @@
|
||||
<Separator orientation="VERTICAL" prefHeight="200.0" styleClass="large" />
|
||||
<VBox alignment="TOP_CENTER" spacing="10.0">
|
||||
<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">
|
||||
<graphic>
|
||||
<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;
|
||||
|
||||
>.top-node,
|
||||
|
Loading…
Reference in New Issue
Block a user