Joda System API

org.joda.swing.binder
Class PropertyPlainDocument

java.lang.Object
  |
  +--javax.swing.text.AbstractDocument
        |
        +--javax.swing.text.PlainDocument
              |
              +--org.joda.swing.binder.PropertyPlainDocument
All Implemented Interfaces:
javax.swing.text.Document, java.util.EventListener, JComponentBinder, java.beans.PropertyChangeListener, java.io.Serializable

public class PropertyPlainDocument
extends javax.swing.text.PlainDocument
implements java.beans.PropertyChangeListener, JComponentBinder

Swing document which binds to an property. Use of this model is best achieved by using SwingBinder.

This class can be used for both mutable and immutable properties. Immutable properties cannot be updated by the swing GUI, however they will update correctly if their value changes.

Author:
Stephen Colebourne
See Also:
Serialized Form

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
PropertyPlainDocument()
          Constructor
PropertyPlainDocument(javax.swing.text.JTextComponent textComp, DataProperty property)
          Constructor that binds to a particular property.
 
Method Summary
protected  void activate()
          Activate the connection between the GUI and the model
 void bind(javax.swing.JComponent component, Property property)
          Bind a Property object to the component.
protected  void deactivate()
          Deactivate the connection between the GUI and the model
 void insertString(int offs, java.lang.String str, javax.swing.text.AttributeSet attrs)
          Inserts some content into the document and updates the property.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Handle programmatic changes made to the property by updating the swing model.
 void remove(int offs, int len)
          Removes some content from the document and updates the property.
 void setActive(boolean active)
          Set the model to GUI binding as active or inactive
 
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

PropertyPlainDocument

public PropertyPlainDocument()
Constructor


PropertyPlainDocument

public PropertyPlainDocument(javax.swing.text.JTextComponent textComp,
                             DataProperty property)
Constructor that binds to a particular property.

Method Detail

insertString

public void insertString(int offs,
                         java.lang.String str,
                         javax.swing.text.AttributeSet attrs)
                  throws javax.swing.text.BadLocationException
Inserts some content into the document and updates the property.

Specified by:
insertString in interface javax.swing.text.Document
Overrides:
insertString in class javax.swing.text.PlainDocument
Parameters:
offs - the starting offset >= 0
str - the string to insert; does nothing with null/empty strings
Throws:
javax.swing.text.BadLocationException - the given insert position is not a valid position within the document
See Also:
Document.insertString(int, java.lang.String, javax.swing.text.AttributeSet)

remove

public void remove(int offs,
                   int len)
            throws javax.swing.text.BadLocationException
Removes some content from the document and updates the property.

Specified by:
remove in interface javax.swing.text.Document
Overrides:
remove in class javax.swing.text.AbstractDocument
Parameters:
offs - 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:
Document.remove(int, int)

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Handle programmatic changes made to the property by updating the swing model.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
event - the property change event

setActive

public void setActive(boolean active)
Set the model to GUI binding as active or inactive

Specified by:
setActive in interface JComponentBinder

activate

protected void activate()
Activate the connection between the GUI and the model


deactivate

protected void deactivate()
Deactivate the connection between the GUI and the model


bind

public void bind(javax.swing.JComponent component,
                 Property property)
Description copied from interface: JComponentBinder
Bind a Property object to the component.

Specified by:
bind in interface JComponentBinder
Parameters:
component - the component to bind
property - the property to bind to
See Also:
JComponentBinder.bind(JComponent,Property)

Joda System API

Copyright © 2001-2003 Stephen Colebourne. All Rights Reserved.