Class CalendarableModel

java.lang.Object
org.eclipse.nebula.widgets.compositetable.timeeditor.CalendarableModel

public class CalendarableModel
extends java.lang.Object
Represents the model behind the calendar control. This model manages three concerns: 1) Setting/maintaining the visible range of days (startDate, numberOfDays) 2) Keeping the events for a particular day within the range of visible days 3) Keeping track of the number of columns required to display the events in a given day from the set of visible days.
Since:
3.2
  • Constructor Details

  • Method Details

    • getNumberOfColumnsWithinDay

      public int getNumberOfColumnsWithinDay​(int dayOffset)
      Parameters:
      dayOffset -
      Returns:
      the number of columns within the day or -1 if this has not been computed yet.
    • setEventLayout

      public void setEventLayout​(int dayOffset, CalendarableItem[][] eventLayout)
      Sets the eventLayout for a particular dayOffset
      Parameters:
      dayOffset -
      eventLayout -
    • getEventLayout

      public CalendarableItem[][] getEventLayout​(int dayOffset)
      Gets the eventLayout for a particular dayOffset
      Parameters:
      dayOffset -
      Returns:
      the eventLayout array for the specified day or null if none has been computed.
    • setTimeBreakdown

      public void setTimeBreakdown​(int numberOfDays, int numberOfDivisionsInHour)
      Parameters:
      numberOfDays -
      numberOfDivisionsInHour -
    • getNumberOfDays

      public int getNumberOfDays()
      Returns:
      The number of days to display
    • getNumberOfDivisionsInHour

      public int getNumberOfDivisionsInHour()
      Returns:
      Returns the numberOfDivisionsInHour.
    • setStartDate

      public java.util.List setStartDate​(java.util.Date startDate)
      Parameters:
      startDate - The starting date to display
      Returns:
      The obsolete Calendarable objects
    • getStartDate

      public java.util.Date getStartDate()
      Returns:
      The starting date to display
    • setEventCountProvider

      public void setEventCountProvider​(EventCountProvider eventCountProvider)
      Sets a strategy pattern object that can return the number of events to display on a particulr day.
      Parameters:
      eventCountProvider -
    • setEventContentProvider

      public void setEventContentProvider​(EventContentProvider eventContentProvider)
      Sets a strategy pattern object that can set the data for the actual events for a particular day.
      Parameters:
      eventContentProvider -
    • calculateDate

      public java.util.Date calculateDate​(java.util.Date startDate, int numberOfDaysFromStartDate)
      Returns the date that is the numberOfDaysFromStartDate.
      Parameters:
      startDate - The start date
      numberOfDaysFromStartDate -
      Returns:
      Date
    • refresh

      public java.util.List refresh​(java.util.Date date)
      Refresh the display for the specified Date. If Date isn't being displayed, this method ignores the request.
      Parameters:
      date - the date to refresh.
      Returns:
      List any Calendarables that were invalidated
    • getCalendarableItems

      public java.util.List getCalendarableItems​(int dayOffset)
      Return the events for a particular day offset.
      Parameters:
      dayOffset -
      Returns:
      A List of events.
    • computeNumberOfAllDayEventRows

      public int computeNumberOfAllDayEventRows()
      Method computeNumberOfAllDayEventRows.
      Returns:
      int representing the max number of events in all visible days.
    • computeStartHour

      public int computeStartHour()
      Method computeStartHour. Computes the start hour of the day for all days that are displayed. If no events are before the defaultStartHour, the defaultStartHour is returned. If any day in the model has an event beginning before defaultStartHour, the hour of the earliest event is used instead.
      Returns:
      int The start hour.
    • setDefaultStartHour

      public void setDefaultStartHour​(int defaultStartHour)
      Method setDefaultStartHour.
      Parameters:
      defaultStartHour - The first hour to be displayed by default.
    • getDefaultStartHour

      public int getDefaultStartHour()
      Method getDefaultStartHour
      Returns:
      int representing the first hour to be displayed by default.
    • getDay

      public int getDay​(CalendarableItem calendarable)
      Method getDay. Returns the day on which the specified Calendarable appers.
      Parameters:
      calendarable - The calendarable to find
      Returns:
      The day offset (0-based)
      Throws:
      java.lang.IllegalArgumentException - if Calendarable isn't found
    • computeHourFromRow

      public int computeHourFromRow​(int row)
      FIXME: Test me please
      Parameters:
      row - The row starting from the beginning of the day
      Returns:
      The hour portion of the time that this row represents
    • computeMinuteFromRow

      public int computeMinuteFromRow​(int row)
      FIXME: Test me please
      Parameters:
      row - The row starting from the beginning of the day
      Returns:
      The minute portion of the time that this row represents
    • getAllDayCalendarables

      public CalendarableItem[] getAllDayCalendarables​(int day)
      Parameters:
      day - The day to return all day Calendarables for
      Returns:
      All the all day Calendarables for the specified day, order maintained
    • findAllDayCalendarable

      public CalendarableItem findAllDayCalendarable​(int day, boolean forward, CalendarableItem selection)
      Parameters:
      day - The day to search
      forward - true if we're going forward; false if we're searching backward
      selection - The currently selected Calendarable or null if none
      Returns:
      The next Calendarable in the specified direction where result != selection; null if none
    • findTimedCalendarable

      public CalendarableItem findTimedCalendarable​(int day, int currentRow, int stopPosition, boolean forward, CalendarableItem selection)
      Parameters:
      day - The day to search
      currentRow - The first row to search
      stopPosition - The row to stop searching on or -1 to search to the first/last element
      forward - true if we're going forward; false if we're searching backward
      selection - The Calendarable associated with currentRow or null if none
      Returns:
      The next Calendarable in the specified direction where result != selection; null if none
    • findNextCalendarable

      public CalendarableItem findNextCalendarable​(int selectedDay, int selectedRow, CalendarableItem selection, boolean isAllDayEventRow)
      Parameters:
      selectedDay -
      selectedRow -
      selection -
      isAllDayEventRow -
      Returns:
    • findPreviousCalendarable

      public CalendarableItem findPreviousCalendarable​(int selectedDay, int selectedRow, CalendarableItem selection, boolean isAllDayEventRow)
      Parameters:
      selectedDay -
      selectedRow -
      selection -
      isAllDayEventRow -
      Returns: