com.bradrydzewski.gwt.calendar.client
Class CalendarWidget

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Composite
              extended by com.bradrydzewski.gwt.calendar.client.InteractiveWidget
                  extended by com.bradrydzewski.gwt.calendar.client.CalendarWidget
All Implemented Interfaces:
HasDateRequestHandlers<Date>, HasDeleteHandlers<Appointment>, HasMouseOverHandlers<Appointment>, HasTimeBlockClickHandlers<Date>, HasUpdateHandlers<Appointment>, HasAppointments, HasLayout, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.logical.shared.HasOpenHandlers<Appointment>, com.google.gwt.event.logical.shared.HasSelectionHandlers<Appointment>, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasVisibility, com.google.gwt.user.client.ui.IsRenderable, com.google.gwt.user.client.ui.IsWidget
Direct Known Subclasses:
Calendar

public class CalendarWidget
extends InteractiveWidget
implements com.google.gwt.event.logical.shared.HasSelectionHandlers<Appointment>, HasDeleteHandlers<Appointment>, com.google.gwt.event.logical.shared.HasOpenHandlers<Appointment>, HasTimeBlockClickHandlers<Date>, HasUpdateHandlers<Appointment>, HasDateRequestHandlers<Date>, HasMouseOverHandlers<Appointment>, HasLayout, HasAppointments

CalendarWidget is an InteractiveWidget that maintains a calendar model (a set of Appointment objects) managed through an AppointmentManager.

TODO: Need Calendar "View" - CHECK TODO: Need CalendarSettings TODO: Need LayoutStrategy - CHECK TODO: Need DragDropStrategy TODO: Need ResizeStrategy ??? or is this same as DragDrop TODO: Add AppointmentBuilder ??? downside is that if the Appointment object is updated, need to refersh widget

Author:
Brad Rydzewski
See Also:
InteractiveWidget

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.bradrydzewski.gwt.calendar.client.InteractiveWidget
rootPanel
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
CalendarWidget()
          Creates a CalendarWidget with an empty set of appointments and the current system date as the date currently displayed by the calendar.
