Class MonthCalendar

  • All Implemented Interfaces:
    IEventEditor, org.eclipse.swt.graphics.Drawable

    public class MonthCalendar
    extends AbstractEventEditor
    implements IEventEditor
    An IEventEditor implementing a month calendar. This class is not intended to be subclassed.
    • Constructor Summary

      Constructors 
      Constructor Description
      MonthCalendar​(org.eclipse.swt.widgets.Composite parent, int style)
      Constructor DayEditor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addFocusListener​(org.eclipse.swt.events.FocusListener listener)
      Adds the listener to the collection of listeners who will be notified when the control gains or loses focus, by sending it one of the messages defined in the FocusListener interface.
      void addItemDeleteHandler​(CalendarableItemEventHandler deleteHandler)
      Adds the handler to the collection of handlers who will be notified when a CalendarableItem is deleted from the receiver, by sending it one of the messages defined in the CalendarableItemEventHandler abstract class.
      void addItemDisposeHandler​(CalendarableItemEventHandler itemDisposeHandler)
      Adds the handler to the collection of handler who will be notified when a CalendarableItem's control is disposed, by sending it one of the messages defined in the CalendarableItemEventHandler abstract class.
      void addItemEditHandler​(CalendarableItemEventHandler handler)
      Adds the handler to the collection of handlers who will be notified when a CalendarableItem is inserted in the receiver, by sending it one of the messages defined in the CalendarableItemInsertHandler abstract class.
      void addKeyListener​(org.eclipse.swt.events.KeyListener listener)
      Adds the listener to the collection of listeners who will be notified when keys are pressed and released on the system keyboard, by sending it one of the messages defined in the KeyListener interface.
      void addMouseListener​(org.eclipse.swt.events.MouseListener listener)  
      void addSelectionChangeListener​(CalendarableSelectionChangeListener l)
      Adds the listener to the collection of listeners who will be notified when the receiver's selection changes, by sending it one of the messages defined in the CalendarableSelectionChangeListener interface.
      private Week createWeek()
      This method initializes week
      private void createWeekHeader()
      This method initializes weekHeader
      private void createWeeksHolder()
      This method initializes composite
      boolean fireDelete​(CalendarableItem toDelete)
      Requests that the event editor delete the specified CalendarableItem's data.
      int getNumberOfDays()
      Method getNumberOfDays.
      int getNumberOfDivisionsInHour()
      Returns the numberOfDivisionsInHour.
      MonthCalendarSelectedDay getSelectedDay()
      Method getSelectedDay.
      java.util.Date getStartDate()
      Return the current start date for this event editor.
      private void initialize()  
      void refresh()
      Tells the IEventEditor to refresh all days in its display.
      void refresh​(java.util.Date date)
      Tells the IEventEditor to refresh its display for the specified date.
      private void refresh​(java.util.Date date, Day dayControl)  
      void removeFocusListener​(org.eclipse.swt.events.FocusListener listener)
      Removes the listener from the collection of listeners who will be notified when the control gains or loses focus.
      void removeItemDeleteHandler​(CalendarableItemEventHandler deleteHandler)
      Removes the handler from the collection of handlers who will be notified when a CalendarableItem is deleted from the receiver, by sending it one of the messages defined in the CalendarableItemEventHandler abstract class.
      void removeItemDisposeHandler​(CalendarableItemEventHandler itemDisposeHandler)
      Removes the handler from the collection of handlers who will be notified when a CalendarableItem is disposed, by sending it one of the messages defined in the CalendarableItemEventHandler abstract class.
      void removeItemEditHandler​(CalendarableItemEventHandler handler)
      Removes the handler from the collection of handlers who will be notified when a CalendarableItem is inserted into the receiver, by sending it one of the messages defined in the CalendarableItemInsertHandler abstract class.
      void removeKeyListener​(org.eclipse.swt.events.KeyListener listener)
      Removes the listener from the collection of listeners who will be notified when keys are pressed and released on the system keyboard.
      void removeMouseListener​(org.eclipse.swt.events.MouseListener listener)  
      void removeSelectionChangeListener​(CalendarableSelectionChangeListener l)
      Removes the listener from the collection of listeners who will be notified when the receiver's selection changes, by sending it one of the messages defined in the CalendarableSelectionChangeListener interface.
      void select​(java.util.Date newDate)  
      void setEventContentProvider​(EventContentProvider eventContentProvider)
      Sets the strategy pattern object that can set the properties of the event objects in order to display the data associated with the specified event.
      void setEventCountProvider​(EventCountProvider eventCountProvider)
      Set the strategy pattern object that can return how many events to display for specific periods of time.
      boolean setFocus()  
      void setStartDate​(java.util.Date startDate)
      Sets the start date for this MonthCalendar.
      void setTimeBreakdown​(int numberOfDays, int numberOfDivisionsInHour)
      Method setTimeBreakdown.
      • Methods inherited from class org.eclipse.swt.widgets.Composite

        changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setLayout, setLayoutDeferred, setTabList
      • Methods inherited from class org.eclipse.swt.widgets.Scrollable

        computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
      • Methods inherited from class org.eclipse.swt.widgets.Control

        addControlListener, addDragDetectListener, addGestureListener, addHelpListener, addMenuDetectListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isAutoScalable, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeGestureListener, removeHelpListener, removeMenuDetectListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
      • Methods inherited from class org.eclipse.swt.widgets.Widget

        addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • startDate

        private java.util.Date startDate
      • weeksHolder

        private org.eclipse.swt.widgets.Composite weeksHolder
      • weeks

        private Week[] weeks
      • focusListeners

        private java.util.List<org.eclipse.swt.events.FocusListener> focusListeners
      • lastSelectedDay

        private Day lastSelectedDay
      • dayFocusListener

        private org.eclipse.swt.events.FocusListener dayFocusListener
      • mouseListeners

        private java.util.List<org.eclipse.swt.events.MouseListener> mouseListeners
      • dayMouseListener

        private org.eclipse.swt.events.MouseListener dayMouseListener
      • keyListeners

        private java.util.List<org.eclipse.swt.events.KeyListener> keyListeners
      • dayKeyListener

        private org.eclipse.swt.events.KeyListener dayKeyListener
    • Constructor Detail

      • MonthCalendar

        public MonthCalendar​(org.eclipse.swt.widgets.Composite parent,
                             int style)
        Constructor DayEditor. Constructs a calendar control that can display events on one or more days.
        Parameters:
        parent -
        style - The same style bits as @see Composite
    • Method Detail

      • initialize

        private void initialize()
      • createWeekHeader

        private void createWeekHeader()
        This method initializes weekHeader
      • createWeeksHolder

        private void createWeeksHolder()
        This method initializes composite
      • createWeek

        private Week createWeek()
        This method initializes week
      • setStartDate

        public void setStartDate​(java.util.Date startDate)
        Sets the start date for this MonthCalendar.

        The date is set to the first day of the specified month and the time part of the Date object is set to midnight before storing. Calling getStartDate() will return this mutilated version instead of the original.

        Specified by:
        setStartDate in interface IEventEditor
        Parameters:
        startDate - The date representing what slice of time to visualize in the editor. null is not permitted. Passing null will result in undefined behavior.
        See Also:
        IEventEditor.setStartDate(java.util.Date)
      • getStartDate

        public java.util.Date getStartDate()
        Description copied from interface: IEventEditor
        Return the current start date for this event editor. This is the date that was set in setStartDate.
        Specified by:
        getStartDate in interface IEventEditor
        Returns:
        The start date, or null if no start date has been specified yet.
        See Also:
        IEventEditor.getStartDate()
      • refresh

        public void refresh​(java.util.Date date)
        Description copied from interface: IEventEditor
        Tells the IEventEditor to refresh its display for the specified date. If the specified date is not being displayed, the request will be ignored. If null is passed as the date, the entire display is refreshed.
        Specified by:
        refresh in interface IEventEditor
        Parameters:
        date - The date to refresh or null to refresh everything.
        See Also:
        IEventEditor.refresh(java.util.Date)
      • refresh

        private void refresh​(java.util.Date date,
                             Day dayControl)
      • setEventCountProvider

        public void setEventCountProvider​(EventCountProvider eventCountProvider)
        Description copied from interface: IEventEditor
        Set the strategy pattern object that can return how many events to display for specific periods of time.

        Note that having a separate event count provider and event content provider assumes that the implementer is single-threaded and that the count can't change between calling the count provider and the content provider.

        Specified by:
        setEventCountProvider in interface IEventEditor
        Parameters:
        eventCountProvider - The eventCountProvider to set.
      • setTimeBreakdown

        public void setTimeBreakdown​(int numberOfDays,
                                     int numberOfDivisionsInHour)
        Description copied from interface: IEventEditor
        Method setTimeBreakdown. Call this method exactly once after constructing the control in order to set the number of day columns to display.

        This method may be executed exactly once. Executing more than once will result in undefined behavior.

        This method is a hint. It may be ignored by specific implementations (ie: a month view).

        Specified by:
        setTimeBreakdown in interface IEventEditor
        Parameters:
        numberOfDays - The number of days to display.
        numberOfDivisionsInHour - 1 == one line per hour; 2 == every 1/2 hour; 4 = every 1/4 hour; etc...
        See Also:
        IEventEditor.setTimeBreakdown(int, int)
      • getSelectedDay

        public MonthCalendarSelectedDay getSelectedDay()
        Method getSelectedDay. Returns the currently-selected day.
        Returns:
        The current MonthCalendarSelection which represents the currently- selected day.
      • addFocusListener

        public void addFocusListener​(org.eclipse.swt.events.FocusListener listener)
        Adds the listener to the collection of listeners who will be notified when the control gains or loses focus, by sending it one of the messages defined in the FocusListener interface.

        In addition, e.data in the FocusEvent is the current MonthCalendarSelectedDay.

        Overrides:
        addFocusListener in class org.eclipse.swt.widgets.Control
        Parameters:
        listener - the listener which should be notified
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the listener is null
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        FocusListener, removeFocusListener(org.eclipse.swt.events.FocusListener), Control.addFocusListener(org.eclipse.swt.events.FocusListener)
      • removeFocusListener

        public void removeFocusListener​(org.eclipse.swt.events.FocusListener listener)
        Removes the listener from the collection of listeners who will be notified when the control gains or loses focus.

        In addition, e.data in the FocusEvent is the current MonthCalendarSelectedDay.

        Overrides:
        removeFocusListener in class org.eclipse.swt.widgets.Control
        Parameters:
        listener - the listener which should no longer be notified
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the listener is null
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        FocusListener, addFocusListener(org.eclipse.swt.events.FocusListener), Control.removeFocusListener(org.eclipse.swt.events.FocusListener)
      • addMouseListener

        public void addMouseListener​(org.eclipse.swt.events.MouseListener listener)
        Overrides:
        addMouseListener in class org.eclipse.swt.widgets.Control
        See Also:
        Control.addMouseListener(org.eclipse.swt.events.MouseListener)
      • removeMouseListener

        public void removeMouseListener​(org.eclipse.swt.events.MouseListener listener)
        Overrides:
        removeMouseListener in class org.eclipse.swt.widgets.Control
        See Also:
        Control.removeMouseListener(org.eclipse.swt.events.MouseListener)
      • addKeyListener

        public void addKeyListener​(org.eclipse.swt.events.KeyListener listener)
        Adds the listener to the collection of listeners who will be notified when keys are pressed and released on the system keyboard, by sending it one of the messages defined in the KeyListener interface.

        In addition to the usual KeyListener contract, MonthCalendar will honor e.doit and will not perform its usual key processing if any KeyListener sets e.doit to false.

        In addition to the usual KeyEvent fields, e.data is set to the current MonthCalendarSelection.

        Overrides:
        addKeyListener in class org.eclipse.swt.widgets.Control
        Parameters:
        listener - the listener which should be notified
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the listener is null
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        Control.addKeyListener(org.eclipse.swt.events.KeyListener)
      • removeKeyListener

        public void removeKeyListener​(org.eclipse.swt.events.KeyListener listener)
        Removes the listener from the collection of listeners who will be notified when keys are pressed and released on the system keyboard.
        Overrides:
        removeKeyListener in class org.eclipse.swt.widgets.Control
        Parameters:
        listener - the listener which should no longer be notified
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the listener is null
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        KeyListener, addKeyListener(org.eclipse.swt.events.KeyListener), Control.removeKeyListener(org.eclipse.swt.events.KeyListener)
      • setFocus

        public boolean setFocus()
        Overrides:
        setFocus in class org.eclipse.swt.widgets.Composite
        See Also:
        Composite.setFocus()
      • select

        public void select​(java.util.Date newDate)