Ontimize 5.2072EN

com.ontimize.gui.field.document
Class DateDocument

java.lang.Object
  extended byjavax.swing.text.AbstractDocument
      extended byjavax.swing.text.PlainDocument
          extended bycom.ontimize.gui.field.document.DateDocument
All Implemented Interfaces:
javax.swing.text.Document, Internationalization, java.io.Serializable
Direct Known Subclasses:
AdvancedDateDocument, HourDateDocument

public class DateDocument
extends javax.swing.text.PlainDocument
implements Internationalization

This document implements the model for managing dates in a JTextField

See Also:
Serialized Form

Nested Class Summary
protected static class DateDocument.DateFormatCache
           
protected static class DateDocument.DateFormatCacheKey
           
 
Nested classes inherited from class javax.swing.text.AbstractDocument
javax.swing.text.AbstractDocument.AbstractElement, javax.swing.text.AbstractDocument.AttributeContext, javax.swing.text.AbstractDocument.BranchElement, javax.swing.text.AbstractDocument.Content, javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AbstractDocument.ElementEdit, javax.swing.text.AbstractDocument.LeafElement
 
Field Summary
protected  java.util.Date currentDate
           
protected  java.sql.Timestamp currentTimestamp
           
protected  java.text.SimpleDateFormat dateFormat
           
protected  java.lang.String datePattern
           
static boolean DEBUG
           
protected static java.util.Locale defaultLocale
           
protected static java.text.SimpleDateFormat dfConstructor
           
protected  java.util.Date insertedDate
           
protected  java.util.Locale locale
           
 
Fields inherited from class javax.swing.text.PlainDocument
lineLimitAttribute, tabSizeAttribute
 
Fields inherited from class javax.swing.text.AbstractDocument
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName
 
Fields inherited from interface com.ontimize.gui.i18n.Internationalization
DEBUG_LANGUAGE
 
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Constructor Summary
DateDocument()
           
 
Method Summary
protected  void buildPattern()
           
 void format()
           
 java.util.Date getDate()
           
 java.lang.String getDatePattern()
           
 java.text.SimpleDateFormat getFormat()
           
 java.util.Vector getTextsToTranslate()
          Returns all the texts in the element suitable for being translated.
 java.sql.Timestamp getTimestampValue()
           
protected  java.sql.Timestamp getTimestampValue(java.lang.String date)
           
 void insertString(int offset, java.lang.String sValue, javax.swing.text.AttributeSet attributes)
          Date pattern is known:
- Non numeric characters are allowed.
protected  void insertStringWithoutCheck(int offset, java.lang.String sValue, javax.swing.text.AttributeSet attributes)
           
 boolean isValid()
           
protected  boolean isValid(java.lang.String date)
           
 void setComponentLocale(java.util.Locale l)
           
 void setDatePattern(java.lang.String newPattern)
           
 void setResourceBundle(java.util.ResourceBundle resources)
          Sets the language resource bundle.
 void setValue(java.util.Date value)
           
 
Methods inherited from class javax.swing.text.PlainDocument
createDefaultRoot, getDefaultRootElement, getParagraphElement, insertUpdate, removeUpdate
 
Methods inherited from class javax.swing.text.AbstractDocument
addDocumentListener, addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, remove, removeDocumentListener, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG

dfConstructor

protected static java.text.SimpleDateFormat dfConstructor

defaultLocale

protected static java.util.Locale defaultLocale

dateFormat

protected java.text.SimpleDateFormat dateFormat

datePattern

protected java.lang.String datePattern

insertedDate

protected java.util.Date insertedDate

currentDate

protected java.util.Date currentDate

currentTimestamp

protected java.sql.Timestamp currentTimestamp

locale

protected java.util.Locale locale
Constructor Detail

DateDocument

public DateDocument()
Method Detail

setValue

public void setValue(java.util.Date value)

getTimestampValue

public java.sql.Timestamp getTimestampValue()

getFormat

public java.text.SimpleDateFormat getFormat()

format

public void format()

buildPattern

protected void buildPattern()

setDatePattern

public void setDatePattern(java.lang.String newPattern)

getDatePattern

public java.lang.String getDatePattern()

getDate

public java.util.Date getDate()

isValid

public boolean isValid()

getTimestampValue

protected java.sql.Timestamp getTimestampValue(java.lang.String date)

isValid

protected boolean isValid(java.lang.String date)

insertString

public void insertString(int offset,
                         java.lang.String sValue,
                         javax.swing.text.AttributeSet attributes)
                  throws javax.swing.text.BadLocationException
Date pattern is known:
- Non numeric characters are allowed.
- Year field has 4 characters (9999 maximum).
- Month and day fields have 2 characters. The maximum value for day is 31 and for month 12. An the minimum value for both is 1.
- When a value is introduced in field, this one is checked and text will be showed in red color until that the value is a correct date. Moreover, field value is also checked when field losts focus or ENTER key is pressed.
- Separator for dates is /. So a valid format date could be: 12/12/2008

Specified by:
insertString in interface javax.swing.text.Document
Throws:
javax.swing.text.BadLocationException

insertStringWithoutCheck

protected void insertStringWithoutCheck(int offset,
                                        java.lang.String sValue,
                                        javax.swing.text.AttributeSet attributes)
                                 throws javax.swing.text.BadLocationException
Throws:
javax.swing.text.BadLocationException

getTextsToTranslate

public java.util.Vector getTextsToTranslate()
Description copied from interface: Internationalization
Returns all the texts in the element suitable for being translated.

Specified by:
getTextsToTranslate in interface Internationalization
Returns:
all the texts in the element suitable for being translated.

setResourceBundle

public void setResourceBundle(java.util.ResourceBundle resources)
Description copied from interface: Internationalization
Sets the language resource bundle. When the application changes the configured language, for all the objects that implement this interface this method must be called with the new file.
The method must translate all the elements that have texts in the GUI

Specified by:
setResourceBundle in interface Internationalization
Parameters:
resources - the new language bundle.

setComponentLocale

public void setComponentLocale(java.util.Locale l)
Specified by:
setComponentLocale in interface Internationalization

Ontimize