com.cburch.editor
Class DirtyTracker

java.lang.Object
  extended by com.cburch.editor.DirtyTracker

public class DirtyTracker
extends java.lang.Object

Tracks whether there have been any changes to a document.

Version:
0.1.1 2005-07-05
Author:
Carl Burch

Field Summary
static java.lang.String isDirtyProperty
          The property associated with the dirtiness currently tracked.
 
Constructor Summary
DirtyTracker(javax.swing.text.Document document)
          Constructs a tracker to determine when the document has changed.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
           
 boolean isDirty()
          Returns true if the document has changed since setDirty(false) was last called.
 boolean isEnabled()
          Returns true if this tracker is currently enabled.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
           
 void setDirty(boolean value)
          Sets the "dirtiness" state we use for the document.
 void setDocument(javax.swing.text.Document value)
          Sets the document that we are tracking.
 void setEnabled(boolean value)
          Enables or disables the tracking.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isDirtyProperty

public static final java.lang.String isDirtyProperty
The property associated with the dirtiness currently tracked.

See Also:
Constant Field Values
Constructor Detail

DirtyTracker

public DirtyTracker(javax.swing.text.Document document)
Constructs a tracker to determine when the document has changed.

Parameters:
document - the document we are to track.
Method Detail

isDirty

public boolean isDirty()
Returns true if the document has changed since setDirty(false) was last called.

Returns:
true if the document has changed.

setDirty

public void setDirty(boolean value)
Sets the "dirtiness" state we use for the document. This is most often used with an argument of false (perhaps when the user has saved the text).

Parameters:
value - the value to assign to the "dirtiness"

setDocument

public void setDocument(javax.swing.text.Document value)
Sets the document that we are tracking. This has no effect on whether this object thinks of the document as dirty; it maintains what we had before.

Parameters:
value - the document to track.

isEnabled

public boolean isEnabled()
Returns true if this tracker is currently enabled. It is enabled by default.

Returns:
true if the tracker is currently tracking the document for changes.

setEnabled

public void setEnabled(boolean value)
Enables or disables the tracking. This has no effect on what this object thinks of the document's "dirtiness."

Parameters:
value - true to enable this tracker, false to disable it.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener listener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener listener)