CalendarWidget(Date date)
           
 
Method Summary
 void addAppointment(Appointment appointment)
          Adds an appointment to the calendar.
 void addAppointments(ArrayList<Appointment> appointments)
          Adds each appointment in the list to the calendar.
 com.google.gwt.event.shared.HandlerRegistration addCreateHandler(CreateHandler<Appointment> handler)
           
 com.google.gwt.event.shared.HandlerRegistration addDateRequestHandler(DateRequestHandler<Date> handler)
          Adds a DateRequestEvent handler.
 void addDaysToDate(int numOfDays)
          Moves this calendar widget current date as many days as specified by the numOfDays parameter.
 com.google.gwt.event.shared.HandlerRegistration addDeleteHandler(DeleteHandler<Appointment> handler)
          Adds a DeleteEvent handler.
 com.google.gwt.event.shared.HandlerRegistration addMouseOverHandler(MouseOverHandler<Appointment> handler)
          Adds a DeleteEvent handler.
 com.google.gwt.event.shared.HandlerRegistration addOpenHandler(com.google.gwt.event.logical.shared.OpenHandler<Appointment> handler)
           
 com.google.gwt.event.shared.HandlerRegistration addSelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler<Appointment> handler)
           
 com.google.gwt.event.shared.HandlerRegistration addTimeBlockClickHandler(TimeBlockClickHandler<Date> handler)
          Adds a DeleteEvent handler.
 void addToRootPanel(com.google.gwt.user.client.ui.Widget widget)
           
 com.google.gwt.event.shared.HandlerRegistration addUpdateHandler(UpdateHandler<Appointment> handler)
          Adds a UpdateEvent handler.
 void clearAppointments()
          Clears all appointment items.
 void doLayout()
          Forces the widget to re-calculate and perform layout operations.
 void doSizing()
           
 void fireCreateEvent(Appointment appointment)
           
 void fireDateRequestEvent(Date date)
           
 void fireDateRequestEvent(Date date, com.google.gwt.user.client.Element clicked)
           
 void fireDeleteEvent(Appointment appointment)
           
 void fireMouseOverEvent(Appointment appointment, com.google.gwt.user.client.Element element)
           
 void fireOpenEvent(Appointment appointment)
           
 void fireSelectionEvent(Appointment appointment)
           
 void fireTimeBlockClickEvent(Date date)
           
 void fireUpdateEvent(Appointment appointment)
           
 ArrayList<Appointment> getAppointments()
          Returns the collection of appointments in the underlying in-memory model of this calendar widget.
 Date getDate()
           
 int getDays()
           
 Appointment getSelectedAppointment()
          Gets the currently selected item.
 CalendarSettings getSettings()
           
 CalendarView getView()
           
 boolean hasAppointmentSelected()
          Indicates whether there is a "currently selected" appointment at the moment.
 boolean isTheSelectedAppointment(Appointment appointment)
          Tells whether the passed appointment is the currently selected appointment.
 void onDeleteKeyPressed()
          Processes com.google.gwt.event.dom.client.KeyCodes.KEY_DELETE keystrokes.
 void onDoubleClick(com.google.gwt.user.client.Element element, com.google.gwt.user.client.Event event)
          Processes mouse double-click events.
 void onDownArrowKeyPressed()
          Processes com.google.gwt.event.dom.client.KeyCodes.KEY_DOWN keystrokes.
 void onLeftArrowKeyPressed()
          Processes com.google.gwt.event.dom.client.KeyCodes.KEY_LEFT keystrokes.
 void onLoad()
           
 void onMouseDown(com.google.gwt.user.client.Element element, com.google.gwt.user.client.Event event)
          Processes mouse button pressing events.
 void onMouseOver(com.google.gwt.user.client.Element element, com.google.gwt.user.client.Event event)
          Processes mouse over events.
 void onRightArrowKeyPressed()
          Processes com.google.gwt.event.dom.client.KeyCodes.KEY_RIGHT keystrokes.
 void onUpArrowKeyPressed()
          Processes com.google.gwt.event.dom.client.KeyCodes.KEY_UP keystrokes.
protected  void refresh()
          Performs all layout calculations for the list of appointments and resizes the Calendar View appropriately.
 void removeAppointment(Appointment appointment)
          Removes an appointment from the calendar.
 void removeAppointment(Appointment appointment, boolean fireEvents)
          Removes an appointment from the calendar.
 void removeCurrentlySelectedAppointment()
          Removes the currently selected appointment from the model, if such appointment is set.
 void resetSelectedAppointment()
          Resets the "currently selected" appointment of this calendar.
 void resumeLayout()
          Allows the calendar to perform a layout, sizing the component and placing all appointments.
 void scrollToHour(int hour)
           
 boolean selectNextAppointment()
           
 boolean selectPreviousAppointment()
           
 void setCommittedAppointment(Appointment appt)
           
 void setDate(Date date)
           
 void setDate(Date date, int days)
           
 void setDays(int days)
           
 void setRollbackAppointment(Appointment appt)
           
 void setSelectedAppointment(Appointment appointment)
          Sets the currently selected item.
 void setSelectedAppointment(Appointment appointment, boolean fireEvents)
           
 void setSettings(CalendarSettings settings)
           
 void setView(CalendarView view)
          Changes the current view of this calendar widget to the specified view.
 void suspendLayout()
          Suspends the calendar from performing a layout.
 
Methods inherited from class com.bradrydzewski.gwt.calendar.client.InteractiveWidget
getRootPanel, keyboardNavigation, onBrowserEvent
 
Methods inherited from class com.google.gwt.user.client.ui.Composite
getWidget, initWidget, isAttached, onAttach, onDetach, performDetachedInitialization, render, render, resolvePotentialElement, setWidget, wrapElement
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onUnload, removeFromParent, setLayoutData, sinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 

