setting selection model on CalendarViewer

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

setting selection model on CalendarViewer

Postby leeuwen » Tue Nov 17, 2009 8:02 am

Dear all,

Of course this is purely speculative, but it seems to me that the CalendarViewer creates a DefaultDateSelectionModel in its constructor. It seems that the following things happen to this default selection model:
- This default selection model gets a DateSelectionListener from the CalendarViewer.
- This default selection model is given to all DateChooserPanels in createDateChooserPanel

It seems that when changing the date selection model using CalendarViewer#setSelectionModel, that these two steps are not done for the new model.

Also there is no way to give a selection model to the contructor (this is possible for a DateModel though).

Now my question:
If I have implemented my own DateSelectionModel, how can I then make the CalendarViewer use it?

Currently I can only think of extending the CalendarViewer and overwriting this:
Code: Select all
  @Override
  public void setSelectionModel(final DateSelectionModel dateSelectionModel)
  {
    super.setSelectionModel(dateSelectionModel);
    // we need our superclass to respond to changes in the selection model
    dateSelectionModel.addDateSelectionListener(new DateSelectionListener()
    {
      @Override
      public void valueChanged(DateSelectionEvent dateselectionevent)
      {
        try
        {
          // private method a() seems to process the update
          final Method respondToDateSelectionEventMethod = super.getClass() //
                   .getDeclaredMethod("a", //
                            new Class[]
                            { DateSelectionModel.class });
          respondToDateSelectionEventMethod.setAccessible(true);
          respondToDateSelectionEventMethod.invoke(EODCalendarViewer.this, //
                   new Object[]
                   { dateSelectionModel });
        } catch (NoSuchMethodException e)
        {
          // method not public so we can expect such exception when switching to newer version
          // of Jide
        } catch (IllegalAccessException e)
        {
          // method not public API so what can we do?..
        } catch (InvocationTargetException e)
        {
          // exceptions in Jide code we can only ignore
        } catch (IllegalArgumentException e)
        {
          // should not happen in this case
        }
      }
    });
    // all date chooser panels got the old selection model when created
    for (DateChooserPanel dateChooserPanel : getDateChooserPanels())
    {
      dateChooserPanel.setSelectionModel(dateSelectionModel);
    }
  }
but this seems a 'bit of a hack' to me. Is there a better way of doing this?

Many thanks for reading. I hope you can help me through this.
Cheers,
Paul
leeuwen
 
Posts: 7
Joined: Thu Oct 29, 2009 7:44 am

Re: setting selection model on CalendarViewer

Postby leeuwen » Tue Nov 17, 2009 8:41 am

Another problem:
after some tiny modifications I got the above hack to actually work: changes in the selection model are correctly displayed on the CalendarViewer. But when I try to make selections on the CalendarViewer (or actually the underlying DateChooserPanel) then none of the methods setSelectedDate(Date), setSelectedDates(Date[]), setSelectionInterval(Date, Date), addSelectionInterval(Date, Date) or removeSelectionInterval(Date, Date) is being called.

The getSelectionMode() is being called though on my selection model (thus it is correctly set on the DateChooserPanels) and I had this method returning DateSelectionModel.MULTIPLE_INTERVAL_SELECTION (because I need to select non-successive multiple days in the end).

After changing this to returning DateSelectionModel.SINGLE_SELECTION the setSelectionInterval(Date, Date) is being called.

Could anybody explain what is happening when in DateSelectionModel.MULTIPLE_INTERVAL_SELECTION mode?

Again, any help is very much appreciated, it would safe my day :-)
Thanks for reading again!

Regards,
Paul
leeuwen
 
Posts: 7
Joined: Thu Oct 29, 2009 7:44 am

Re: setting selection model on CalendarViewer

Postby leeuwen » Tue Nov 17, 2009 8:43 am

( PS (2) : this is all on Jide version 2.7.5 off course )
leeuwen
 
Posts: 7
Joined: Thu Oct 29, 2009 7:44 am

Re: setting selection model on CalendarViewer

Postby JIDE Support » Tue Nov 17, 2009 9:53 am

We would consider add the support for selection model change in CalendarViewer in 2.8.1. Please let us know if you would like to see this bug fix in 2.7.6 either.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: setting selection model on CalendarViewer

Postby leeuwen » Tue Nov 17, 2009 10:45 am

Hi, thank you for responding!

Also thank you for considering fixing the CalendarViewer#setSelectionModel method.
For me the most pressing: could you maybe look into the problem with the MULTIPLE_INTERVAL_SELECTION mode? This issue is more pressing to me than the setSelectionModel, since (though dirty) at least I have a workaround for that.

