de.sciss.app
Class AbstractDocumentHandler

java.lang.Object
  extended by de.sciss.app.AbstractDocumentHandler
All Implemented Interfaces:
DocumentHandler, EventManager.Processor

public abstract class AbstractDocumentHandler
extends java.lang.Object
implements DocumentHandler, EventManager.Processor

A basic implementation of the DocumentHandler interface.

Version:
0.15, 02-Feb-06
Author:
Hanns Holger Rutz

Field Summary
protected  java.lang.Object sync
           
 
Constructor Summary
protected AbstractDocumentHandler(boolean isMDA)
           
 
Method Summary
 void addDocument(java.lang.Object source, Document doc)
          Adds a new document to the list of open documents.
 void addDocumentListener(DocumentListener l)
          Registeres a listener which will be informed about document handler actions such as adding or removing a document.
 Document getActiveDocument()
          Determines the currently active document.
 Document getDocument(int idx)
          Returns one of the open documents.
 int getDocumentCount()
          Returns the number of open documents
 boolean isMultiDocumentApplication()
          Determines whether the underlying application handles more than a single open document or not.
 void processEvent(BasicEvent e)
          This is called by the EventManager if new events are to be processed.
 void removeDocument(java.lang.Object source, Document doc)
          Removes a document from the list of open documents.
 void removeDocumentListener(DocumentListener l)
          Unregisteres a listener who wishes to not be notified any more about document handler actions such as adding or removing a document.
 void setActiveDocument(java.lang.Object source, Document doc)
          Makes a document the active one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sync

protected final java.lang.Object sync
Constructor Detail

AbstractDocumentHandler

protected AbstractDocumentHandler(boolean isMDA)
Method Detail

isMultiDocumentApplication

public boolean isMultiDocumentApplication()
Description copied from interface: DocumentHandler
Determines whether the underlying application handles more than a single open document or not.

Specified by:
isMultiDocumentApplication in interface DocumentHandler
Returns:
true if the application allows more than one document to be opened at a time. false for a single-document-application.

getDocumentCount

public int getDocumentCount()
Description copied from interface: DocumentHandler
Returns the number of open documents

Specified by:
getDocumentCount in interface DocumentHandler
Returns:
the number of open documents

getDocument

public Document getDocument(int idx)
Description copied from interface: DocumentHandler
Returns one of the open documents.

Specified by:
getDocument in interface DocumentHandler
Parameters:
idx - the index of the document, ranging from 0 to getDocumentCount() - 1.
Returns:
the requested document

addDocument

public void addDocument(java.lang.Object source,
                        Document doc)
Description copied from interface: DocumentHandler
Adds a new document to the list of open documents. A DocumentEvent is generated and dispatched to all registered listeners. The caller is responsible for calling setActiveDocument separately, if desired.

Specified by:
addDocument in interface DocumentHandler
Parameters:
source - the source of the dispatched DocumentEvent, or null to not dispatch an event.
doc - the document to add.
See Also:
DocumentHandler.isMultiDocumentApplication()

removeDocument

public void removeDocument(java.lang.Object source,
                           Document doc)
Description copied from interface: DocumentHandler
Removes a document from the list of open documents. A DocumentEvent is generated and dispatched to all registered listeners. This method will first call setActiveDocument( null ) if the removed document was the active document. After removing the document, this method will call doc.dispose() to free resources occupied by the document.

Specified by:
removeDocument in interface DocumentHandler
Parameters:
source - the source of the dispatched DocumentEvent, or null to not dispatch an event.
doc - the document to remove.

setActiveDocument

public void setActiveDocument(java.lang.Object source,
                              Document doc)
Description copied from interface: DocumentHandler
Makes a document the active one. The active document is the one whose data representation window has the focus, are more generally speaking, is the one who is affected by editing operations. A DocumentEvent is generated and dispatched to all registered listeners.

Specified by:
setActiveDocument in interface DocumentHandler
Parameters:
source - the source of the dispatched DocumentEvent, or null to not dispatch an event.
doc - the document to make the active one, or null to indicate that no document is active.
See Also:
DocumentHandler.getActiveDocument()

getActiveDocument

public Document getActiveDocument()
Description copied from interface: DocumentHandler
Determines the currently active document. The active document is the one whose data representation window has the focus, are more generally speaking, is the one who is affected by editing operations.

Specified by:
getActiveDocument in interface DocumentHandler
Returns:
the active document or null, if there is none (this is the case when all documents have been removed)
See Also:
DocumentHandler.setActiveDocument( Object, Document )

addDocumentListener

public void addDocumentListener(DocumentListener l)
Description copied from interface: DocumentHandler
Registeres a listener which will be informed about document handler actions such as adding or removing a document.

Specified by:
addDocumentListener in interface DocumentHandler
Parameters:
l - the listener to add
See Also:
DocumentHandler.removeDocumentListener( DocumentListener )

removeDocumentListener

public void removeDocumentListener(DocumentListener l)
Description copied from interface: DocumentHandler
Unregisteres a listener who wishes to not be notified any more about document handler actions such as adding or removing a document.

Specified by:
removeDocumentListener in interface DocumentHandler
Parameters:
l - the listener to remove
See Also:
DocumentHandler.addDocumentListener( DocumentListener )

processEvent

public void processEvent(BasicEvent e)
This is called by the EventManager if new events are to be processed.

Specified by:
processEvent in interface EventManager.Processor