public class CalendarGuiImpl extends BorderedPanelGuiImpl implements WidgetWithConfig<CalendarConfig>, FocusListener, DataContainer
Modifier and Type | Class and Description |
---|---|
class |
CalendarGuiImpl.DateTimeContent
Represents a scrollable widget and control displaying and modifying the date/time content
with help of keyboard keys.
|
Modifier and Type | Field and Description |
---|---|
private GuiColorResolver |
bodyColorResolver
Body color resolver
|
(package private) static int |
BUTTON_MARGIN
The standard margins around a given button
|
(package private) static int |
BUTTON_SIZE
The standard button's size
|
private ButtonFactory |
buttonFactory
GUI button factory
|
private BorderedPanelGuiImpl |
buttonsPanel
The button's panel
|
private CoordinatesConversion |
cc
Coordinate converter
|
private static java.time.chrono.Chronology |
chrono
The system calendar
|
(package private) static int |
COLUMNS_NUMBER
The displayed columns
|
private CalendarConfig |
config
Holds its settings
|
private CalendarGuiImpl.DateTimeContent |
dateTimeContent
The date/time content is implemented as a scrollable widget.
|
private java.time.format.DateTimeFormatter |
dateTimeFormatter
The date time formatter
|
private java.lang.String |
dateTimePattern
The current date and time pattern
|
private java.time.LocalDateTime |
displayedDateTime
The displayed date and time value without a time-zone in the ISO-8601 calendar system
|
private ButtonGuiImpl |
downButton
The down button
|
private java.text.FieldPosition[] |
fieldPositions
The array of date and time fields displayed by the current pattern
|
private GuiFontResolver |
fontResolver
Font resolver
|
private GuiDriver |
gd
Screen driver
|
(package private) static int |
HORIZONTAL_CELL_MARGIN
The standard margin between controls in a row
|
private boolean |
init
This flag has been set once, required for this widget initialization
|
private static java.util.Locale |
locale
The system locale
|
private ButtonGuiImpl |
popupButton
The popup button
|
(package private) boolean |
popupIsActive
The flag indicating that the calendar popup is active or not
|
private int |
previousFormatStyle
The format style is used to format the current date and time before the current format
is changed to the custom format.
|
(package private) static int |
ROWS_NUMBER
The displayed rows
|
private GuiOutputManager |
screen
Output manager
|
private GuiColorResolver |
titleColorResolver
Title color resolver for calendar header
|
private ToggleBoxGuiImpl |
toggleButton
The toggle button
|
private GuiColorResolver |
trailingColorResolver
Trailing days and selected day color resolver
|
private ButtonGuiImpl |
upButton
The up button
|
(package private) static int |
VERTICAL_ROW_MARGIN
The standard margin between rows
|
private Viewport<GuiOutputManager> |
viewport
The date/time content view
|
border
location, mousePtr, nativeInsets, physicalLocation
Constructor and Description |
---|
CalendarGuiImpl(WidgetId id,
CalendarConfig cfg)
Creates the calendar widget.
|
Modifier and Type | Method and Description |
---|---|
void |
afterConfigUpdate(CalendarConfig beforeUpdate)
Notifies this widget that its settings are changed.
|
CalendarConfig |
config()
Returns the widget's configuration.
|
Widget<GuiOutputManager> |
currentFocus()
Returns this widget itself.
|
Widget<GuiOutputManager> |
defaultFocus()
Returns this widget itself.
|
Dimension |
dimension()
Calculates the size of this widget in character units.
|
void |
fireValueChanged()
Fires a new value changed event.
|
void |
firstFocus()
Sets the current focus to this widget itself.
|
boolean |
focusTraversable()
Returns true.
|
int |
getSelectedFieldIndex()
Gets the currently selected data and time field's index.
|
java.lang.String |
getText()
Gets the current screen value formatted according its format style.
|
BaseDataType |
getValue()
Gets the current screen value formatted according its format style.
|
boolean |
hasFocusable(Widget<GuiOutputManager> exclude)
Tests if there is a focusable widget in this container except the given widget.
|
double |
height()
Returns the height of this widget.
|
void |
initialize(WidgetId id,
CalendarConfig cfg)
Initializes the date and time widget.
|
boolean |
isModified()
Tests if this widget has new settings.
|
Dimension |
minimumSize()
Returns the minimum size of this widget.
|
protected int[] |
mouseActions()
Determine the mouse actions processed by this widget.
|
void |
mousePressed(java.awt.event.MouseEvent event)
Selects a field under the mouse click pointer.
|
void |
onFocusGained(FocusEvent event)
Handles the focus gained event.
|
void |
onFocusLost(FocusEvent event)
Handles the focus lost event.
|
private java.time.LocalDateTime |
parse()
Parse the calendar date and time value from its configuration settings.
|
private java.time.LocalDateTime |
parse(int formatStyle,
java.time.format.DateTimeFormatter dateTimeFormatter)
Returns the calendar date and time from its configuration settings.
|
private java.time.LocalDateTime |
parseISO8601DateTimeString(java.time.LocalDateTime defaultDateTime)
Try to parse the current date or time value as a string value in the ISO-8601 calendar
system.
|
void |
processKeyEvent(KeyInput keyEvent)
Process key events that have been generated by this component.
|
private void |
recreateLayout()
Recreate this calendar widget.
|
private void |
scrollLeftToTheCurrentField(int currentIndex,
int upperLimit)
Scrolls the date and time content left to the current highlighted field.
|
private void |
scrollRightToTheCurrentField(int currentIndex)
Scrolls the date and time content right to the current highlighted field.
|
void |
setEnabled(boolean enabled)
Enable/disable widget.
|
void |
setValue(BaseDataType value)
Sets the new selected date value.
|
void |
updateBodyBackgroundColor(int color)
Updates the body background color used by CalendarPopup and DateTimeContent to color
their backgrounds.
|
void |
updateBodyForegroundColor(int color)
Updates the body foreground color used by CalendarPopup and DateTimeContent to color
their contents.
|
void |
updateCalendarLayout()
Updates its size and sizes of its components and positions them within this widget.
|
void |
updateDateTime()
Updates the date time value according to config.dateTimeValue.
|
void |
updateDateTimeDisplayValue(java.time.LocalDateTime dateTime)
Update the date time display value and date and time fields model.
|
void |
updateDateTimeFormatStyle(int oldFormatStyle,
java.lang.String oldFormatString)
Updates the date time content and its format style.
|
void |
updateDateTimePattern(int formatStyle,
java.lang.String customPattern)
Update the date time pattern and date and time model.
|
void |
updateFont()
Update the font.
|
void |
updateFontSize()
Update the font size for the same font.
|
void |
updateSize()
Update widget's size.
|
void |
updateTitleBackgroundColor(int color)
Updates the title background color used by CalendarPopup to the current month and year.
|
void |
updateTitleForegroundColor(int color)
Updates the title foreground color used by CalendarPopup to the current month and year.
|
void |
updateTrailingForegroundColor(int color)
Updates the trailing foreground color used by CalendarPopup to represents days from the previous
month and the next month to the current month.
|
double |
width()
Returns the width of this widget.
|
draw, drawPanel, getId, is3DBorder, isRMBEntrySupported, set3DBorder, setColorResolver, setCustomDraw, setId, setOptionalDraw
border, insets, isTransparent, setBorder, setTransparent
add, add, add, addContainerStateListener, addDirectly, belongsTo, checkWidget, childrenLocation, clipping, clipRectangle, copyState, currentFocus, cycleFocus, deregisterSelectedWidget, destroy, detach, doLayout, dumpCurrentWidgets, dumpWidgets, endSizeChange, findMouseSource, focus, focusWorker, formatDump, get, getAllSelectedWidgets, getClipRect, getEffectiveScrollableSize, getFocusInt, getIgnoreFocus, getLayout, getScrollableSize, getTabItemList, lastFocus, moveAfterTabItem, moveBeforeTabItem, moveToBottom, moveToBottomInClass, moveToTop, moveToTopInClass, moveToZpos, nextFocus, normalizeZOrder, onWidgetAdded, onWidgetRemoved, paintOnTop, parentOf, prepareWidgets, prevFocus, reflectAncestorChange, reflectLocationChange, registerSelectedWidget, remove, removeContainerStateListener, repaint, replace, requestFocus, requestFocus, setFocus, setFocusInt, setHeight, setIgnoreFocus, setInsets, setLayout, setSize, setSize, setTabItemList, setWidth, startSizeChange, triggerContainerStateRedrawEnabled, unrealize, updateSizeWorker, widgets, widgetsAsList, widgetStateChanged
_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, copyColors, createMouseHoverAction, deactivateDirectManipulation, debug, disable, disableTooltip, displayPhysicalLocation, drawCaret, enable, enableTooltip, enclosingFrame, forceCursorOnFocus, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCachedScreenLocation, getCachedScreenPhysicalLocation, getCustomMousePointer, getDefaultEvent, getEffectiveMousePointer, getLoadedMousePointer, getMenuMouse, getMouseActions, getMousePosition, getPortableMouseEventCoordinates, getSelectedText, getState, getTextHeight, getTextHeightNative, getTextHeightNative, getTextWidth, getTextWidth, getTextWidthNative, getTextWidthNative, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, ignoreAction, initialHeight, initialWidth, isCurrent, isDirectManipulationActive, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isFocusable, isHeader, isMouseDrag, isRealized, isRepaintDisabled, isScreenLocationCached, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, manageSystemActions, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseReleased, mouseWheelMoved, moveToBottom, moveToTop, name, navigable, oleDoDrop, oleDrag, oleDragging, oleStartDragging, onOleDragging, onOleDropEnd, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, prepParentLocation, preventFocusWhenMouseDownEventDefined, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyEventForSelectableWidget, processKeyListeners, processMnemonic, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, refresh, registerWidgetStateListener, repaint, repaint, requestSync, resetBitmap, resizeTo, resolveFont, resolvePopupMenuId, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setCachedScreenLocation, setCachedScreenPhysicalLocation, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, setVisible, show, showPopupMenu, supportsCustomMousePointer, sync, topLevelWindow, toString, translate, unregisterWidgetStateListener, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
widgetsAsList
addFocusListener, addKeyListener, ancestor, ancestorId, bounds, canMovetoTop, clearWidget, defaultMousePtr, displayPhysicalLocation, drawCaret, enclosingFrame, enforceDefaultMousePtr, forceCursorOnFocus, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getMousePosition, getSelectedText, getState, getTriggerWidget, getTriggerWidget, getVisiblePart, getZOrderClass, hasFocus, hasFocus, hidden, hide, highlighted, ignoreEnable, initialHeight, initialWidth, isCurrent, isDirectManipulable, isDirectManipulationActive, isDisplayed, isDroppable, isEnabled, isFocusable, isHeader, isInitialValueLayout, isLegacyFocus, isRealized, isRepaintDisabled, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, maySwitchFocus, moveToBottom, moveToTop, name, navigable, oleDrag, parent, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, preventFocusWhenMouseDownEventDefined, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, raiseLegacyMouseEvents, refreshWidget, registerWidgetStateListener, repaint, repaint, requestFocus, requestSync, resizeTo, resolvePopupMenuId, screen, screenLocation, screenPhysicalLocation, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, setVisible, show, supportsCustomMousePointer, systemFocusGrabbed, topLevelWindow, unregisterWidgetStateListener, validateDisplayValue, window
static final int BUTTON_SIZE
static final int BUTTON_MARGIN
static final int HORIZONTAL_CELL_MARGIN
static final int VERTICAL_ROW_MARGIN
static final int ROWS_NUMBER
static final int COLUMNS_NUMBER
private CalendarConfig config
private GuiDriver gd
private GuiOutputManager screen
private ButtonFactory buttonFactory
private CoordinatesConversion cc
private GuiColorResolver bodyColorResolver
private GuiColorResolver titleColorResolver
private GuiColorResolver trailingColorResolver
private GuiFontResolver fontResolver
private static final java.util.Locale locale
private static final java.time.chrono.Chronology chrono
private java.time.format.DateTimeFormatter dateTimeFormatter
private java.lang.String dateTimePattern
private java.text.FieldPosition[] fieldPositions
private java.time.LocalDateTime displayedDateTime
private CalendarGuiImpl.DateTimeContent dateTimeContent
private int previousFormatStyle
private Viewport<GuiOutputManager> viewport
private BorderedPanelGuiImpl buttonsPanel
private ButtonGuiImpl popupButton
private ButtonGuiImpl upButton
private ButtonGuiImpl downButton
private ToggleBoxGuiImpl toggleButton
private boolean init
boolean popupIsActive
public CalendarGuiImpl(WidgetId id, CalendarConfig cfg)
id
- The given widget's id.cfg
- The widget's configurationpublic Dimension dimension()
dimension
in interface Widget<GuiOutputManager>
dimension
in class AbstractContainer<GuiOutputManager>
public double height()
height
in interface Widget<GuiOutputManager>
height
in class AbstractContainer<GuiOutputManager>
public Dimension minimumSize()
minimumSize
in interface Widget<GuiOutputManager>
minimumSize
in class AbstractContainer<GuiOutputManager>
public double width()
width
in interface Widget<GuiOutputManager>
width
in class AbstractContainer<GuiOutputManager>
public CalendarConfig config()
config
in interface Widget<GuiOutputManager>
config
in interface ConfigOwner<CalendarConfig>
config
in class AbstractWidget<GuiOutputManager>
public void updateCalendarLayout()
public void afterConfigUpdate(CalendarConfig beforeUpdate)
afterConfigUpdate
in interface ConfigOwner<CalendarConfig>
beforeUpdate
- The old configurationpublic void updateDateTime()
public void updateDateTimeFormatStyle(int oldFormatStyle, java.lang.String oldFormatString)
oldFormatStyle
- The value for the format style before the config.formatStyle has been updatedoldFormatString
- The value for the format string before the config.customFormat has been updatedpublic void updateFont()
public void updateFontSize()
public void updateBodyBackgroundColor(int color)
color
- The new background color given by RGB color encoding.public void updateBodyForegroundColor(int color)
color
- The new foreground color given by RGB color encoding.public void updateTitleBackgroundColor(int color)
color
- The new background color given by RGB color encoding.public void updateTitleForegroundColor(int color)
color
- The new foreground color given by RGB color encoding.public void updateTrailingForegroundColor(int color)
color
- The new foreground color given by RGB color encoding.public void setEnabled(boolean enabled)
setEnabled
in interface Widget<GuiOutputManager>
setEnabled
in class AbstractWidget<GuiOutputManager>
enabled
- New enabled state.private java.time.LocalDateTime parse()
private java.time.LocalDateTime parseISO8601DateTimeString(java.time.LocalDateTime defaultDateTime)
defaultDateTime
- The given default date and time valueprivate java.time.LocalDateTime parse(int formatStyle, java.time.format.DateTimeFormatter dateTimeFormatter) throws java.time.format.DateTimeParseException
formatStyle
- The format style for the current date time valuedateTimeFormatter
- The formatter for the current date time valuejava.time.format.DateTimeParseException
- If the current date time value can't be parsed using the given date and time
formatterpublic void initialize(WidgetId id, CalendarConfig cfg)
initialize
in interface WidgetWithConfig<CalendarConfig>
id
- This widget idcfg
- This widget configurationprivate void recreateLayout()
public void onFocusGained(FocusEvent event)
onFocusGained
in interface FocusListener
event
- The focus eventpublic void onFocusLost(FocusEvent event)
onFocusLost
in interface FocusListener
event
- The focus eventpublic void firstFocus()
firstFocus
in interface Container<GuiOutputManager>
firstFocus
in class AbstractContainer<GuiOutputManager>
public boolean focusTraversable()
focusTraversable
in interface Widget<GuiOutputManager>
focusTraversable
in class AbstractContainer<GuiOutputManager>
public Widget<GuiOutputManager> currentFocus()
currentFocus
in interface Container<GuiOutputManager>
currentFocus
in class AbstractContainer<GuiOutputManager>
public Widget<GuiOutputManager> defaultFocus()
defaultFocus
in interface Container<GuiOutputManager>
defaultFocus
in class AbstractContainer<GuiOutputManager>
public boolean hasFocusable(Widget<GuiOutputManager> exclude)
hasFocusable
in interface Container<GuiOutputManager>
hasFocusable
in class AbstractContainer<GuiOutputManager>
exclude
- The given widgetpublic void updateSize()
public void updateDateTimePattern(int formatStyle, java.lang.String customPattern)
formatStyle
- The calendar look and feel stylecustomPattern
- The date and time pattern for date and time presentationpublic void updateDateTimeDisplayValue(java.time.LocalDateTime dateTime)
dateTime
- The date and time to displaypublic int getSelectedFieldIndex()
public void processKeyEvent(KeyInput keyEvent)
processKeyEvent
in interface Widget<GuiOutputManager>
processKeyEvent
in class AbstractContainer<GuiOutputManager>
keyEvent
- The key event to be handled.public void fireValueChanged()
public void mousePressed(java.awt.event.MouseEvent event)
mousePressed
in interface java.awt.event.MouseListener
mousePressed
in class AbstractWidget<GuiOutputManager>
event
- The mouse eventprivate void scrollRightToTheCurrentField(int currentIndex)
currentIndex
- The current index of the target fieldprivate void scrollLeftToTheCurrentField(int currentIndex, int upperLimit)
currentIndex
- The current index of the target fieldupperLimit
- The number of all date and time fields displayed by the date and time widgetprotected int[] mouseActions()
mouseActions
in class AbstractWidget<GuiOutputManager>
public BaseDataType getValue()
getValue
in interface DataContainer
public void setValue(BaseDataType value)
setValue
in interface DataContainer
value
- The new selected date valuepublic java.lang.String getText()
getText
in interface DataContainer
public boolean isModified()
isModified
in interface DataContainer