- (BOOL)browser:(NSBrowser *)aBrowser writeRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column
toPasteboard:(NSPasteboard *)pasteboard {
NSMutableArray *propertyList = [NSMutableArray arrayWithCapacity:[rowIndexes count]];
- NSIndexPath *baseIndexPath = [browser indexPathForColumn:column];
- for (NSUInteger i = [rowIndexes firstIndex]; i <= [rowIndexes lastIndex]; i = [rowIndexes indexGreaterThanIndex:i]) {
- PithosNode *node = [browser itemAtIndexPath:[baseIndexPath indexPathByAddingIndex:i]];
+ NSIndexPath *baseIndexPath = [browser indexPathForColumn:column];
+ [rowIndexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop){
+ PithosNode *node = [browser itemAtIndexPath:[baseIndexPath indexPathByAddingIndex:idx]];
[propertyList addObject:[node.pithosObject.name pathExtension]];
- }
+ }];
[pasteboard declareTypes:[NSArray arrayWithObject:NSFilesPromisePboardType] owner:self];
[pasteboard setPropertyList:propertyList forType:NSFilesPromisePboardType];
- (NSArray *)browser:(NSBrowser *)aBrowser namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column {
NSMutableArray *names = [NSMutableArray arrayWithCapacity:[rowIndexes count]];
- NSIndexPath *baseIndexPath = [browser indexPathForColumn:column];
- for (NSUInteger i = [rowIndexes firstIndex]; i <= [rowIndexes lastIndex]; i = [rowIndexes indexGreaterThanIndex:i]) {
- PithosNode *node = [browser itemAtIndexPath:[baseIndexPath indexPathByAddingIndex:i]];
+ NSIndexPath *baseIndexPath = [browser indexPathForColumn:column];
+ [rowIndexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop){
+ PithosNode *node = [browser itemAtIndexPath:[baseIndexPath indexPathByAddingIndex:idx]];
// If the node is a subdir ask if the whole tree should be downloaded
if ([node class] == [PithosSubdirNode class]) {
[objectRequest startAsynchronous];
}
}
- }
+ }];
return names;
}
return 220;
}
+- (CGFloat)splitView:(NSSplitView *)splitView constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)dividerIndex {
+ if (proposedPosition < 120)
+ return 120;
+ else if (proposedPosition > 220)
+ return 220;
+ else
+ return proposedPosition;
+}
+
#pragma mark -
#pragma mark NSOutlineViewDelegate
if ((column == -1) || (row == -1)) {
// General context menu
} else {
+ NSIndexPath *clickedNodeIndexPath = [[browser indexPathForColumn:column] indexPathByAddingIndex:row];
+ NSArray *menuNodesIndexPaths = [browser selectionIndexPaths];
+ if (![menuNodesIndexPaths containsObject:clickedNodeIndexPath])
+ menuNodesIndexPaths = [NSArray arrayWithObject:clickedNodeIndexPath];
+
// Move to Trash (pithos container only)
// Delete
if ([rootNode class] == [PithosContainerNode class]) {
if ([rootNode.pithosContainer.name isEqualToString:@"pithos"]) {
menuItem = [[[NSMenuItem alloc] initWithTitle:@"Move to Trash" action:@selector(moveToTrash:) keyEquivalent:@""] autorelease];
- [menuItem setRepresentedObject:[browser itemAtRow:row inColumn:column]];
+ [menuItem setRepresentedObject:menuNodesIndexPaths];
[menu addItem:menuItem];
}
menuItem = [[[NSMenuItem alloc] initWithTitle:@"Delete" action:@selector(deleteObject:) keyEquivalent:@""] autorelease];
- [menuItem setRepresentedObject:[browser itemAtRow:row inColumn:column]];
+ [menuItem setRepresentedObject:menuNodesIndexPaths];
[menu addItem:menuItem];
[menu addItem:[NSMenuItem separatorItem]];
}
// Get Info
menuItem = [[[NSMenuItem alloc] initWithTitle:@"Get Info" action:@selector(getInfo:) keyEquivalent:@""] autorelease];
- [menuItem setRepresentedObject:[browser itemAtRow:row inColumn:column]];
+ [menuItem setRepresentedObject:menuNodesIndexPaths];
[menu addItem:menuItem];
}
}
#pragma mark Menu Actions
- (void)getInfo:(NSMenuItem *)sender {
- [(PithosNode *)[sender representedObject] showPithosNodeInfo:sender];
+ for (NSIndexPath *nodeIndexPath in ((NSArray *)[sender representedObject])) {
+ PithosNode *node = [browser itemAtIndexPath:nodeIndexPath];
+ [node showPithosNodeInfo:sender];
+ }
}
- (void)deleteObject:(NSMenuItem *)sender {
- PithosNode *node = (PithosNode *)[sender representedObject];
- if (([node class] == [PithosObjectNode class]) ||
- (([node class] == [PithosSubdirNode class]) &&
- !node.pithosObject.subdir &&
- [node.pithosObject.name hasSuffix:@"/"])) {
- ASIPithosObjectRequest *objectRequest = [ASIPithosObjectRequest deleteObjectRequestWithContainerName:node.pithosContainer.name
- objectName:node.pithosObject.name];
- objectRequest.delegate = self;
- objectRequest.didFinishSelector = @selector(deleteObjectFinished:);
- objectRequest.didFailSelector = @selector(deleteObjectFailed:);
- [objectRequest startAsynchronous];
- } else if ([node class] == [PithosSubdirNode class]) {
- NSArray *objectRequests = [PithosFileUtilities deleteObjectRequestsForSubdirWithContainerName:node.pithosContainer.name
- objectName:node.pithosObject.name];
- if (objectRequests) {
- for (ASIPithosObjectRequest *objectRequest in objectRequests) {
- objectRequest.delegate = self;
- objectRequest.didFinishSelector = @selector(deleteObjectFinished:);
- objectRequest.didFailSelector = @selector(deleteObjectFailed:);
- [objectRequest startAsynchronous];
- }
- }
-
- }
-}
-
-- (void)moveToTrash:(NSMenuItem *)sender {
- PithosNode *node = (PithosNode *)[sender representedObject];
- if (([node class] == [PithosObjectNode class]) ||
- (([node class] == [PithosSubdirNode class]) &&
- !node.pithosObject.subdir &&
- [node.pithosObject.name hasSuffix:@"/"])) {
- NSString *safeObjectName = [PithosFileUtilities safeObjectNameForContainerName:@"trash"
- objectName:node.pithosObject.name];
- if (safeObjectName) {
- ASIPithosObjectRequest *objectRequest = [ASIPithosObjectRequest moveObjectDataRequestWithContainerName:node.pithosContainer.name
- objectName:node.pithosObject.name
- contentType:nil
- contentEncoding:nil
- contentDisposition:nil
- manifest:nil
- sharing:nil
- isPublic:ASIPithosObjectRequestPublicIgnore
- metadata:nil
- destinationContainerName:@"trash"
- destinationObjectName:safeObjectName];
+ for (NSIndexPath *nodeIndexPath in ((NSArray *)[sender representedObject])) {
+ PithosNode *node = [browser itemAtIndexPath:nodeIndexPath];
+ if (([node class] == [PithosObjectNode class]) ||
+ (([node class] == [PithosSubdirNode class]) &&
+ !node.pithosObject.subdir &&
+ [node.pithosObject.name hasSuffix:@"/"])) {
+ ASIPithosObjectRequest *objectRequest = [ASIPithosObjectRequest deleteObjectRequestWithContainerName:node.pithosContainer.name
+ objectName:node.pithosObject.name];
objectRequest.delegate = self;
- objectRequest.didFinishSelector = @selector(moveToTrashFinished:);
- objectRequest.didFailSelector = @selector(moveToTrashFailed:);
+ objectRequest.didFinishSelector = @selector(deleteObjectFinished:);
+ objectRequest.didFailSelector = @selector(deleteObjectFailed:);
[objectRequest startAsynchronous];
- }
- } else if ([node class] == [PithosSubdirNode class]) {
- NSString *safeObjectName = [PithosFileUtilities safeSubdirNameForContainerName:@"trash"
- subdirName:node.pithosObject.name];
- if (safeObjectName) {
- NSArray *objectRequests = [PithosFileUtilities moveObjectRequestsForSubdirWithContainerName:node.pithosContainer.name
- objectName:node.pithosObject.name
- destinationContainerName:@"trash"
- destinationObjectName:safeObjectName];
+ } else if ([node class] == [PithosSubdirNode class]) {
+ NSArray *objectRequests = [PithosFileUtilities deleteObjectRequestsForSubdirWithContainerName:node.pithosContainer.name
+ objectName:node.pithosObject.name];
if (objectRequests) {
for (ASIPithosObjectRequest *objectRequest in objectRequests) {
objectRequest.delegate = self;
- objectRequest.didFinishSelector = @selector(moveToTrashFinished:);
- objectRequest.didFailSelector = @selector(moveToTrashFailed:);
+ objectRequest.didFinishSelector = @selector(deleteObjectFinished:);
+ objectRequest.didFailSelector = @selector(deleteObjectFailed:);
[objectRequest startAsynchronous];
}
}
- }
+
+ }
+ }
+}
+
+- (void)moveToTrash:(NSMenuItem *)sender {
+ for (NSIndexPath *nodeIndexPath in ((NSArray *)[sender representedObject])) {
+ PithosNode *node = [browser itemAtIndexPath:nodeIndexPath];
+ if (([node class] == [PithosObjectNode class]) ||
+ (([node class] == [PithosSubdirNode class]) &&
+ !node.pithosObject.subdir &&
+ [node.pithosObject.name hasSuffix:@"/"])) {
+ NSString *safeObjectName = [PithosFileUtilities safeObjectNameForContainerName:@"trash"
+ objectName:node.pithosObject.name];
+ if (safeObjectName) {
+ ASIPithosObjectRequest *objectRequest = [ASIPithosObjectRequest moveObjectDataRequestWithContainerName:node.pithosContainer.name
+ objectName:node.pithosObject.name
+ contentType:nil
+ contentEncoding:nil
+ contentDisposition:nil
+ manifest:nil
+ sharing:nil
+ isPublic:ASIPithosObjectRequestPublicIgnore
+ metadata:nil
+ destinationContainerName:@"trash"
+ destinationObjectName:safeObjectName];
+ objectRequest.delegate = self;
+ objectRequest.didFinishSelector = @selector(moveToTrashFinished:);
+ objectRequest.didFailSelector = @selector(moveToTrashFailed:);
+ [objectRequest startAsynchronous];
+ }
+ } else if ([node class] == [PithosSubdirNode class]) {
+ NSString *safeObjectName = [PithosFileUtilities safeSubdirNameForContainerName:@"trash"
+ subdirName:node.pithosObject.name];
+ if (safeObjectName) {
+ NSArray *objectRequests = [PithosFileUtilities moveObjectRequestsForSubdirWithContainerName:node.pithosContainer.name
+ objectName:node.pithosObject.name
+ destinationContainerName:@"trash"
+ destinationObjectName:safeObjectName];
+ if (objectRequests) {
+ for (ASIPithosObjectRequest *objectRequest in objectRequests) {
+ objectRequest.delegate = self;
+ objectRequest.didFinishSelector = @selector(moveToTrashFinished:);
+ objectRequest.didFailSelector = @selector(moveToTrashFailed:);
+ [objectRequest startAsynchronous];
+ }
+ }
+ }
+ }
}
}