de.sciss.app
Class DocumentEvent

java.lang.Object
  extended by java.util.EventObject
      extended by de.sciss.app.BasicEvent
          extended by de.sciss.app.DocumentEvent
All Implemented Interfaces:
java.io.Serializable

public class DocumentEvent
extends BasicEvent

This kind of event is fired from a DocumentHandler when a document as been created, destroyed or switched.

Version:
0.17, 18-Mar-08
Author:
Hanns Holger Rutz
See Also:
DocumentHandler.addDocumentListener( DocumentListener ), DocumentHandler, Document, Serialized Form

Field Summary
static int ADDED
          returned by getID() : the document has been added
static int FOCUSSED
          returned by getID() : the document has become the active document
static int REMOVED
          returned by getID() : the document has been removed
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
DocumentEvent(java.lang.Object source, int ID, long when, Document doc)
          Constructs a new DocumentEvent
 
Method Summary
 Document getDocument()
          Queries the related document
 boolean incorporate(BasicEvent oldEvent)
          Asks the event to incorporate the action described by another (older) event.
 
Methods inherited from class de.sciss.app.BasicEvent
getID, getWhen
 
Methods inherited from class java.util.EventObject
getSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ADDED

public static final int ADDED
returned by getID() : the document has been added

See Also:
Constant Field Values

REMOVED

public static final int REMOVED
returned by getID() : the document has been removed

See Also:
Constant Field Values

FOCUSSED

public static final int FOCUSSED
returned by getID() : the document has become the active document

See Also:
Constant Field Values
Constructor Detail

DocumentEvent

public DocumentEvent(java.lang.Object source,
                     int ID,
                     long when,
                     Document doc)
Constructs a new DocumentEvent

Parameters:
source - who originated the action
ID - ADDED, REMOVED, or FOCUSSED
when - system time when the event occured
doc - the related document
Method Detail

getDocument

public Document getDocument()
Queries the related document

Returns:
the document which was added, removed or focussed.

incorporate

public boolean incorporate(BasicEvent oldEvent)
Description copied from class: BasicEvent
Asks the event to incorporate the action described by another (older) event. This method has been created to reduce overhead; when many events are added to the event queue of an ELM, this allows to fuse two adjectant events. The idea is mainly based on the replaceEdit() method of the javax.swing.undo.UndoableEdit interface; a pendant of a symmetric addEdit() like method is not provided because it seems to be unnecessary.

Implementation notes : the oldEvent should generally only be incorporated if it refers to the same source object (getSource()) and has the same ID (getD()). the timestamp of the current event should not be modified.

Specified by:
incorporate in class BasicEvent
Parameters:
oldEvent - the most recent event in the queue which might be incorporated by this new event.
Returns:
true if this object was able to incorporate the older event. in this case the oldEvent is removed from the event queue. false states that the oldEvent was incompatible and should remain in the queue.
See Also:
UndoableEdit.replaceEdit( UndoableEdit )