com.sdm.quasar.client.swing.ui.text
Class DateFilterDocument

java.lang.Object
  extended byjavax.swing.text.AbstractDocument
      extended byjavax.swing.text.PlainDocument
          extended bycom.sdm.quasar.client.swing.ui.text.DateFilterDocument
All Implemented Interfaces:
javax.swing.text.Document, java.io.Serializable

public class DateFilterDocument
extends javax.swing.text.PlainDocument

This Document formats a text while editing like a date with given date format.

Author:
Martin Haft
See Also:
Serialized Form

Nested Class Summary
 
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
 
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 javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Constructor Summary
DateFilterDocument()
          Constructs a JDateFieldFilter object with the default format
DateFilterDocument(int style, java.util.Locale locale)
          Constructs a JDateFieldFilter object with the format definde by a style and Locale, see DateFormat.getDateInstance(int, Locale)
DateFilterDocument(java.text.SimpleDateFormat aFormat)
          Constructs a JDateFieldFilter object with the given format.
DateFilterDocument(java.lang.String aFormat)
          Constructs a JDateFieldFilter object with the given format.
DateFilterDocument(java.lang.String aFormat, java.util.Locale locale)
          Constructs a JDateFieldFilter object with the given format.
 
Method Summary
 java.util.Date getDate()
          Gets the date property (java.util.Date) value.
 java.text.SimpleDateFormat getDateFormat()
           
 java.lang.String getFormat()
          Gets the format property (java.lang.String) value.
 void insertString(int offset, java.lang.String str, javax.swing.text.AttributeSet attr)
          Inserts some content into the document.
 boolean isDoBeep()
           
static void main(java.lang.String[] args)
           
 void remove(int offset, int len)
          Removes some content from the document.
 void setDate(java.util.Date date)
          Sets the date property (java.util.Date) value.
 void setDateFormat(java.text.SimpleDateFormat dateFormat)
           
 void setDoBeep(boolean doBeep)
           
 void setFormat(java.lang.String format)
          Sets the format property (java.lang.String) value.
 void setFormat(java.lang.String format, java.util.Locale locale)
          Sets the format property (java.lang.String) 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, 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
 

Constructor Detail

DateFilterDocument

public DateFilterDocument()
Constructs a JDateFieldFilter object with the default format


DateFilterDocument

public DateFilterDocument(int style,
                          java.util.Locale locale)
Constructs a JDateFieldFilter object with the format definde by a style and Locale, see DateFormat.getDateInstance(int, Locale)


DateFilterDocument

public DateFilterDocument(java.lang.String aFormat)
Constructs a JDateFieldFilter object with the given format.

Parameters:
aFormat - the date format pattern

DateFilterDocument

public DateFilterDocument(java.lang.String aFormat,
                          java.util.Locale locale)
Constructs a JDateFieldFilter object with the given format.

Parameters:
aFormat - the date format pattern

DateFilterDocument

public DateFilterDocument(java.text.SimpleDateFormat aFormat)
Constructs a JDateFieldFilter object with the given format.

Parameters:
aFormat - the date format
Method Detail

isDoBeep

public boolean isDoBeep()

setDoBeep

public void setDoBeep(boolean doBeep)

getDate

public java.util.Date getDate()
Gets the date property (java.util.Date) value.

Returns:
The date property value.
See Also:
setDate(java.util.Date)

getDateFormat

public java.text.SimpleDateFormat getDateFormat()

getFormat

public java.lang.String getFormat()
Gets the format property (java.lang.String) value.

Returns:
The format property value.
See Also:
setFormat(java.lang.String)

insertString

public void insertString(int offset,
                         java.lang.String str,
                         javax.swing.text.AttributeSet attr)
                  throws javax.swing.text.BadLocationException
Inserts some content into the document. Inserting content causes a write lock to be held while the actual changes are taking place, followed by notification to the observers on the thread that grabbed the write lock.

This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.

Parameters:
offset - the starting offset >= 0
str - the string to insert; does nothing with null/empty strings
attr - the attributes for the inserted content
Throws:
javax.swing.text.BadLocationException - the given insert position is not a valid position within the document
See Also:
AbstractDocument.insertString(int, java.lang.String, javax.swing.text.AttributeSet)

remove

public void remove(int offset,
                   int len)
            throws javax.swing.text.BadLocationException
Removes some content from the document. Removing content causes a write lock to be held while the actual changes are taking place. Observers are notified of the change on the thread that called this method.

This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.

Parameters:
offset - the starting offset >= 0
len - the number of characters to remove >= 0
Throws:
javax.swing.text.BadLocationException - the given remove position is not a valid position within the document
See Also:
AbstractDocument.remove(int, int)

setDate

public void setDate(java.util.Date date)
Sets the date property (java.util.Date) value.

Parameters:
date - The new value for the property.
See Also:
getDate()

setDateFormat

public void setDateFormat(java.text.SimpleDateFormat dateFormat)

setFormat

public void setFormat(java.lang.String format)
Sets the format property (java.lang.String) value.

Parameters:
format - The new value for the property.
See Also:
getFormat()

setFormat

public void setFormat(java.lang.String format,
                      java.util.Locale locale)
Sets the format property (java.lang.String) value.

Parameters:
format - The new value for the property.
See Also:
getFormat()

main

public static void main(java.lang.String[] args)