public class DateFormField extends AbstractFormField implements SqlDateField
Date object.
The date can be entered in the specified format or as a shortcut. The following shortcuts are defined:
SimpleDateFormat with some
minor differences:
| Modifier and Type | Class and Description |
|---|---|
static interface |
DateFormField.ReferenceDateProvider
Provider for the reference date.
Invoked whenever the input starts with a '@' which will invoke setReferenceDate(getReferenceDateProvider().getReferenceDate()) |
JTextField.AccessibleJTextFieldJTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBindingJComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
static Logger.Level |
defaultInformationLossLogLevel
Determines how to handle information loss when a timestamp is edited
by a date field without a time format.
Primarily this is the log-level, but the level also controls what to log and/or when to throw an exception: FINER: log with stacktrace and throw a GUIRuntimeException
FINE: log with stacktrace
SEVERE: check disabled
all other levels: just log without stacktrace
The default is INFO. |
static Date |
defaultMaxDate
The default maximum date for all instances.
|
static Date |
defaultMinDate
The default minimum date for all instances.
|
errorMessage, errorOffset, savedValuenotifyActionDEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEYlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTADJUST_LEFT, ADJUST_NONE, ADJUST_RIGHT, ADJUST_TRIM, CONVERT_LC, CONVERT_NONE, CONVERT_UCBOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WESTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
DateFormField()
Creates an empty DateFormField with the default document model
and minimum width.
|
DateFormField(Document doc,
int columns)
Creates an empty DateFormField.
Notice: setting doc != null requires a doc derived from FormFieldDocument. |
DateFormField(int columns)
Creates an empty DateFormField with the default document model.
|
DateFormField(String pattern)
Creates an empty DateFormField with the default document model,
mininum width and a given format.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
convert2DigitYearTo4DigitYear(int year2)
Converts a short 2-digit year to a 4-digit year.
|
String |
doFormat(Object value)
Does the formatting of the given object.
Renders the object and returns the string. |
org.tentackle.common.Date |
getDate()
Gets the SQL-Date.
|
SimpleDateFormat |
getDateFormat()
Gets the date format.
|
char |
getDefaultUnit()
Gets the default unit.
|
protected Logger.Level |
getEffectiveInformationLossLogLevel()
Gets the effective log level.
|
protected Date |
getEffectiveMaxDate()
Gets the effective maximum date.
|
protected Date |
getEffectiveMinDate()
Gets the effective minimum date.
|
String |
getFormat()
Gets the format string.
|
Date |
getFormValue()
Retrieves the value from this component.
The method is used to update the data model if the view has changed because the user edited it. |
Logger.Level |
getInformationLossLogLevel()
Gets the information log level.
|
Date |
getMaxDate()
Gets the maximum date.
|
Date |
getMinDate()
Gets the minimum date.
|
Date |
getReferenceDate()
Gets the reference date for the input shortcuts.
|
DateFormField.ReferenceDateProvider |
getReferenceDateProvider()
Gets the reference date provider.
|
org.tentackle.common.Time |
getTime()
Gets the SQL-Time.
|
org.tentackle.common.Timestamp |
getTimestamp()
Gets the SQL-Timestamp.
|
boolean |
isLenient()
Returns the lenient flag for the date format
|
void |
setDateFormat(SimpleDateFormat fmt)
Sets the date format.
|
void |
setDefaultUnit(char defaultUnit)
Sets the default unit.
|
void |
setFormat(String pattern)
Sets the format string.
The format string is used to format the view of the data. |
void |
setFormValue(Object date)
Sets a value in this component.
The method is used to update the view if the data has changed. |
protected void |
setGregorianValue(GregorianCalendar cal,
int field,
int value)
Sets the gregorian value and checks whether the value is valid if date format is not lenient.
|
void |
setInformationLossLogLevel(Logger.Level informationLossLogLevel)
Sets the information log level.
Overwrites the default defaultInformationLossLogLevel. |
void |
setLenient(boolean lenient)
Sets the "lenient" flag for the date format.
|
void |
setMaxDate(Date maxDate)
Sets the maximum date.
|
void |
setMinDate(Date minDate)
Sets the minimum date.
|
void |
setReferenceDate(Date referenceDate)
Sets the reference date for the input shortcuts.
|
void |
setReferenceDateProvider(DateFormField.ReferenceDateProvider refProvider)
Sets the reference date provider.
|
void |
setText(String str)
Sets the given text in the view of this component.
|
addValueListener, clearText, clearValueShownModified, createDefaultModel, downRight, fireValueChanged, fireValueEntered, getAdjust, getBinding, getBindingPath, getComponentPath, getConvert, getConverter, getDefaultColumns, getErrorMessage, getErrorOffset, getFiller, getFocusTraversalGroup, getHelpURL, getInvalidChars, getMaxColumns, getParentWindow, getPreferredSize, getPropertyGroup, getText, getToolTipText, getValidChars, getValueShown, getVerticalAlignment, hideErrorPopup, invalidateParentInfo, isAutoNext, isAutoSelect, isAutoUpdate, isBindable, isCaretLeft, isCaretRight, isCellEditorUsage, isChangeable, isEmpty, isEraseFirst, isFireRunning, isFormTraversable, isHonourChangeable, isInhibitAutoSelect, isMandatory, isOverwrite, isSmartValueEntered, isStartEditLeftmost, isTriggerValueChangedEnabled, isValueChanged, isValueShownModified, prepareFocusLost, processFocusEvent, processKeyBinding, removeValueListener, requestFocusLater, restoreSavedValue, saveValue, setAdjust, setAutoNext, setAutoSelect, setAutoUpdate, setBindable, setBinding, setBindingPath, setCaretLeft, setCaretRight, setCellEditorUsage, setChangeable, setColumns, setComponentPath, setConvert, setConverter, setDefaultColumns, setEditable, setEraseFirst, setErrorMessage, setErrorOffset, setFiller, setFireRunning, setFocusTraversalGroup, setFormTraversable, setFormWrapWindow, setHelpURL, setHonourChangeable, setInhibitAutoSelect, setInvalidChars, setMandatory, setMaxColumns, setOverwrite, setPropertyGroup, setSmartValueEntered, setStartEditLeftmost, setTriggerValueChangedEnabled, setValidChars, setVerticalAlignment, showErrorPopup, showErrorPopup, showHelp, transferFocus, transferFocusBackward, triggerValueChanged, updateAllChangeable, upLeft, wasFocusGainedFromTransfer, wasFocusGainedFromTransferBackward, wasTransferFocus, wasTransferFocusBackward, wasTransferFocusByEnteractionPropertyChanged, addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, fireActionPerformed, getAccessibleContext, getAction, getActionListeners, getActions, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getScrollOffset, getUIClassID, isValidateRoot, paramString, postActionEvent, removeActionListener, scrollRectToVisible, setAction, setActionCommand, setDocument, setFont, setHorizontalAlignment, setScrollOffsetaddCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, restoreComposedText, saveComposedText, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, writeaddAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocusUpCycleclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetCaretPosition, getColumns, getHorizontalAlignment, postActionEvent, setCaretPosition, setHorizontalAlignment, setToolTipTextgetBaseline, hasFocuspublic static Date defaultMinDate
public static Date defaultMaxDate
public static Logger.Level defaultInformationLossLogLevel
GUIRuntimeExceptionThe check can be turned off if the level of the logger does not cover the given check level.
public DateFormField(Document doc, int columns)
doc - the document model, null = defaultcolumns - the number of columns, 0 = minimum widthpublic DateFormField(int columns)
columns - the number of columns, 0 = minimum widthpublic DateFormField()
public DateFormField(String pattern)
pattern - the date format stringpublic void setFormValue(Object date)
FormComponentsetFormValue in interface FormComponentdate - is the object to setpublic void setInformationLossLogLevel(Logger.Level informationLossLogLevel)
defaultInformationLossLogLevel.informationLossLogLevel - the level, null if defaultpublic Logger.Level getInformationLossLogLevel()
protected Logger.Level getEffectiveInformationLossLogLevel()
public String doFormat(Object value)
FormFieldComponentdoFormat in interface FormFieldComponentvalue - the objectpublic void setText(String str)
AbstractFormFieldOverridden to turn off autoNext during inserts and to implement eraseFirst.
setText in interface FormFieldComponentsetText in class AbstractFormFieldstr - the textpublic Date getFormValue()
getFormValue in interface FormComponentpublic void setMinDate(Date minDate)
minDate - the minimum date, null if nonepublic Date getMinDate()
public void setMaxDate(Date maxDate)
maxDate - the maximum date, null if nonepublic Date getMaxDate()
public org.tentackle.common.Date getDate()
getDate in interface SqlDateFieldpublic org.tentackle.common.Timestamp getTimestamp()
getTimestamp in interface SqlDateFieldpublic org.tentackle.common.Time getTime()
getTime in interface SqlDateFieldpublic void setDateFormat(SimpleDateFormat fmt)
Useful if format cannot be fully described by setFormat(java.lang.String).
fmt - the formatpublic SimpleDateFormat getDateFormat()
Useful if the format must be tailored beyond the possibilities offered by setFormat(java.lang.String).
public void setFormat(String pattern)
FormFieldComponentsetFormat in interface FormFieldComponentpattern - the format stringSimpleDateFormatpublic String getFormat()
FormFieldComponentgetFormat in interface FormFieldComponentpublic void setLenient(boolean lenient)
lenient - true if lenientSimpleDateFormatpublic boolean isLenient()
public Date getReferenceDate()
public void setReferenceDate(Date referenceDate)
referenceDate - reference date for input shortcuts, null = nowpublic char getDefaultUnit()
public void setDefaultUnit(char defaultUnit)
The default unit applies to number-only input, for example "6" in a time field. By default, the unit is derived from the format and corresponds to the smallest unit. For example, in "HH:mm" the default unit is minute and in "yy/mm/dd" the default unit is day. Input of "6" will by default be translated to "6 minutes (in current hour)", respectively 6th day in current month. If the default unit, however, is explicitly set to "H" (or "y") an input of "6" will result in "06:00" ("06/xx/xx" respectively).
defaultUnit - the default unit (formatting char), blank or 0 if defaultpublic DateFormField.ReferenceDateProvider getReferenceDateProvider()
public void setReferenceDateProvider(DateFormField.ReferenceDateProvider refProvider)
The provider is consulted whenever the input starts with a '@'. It will be used to retrieve the reference date. For example: "@+7" to add 7 days to a specific date from the model.
refProvider - the provider, null to clearprotected Date getEffectiveMinDate()
protected Date getEffectiveMaxDate()
protected void setGregorianValue(GregorianCalendar cal, int field, int value) throws ParseException
cal - the gregorian calendar objectfield - the field indexvalue - the valueParseException - if value out of bounds (if not lenient)protected int convert2DigitYearTo4DigitYear(int year2)
year2 - the 2-digit yearTentackle - a domain driven enterprise framework