DockContentsDataSource

Dockyard > Objective-C Classes > DockContentsDataSource

DockContentsDataSource

Class Description

Provides data for the dock contents table in Dockyard Manager. Also provides support for copy and paste, drag-and-drop, opening and revealing items, and undoing item operations.

Methods

- addItem:

- addItemWithURL:label:

- addItemsWithPaths:

- copy:

- copyPath:

- createDataForDock:

- cut:

- delete:

- dockItemInfoWithData:type:

- errorSheetEnded:returnCode:defaultsKey:

- labelForDockItemTileData:type:

- numberOfRowsInTableView:

- open:

- paste:

- pasteboard:provideDataForType:

- pathForDockItemTileData:type:

- reveal:

- selectedDock

- selectedItem

- setItems:inSet:ofDock:newSelection:prevSelection:

- setSelectedDock:

- tableOpen:

- tableView:acceptDrop:row:dropOperation:

- tableView:draggingSourceOperationMaskForLocal:

- tableView:objectValueForTableColumn:row:

- tableView:shouldSelectRow:

- tableView:validateDrop:proposedRow:proposedDropOperation:

- tableView:willDisplayCell:forTableColumn:row:

- tableView:writeRows:toPasteboard:

- tableView:writeRowsWithIndexes:toPasteboard:

- tableViewSelectionDidChange:

- typeForDockItemData:rawType:

- validateMenuItem:

Method Detail

addItem:

- (IBAction)addItem:(id)sender

Runs an open panel that allows the user to choose items to add to the selected dock.

See also: addItemsWithPaths:

addItemWithURL:label:

- (void)addItemWithURL:(NSURL *)url label:(NSString *)label

Adds the URL to the item set of the current dock, using `label` as the item's title.

See also: DockyardPreferences.addURL:withLabel:toDock:, addItemsWithPaths:

addItemsWithPaths:

- (void)addItemsWithPaths:(NSArray *)paths

Adds the items at `paths` to the selected docks, automatically figuring out which item set they belong to.

See also: DockyardPreferences.addItem:toSet:ofDock:, addItemWithURL:label:

copy:

- (IBAction)copy:(id)sender

Copies the currently selected item to the clipboard, in the form of a URL, a filename, its label, and its item type. If multiple items are being copied only the first URL will be put on the pasteboard.

See also: copyPath:, cut:, paste:

copyPath:

- (IBAction)copyPath:(id)sender

Copies the currently selected item to the clipboard, in the form of a URL, a filename, its path (not its label), and its item type. If multiple items are being copied only the first URL will be put on the pasteboard.

See also: copy:, cut:, paste:

createDataForDock:

- (NSArray *)createDataForDock:(NSString *)dockName

Creates an array of DockItemInfo objects, to be used as data when displaying `dockName`'s contents. Uses localized NSStrings to head each section: `@"Dock Applications"`, `@"Dock Items"`, and `@"Dashboard Widgets"`. If a section has no items in it, the header will not be displayed. If Dashboard switching is disabled, the widget section will not be displayed. If there ends up being no items in the Dock, a header cell will be displayed, saying `@"Empty Dock"`. This data will not be autoreleased.

cut:

- (IBAction)cut:(id)sender

Cuts the currently selected items by calling `copy:`, `delete:`.

See also: copy:, copyPath:, paste:

delete:

- (IBAction)delete:(id)sender

Deletes the currently selected items, unless the selected dock is the current dock.

See also: DockyardPreferences.removeItemsAtIndexes:fromSet:ofDock:

dockItemInfoWithData:type:

- (DockItemInfo *)dockItemInfoWithData:(NSDictionary *)itemData type:(enum DockyardItemType)itemType

This method takes the data of an item in a dock and creates an instance of DockItemInfo. The two attributes focused on are the label and path of the item (so it can be opened later) but these are taken from labelForDockItemData: and pathForDockItemData:.

errorSheetEnded:returnCode:defaultsKey:

- (void)errorSheetEnded:(NSWindow *)sheet returnCode:(int)returnCode defaultsKey:(NSString *)defaultsKey

Alerts the receiver that a warning sheet has been dismissed. If `returnCode` is `NSAlertAlternateReturn`, stores `NO` for `defaultsKey` in `DockyardPreferences`. In the future, `defaultsKey` should be checked to see if this dialog should be shown again. This method should never be invoked directly.

labelForDockItemTileData:type:

- (NSString *)labelForDockItemTileData:(NSDictionary *)itemData type:(enum DockyardItemType)itemType

Finds a label for the specified data by searching the item data for the value of "file-label" or "label". If neither is found, the display name of the program or file is returned.

numberOfRowsInTableView:

- (int)numberOfRowsInTableView:(NSTableView *)aTableView

Returns the number of rows in the table view at this time. If no dock is selected, there are zero rows. If there is a dock selected, the number of rows is equal to the number of items in the dock plus extra rows for headers (e.g., "Dock Applications"). If the user has Dashboard switching enabled, the widgets in this dock are also shown.

See also: tableView:objectForTableColumn:row:

open:

- (IBAction)open:(id)sender

Opens the selected item(s), using their default file associations. If the item is a URL, opens it using the user's default browser. If the item is a widget and the selected dock is the current one, merely opens the Dashboard, as opposed to adding the item once more.

See also: reveal:

paste:

- (IBAction)paste:(id)sender

Pastes the item(s) on the clipboard into the currently selected dock. Does not support pasting from outside of the application. This method automatically sorts pasted items into their proper item sets.

