Home Forums FlexGantt DateLineModelListener

  • Author
    Posts
  • Brian
    Participant
    Post count: 21
    #12831 |

    I have a class that I have registered as a dateline listener, defines as:
    public class DatelineModelListener implements IDatelineModelListener {

    I am getting calls to public void datelineModelChanged(final DatelineModelEvent event) & the will change method. So far, so good. I have put all my logic in the above method and am ignoring the willChange method. The javadoc are a bit light here, but based on the function names, I think I am doing the right thing.

    But, when I change the horizon using the selector in the top right corner, I have a few concerns.
    1) I am getting multiple calls to the listener method; though I have only registered it once
    2) I don’t seem to have a way to know what the old time was to be sure that the new time is really a change. The operation required for a horizon change is expensive in our case. I considered the following
    2a) final ITimeSpan requestedTimeSpan = event.getRequestedVisibleTimeSpan(); this gives me null times for horizon changes drive from the UI, but I get dates when the change was caused through my code.
    2b) I was hoping to use something like this from AbstractTimeControlPanel, but don’t believe I have access to this data.
    final IDatelineModel< ?> oldModel = (IDatelineModel< ?>) evt.getOldValue();
    final IDatelineModel< ?> newModel = (IDatelineModel< ?>) evt.getNewValue();
    2c) I was hoping I might get the old horizon date and the new one from different calls, but that has not panned out. For example:
    final TimeGranularityDatelineModel sourceModel = (TimeGranularityDatelineModel) event.getSource();
    LOG.debug(“source model time span: {}”, sourceModel.getTimeSpan());
    vs
    ganttChart.getTimeline().getDateline().getTimeSpan();

    So, I have the plumbing roughly correct, but could use some pointers on how to get the old and new timelines or some other thoughts on how to approach the problem.
    Thanks.

  • Brian
    Participant
    Post count: 21
    #12835 |

    update to:
    2a) final ITimeSpan requestedTimeSpan = event.getRequestedVisibleTimeSpan(); this gives me null times for horizon changes drive from the UI, but I get dates when the change was caused through my code.

    I actually call setVisibleTimeSpan in my code, so I guess I understand why it is getting called with values in those cases, but not all cases.
    However, the crux of the problem still remains, I feel like the method gets called too many times and I dont see a way to compare the old & new time windows.

  • Brian
    Participant
    Post count: 21
    #12836 |

    Also, I see that this listener gets called for all sorts of things, like zooming in on the screen, in addition to just changes in the horizon. Is there a way to distinguish the different types of events from each other? I must be missing something here.

  • Brian
    Participant
    Post count: 21
    #12837 |

    OH, I see. The event has an ID, such as TIME_SPAN_CHANGED. That clears a lot of things up for me!

  • Dirk Lemmermann
    Keymaster
    Post count: 64
    #12838 |

    “That clears a lot of things up for me!” -> does this mean this topic can be closed?

  • Brian
    Participant
    Post count: 21
    #12858 |

    Yes, I got where I needed to be. thanks.

  • Dirk Lemmermann
    Keymaster
    Post count: 64
    #12859 |

    OK, glad to hear it.

You must be logged in to reply to this topic.