[browser setAllowsMultipleSelection:YES];
[browser setAllowsEmptySelection:YES];
[browser setAllowsTypeSelect:YES];
+ [browser setDoubleAction:@selector(browserDoubleAction:)];
moveNetworkQueue = [[ASINetworkQueue alloc] init];
moveNetworkQueue.shouldCancelAllRequestsOnFailure = NO;
}
#pragma mark -
+#pragma mark NSBrowser Actions
+
+- (void)browserDoubleAction:(id)sender {
+ NSInteger column = [browser clickedColumn];
+ NSInteger row = [browser clickedRow];
+ if ((column == -1) || (row == -1))
+ return;
+ NSIndexPath *clickedNodeIndexPath = [[browser indexPathForColumn:column] indexPathByAddingIndex:row];
+ NSArray *menuNodesIndexPaths = [browser selectionIndexPaths];
+ NSMutableArray *menuNodes = [NSMutableArray arrayWithCapacity:[menuNodesIndexPaths count]];
+ if ([menuNodesIndexPaths containsObject:clickedNodeIndexPath]) {
+ for (NSIndexPath *nodeIndexPath in menuNodesIndexPaths) {
+ [menuNodes addObject:[browser itemAtIndexPath:nodeIndexPath]];
+ }
+ } else {
+ [menuNodes addObject:[browser itemAtIndexPath:clickedNodeIndexPath]];
+ }
+ NSMenuItem *menuItem = [[[NSMenuItem alloc] init] autorelease];
+ menuItem.representedObject = menuNodes;
+ [self menuDownload:menuItem];
+}
+
+#pragma mark -
#pragma mark Drag and Drop methods
- (void)downloadNode:(PithosNode *)node toDirectory:(NSString *)dirPath withNewFileName:(NSString *)newFileName
NSInteger column = [browser clickedColumn];
NSInteger row = [browser clickedRow];
if ((column == -1) || (row == -1)) {
- // General context menu
- NSArray *menuNodesIndexPaths = [browser selectionIndexPaths];
- if ([menuNodesIndexPaths count] == 0) {
- menuNode = [browser parentForItemsInColumn:0];
- } else if (([menuNodesIndexPaths count] != 1) ||
- ([[browser itemAtIndexPath:[menuNodesIndexPaths objectAtIndex:0]] class] == [PithosObjectNode class])) {
- menuNode = [browser parentForItemsInColumn:([[menuNodesIndexPaths objectAtIndex:0] length] - 1)];
+ if (column == -1) {
+ // General context menu
+ NSArray *menuNodesIndexPaths = [browser selectionIndexPaths];
+ if ([menuNodesIndexPaths count] == 0) {
+ menuNode = [browser parentForItemsInColumn:0];
+ } else if (([menuNodesIndexPaths count] != 1) ||
+ ([[browser itemAtIndexPath:[menuNodesIndexPaths objectAtIndex:0]] class] == [PithosObjectNode class])) {
+ menuNode = [browser parentForItemsInColumn:([[menuNodesIndexPaths objectAtIndex:0] length] - 1)];
+ } else {
+ menuNode = [browser itemAtIndexPath:[menuNodesIndexPaths objectAtIndex:0]];
+ }
} else {
- menuNode = [browser itemAtIndexPath:[menuNodesIndexPaths objectAtIndex:0]];
+ menuNode = [browser parentForItemsInColumn:column];
+ if ([menuNode class] == [PithosObjectNode class]) {
+ // Node context menu
+ menuNodes = [NSMutableArray arrayWithObject:menuNode];
+ nodeContextMenu = YES;
+ }
+ // else
+ // General context menu
}
} else {
// Node context menu