JFXtras / jfxtras

A supporting library for JavaFX, containing helper classes, extended layouts, controls and other interesting widgets.
http://jfxtras.org
Other
599 stars 123 forks source link

allow constrained date ranges on date/time pickers #7

Closed millmanorama closed 9 years ago

millmanorama commented 10 years ago

It would be great if there was a way to constrain the available date/times to a within a range, so the user could not pick a date/time outside that range.

tbee commented 10 years ago

CalendarPicker has a disabledCalendars property. You can register a callback in the calendarRangeCallbackProperty and set the disabledCalendars accordingly.

millmanorama commented 10 years ago

that you for the quick reply. I am using a LocalDateTimeTextField, is there a corresponding feature for it?

On Mon, May 5, 2014 at 11:29 AM, Tom Eugelink notifications@github.comwrote:

CalendarPicker has a disabledCalendars property. You can register a callback in the calendarRangeCallbackProperty and set the disabledCalendars accordingly.

— Reply to this email directly or view it on GitHubhttps://github.com/JFXtras/jfxtras/issues/7#issuecomment-42200261 .

Jonathan Millman www.jmillman.com

tbee commented 10 years ago

There should be (because I reuse CalendarPicker everywhere) but I see the property is not forwarded. So that would need a small extension.

tbee commented 10 years ago

I've created a first implementation and it works. But because it's JFXtras and not JFXtras-labs I need to roll it out to all components (Calendar, LocalDate, LocalDateTime) with tests and samples. It will take some more work.

tbee commented 10 years ago

The latest 8.0-r2-SNAPSHOT should have the code now

millmanorama commented 10 years ago

thanks, for working on this so quickly. I will take look soon.

millmanorama commented 10 years ago

I see the callback, but I am a little confused about what to do with it. Could you post a short example?

tbee commented 10 years ago

Upon a range change, you can modify the disabled calendar/date property to hold the appropriate values for the active range.

Tom

On 2014-6-13 17:57, jonathan millman wrote:

I see the callback, but I am a little confused about what to do with it. Could you post a short example?

— Reply to this email directly or view it on GitHub https://github.com/JFXtras/jfxtras/issues/7#issuecomment-46028418.

millmanorama commented 10 years ago

This does not seem like a viable way to achieve my goal of not allowing selection outside a range. If I have to add every possible disabled LocalDateTime to a list i will have to generate thousands and thousands of them, one for every possible time (at least to the minute...). It seems better to provide a validation callback and test potential LocalDateTimes as needed.

tbee commented 10 years ago

Hmmm, disabled date does not work on time level.

How do you see that? While dragging the slider you cannot skip values. So once a value is selected, it gets validated and if disapproved the old value is set?

Tom

On 2014-6-13 18:51, jonathan millman wrote:

This does not seem like a viable way to achieve my goal of not allowing selection outside a range. If I have to add every possible disabled LocalDateTime to a list i will have to generate thousands and thousands of them, one for every possible time (at least to the minute...). It seems better to provide a validation callback and test potential LocalDateTimes as needed.

— Reply to this email directly or view it on GitHub https://github.com/JFXtras/jfxtras/issues/7#issuecomment-46034142.

millmanorama commented 10 years ago

yes. or in my use case, since validation is simply 'is it within valid range?', the end point of the range could be selected.

tbee commented 10 years ago

I'll give it some thought. I see some problems but maybe that is just me :-)

On 2014-6-13 19:18, jonathan millman wrote:

yes. or in my use case, since validation is simply 'is it within valid range?', the end point of the range could be selected.

— Reply to this email directly or view it on GitHub https://github.com/JFXtras/jfxtras/issues/7#issuecomment-46036902.

millmanorama commented 10 years ago

well, you know much more about how these controls work, And I mostly just care about my use case ;)

Thanks for all your help.

PS. If it makes it any easier (it might make it harder!), What I REALLY want is to not even show the date/times out side the range, so for example if the range was march 2000 - jan 2001, the user would never even be able to show the date/times in feb 2000

tbee commented 10 years ago

Well, that all is not that hard to add, it seems, at least on day level. And sounds like a fair use case. The advantage of open source is that I can switch much quicker than the official controls ;-)

Tom

On 2014-6-13 19:40, jonathan millman wrote:

well, you know much more about how these controls work, And I mostly just care about my use case ;)

Thanks for all your help.

PS. If it makes it any easier (it might make it harder!), What I REALLY want is to not even show the date/times out side the range, so for example if the range was march 2000 - jan 2001, the user would never even be able to show the date/times in feb 2000

— Reply to this email directly or view it on GitHub https://github.com/JFXtras/jfxtras/issues/7#issuecomment-46039259.

tbee commented 10 years ago

Ok. I've added a valueValidationCallback to the Calendar versions of the pickers. Not the textfield or the JSR-310 versions. Can you give them a test before I roll this out further (that is always a lot of repetitive work)?

tbee commented 9 years ago

No feedback in a long time. Closing.