de.esprit.appsuite.database.dbgui.field

## Class TimeSpanField

- java.lang.Object
- - java.awt.Component
  - - java.awt.Container
    - - javax.swing.JComponent
      - - javax.swing.JPanel
        - - de.esprit.common.gui.ZPanel
          - - de.esprit.common.gui.gridbag.GridBagPanel
            - - de.esprit.appsuite.database.dbgui.field.AbstractFieldContainer
              - - de.esprit.appsuite.database.dbgui.field.TimeSpanField

- All Implemented Interfaces:
    Field, GridBagConstants, Clearable, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

      public class TimeSpanField
      extends AbstractFieldContainer

  This field provides a means for timespan input. It's value is a Timestamp calculated rolling the given amount forward or backward from the given base timestamp. The default behavior is rolling back from the current time as the base timestamp.
  Author:
    Rainer Buesch
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class javax.swing.JPanel

      `javax.swing.JPanel.AccessibleJPanel`

    - ### Nested classes/interfaces inherited from class javax.swing.JComponent

      `javax.swing.JComponent.AccessibleJComponent`

    - ### Nested classes/interfaces inherited from class java.awt.Container

      `java.awt.Container.AccessibleAWTContainer`

    - ### Nested classes/interfaces inherited from class java.awt.Component

      `java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy`

  - ### Field Summary

    - ### Fields inherited from class javax.swing.JComponent

      `accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW`

    - ### Fields inherited from class java.awt.Component

      `BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

    - ### Fields inherited from interface de.esprit.common.gui.gridbag.GridBagConstants

      `BOTH, C, CENTER, E, EAST, HOR, HORIZONTAL, N, NE, NONE, NORTH, NORTHEAST, NORTHWEST, NW, REM, REMAINDER, S, SE, SOUTH, SOUTHEAST, SOUTHWEST, SW, VER, VERTICAL, W, WEST`

    - ### Fields inherited from interface java.awt.image.ImageObserver

      `ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TimeSpanField(NlsDatabaseKey nls)`
    `TimeSpanField(NlsDatabaseKey nls, int length)`
    `TimeSpanField(NlsDatabaseKey nls, int length, boolean isNotNull)`
    `TimeSpanField(NlsDatabaseKey nls, int length, boolean isNotNull, java.util.EnumSet<TimeSpan> values)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Clears the content
    `protected javax.swing.text.Document` | `createDefaultModel()`
    `protected AbstractFieldDialog` | `createEditor()`
    `java.sql.Timestamp` | `createValue()` Creates the input Object typically from the textual String input.
    `int` | `getAmount()`
    `java.sql.Timestamp` | `getBaseTimestamp()`
    `protected IconKey` | `getEditorIcon()`
    `IntegerField` | `getField()` Returns a reference to the contained field.
    `java.lang.String` | `getStringValue()` Returns the field value as a String - or an empty String if the field is empty.
    `TimeSpan` | `getTimeSpan()`
    `java.sql.Timestamp` | `getValue()` Returns the field value as an Object - or null if the field is empty.
    `IntegerField` | `getWidget()` Returns a JComponent that represents the layoutable GUI component.
    `boolean` | `inputEquals(boolean b)` Tests if the field input is equal to the given boolean value.
    `boolean` | `inputEquals(double d)` Tests if the field input is equal to the given double number.
    `boolean` | `inputEquals(int i)` Tests if the field input is equal to the given int number.
    `boolean` | `inputEquals(java.lang.Object obj)` Tests if the field input is equal to the given object.
    `boolean` | `isRollForward()`
    `void` | `setAmount(int value)`
    `void` | `setLocked(boolean isLocked)` Locks the field for editing.
    `void` | `setReferenceTimestamp(java.sql.Timestamp baseTs)` Defines from where on the resulting timestamp is calculated.
    `void` | `setRollForward(boolean isForward)` Defines whether the resulting timestamp is calculated in the future or the past.
    `void` | `setTimeSpan(TimeSpan second)`
    `void` | `setValue(java.lang.Object obj)` Setting a Timestamp value sets the timespan choice to the next appropriate time unit and the value field to the number of units.
    `java.lang.String` | `toString(java.lang.Object tsObj)` Converts the object to a String according to the policy of the affected field component.
    `java.lang.Long` | `toValue(java.lang.Object o)` Tries to convert any object value to the target data type of this field.

    - ### Methods inherited from class de.esprit.appsuite.database.dbgui.field.AbstractFieldContainer

      `getActionOpenEditor, getFieldDialog, getJLabel, getLabel, getName, getNlsKey, getUnitComponent, isEmpty, isLocked, isNotNull, isPrimaryKey, isRecordTypeField, isStretchableX, isStretchableY, setInsertDefaultValue, setModifyFlag, setNotNull, setPrimaryKey, setStretchableX, setStretchableY, setUnitComponent, setUnitString, toString`

    - ### Methods inherited from class de.esprit.common.gui.gridbag.GridBagPanel

      `alignFirstColumnsInSubPanels, getDefaultInsets, getFirstColumnMaxWidth, horizontalStretch, place, place, place, place, place, place, place, setDefaultInsets, setFirstColumnWidth, stretchX, stretchY, verticalStretch`

    - ### Methods inherited from class de.esprit.common.gui.ZPanel

      `addBorder, contains, getTileIcon, insertBorder, paintComponent, setTileIcon, setTileIcon, setTitledBorder`

    - ### Methods inherited from class javax.swing.JPanel

      `getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI`

    - ### Methods inherited from class javax.swing.JComponent

      `addAncestorListener, 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, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update`

    - ### Methods inherited from class java.awt.Container

      `add, 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, validateTree`

    - ### Methods inherited from class java.awt.Component

      `action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, 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, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, 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, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### TimeSpanField

          public TimeSpanField(NlsDatabaseKey nls)

    - #### TimeSpanField

          public TimeSpanField(NlsDatabaseKey nls,
                       int length)

    - #### TimeSpanField

          public TimeSpanField(NlsDatabaseKey nls,
                       int length,
                       boolean isNotNull)

    - #### TimeSpanField

          public TimeSpanField(NlsDatabaseKey nls,
                       int length,
                       boolean isNotNull,
                       java.util.EnumSet<TimeSpan> values)

  - ### Method Detail

    - #### getField

          public IntegerField getField()

      Description copied from class: `AbstractFieldContainer`
      Returns a reference to the contained field.
      Overrides:
        `getField` in class `AbstractFieldContainer`

    - #### getWidget

          public IntegerField getWidget()

      Description copied from interface: `Field`
      Returns a JComponent that represents the layoutable GUI component.
      Specified by:
        `getWidget` in interface `Field`
      Overrides:
        `getWidget` in class `AbstractFieldContainer`

    - #### setAmount

          public void setAmount(int value)

    - #### getAmount

          public int getAmount()

    - #### getTimeSpan

          public TimeSpan getTimeSpan()

    - #### setTimeSpan

          public void setTimeSpan(TimeSpan second)

    - #### createEditor

          protected AbstractFieldDialog createEditor()

      Specified by:
        `createEditor` in class `AbstractFieldContainer`

    - #### getEditorIcon

          protected IconKey getEditorIcon()

      Specified by:
        `getEditorIcon` in class `AbstractFieldContainer`

    - #### createDefaultModel

          protected javax.swing.text.Document createDefaultModel()

    - #### createValue

          public java.sql.Timestamp createValue()
                                         throws InvalidFieldInputException

      Description copied from interface: `Field`
      Creates the input Object typically from the textual String input.
      Specified by:
        `createValue` in interface `Field`
      Overrides:
        `createValue` in class `AbstractFieldContainer`
      Throws:
        `InvalidFieldInputException` - If the input Object cannot be created due to a parsing error.

    - #### setLocked

          public void setLocked(boolean isLocked)

      Description copied from interface: `Field`
      Locks the field for editing.
      Specified by:
        `setLocked` in interface `Field`
      Overrides:
        `setLocked` in class `AbstractFieldContainer`

    - #### setValue

          public void setValue(java.lang.Object obj)

      Setting a Timestamp value sets the timespan choice to the next appropriate time unit and the value field to the number of units. Note that this field cannot store the precise interval value but an approximate value only rounded on the time unit.

      Note also that the the field does not store whether the Timestamp is in the future or in the past.

      Specified by:
        `setValue` in interface `Field`
      Overrides:
        `setValue` in class `AbstractFieldContainer`
      See Also:
        `setRollForward(boolean)`

    - #### clear

          public void clear()

      Description copied from interface: `Clearable`
      Clears the content
      Specified by:
        `clear` in interface `Clearable`
      Overrides:
        `clear` in class `AbstractFieldContainer`

    - #### setReferenceTimestamp

          public void setReferenceTimestamp(java.sql.Timestamp baseTs)

      Defines from where on the resulting timestamp is calculated. If no base timestamp is given then the current time is used.

    - #### getBaseTimestamp

          public java.sql.Timestamp getBaseTimestamp()

    - #### setRollForward

          public void setRollForward(boolean isForward)

      Defines whether the resulting timestamp is calculated in the future or the past. Default is a timepoint in the future.

    - #### isRollForward

          public boolean isRollForward()

    - #### toString

          public java.lang.String toString(java.lang.Object tsObj)

      Description copied from interface: `Field`
      Converts the object to a String according to the policy of the affected field component. This is important for DecimalField and DateField which eventually use localized strings. Note that this method must return an empty string if the object cannot be parsed.
      Specified by:
        `toString` in interface `Field`
      Overrides:
        `toString` in class `AbstractFieldContainer`

    - #### getValue

          public java.sql.Timestamp getValue()

      Description copied from interface: `Field`
      Returns the field value as an Object - or null if the field is empty.
      Specified by:
        `getValue` in interface `Field`
      Overrides:
        `getValue` in class `AbstractFieldContainer`

    - #### getStringValue

          public java.lang.String getStringValue()

      Description copied from interface: `Field`
      Returns the field value as a String - or an empty String if the field is empty.
      Specified by:
        `getStringValue` in interface `Field`
      Overrides:
        `getStringValue` in class `AbstractFieldContainer`

    - #### inputEquals

          public boolean inputEquals(java.lang.Object obj)

      Description copied from interface: `Field`
      Tests if the field input is equal to the given object.
      Specified by:
        `inputEquals` in interface `Field`
      Overrides:
        `inputEquals` in class `AbstractFieldContainer`

    - #### inputEquals

          public boolean inputEquals(int i)

      Description copied from interface: `Field`
      Tests if the field input is equal to the given int number.
      Specified by:
        `inputEquals` in interface `Field`
      Overrides:
        `inputEquals` in class `AbstractFieldContainer`

    - #### inputEquals

          public boolean inputEquals(double d)

      Description copied from interface: `Field`
      Tests if the field input is equal to the given double number.
      Specified by:
        `inputEquals` in interface `Field`
      Overrides:
        `inputEquals` in class `AbstractFieldContainer`

    - #### inputEquals

          public boolean inputEquals(boolean b)

      Description copied from interface: `Field`
      Tests if the field input is equal to the given boolean value.
      Specified by:
        `inputEquals` in interface `Field`
      Overrides:
        `inputEquals` in class `AbstractFieldContainer`

    - #### toValue

          public java.lang.Long toValue(java.lang.Object o)

      Description copied from interface: `Field`
      Tries to convert any object value to the target data type of this field. An `IllegalArgumentException` is thrown when the type is not supported by the field.
      Specified by:
        `toValue` in interface `Field`
      Overrides:
        `toValue` in class `AbstractFieldContainer`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.