com.inet.html
Class InetHtmlDocument.ExtendedDocuementEvent

java.lang.Object
  extended by javax.swing.undo.AbstractUndoableEdit
      extended by javax.swing.undo.CompoundEdit
          extended by javax.swing.text.AbstractDocument.DefaultDocumentEvent
              extended by com.inet.html.InetHtmlDocument.ExtendedDocuementEvent
All Implemented Interfaces:
java.io.Serializable, javax.swing.event.DocumentEvent, javax.swing.undo.UndoableEdit
Enclosing class:
InetHtmlDocument

public class InetHtmlDocument.ExtendedDocuementEvent
extends javax.swing.text.AbstractDocument.DefaultDocumentEvent

Extends the DefaultDocumentEvent to support the update events by grouping the changes by paragraph element. This is required to avoid problems with the different structure of view and model.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface javax.swing.event.DocumentEvent
javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent.EventType
 
Constructor Summary
InetHtmlDocument.ExtendedDocuementEvent(int offs, int len, javax.swing.event.DocumentEvent.EventType type, InetHtmlDocument document)
          Generates a Document event.
InetHtmlDocument.ExtendedDocuementEvent(int offs, int len, int contentChangeLen, javax.swing.event.DocumentEvent.EventType type, InetHtmlDocument document)
          Generates a Document event.
InetHtmlDocument.ExtendedDocuementEvent(int offs, int len, int contentChangeStart, int contentChangeLen, javax.swing.event.DocumentEvent.EventType type, InetHtmlDocument document)
          Generates a Document event.
 
Method Summary
 boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
          
 java.util.ArrayList<javax.swing.undo.UndoableEdit> getAllChanges()
          Returns a list of all changes registered to this event
 java.util.ArrayList<javax.swing.event.DocumentEvent.ElementChange> getEditsFor(javax.swing.text.Element paragraph)
          Returns all edits for paragraph
 int getLength()
          
 int getOffset()
          
 int getStructureChangeLen()
          Returns the length of the structural change.
 int getStructureChangeStart()
          Returns the start of the structural change.
 javax.swing.event.DocumentEvent.EventType getType()
          
 boolean hasEditsFor(javax.swing.text.Element paragraph)
           
 void redo()
          
 void undo()
          
 
Methods inherited from class javax.swing.text.AbstractDocument.DefaultDocumentEvent
getChange, getDocument, getPresentationName, getRedoPresentationName, getUndoPresentationName, isSignificant, toString
 
Methods inherited from class javax.swing.undo.CompoundEdit
canRedo, canUndo, die, end, isInProgress
 
Methods inherited from class javax.swing.undo.AbstractUndoableEdit
replaceEdit
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InetHtmlDocument.ExtendedDocuementEvent

public InetHtmlDocument.ExtendedDocuementEvent(int offs,
                                               int len,
                                               javax.swing.event.DocumentEvent.EventType type,
                                               InetHtmlDocument document)
Generates a Document event.

Parameters:
offs - the offset into the document of the change >= 0
len - the length of the change >= 0
type - the type of event (DocumentEvent.EventType)
document - The enclosing document

InetHtmlDocument.ExtendedDocuementEvent

public InetHtmlDocument.ExtendedDocuementEvent(int offs,
                                               int len,
                                               int contentChangeLen,
                                               javax.swing.event.DocumentEvent.EventType type,
                                               InetHtmlDocument document)
Generates a Document event.

Parameters:
offs - the offset within the document where the structural change starts
len - the length of the change structural >= 0
contentChangeLen - the length of content added/removed
type - the type of event (DocumentEvent.EventType)
document - The enclosing document

InetHtmlDocument.ExtendedDocuementEvent

public InetHtmlDocument.ExtendedDocuementEvent(int offs,
                                               int len,
                                               int contentChangeStart,
                                               int contentChangeLen,
                                               javax.swing.event.DocumentEvent.EventType type,
                                               InetHtmlDocument document)
Generates a Document event.

Parameters:
offs - the offset within the document where the structural change starts
len - the length of the change structural >= 0
contentChangeStart - the length of content added/removed
contentChangeLen - the length of content added/removed
type - the type of event (DocumentEvent.EventType)
document - The enclosing document
Method Detail

getStructureChangeLen

public int getStructureChangeLen()
Returns the length of the structural change. If the content change length is not explicitly set, it returns the normal getLength()

Returns:
the structure or content change length

getStructureChangeStart

public int getStructureChangeStart()
Returns the start of the structural change. If the content start length is not explicitly set, it returns the normal getOffset()

Returns:
the structure or content change start

getLength

public int getLength()

Specified by:
getLength in interface javax.swing.event.DocumentEvent
Overrides:
getLength in class javax.swing.text.AbstractDocument.DefaultDocumentEvent

getOffset

public int getOffset()

Specified by:
getOffset in interface javax.swing.event.DocumentEvent
Overrides:
getOffset in class javax.swing.text.AbstractDocument.DefaultDocumentEvent

addEdit

public boolean addEdit(javax.swing.undo.UndoableEdit anEdit)

Specified by:
addEdit in interface javax.swing.undo.UndoableEdit
Overrides:
addEdit in class javax.swing.text.AbstractDocument.DefaultDocumentEvent

getAllChanges

public java.util.ArrayList<javax.swing.undo.UndoableEdit> getAllChanges()
Returns a list of all changes registered to this event

Returns:
a list of all changes registered to this event

hasEditsFor

public boolean hasEditsFor(javax.swing.text.Element paragraph)
Parameters:
paragraph - The paragraph to get the edits for
Returns:
true, if any element edits are registered for this paragraph

getEditsFor

public java.util.ArrayList<javax.swing.event.DocumentEvent.ElementChange> getEditsFor(javax.swing.text.Element paragraph)
Returns all edits for paragraph

Parameters:
paragraph - The paragraph to get the edits for
Returns:
all edits for paragraph or null if none were registered

getType

public javax.swing.event.DocumentEvent.EventType getType()

Specified by:
getType in interface javax.swing.event.DocumentEvent
Overrides:
getType in class javax.swing.text.AbstractDocument.DefaultDocumentEvent

undo

public void undo()
          throws javax.swing.undo.CannotUndoException

Specified by:
undo in interface javax.swing.undo.UndoableEdit
Overrides:
undo in class javax.swing.text.AbstractDocument.DefaultDocumentEvent
Throws:
javax.swing.undo.CannotUndoException

redo

public void redo()
          throws javax.swing.undo.CannotUndoException

Specified by:
redo in interface javax.swing.undo.UndoableEdit
Overrides:
redo in class javax.swing.text.AbstractDocument.DefaultDocumentEvent
Throws:
javax.swing.undo.CannotUndoException