Constructor Detail

CalendarWidget

public CalendarWidget()
Creates a CalendarWidget with an empty set of appointments and the current system date as the date currently displayed by the calendar.


CalendarWidget

public CalendarWidget(Date date)
Method Detail

setView

public final void setView(CalendarView view)
Changes the current view of this calendar widget to the specified view. By setting this widget's current view the whole widget panel is cleared.

Parameters:
view - The CalendarView implementation to render this widget's underlying calendar

getView

public final CalendarView getView()

getDate

public Date getDate()

setDate

public void setDate(Date date,
                    int days)

setDate

public void setDate(Date date)

addDaysToDate

public void addDaysToDate(int numOfDays)
Moves this calendar widget current date as many days as specified by the numOfDays parameter.

Parameters:
numOfDays - The number of days to change the calendar date forward (positive number) or backwards.

getDays

public int getDays()

setDays

public void setDays(int days)

getAppointments

public ArrayList<Appointment> getAppointments()
Returns the collection of appointments in the underlying in-memory model of this calendar widget. Warning: the returned collection of apointments can be modified by client code, possibly breaking the system model invariants.

Returns:
The set of appointments to be displayed by this calendar widget
See Also:
AppointmentManager.getAppointments()

removeAppointment

public void removeAppointment(Appointment appointment)
Removes an appointment from the calendar.

Specified by:
removeAppointment in interface HasAppointments
Parameters:
appointment - the item to be removed.

removeCurrentlySelectedAppointment

public void removeCurrentlySelectedAppointment()
Removes the currently selected appointment from the model, if such appointment is set.


removeAppointment

public void removeAppointment(Appointment appointment,
                              boolean fireEvents)
Removes an appointment from the calendar.

Specified by:
removeAppointment in interface HasAppointments
Parameters:
appointment - the item to be removed.
fireEvents - true to allow deletion events to be fired

resetSelectedAppointment

public void resetSelectedAppointment()
Resets the "currently selected" appointment of this calendar.

See Also:
AppointmentManager

addAppointment

public void addAppointment(Appointment appointment)
Adds an appointment to the calendar.

Specified by:
addAppointment in interface HasAppointments
Parameters:
appointment - item to be added

addAppointments

public void addAppointments(ArrayList<Appointment> appointments)
Adds each appointment in the list to the calendar.

Specified by:
addAppointments in interface HasAppointments
Parameters:
appointments - items to be added.

clearAppointments

public void clearAppointments()
Clears all appointment items.

Specified by:
clearAppointments in interface HasAppointments

setSelectedAppointment

public void setSelectedAppointment(Appointment appointment)
Sets the currently selected item.

Specified by:
setSelectedAppointment in interface HasAppointments
Parameters:
appointment - the item to be selected, or null to de-select all items.

setSelectedAppointment

public void setSelectedAppointment(Appointment appointment,
                                   boolean fireEvents)
Specified by:
setSelectedAppointment in interface HasAppointments

hasAppointmentSelected

public boolean hasAppointmentSelected()
Indicates whether there is a "currently selected" appointment at the moment.

Specified by:
hasAppointmentSelected in interface HasAppointments
Returns:
true if there is an appointment currently selected, false if it is null.
See Also:
AppointmentManager.hasAppointmentSelected()

getSelectedAppointment

public Appointment getSelectedAppointment()
Gets the currently selected item.

Specified by:
getSelectedAppointment in interface HasAppointments
Returns:
the selected item.

isTheSelectedAppointment

public boolean isTheSelectedAppointment(Appointment appointment)
Tells whether the passed appointment is the currently selected appointment.

Parameters:
appointment - The appointment to test to be the currently selected
Returns:
true if there is a currently selected appointment and happens to be equal to the passed appointment
See Also:
AppointmentManager.isTheSelectedAppointment(Appointment)

