diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-08-13 13:11:07 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-08-13 13:11:07 +0000 |
commit | efdcfb17f87863fef42f209f72eb4c4ccd888d35 (patch) | |
tree | 91e9f02badaba1b3e00b1988508d462937c56049 /Source/SPNavigatorController.m | |
parent | 1b2508ed0b5489ec2abe1dd148d1a208bf67bd40 (diff) | |
download | sequelpro-efdcfb17f87863fef42f209f72eb4c4ccd888d35.tar.gz sequelpro-efdcfb17f87863fef42f209f72eb4c4ccd888d35.tar.bz2 sequelpro-efdcfb17f87863fef42f209f72eb4c4ccd888d35.zip |
• fixed bug while closing a tab to remove the connection from Navigator
• FIRST implementation to allow to drag a table from the Navigator to the connection window's table list to copy this table with content (it works but needs to be improved!)
Diffstat (limited to 'Source/SPNavigatorController.m')
-rw-r--r-- | Source/SPNavigatorController.m | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m index 191e7043..3ce8a090 100644 --- a/Source/SPNavigatorController.m +++ b/Source/SPNavigatorController.m @@ -37,6 +37,7 @@ static SPNavigatorController *sharedNavigatorController = nil; #define DragFromNavigatorPboardType @"SPDragFromNavigatorPboardType" +#define DragTableDataFromNavigatorPboardType @"SPDragTableDataFromNavigatorPboardType" @implementation SPNavigatorController @@ -131,7 +132,7 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte prefs = [NSUserDefaults standardUserDefaults]; [self setWindowFrameAutosaveName:@"SPNavigator"]; - [outlineSchema2 registerForDraggedTypes:[NSArray arrayWithObjects:DragFromNavigatorPboardType, NSStringPboardType, nil]]; + [outlineSchema2 registerForDraggedTypes:[NSArray arrayWithObjects:DragTableDataFromNavigatorPboardType, DragFromNavigatorPboardType, NSStringPboardType, nil]]; [outlineSchema2 setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES]; [outlineSchema2 setDraggingSourceOperationMask:NSDragOperationEvery forLocal:NO]; @@ -1082,7 +1083,7 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard { // Provide data for our custom type, and simple NSStrings. - [pboard declareTypes:[NSArray arrayWithObjects:DragFromNavigatorPboardType, NSStringPboardType, nil] owner:self]; + [pboard declareTypes:[NSArray arrayWithObjects:DragTableDataFromNavigatorPboardType, DragFromNavigatorPboardType, NSStringPboardType, nil] owner:self]; // Collect the actual schema paths without leading connection ID NSMutableArray *draggedItems = [NSMutableArray array]; @@ -1101,6 +1102,16 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte [archiver finishEncoding]; [pboard setData:arraydata forType:DragFromNavigatorPboardType]; + if([draggedItems count] == 1) { + NSArray *pathComponents = [[draggedItems objectAtIndex:0] componentsSeparatedByString:SPUniqueSchemaDelimiter]; + // Is a table? + if([pathComponents count] == 2) { + [pboard setString:[NSString stringWithFormat:@"CREATE TABLE IF NOT EXISTS %@ SELECT * FROM %@", + [[pathComponents lastObject] backtickQuotedString], + [pathComponents componentsJoinedByPeriodAndBacktickQuoted] + ] forType:DragTableDataFromNavigatorPboardType]; + } + } // For external destinations provide a comma separated string NSMutableString *dragString = [NSMutableString string]; for(id item in draggedItems) { |