Plugin Delegate
A Plugin Delegate is a class which acts somewhat like a subclass of a plug-in object ... except that it really responds only to certain methods, and is thus not quite an arbitrary subclass. Thanks to key-value binding, it's not really that limiting; you can have arbitrary setter and getter methods to access properties.
These are methods defined in KTAbstractPluginDelegate that you can call from your code:
- (NSBundle *)bundle;- Bundle of your component, usually used for fetching resources
- (KTMediaManager *)mediaManager;- For Media operations
- (NSUndoManager *)undoManager;- For undo support
- (id)delegateOwner;- The actual component object that this delegate serves. e.g. a KTPage or KTPagelet object.
- (KTPage *)page;- A reference to the containing page, regardless of whether the element is a delegate for a page or pagelet.
- (BOOL)documentIsPublishing;- Whether or not the page is being generated for publishing the document (as opposed to previewing it)
These are methods in a plug-in delegate that you can override:
- (void)awakeFromBundleAsNewlyCreatedObject:(BOOL)isNewObject;- Initialization for your component
- (void)awakeFromDragWithDictionary:(NSDictionary *)aDictionary;- For population of your component from a dictionary of properties that may be of use
- (BOOL)validatePluginValue:(id *)ioValue forKeyPath:(NSString *)inKeyPath error:(NSError **)outError;- This is called by our delegateOwner whenever it is asked to validate something. By default we always accept the value; the subclass can override this.
- (void)setDelegateOwner:(id)plugin- The accessor method user by Sandvox to store the delegate owner. You can override this method to add or remove observation of the delegate owner, but you must always call super's implementation.
- (void)plugin:(KTAbstractElement *)plugin didSetValue:(id)value forPluginKey:(NSString *)key oldValue:(id)oldValue;- Called at the end of every
-setValue:forKey:message sent to the delegate owner. Useful for knowing when to update one of your plug-in's properties after another is edited. This method is not called during undo or redo operations. - (NSSet *)requiredMediaIdentifiers- Override to return a set of the identifiers of all the KTMediaContainer objects your plug-in currently needs to function.
Pasteboard Creation Support
+ (NSArray *)supportedPasteboardTypes
+ (unsigned)numberOfItemsFoundOnPasteboard:(NSPasteboard *)sender
+ (KTSourcePriority)priorityForItemOnPasteboard:(NSPasteboard *)pboard atIndex:(unsigned)dragIndex;
+ (BOOL)populateDataSourceDictionary:(NSMutableDictionary *)aDictionary
fromPasteboard:(NSPasteboard *)pasteboard
atIndex:(unsigned)dragIndex
Data Migration from older Sandvox 1.2.x documents. You probably won't need to implemenent these:
- (BOOL)importPluginProperties:(NSDictionary *)oldPluginProperties fromPlugin:(NSManagedObject *)oldPlugin error:(NSError **)error
A delegate may also optionally implement:
- - (void) findMinimumDocType:(void *)aDocTypePointer forPage:(KTPage *)aPage
- - (void) addPageTextToHead:(NSMutableString *)aString forPage:(KTPage *)aPage
- - (void)addResourcesToSet:(NSMutableSet *)aSet forPage:(KTPage *)aPage
- - (void)addCSSFilePathToSet:(NSMutableSet *)aSet forPage:(KTPage *)aPage
- - (void) addLevelTextToEndBody:(NSMutableString *)aString forPage:(KTPage *)aPage
- - (void) addSitewideTextToEndBody:(NSMutableString *)aString forPage:(KTPage *)aPage