refresh

protected void refresh()
Performs all layout calculations for the list of appointments and resizes the Calendar View appropriately.


doLayout

public void doLayout()
Description copied from interface: HasLayout
Forces the widget to re-calculate and perform layout operations.

Specified by:
doLayout in interface HasLayout

doSizing

public void doSizing()

onLoad

public void onLoad()
Overrides:
onLoad in class com.google.gwt.user.client.ui.Widget

suspendLayout

public void suspendLayout()
Suspends the calendar from performing a layout. This can be useful when adding a large number of appointments at a time, since a layout is performed each time an appointment is added.

Specified by:
suspendLayout in interface HasLayout

resumeLayout

public void resumeLayout()
Allows the calendar to perform a layout, sizing the component and placing all appointments. If a layout is pending it will get executed when this method is called.

Specified by:
resumeLayout in interface HasLayout

getSettings

public CalendarSettings getSettings()

setSettings

public void setSettings(CalendarSettings settings)

scrollToHour

public void scrollToHour(int hour)

selectPreviousAppointment

public boolean selectPreviousAppointment()

selectNextAppointment

public boolean selectNextAppointment()

onDeleteKeyPressed

public void onDeleteKeyPressed()
Description copied from class: InteractiveWidget
Processes com.google.gwt.event.dom.client.KeyCodes.KEY_DELETE keystrokes. Concrete interactive widgets should provide the component's specific logic.

Specified by:
onDeleteKeyPressed in class InteractiveWidget

onDoubleClick

public void onDoubleClick(com.google.gwt.user.client.Element element,
                          com.google.gwt.user.client.Event event)
Description copied from class: InteractiveWidget
Processes mouse double-click events. Concrete interactive widgets should provide the component's specific logic.

Specified by:
onDoubleClick in class InteractiveWidget
Parameters:
element - The HTML DOM element that originated the event

onDownArrowKeyPressed

public void onDownArrowKeyPressed()
Description copied from class: InteractiveWidget
Processes com.google.gwt.event.dom.client.KeyCodes.KEY_DOWN keystrokes. Concrete interactive widgets should provide the component's specific logic.

Specified by:
onDownArrowKeyPressed in class InteractiveWidget

onLeftArrowKeyPressed

public void onLeftArrowKeyPressed()
Description copied from class: InteractiveWidget
Processes com.google.gwt.event.dom.client.KeyCodes.KEY_LEFT keystrokes. Concrete interactive widgets should provide the component's specific logic.

Specified by:
onLeftArrowKeyPressed in class InteractiveWidget

onMouseDown

public void onMouseDown(com.google.gwt.user.client.Element element,
                        com.google.gwt.user.client.Event event)
Description copied from class: InteractiveWidget
Processes mouse button pressing events. Concrete interactive widgets should provide the component's specific logic.

Specified by:
onMouseDown in class InteractiveWidget
Parameters:
element - The HTML DOM element that originated the event

onMouseOver

public void onMouseOver(com.google.gwt.user.client.Element element,
                        com.google.gwt.user.client.Event event)
Description copied from class: InteractiveWidget
Processes mouse over events. Concrete interactive widgets should provide the component's specific logic.

Specified by:
onMouseOver in class InteractiveWidget
Parameters:
element - The HTML DOM element that originated the event
event - The HTML DOM event that was triggered

onRightArrowKeyPressed

public void onRightArrowKeyPressed()
Description copied from class: InteractiveWidget
Processes com.google.gwt.event.dom.client.KeyCodes.KEY_RIGHT keystrokes. Concrete interactive widgets should provide the component's specific logic.

Specified by:
onRightArrowKeyPressed in class InteractiveWidget

onUpArrowKeyPressed

public void onUpArrowKeyPressed()
Description copied from class: InteractiveWidget
Processes com.google.gwt.event.dom.client.KeyCodes.KEY_UP keystrokes. Concrete interactive widgets should provide the component's specific logic.

