org.argouml.uml.ui
Class UMLPlainTextDocument

java.lang.Object
  |
  +--javax.swing.text.AbstractDocument
        |
        +--javax.swing.text.PlainDocument
              |
              +--org.argouml.uml.ui.UMLPlainTextDocument
All Implemented Interfaces:
javax.swing.text.Document, java.util.EventListener, java.io.Serializable, TargetListener
Direct Known Subclasses:
UMLExtensionPointLocationDocument, UMLModelElementNameDocument, UMLModelElementTaggedValueDocument

public abstract class UMLPlainTextDocument
extends javax.swing.text.PlainDocument
implements 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

Field Summary
private  boolean _editing
          True if an user edits the document directly (by typing in text)
private  java.lang.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  java.lang.Object _target
          The target of the propertypanel that's behind this property.
static Logger cat
           
 
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(java.lang.String eventName)
          Constructor for UMLPlainTextDocument.
 
Method Summary
 java.lang.String getEventName()
          Returns the eventName.
protected abstract  java.lang.String getProperty()
           
 java.lang.Object getTarget()
          Returns the target.
private  void handleEvent()
           
 void insertString(int offset, java.lang.String str, javax.swing.text.AttributeSet a)
           
 boolean isEditing()
          Returns the editing.
private  boolean isFiring()
           
 void listRoleItemSet(MElementEvent e)
           
 void propertySet(MElementEvent e)
           
 void recovered(MElementEvent e)
           
 void remove(int offs, int len)
           
 void removed(MElementEvent e)
           
 void roleAdded(MElementEvent e)
           
 void roleRemoved(MElementEvent e)
           
 void setEditing(boolean editing)
          Sets the editing.
protected  void setEventName(java.lang.String eventName)
          Sets the eventName.
private  void setFiring(boolean firing)
           
protected abstract  void setProperty(java.lang.String text)
           
 void setTarget(java.lang.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

cat

public static Logger cat

_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)


_target

private java.lang.Object _target
The target of the propertypanel that's behind this property.


_eventName

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

Constructor Detail

UMLPlainTextDocument

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

Method Detail

propertySet

public void propertySet(MElementEvent e)
See Also:
ru.novosoft.uml.MElementListener#propertySet(ru.novosoft.uml.MElementEvent)

roleAdded

public void roleAdded(MElementEvent e)
See Also:
ru.novosoft.uml.MElementListener#roleAdded(ru.novosoft.uml.MElementEvent)

roleRemoved

public void roleRemoved(MElementEvent e)
See Also:
ru.novosoft.uml.MElementListener#roleRemoved(ru.novosoft.uml.MElementEvent)

listRoleItemSet

public void listRoleItemSet(MElementEvent e)
See Also:
ru.novosoft.uml.MElementListener#listRoleItemSet(ru.novosoft.uml.MElementEvent)

removed

public void removed(MElementEvent e)
See Also:
ru.novosoft.uml.MElementListener#removed(ru.novosoft.uml.MElementEvent)

recovered

public void recovered(MElementEvent e)
See Also:
ru.novosoft.uml.MElementListener#recovered(ru.novosoft.uml.MElementEvent)

getTarget

public final java.lang.Object getTarget()
Returns the target.

Returns:
Object

setTarget

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

Parameters:
target - The target to set

insertString

public void insertString(int offset,
                         java.lang.String str,
                         javax.swing.text.AttributeSet a)
                  throws javax.swing.text.BadLocationException
Specified by:
insertString in interface javax.swing.text.Document
Overrides:
insertString in class javax.swing.text.PlainDocument
javax.swing.text.BadLocationException
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
Specified by:
remove in interface javax.swing.text.Document
Overrides:
remove in class javax.swing.text.AbstractDocument
javax.swing.text.BadLocationException
See Also:
Document.remove(int, int)

setProperty

protected abstract void setProperty(java.lang.String text)

getProperty

protected abstract java.lang.String getProperty()

setFiring

private final void setFiring(boolean firing)

isFiring

private final boolean isFiring()

handleEvent

private final void handleEvent()

isEditing

public boolean isEditing()
Returns the editing.

Returns:
boolean

setEditing

public void setEditing(boolean editing)
Sets the editing.

Parameters:
editing - The editing to set

getEventName

public java.lang.String getEventName()
Returns the eventName.

Returns:
String

setEventName

protected void setEventName(java.lang.String eventName)
Sets the eventName.

Parameters:
eventName - 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 (20040306)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook