ETDocumentController
ETDocumentController : ETControllerOverview
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.
Querying Controller Content
- - (NSArray *) itemsForType: (ETUTI *)aUTI
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:] .
- - (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).
Insertion
- - (ETLayoutItem *) openItemWithURL: (NSURL *)aURL options: (NSDictionary *)options
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.
- - (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.
Type Determination
- + (ETUTI *) typeForURL: (NSURL *)aURL
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.
- - (ETUTI *) typeForWritingItem: (ETLayoutItem *)anItem
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.
Notifications
- - (void) didOpenDocumentItem: (ETLayoutItem *)anItem
- Description forthcoming.
- - (void) didCreateDocumentItem: (ETLayoutItem *)anItem
- Description forthcoming.
- - (void) willCloseDocumentItem: (ETLayoutItem *)anItem
- Description forthcoming.
Creation Actions
- - (IBAction) newDocument: (id)sender
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 .
Opening Actions
- - (IBAction) openDocument: (id)sender
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 ETDocumentCreationprotocol.
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 ETDocumentCreationprotocol.
