ETDocumentController

Authors

Quentin Mathe (quentin.mathe@gmail.com)
A controller to manage a collection of documents.

Copyright: (C) 2010 Quentin Mathe

Software documentation for the ETDocumentController class

ETDocumentController : ETController

Declared in:
ETDocumentController.h

ETDocumentController provides a generic editor/viewer controller to manage the items getting edited or viewed, where each item represents a content unit (a web page, an image, a mail, a compound document etc.).
A content unit is usually a document.

ETDocumentController might include unrelated items in its content. For example, the controller bound to -[ETLayoutItemFactory windowGroup] will include non-document windows such as inspectors, palettes etc. when other windows are visible. You can use -documentItems to retrieve the items marked as document. See also -itemForTypes: and itemsForURL: to retrieve a document. For the AppKit backend, it is designed as a NSDocumentController replacement. Unlike NSDocumentController, it can manage multiple documents at any level of the UI, in the sense it doesn't require to have a window per document, and support NSController rich behavior (pick and drop, sorting, filtering, nib integration etc.) without having to resort to another API.

Method summary

typeForURL: 

+ (ETUTI*) typeForURL: (NSURL*)aURL;

@taskunit Type Determination

Returns the UTI that describes the content at the given URL.

Will call -[ETUTI typeWithPath:] to determine the type, can be overriden to implement a tailored behavior.

Returns the UTI that describes the content at the given URL.

Will call -[ETUTI typeWithPath:] to determine the type, can be overriden to implement a tailored behavior.


activeItem 

- (id) activeItem;
Description forthcoming.

allowsMultipleInstancesForURL: 

- (BOOL) allowsMultipleInstancesForURL: (NSURL*)aURL;

Returns whether the same document can appear multiple times on screen for the given URL.

By default, tries to find a template that matches the content type at the given URL and delegates -allowsMultipleInstancesForURL: to it. If no template can be found, returns NO.

You should usually override -[ETItemTemplate allowsMultipleInstancesForURL:] and not this method.


browseDocumentHistory: 

- (IBAction) browseDocumentHistory: (id)sender;
Description forthcoming.

close: 

- (IBAction) close: (id)sender;

@taskunit Other Actions


didCreateDocumentItem: 

- (void) didCreateDocumentItem: (ETLayoutItem*)anItem;
Description forthcoming.

didOpenDocumentItem: 

- (void) didOpenDocumentItem: (ETLayoutItem*)anItem;

@taskunit Notifications


documentItems 

- (NSArray*) documentItems;
Description forthcoming.

error 

- (NSError*) error;

@taskunit Error Reporting

Returns the last error that was reported to the receiver.

Returns the last error that was reported to the receiver.


exportDocument: 

- (IBAction) exportDocument: (id)sender;
Description forthcoming.

itemsForType: 

- (NSArray*) itemsForType: (ETUTI*)aUTI;

@taskunit Querying Controller Content

Returns the items that match the given UTI in the receiver content.

Each item subtype must conform to the given type to be matched.

See -[ETLayoutItem subtype] and -[ETUTI conformsToType:].

Returns the items that match the given UTI in the receiver content.

Each item subtype must conform to the given type to be matched.

See -[ETLayoutItem subtype] and -[ETUTI conformsToType:].


itemsForURL: 

- (NSArray*) itemsForURL: (NSURL*)aURL;

Returns the items that match the given URL in the receiver content.

Either the item or its represented object must have a URL property to be matched.

The returned array usually contains a single item, unless the application allows to open multiple instances of the same document (e.g. a web browser).


markDocumentVersion: 

- (IBAction) markDocumentVersion: (id)sender;
Description forthcoming.

newDocument: 

- (IBAction) newDocument: (id)sender;

@taskunit Creation Actions

Creates a new object of the current object type and adds it to the receiver content.

Will call -newInstanceWithURL:ofType:options: to create the new document.

See also -currentObjectType .

Creates a new object of the current object type and adds it to the receiver content.

Will call -newInstanceWithURL:ofType:options: to create the new document.

See also -currentObjectType .


newDocumentCopy: 

- (IBAction) newDocumentCopy: (id)sender;
Description forthcoming.

newDocumentFromTemplate: 

- (IBAction) newDocumentFromTemplate: (id)sender;
Description forthcoming.

numberOfUntitledDocuments 

- (NSUInteger) numberOfUntitledDocuments;
Description forthcoming.

openDocument: 

- (IBAction) openDocument: (id)sender;

@taskunit Opening Actions

Creates one or more objects with the URLs the user has choosen in an open panel and adds them to the receiver content.

Will call -openInstanceWithURL:options: to open the document(s).

See also ETDocumentCreation protocol.

Creates one or more objects with the URLs the user has choosen in an open panel and adds them to the receiver content.

Will call -openInstanceWithURL:options: to open the document(s).

See also ETDocumentCreation protocol.


openItemWithURL: options: 

- (ETLayoutItem*) openItemWithURL: (NSURL*)aURL options: (NSDictionary*)options;

@taskunit Insertion

Returns a retained ETLayoutItem or ETLayoutItemGroup object that presents the content at the given URL.

This method doesn't create the returned item but delegates that to -[ETItemTemplate newItemReadFromURL:options:].

This method is used by -openDocument: action to generate the object to be inserted into the content of the controller.
You must use this method in any 'open' action methods to open a content unit and mutate the controller content.

See -allowsMultipleInstancesForURL: to enable repopening a content unit already opened.

The returned object is retained.

Raises a NSInvalidArgumentException if the given URL is nil.

Returns a retained ETLayoutItem or ETLayoutItemGroup object that presents the content at the given URL.

This method doesn't create the returned item but delegates that to -[ETItemTemplate newItemReadFromURL:options:].

This method is used by -openDocument: action to generate the object to be inserted into the content of the controller.
You must use this method in any 'open' action methods to open a content unit and mutate the controller content.

See -allowsMultipleInstancesForURL: to enable repopening a content unit already opened.

The returned object is retained.

Raises a NSInvalidArgumentException if the given URL is nil.


openSelection: 

- (IBAction) openSelection: (id)sender;
Description forthcoming.

revertDocumentTo: 

- (IBAction) revertDocumentTo: (id)sender;
Description forthcoming.

saveDocument: 

- (IBAction) saveDocument: (id)sender;

@taskunit History Actions


showDocumentInfos: 

- (IBAction) showDocumentInfos: (id)sender;
Description forthcoming.

typeForWritingItem: 

- (ETUTI*) typeForWritingItem: (ETLayoutItem*)anItem;
An empty method provided for subclasses to override.

Returns the UTI that describes the item (or its content) to be saved or written.

The returned UTI is used to look up the template to which the writing/saving is delegated.

By default, returns the item represented object UTI, otherwise the item UTI.


willCloseDocumentItem: 

- (void) willCloseDocumentItem: (ETLayoutItem*)anItem;
Description forthcoming.