ETItemTemplate

Authors

Quentin Mathe (quentin.mathe@gmail.com)
A template to instantiate the right UI and model for a URL.

Copyright: (C) 2010 Quentin Mathe

Software documentation for the ETItemTemplate class

ETItemTemplate : ETUIObject

Declared in:
ETItemTemplate.h

A template that embeds both an item template and an object class template, and can build new items initialized with a represented object for a given URL.

ETItemTemplate allows to support various strategy to open or create documents or content units in collaboration with a client object e.g. a ETDocumentController instance.
Subclassing is possible to implement new strategies, but in many cases a new template with a particular UI and model combination should give you enough flexibility.

The client object invokes -newItemWithURL:options: to get a new instance. -newItemWithURL:options: in turn uses ETDocumentCreation to delegate the model initialization.

Method summary

templateWithItem: entityName: objectGraphContext: 

+ (id) templateWithItem: (ETLayoutItem*)anItem entityName: (NSString*)anEntityName objectGraphContext: (COObjectGraphContext*)aContext;

Returns a new autoreleased template based on the given item and entity name for the represented object.


templateWithItem: objectClass: objectGraphContext: 

+ (id) templateWithItem: (ETLayoutItem*)anItem objectClass: (Class)aClass objectGraphContext: (COObjectGraphContext*)aContext;

@taskunit Initialization

Returns a new autoreleased template based on the given item and represented object class.

Returns a new autoreleased template based on the given item and represented object class.


URLFromRunningSavePanel 

- (NSURL*) URLFromRunningSavePanel;
Description forthcoming.

allowsMultipleInstancesForURL: 

- (BOOL) allowsMultipleInstancesForURL: (NSURL*)aURL;
An empty method provided for subclasses to override.

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

By default, returns NO.

Can be overriden in a subclass to implement a web browser for example.


baseName 

- (NSString*) baseName;
Description forthcoming.

contentItem 

- (ETLayoutItem*) contentItem;
An empty method provided for subclasses to override.

Returns the item to which the represented object should be attached to.

By default, returns -item .

Can be overriden to return a descendant item.


entityName 

- (NSString*) entityName;

Returns the template entity name for the represented object. Can return Nil. See also -newItemWithURL:options: and -objectClassWithOptions: .


initWithItem: objectClass: entityName: objectGraphContext: 

- (id) initWithItem: (ETLayoutItem*)anItem objectClass: (Class)aClass entityName: (NSString*)anEntityName objectGraphContext: (COObjectGraphContext*)aContext;
This is a designated initialiser for the class.

Initializes and returns a new template based on the given item and represented object class (or entity name as an alternative).

You cannot provide both an object class and an entity name at the same time, at least one argument must be nil, otherwise an NSInvalidArgumentException is raised.

Raises an NSInvalidArgumentException if the item is nil.


item 

- (ETLayoutItem*) item;

Returns the template item.

See also -newItemWithRepresentedObject:options: .


nameFromBaseNameAndOptions: 

- (NSString*) nameFromBaseNameAndOptions: (NSDictionary*)options;
Description forthcoming.

newItemReadFromURL: options: 

- (ETLayoutItem*) newItemReadFromURL: (NSURL*)aURL options: (NSDictionary*)options;
Description forthcoming.

newItemWithRepresentedObject: URL: options: 

- (ETLayoutItem*) newItemWithRepresentedObject: (id)anObject URL: (NSURL*)aURL options: (NSDictionary*)options;
Description forthcoming.

newItemWithRepresentedObject: options: 

- (ETLayoutItem*) newItemWithRepresentedObject: (id)anObject options: (NSDictionary*)options;

Returns a new retained ETLayoutItem or ETLayoutItemGroup object with the given represented object and options.

The returned item is a copy of -item .
The represented object will be attached to a copy of -contentItem .

All arguments can be nil.

Can be overriden in subclasses.


newItemWithURL: options: 

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

Returns a new retained ETLayoutItem or ETLayoutItemGroup object for the given URL and options.

If -objectClassWithOptions: doesn't return Nil, a represented object is instantiated with -init or -initWithURL:options: if the object class conforms to ETDocumentCreation protocol. If the options includes kETTemplateOptionKeyValuePairKey, the new represented object is wrapped in a ETKeyValuePair object. The option value becomes the pair key.

If the given URL is nil, the user action is a 'New' and not 'Open'.

All arguments can be nil.

Can be overriden in subclasses.

See also -newItemWithRepresentedObject:options: .


objectClass 

- (Class) objectClass;

@taskunit Properties

Returns the represented object template class.

Can return Nil.

See also -newItemWithURL:options: and -objectClassWithOptions: .

Returns the represented object template class.

Can return Nil.

See also -newItemWithURL:options: and -objectClassWithOptions: .


objectClassWithOptions: 

- (Class) objectClassWithOptions: (NSDictionary*)options;
An empty method provided for subclasses to override.

@taskunit Template Instantiation