Package de.sciss.app
Interface DocumentHandler
-
- All Known Implementing Classes:
AbstractDocumentHandler
public interface DocumentHandlerTheDocumentHandlerinterface describes an object that manages registration and unregistration of documents in a multi-document-environment.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddDocument(java.lang.Object source, Document doc)Adds a new document to the list of open documents.voidaddDocumentListener(DocumentListener l)Registeres a listener which will be informed about document handler actions such as adding or removing a document.DocumentgetActiveDocument()Determines the currently active document.DocumentgetDocument(int idx)Returns one of the open documents.intgetDocumentCount()Returns the number of open documentsbooleanisMultiDocumentApplication()Determines whether the underlying application handles more than a single open document or not.voidremoveDocument(java.lang.Object source, Document doc)Removes a document from the list of open documents.voidremoveDocumentListener(DocumentListener l)Unregisteres a listener who wishes to not be notified any more about document handler actions such as adding or removing a document.voidsetActiveDocument(java.lang.Object source, Document doc)Makes a document the active one.
-
-
-
Method Detail
-
isMultiDocumentApplication
boolean isMultiDocumentApplication()
Determines whether the underlying application handles more than a single open document or not.- Returns:
trueif the application allows more than one document to be opened at a time.falsefor a single-document-application.
-
getDocumentCount
int getDocumentCount()
Returns the number of open documents- Returns:
- the number of open documents
-
getDocument
Document getDocument(int idx)
Returns one of the open documents.- Parameters:
idx- the index of the document, ranging from0togetDocumentCount() - 1.- Returns:
- the requested document
- Throws:
java.lang.IndexOutOfBoundsException- ifidxis invalid
-
addDocument
void addDocument(java.lang.Object source, Document doc)Adds a new document to the list of open documents. ADocumentEventis generated and dispatched to all registered listeners. The caller is responsible for callingsetActiveDocumentseparately, if desired.- Parameters:
source- the source of the dispatchedDocumentEvent, ornullto not dispatch an event.doc- the document to add.- Throws:
java.lang.UnsupportedOperationException- if the caller tries to add a document when there is already one andisMultiDocumentApplicationreturnsfalse.java.lang.IllegalArgumentException- if the document has been added before- See Also:
isMultiDocumentApplication()
-
removeDocument
void removeDocument(java.lang.Object source, Document doc)Removes a document from the list of open documents. ADocumentEventis generated and dispatched to all registered listeners. This method will first callsetActiveDocument( null )if the removed document was the active document. After removing the document, this method will calldoc.dispose()to free resources occupied by the document.- Parameters:
source- the source of the dispatchedDocumentEvent, ornullto not dispatch an event.doc- the document to remove.- Throws:
java.lang.IllegalArgumentException- if the document was not in the list of known documents
-
setActiveDocument
void setActiveDocument(java.lang.Object source, Document doc)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. ADocumentEventis generated and dispatched to all registered listeners.- Parameters:
source- the source of the dispatchedDocumentEvent, ornullto not dispatch an event.doc- the document to make the active one, ornullto indicate that no document is active.- Throws:
java.lang.IllegalArgumentException- if the document is not in the list of known documents- See Also:
getActiveDocument()
-
getActiveDocument
Document getActiveDocument()
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.- Returns:
- the active document or
null, if there is none (this is the case when all documents have been removed) - See Also:
setActiveDocument( Object, Document )
-
addDocumentListener
void addDocumentListener(DocumentListener l)
Registeres a listener which will be informed about document handler actions such as adding or removing a document.- Parameters:
l- the listener to add- See Also:
removeDocumentListener( DocumentListener )
-
removeDocumentListener
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.- Parameters:
l- the listener to remove- See Also:
addDocumentListener( DocumentListener )
-
-