diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-03-21 22:17:50 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-03-21 22:17:50 +0000 |
commit | b5cabd449156acaf18815759ee4cc5383e8fa4f6 (patch) | |
tree | 7e1c0c01cb8c86fb7dba26abf4c0b7a582d0a20f /Source/CMTextView.m | |
parent | 919f4705fc4d4e59133e4279a1e87dc432e12f2d (diff) | |
download | sequelpro-b5cabd449156acaf18815759ee4cc5383e8fa4f6.tar.gz sequelpro-b5cabd449156acaf18815759ee4cc5383e8fa4f6.tar.bz2 sequelpro-b5cabd449156acaf18815759ee4cc5383e8fa4f6.zip |
• Navigator
- added 'sync' mode - the navigator follows the active window db/table selection if navigator has not multiple selected items
- added drag support of selected items
-- as comma separated and backtick quoted string for external apps
-- as array of schema paths for SP
• CMTextView
- added drop support for selected items coming from the Navigator
- insert them as comma list relative to current selected db/table
Diffstat (limited to 'Source/CMTextView.m')
-rw-r--r-- | Source/CMTextView.m | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m index 6d6befc8..2a5c43c7 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -3056,6 +3056,44 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) } return YES; } + + // Insert selected items coming from the Navigator + if ( [[pboard types] containsObject:@"SPDragFromNavigatorPboardType"] ) { + NSPoint draggingLocation = [sender draggingLocation]; + draggingLocation = [self convertPoint:draggingLocation fromView:nil]; + NSUInteger characterIndex = [self characterIndexOfPoint:draggingLocation]; + [self setSelectedRange:NSMakeRange(characterIndex,0)]; + + NSKeyedUnarchiver *unarchiver = [[[NSKeyedUnarchiver alloc] initForReadingWithData:[pboard dataForType:@"SPDragFromNavigatorPboardType"]] autorelease]; + NSArray *draggedItems = [[NSArray alloc] initWithArray:(NSArray *)[unarchiver decodeObjectForKey:@"itemdata"]]; + [unarchiver finishDecoding]; + + NSMutableString *dragString = [NSMutableString string]; + NSMutableString *aPath = [NSMutableString string]; + + NSString *currentDb = nil; + NSString *currentTable = nil; + + if ([[[[self window] delegate] valueForKeyPath:@"tablesListInstance"] valueForKey:@"selectedDatabase"] != nil) + currentDb = [[[[self window] delegate] valueForKeyPath:@"tablesListInstance"] valueForKeyPath:@"selectedDatabase"]; + if ([[[[self window] delegate] valueForKeyPath:@"tablesListInstance"] valueForKey:@"tableName"] != nil) + currentTable = [[[[self window] delegate] valueForKeyPath:@"tablesListInstance"] valueForKeyPath:@"tableName"]; + + if(!currentDb) currentDb = @""; + if(!currentTable) currentTable = @""; + + for(NSString* item in draggedItems) { + if([dragString length]) [dragString appendString:@", "]; + [aPath setString:item]; + // Insert path relative to the current selected db and table if any + [aPath replaceOccurrencesOfRegex:[NSString stringWithFormat:@"^%@%@", currentDb, SPUniqueSchemaDelimiter] withString:@""]; + [aPath replaceOccurrencesOfRegex:[NSString stringWithFormat:@"^%@%@", currentTable, SPUniqueSchemaDelimiter] withString:@""]; + [dragString appendString:[[aPath componentsSeparatedByString:SPUniqueSchemaDelimiter] componentsJoinedByPeriodAndBacktickQuoted]]; + } + [self breakUndoCoalescing]; + [self insertText:dragString]; + return YES; + } return [super performDragOperation:sender]; } |