Our product is now in the phase of stabilizing and trying to get ready for release in 1 or max 2 weeks. We use a quite simple version of the CalendarViewer, disabling all navigation options (I think my colleague already got good help from you guys trying to do that). So we only use this CalendarViewer to select days.

So we are on quite a tight schedule, and any solution also needs to be on a non-snapshot version.
- could you please help me with the MULTIPLE_INTERVAL_SELECTION issue?
- would it be possible to get any fixes within some days, and how it the time line for the next Jide release?

Thank you for any help you could give!
leeuwen
 
Posts: 7
Joined: Thu Oct 29, 2009 7:44 am

Re: setting selection model on CalendarViewer

Postby JIDE Support » Tue Nov 17, 2009 11:50 am

I tried it but didn't notice the issue. Will have this fix in 2.7.6 as well. The release will be ready within this week. We would send you a pre-release for you to test the MULTIPLE_SELECTION_INTERVAL issue before that.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: setting selection model on CalendarViewer

Postby leeuwen » Tue Nov 17, 2009 12:31 pm

Thank you for your answers. I will continue to try to find out why this MULTIPLE_SELECTION_INTERVAL is not working in my situation / with the new selection model. When a pre-release is available, then I would be happy to try it as quick as possible. Many thanks, I will await your pre-release.
leeuwen
 
Posts: 7
Joined: Thu Oct 29, 2009 7:44 am

Re: setting selection model on CalendarViewer

Postby JIDE Support » Tue Nov 17, 2009 6:00 pm

JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: setting selection model on CalendarViewer

Postby chamberlain » Wed Nov 18, 2009 1:07 am

Thanks for the pre-release version, we will test this out and report back.

Steve Chamberlain
chamberlain
 
Posts: 131
Joined: Fri Jul 13, 2007 2:43 am

Re: setting selection model on CalendarViewer

Postby chamberlain » Wed Nov 18, 2009 1:30 am

Ok, I tried to download but got a "404 Wrong Page", page does not exist message. Could you reupload this file?

Regards,

Steve Chamberlain.
chamberlain
 
Posts: 131
Joined: Fri Jul 13, 2007 2:43 am

Re: setting selection model on CalendarViewer

Postby chamberlain » Wed Nov 18, 2009 2:37 am

It seems the problem is the full stop in your hyperlink, we removed this and it's downloading now.
chamberlain
 
Posts: 131
Joined: Fri Jul 13, 2007 2:43 am

Re: setting selection model on CalendarViewer

Postby chamberlain » Wed Nov 18, 2009 4:21 am

Ok, I have just tested with the 2.7.6 pre-release. It seems this release makes no difference to the selection behaviour; if we specify that our selection model mode is MULTIPLE_INTERVAL_SELECTION, neither addSelectionInternal or setSelectionInterval are called. Has this code changed in 2.7.6?
chamberlain
 
Posts: 131
Joined: Fri Jul 13, 2007 2:43 am

Re: setting selection model on CalendarViewer

Postby JIDE Support » Wed Nov 18, 2009 7:49 am

Would you please check if the selection model is configured to the underlying DateChooserPanel and the listener is installed correctly when you set your own selection model? If not, it's probably there is some issue when we build the release. If so, please share with us a test case to demonstrate the issue. I just tested and it worked just fine.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: setting selection model on CalendarViewer

Postby chamberlain » Thu Nov 19, 2009 4:11 am

Hi, I tracked down the multiple selection problem to a bug in our code, so this is now fixed. It was due to the fact that we were overriding the mouse listener methods declared in DateChooserPanel, but they did not call super. Most of these methods were IDE generated, so it was a simple matter of removing them.

However, we are a bit unclear about how the DateChooserPanel processes mouse events when the model is in different selection modes. More specifically, we are not sure why we had problems only in multiple interval selection mode and not in single selection mode. Are you using different listeners within DateChooserPanel to handle events for the different selection modes?
chamberlain
 
Posts: 131
Joined: Fri Jul 13, 2007 2:43 am

Re: setting selection model on CalendarViewer

Postby JIDE Support » Thu Nov 19, 2009 7:49 am

Good to know that. Different selection models use the same mouse listener although they do have different branch to handle the event.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: setting selection model on CalendarViewer

Postby JIDE Support » Fri Nov 20, 2009 6:26 pm

Just so you know, this is fixed in 2.7.6 release.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: setting selection model on CalendarViewer

Postby JIDE Support » Fri Dec 04, 2009 4:26 pm

Just so you know, this is also fixed in 2.8.1 release.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 72 guests