Specified by:
onUpArrowKeyPressed in class InteractiveWidget

fireOpenEvent

public void fireOpenEvent(Appointment appointment)

fireDeleteEvent

public void fireDeleteEvent(Appointment appointment)

fireSelectionEvent

public void fireSelectionEvent(Appointment appointment)

fireMouseOverEvent

public void fireMouseOverEvent(Appointment appointment,
                               com.google.gwt.user.client.Element element)

fireTimeBlockClickEvent

public void fireTimeBlockClickEvent(Date date)

fireCreateEvent

public void fireCreateEvent(Appointment appointment)

fireDateRequestEvent

public void fireDateRequestEvent(Date date)

fireDateRequestEvent

public void fireDateRequestEvent(Date date,
                                 com.google.gwt.user.client.Element clicked)

fireUpdateEvent

public void fireUpdateEvent(Appointment appointment)

addSelectionHandler

public com.google.gwt.event.shared.HandlerRegistration addSelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler<Appointment> handler)
Specified by:
addSelectionHandler in interface com.google.gwt.event.logical.shared.HasSelectionHandlers<Appointment>

addDeleteHandler

public com.google.gwt.event.shared.HandlerRegistration addDeleteHandler(DeleteHandler<Appointment> handler)
Description copied from interface: HasDeleteHandlers
Adds a DeleteEvent handler.

Specified by:
addDeleteHandler in interface HasDeleteHandlers<Appointment>
Parameters:
handler - the handler
Returns:
the registration for the event

addMouseOverHandler

public com.google.gwt.event.shared.HandlerRegistration addMouseOverHandler(MouseOverHandler<Appointment> handler)
Description copied from interface: HasMouseOverHandlers
Adds a DeleteEvent handler.

Specified by:
addMouseOverHandler in interface HasMouseOverHandlers<Appointment>
Parameters:
handler - the handler
Returns:
the registration for the event

addTimeBlockClickHandler

public com.google.gwt.event.shared.HandlerRegistration addTimeBlockClickHandler(TimeBlockClickHandler<Date> handler)
Description copied from interface: HasTimeBlockClickHandlers
Adds a DeleteEvent handler.

Specified by:
addTimeBlockClickHandler in interface HasTimeBlockClickHandlers<Date>
Parameters:
handler - the handler
Returns:
the registration for the event

addUpdateHandler

public com.google.gwt.event.shared.HandlerRegistration addUpdateHandler(UpdateHandler<Appointment> handler)
Description copied from interface: HasUpdateHandlers
Adds a UpdateEvent handler.

Specified by:
addUpdateHandler in interface HasUpdateHandlers<Appointment>
Parameters:
handler - the handler
Returns:
the registration for the event

addCreateHandler

public com.google.gwt.event.shared.HandlerRegistration addCreateHandler(CreateHandler<Appointment> handler)

addOpenHandler

public com.google.gwt.event.shared.HandlerRegistration addOpenHandler(com.google.gwt.event.logical.shared.OpenHandler<Appointment> handler)
Specified by:
addOpenHandler in interface com.google.gwt.event.logical.shared.HasOpenHandlers<Appointment>

addDateRequestHandler

public com.google.gwt.event.shared.HandlerRegistration addDateRequestHandler(DateRequestHandler<Date> handler)
Description copied from interface: HasDateRequestHandlers
Adds a DateRequestEvent handler.

Specified by:
addDateRequestHandler in interface HasDateRequestHandlers<Date>
Parameters:
handler - the handler
Returns:
the registration for the event

addToRootPanel

public void addToRootPanel(com.google.gwt.user.client.ui.Widget widget)

setRollbackAppointment

public void setRollbackAppointment(Appointment appt)

setCommittedAppointment

public void setCommittedAppointment(Appointment appt)


Copyright © 2012. All Rights Reserved.