org.argouml.uml.ui
Class UMLPlainTextDocument

java.lang.Object
  extended byjavax.swing.text.AbstractDocument
      extended byjavax.swing.text.PlainDocument
          extended byorg.argouml.uml.ui.UMLPlainTextDocument
All Implemented Interfaces:
Document, EventListener, PropertyChangeListener, Serializable, TargetListener
Direct Known Subclasses:
UMLDiagramNameDocument, UMLDiscriminatorNameDocument, UMLExtensionPointLocationDocument, UMLModelElementNameDocument, UMLModelElementTaggedValueDocument, UMLReceptionSpecificationDocument, UMLSynchStateBoundDocument

public abstract class UMLPlainTextDocument
extends PlainDocument
implements PropertyChangeListener, TargetListener

A new model for a textproperty. This model does not use reflection to reach its goal and will perform better therefore. Furthermore, it only reacts to events that are meant for this model which improves maintainability and performance.

Since:
Oct 6, 2002
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.text.AbstractDocument
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement
 
Field Summary
private  boolean editing
          True if an user edits the document directly (by typing in text)
private  String eventName
          The name of the property set event that will change the property this document shows.
private  boolean firing
          True if an event should be fired when the text of the document is changed
private static Logger LOG
           
private  Object panelTarget
          The target of the propertypanel that's behind this property.
 
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
UMLPlainTextDocument(String name)
          Constructor for UMLPlainTextDocument.
 
Method Summary
 String getEventName()
          Returns the eventName.
protected abstract  String getProperty()
           
 Object getTarget()
          Returns the target.
private  void handleEvent()
           
 void insertString(int offset, String str, AttributeSet a)
           
 boolean isEditing()
          Returns the editing.
private  boolean isFiring()
           
 void propertyChange(PropertyChangeEvent evt)
           
 void remove(int offs, int len)
           
 void setEditing(boolean ed)
          Sets the editing.
protected  void setEventName(String en)
          Sets the eventName.
private  void setFiring(boolean f)
           
protected abstract  void setProperty(String text)
           
 void setTarget(Object target)
          Sets the target.
 void targetAdded(TargetEvent e)
          Fired when a target is added to the list of targets.
 void targetRemoved(TargetEvent e)
          Fired when a target is removed from the list of targets
 void targetSet(TargetEvent e)
          Fired when a total new set of targets is set
 
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
 

Field Detail

LOG

private static final Logger LOG

firing

private boolean firing
True if an event should be fired when the text of the document is changed


editing

private boolean editing
True if an user edits the document directly (by typing in text)


panelTarget

private Object panelTarget
The target of the propertypanel that's behind this property.


eventName

private String eventName
The name of the property set event that will change the property this document shows.

Constructor Detail

UMLPlainTextDocument

public UMLPlainTextDocument(String name)
Constructor for UMLPlainTextDocument. This takes a panel to set the thirdpartyeventlistener to the given list of events to listen to.

Parameters:
name - the event
Method Detail

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener
See Also:
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)

getTarget

public final Object getTarget()
Returns the target.

Returns:
Object

setTarget

public final void setTarget(Object target)
Sets the target.

Parameters:
target - The target to set

insertString

public void insertString(int offset,
                         String str,
                         AttributeSet a)
                  throws BadLocationException
Specified by:
insertString in interface Document
Throws:
BadLocationException
See Also:
Document.insertString( int, java.lang.String, javax.swing.text.AttributeSet)

remove

public void remove(int offs,
                   int len)
            throws BadLocationException
Specified by:
remove in interface Document
Throws:
BadLocationException
See Also:
Document.remove(int, int)

setProperty

protected abstract void setProperty(String text)
Parameters:
text - the value of the property

getProperty

protected abstract String getProperty()
Returns:
the value of the property

setFiring

private final void setFiring(boolean f)

isFiring

private final boolean isFiring()

handleEvent

private final void handleEvent()

isEditing

public boolean isEditing()
Returns the editing.

Returns:
boolean

setEditing

public void setEditing(boolean ed)
Sets the editing.

Parameters:
ed - The editing to set

getEventName

public String getEventName()
Returns the eventName.

Returns:
String

setEventName

protected void setEventName(String en)
Sets the eventName.

Parameters:
en - The eventName to set

targetAdded

public void targetAdded(TargetEvent e)
Description copied from interface: TargetListener
Fired when a target is added to the list of targets.

Specified by:
targetAdded in interface TargetListener
Parameters:
e - The targetevent, name will be TARGET_ADDED
See Also:
TargetListener.targetAdded(org.argouml.ui.targetmanager.TargetEvent)

targetRemoved

public void targetRemoved(TargetEvent e)
Description copied from interface: TargetListener
Fired when a target is removed from the list of targets

Specified by:
targetRemoved in interface TargetListener
Parameters:
e - The targetevent, name will be TARGET_REMOVED
See Also:
TargetListener.targetRemoved(org.argouml.ui.targetmanager.TargetEvent)

targetSet

public void targetSet(TargetEvent e)
Description copied from interface: TargetListener
Fired when a total new set of targets is set

Specified by:
targetSet in interface TargetListener
Parameters:
e - The targetevent, name will be TARGET_SET
See Also:
TargetListener.targetSet(org.argouml.ui.targetmanager.TargetEvent)


ArgoUML © 1996-2004 (20050222)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook