Class CPDocumentController

CPObject
    extended byCPDocumentController

@implementation CPDocumentController : CPObject

This class is responsible for managing an application's open documents.


Method Summary
+(id)sharedDocumentController
          Returns the singleton instance of the application's document controller.
-(void)addDocument:(CPDocument)aDocument
          Adds aDocument under the control of the receiver.
-(Class)documentClassForType:(CPString)aType
          Returns the CPDocument subclass associated with aType.
-(CPDocument)documentForURL:(CPURL)aURL
          Returns the document matching the specified URL.
-(CPArray)documents
          Returns the array of all documents being managed.
-(CPDocument)makeDocumentForURL:(CPURL)anAbsoluteURL withContentsOfURL:(CPURL)absoluteContentsURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aSelector contextInfo:(id)aContextInfo
          Creates a document from the contents of a URL, and sets the document's URL location as another URL.
-(CPDocument)makeDocumentWithContentsOfURL:(CPURL)anAbsoluteURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aSelector contextInfo:(id)aContextInfo
          Creates a document from the contents at the specified URL.
-(CPDocument)makeUntitledDocumentOfType:(CPString)aType error:(CPError)anError
          Creates a document of the specified type.
-(CFAction)newDocument:(id)aSender
          Opens a new document in the application.
-(CPDocument)openDocumentWithContentsOfURL:(CPURL)anAbsoluteURL display:(BOOL)shouldDisplay error:(CPError)anError
          Opens the document at the specified URL.
-(void)openUntitledDocumentOfType:(CPString)aType display:(BOOL)shouldDisplay
          Creates a new document of the specified type.
-(void)removeDocument:(CPDocument)aDocument
          Removes aDocument from the control of the receiver.
-(CPDocument)reopenDocumentForURL:(CPURL)anAbsoluteURL withContentsOfURL:(CPURL)absoluteContentsURL error:(CPError)anError
          Loads a document for a specified URL with it's content retrieved from another URL.

Methods inherited from class CPObject
initialize, alloc, class, instanceMethodForSelector, instancesRespondToSelector, isSubclassOfClass, load, new, setVersion, superclass, version, init, autorelease, awakeAfterUsingCoder, class, classForCoder, classForKeyedArchiver, className, copy, dealloc, description, doesNotRecognizeSelector, forwardInvocation, hash, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableCopy, performSelector, performSelector, performSelector, release, replacementObjectForArchiver, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, retain, self, superclass


Method Detail

sharedDocumentController

+(id)sharedDocumentController
Returns the singleton instance of the application's document controller. If it has not been created yet, it will be created then returned.
Returns:
a CPDocumentController

addDocument

-(void)addDocument:(CPDocument)aDocument
Adds aDocument under the control of the receiver.
Parameters:
aDocument - the document to add

documentClassForType

-(Class)documentClassForType:(CPString)aType
Returns the CPDocument subclass associated with aType.
Parameters:
aType - the type of document
Returns:
a Cappuccino Class object, or nil if no match was found

documentForURL

-(CPDocument)documentForURL:(CPURL)aURL
Returns the document matching the specified URL. This method searches documents already open. It does not open the document at the URL if it is not already open.
Parameters:
aURL - the url of the document
Returns:
the document, or nil if such a document is not open

documents

-(CPArray)documents
Returns the array of all documents being managed. This is the same as all open documents in the application.

makeDocumentForURL

-(CPDocument)makeDocumentForURL:(CPURL)anAbsoluteURL withContentsOfURL:(CPURL)absoluteContentsURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aSelector contextInfo:(id)aContextInfo
Creates a document from the contents of a URL, and sets the document's URL location as another URL.
Parameters:
anAbsoluteURL - the document's location
absoluteContentsURL - the location of the document's contents
aType - the document's data type
aDelegate - receives a callback after the load has completed
aSelector - the selector to invoke for the callback
aContextInfo - an object passed as an argument for the callback
Returns:
a new document or nil if there was an error

makeDocumentWithContentsOfURL

-(CPDocument)makeDocumentWithContentsOfURL:(CPURL)anAbsoluteURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aSelector contextInfo:(id)aContextInfo
Creates a document from the contents at the specified URL. Notifies the provided delegate with the provided selector afterwards.
Parameters:
anAbsoluteURL - the location of the document data
aType - the document type
aDelegate - the delegate to notify
aSelector - the selector to notify with
aContextInfo - the context infomration passed to the delegate

makeUntitledDocumentOfType

-(CPDocument)makeUntitledDocumentOfType:(CPString)aType error:(CPError)anError
Creates a document of the specified type.
Parameters:
aType - the document type
anError - not used
Returns:
the created document

newDocument

-(CFAction)newDocument:(id)aSender
Opens a new document in the application.
Parameters:
aSender - the requesting object

openDocumentWithContentsOfURL

-(CPDocument)openDocumentWithContentsOfURL:(CPURL)anAbsoluteURL display:(BOOL)shouldDisplay error:(CPError)anError
Opens the document at the specified URL.
Parameters:
anAbsoluteURL - the path to the document's file
shouldDisplay - whether to display the document on screen
anError - not used
Returns:
the opened document

openUntitledDocumentOfType

-(void)openUntitledDocumentOfType:(CPString)aType display:(BOOL)shouldDisplay
Creates a new document of the specified type.
Parameters:
aType - the type of the new document
shouldDisplay - whether to display the document on screen

removeDocument

-(void)removeDocument:(CPDocument)aDocument
Removes aDocument from the control of the receiver.
Parameters:
aDocument - the document to remove

reopenDocumentForURL

-(CPDocument)reopenDocumentForURL:(CPURL)anAbsoluteURL withContentsOfURL:(CPURL)absoluteContentsURL error:(CPError)anError
Loads a document for a specified URL with it's content retrieved from another URL.
Parameters:
anAbsoluteURL - the document URL
absoluteContentsURL - the location of the document's contents
anError - not used
Returns:
the loaded document or nil if there was an error

Created on Sat Sep 13 14:15:43 PDT 2008