See also: copy:, copyPath:, cut:

pasteboard:provideDataForType:

- (void)pasteboard:(NSPasteboard *)pboard provideDataForType:(NSString *)type

Provides filename or URL data to `pboard` when requested.

pathForDockItemTileData:type:

- (NSString *)pathForDockItemTileData:(NSDictionary *)itemData type:(enum DockyardItemType)itemType

Finds the path of the given data by first looking for a file path, then URL data.

reveal:

- (IBAction)reveal:(id)sender

Reveals the currently selected item(s) in the Finder. If more than one item is a certain folder, only one of them will be selected.

See also: open:

selectedDock

- (NSString *)selectedDock

Returns the name of the currently selected dock. This is provided mainly for KVC completion and should not be used in code

See also: setSelectedDock:, DockManager.selectedDock

selectedItem

- (DockItemInfo *)selectedItem

Returns the cached info of the currently selected item. If more than one item is selected, or if no items are selected, returns `nil`.

setItems:inSet:ofDock:newSelection:prevSelection:

- (void)setItems:(NSArray *)items inSet:(enum DockyardItemSet)itemSet ofDock:(NSString *)dockName newSelection:(NSIndexSet *)rowIndexes prevSelection:(NSIndexSet *)prevIndexes

Sets the items in the given item set of the specified dock to `items`. This method is used for undo support and should never be called directly. Also updates the selection indexes of the tables to match what they were previously.

See also: DockyardPreferences.itemsInSet:ofDock:, DockyardPreferences.setItems:inSet:ofDock:

setSelectedDock:

- (void)setSelectedDock:(NSString *)newDock

Sets the selected dock to `newDock`. This is used in Cocoa Bindings, and should not be called directly. This will update the table view to reflect the contents of the newly selected dock. If more than one dock is selected, or if no dock is selected, the table is blank.

See also: selectedDock

tableOpen:

- (IBAction)tableOpen:(id)sender

Makes sure the row clicked in the table view was not one of the header cells (e.g., "Dock Applications") before calling `open:`.

See also: open:

tableView:acceptDrop:row:dropOperation:

- (BOOL)tableView:(NSTableView *)dragTable acceptDrop:(id <NSDraggingInfo>)info row:(int)row dropOperation:(NSTableViewDropOperation)operation

Accepts a drop from inside or outside the application. If the dragged item is a URL, adds it to the selected dock's item set. If the items are files, adds them to their respective item sets. If the drag is internal, and all of the items are from the same type, reorders the items.

See also: addItemsWithPaths:, addItemWithURL:label:, DockyardPreferences.moveItemsAtIndexes:toIndex:inSet:ofDock:

tableView:draggingSourceOperationMaskForLocal:

- (NSDragOperation)tableView:(NSTableView *)tableView draggingSourceOperationMaskForLocal:(BOOL)isLocal

Allows the table view to drag copies or links of its items outside of the application.

tableView:objectValueForTableColumn:row:

- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)row

Returns the object at the specified `row`. If there is no dock currently selected, returns `nil`.

See also: numberOfRowsInTableView:

tableView:shouldSelectRow:

- (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(int)row

Returns `YES` if the item at `row` is a dock item, `NO` if it is a header cell (e.g., "Dock Applications").

tableView:validateDrop:proposedRow:proposedDropOperation:

- (NSDragOperation)tableView:(NSTableView *)dragTable validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)operation

Decides whether or not to allow a drop. If no dock is selected, no drop is allowed. If it's an external drag, makes sure that it is files or a URL that is being dragged. If it's an internal drag, makes sure that all of the items are the same type.

tableView:willDisplayCell:forTableColumn:row:

- (void)tableView:(NSTableView *)aTableView willDisplayCell:(NSCell *)cell forTableColumn:(NSTableColumn *)aTableColumn row:(int)row

If the cell at `row` is a dock item (not a header), sets its icon and enables it. Otherwise, clears the icon and disables the cell.

tableView:writeRows:toPasteboard:

- (BOOL)tableView:(NSTableView *)tv writeRows:(NSArray *)rows toPasteboard:(NSPasteboard *)pboard

Provided for compatibility with 10.3 systems. Forwards the message to `tableView:writeRowsWithIndexes:toPasteboard:`.

Availability

Deprecated in 10.4

See also: tableView:writeRowsWithIndexes:toPasteboard:

tableView:writeRowsWithIndexes:toPasteboard:

- (BOOL)tableView:(NSTableView *)dragTable writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard

Starts a drag of the rows at `rowIndexes`. If the dragged rows are all of one type (applications, items, or widgets), they can be reordered within this dock. The rows can also be dragged anywhere that accepts a URL (`NSURLPboardType`; only the first row will be written), or a list of files (`NSFilenamesPboardType`).

tableViewSelectionDidChange:

- (void)tableViewSelectionDidChange:(NSNotification *)note

Updates the value of `selectedItem` to reflect the currently selected row.

See also: selectedItem

typeForDockItemData:rawType:

- (enum DockyardItemType)typeForDockItemData:(NSDictionary *)itemData rawType:(NSString *)rawType

Returns the item type for the given data, where `rawType` is in the form of a @"tile-type" string from the defaults domain com.apple.dock.

validateMenuItem:

- (BOOL)validateMenuItem:(NSMenuItem *)menuItem

Validates all item-related menu items by selector. This allows localization. Items that access dock data require that a dock is selected, as well as one or more items. Items that change the dock require that the selected dock is not the current dock.

This page was generated with DocYouMeant, a program created by Belkadan Software