diff options
Diffstat (limited to 'Source/SPTablesList.m')
-rw-r--r-- | Source/SPTablesList.m | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index 9e74e9d2..60961e98 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -1555,7 +1555,7 @@ [(ImageAndTextCell*)aCell setIndentationLevel:0]; } else { [(ImageAndTextCell*)aCell setIndentationLevel:1]; - [(ImageAndTextCell*)aCell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [(ImageAndTextCell*)aCell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } } else { [(ImageAndTextCell*)aCell setImage:nil]; @@ -1571,6 +1571,40 @@ return (row == 0) ? 25 : 17; } +- (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id <NSDraggingInfo>)info row:(NSInteger)row dropOperation:(NSTableViewDropOperation)operation +{ + NSPasteboard *pboard = [info draggingPasteboard]; + + // tables were dropped coming from the Navigator + if ( [[pboard types] containsObject:@"SPDragTableDataFromNavigatorPboardType"] ) { + NSString *query = [pboard stringForType:@"SPDragTableDataFromNavigatorPboardType"]; + if(!query) return NO; + + [mySQLConnection queryString:query]; + if ([mySQLConnection queryErrored]) { + NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error while importing table", @"rror while importing table message") + defaultButton:NSLocalizedString(@"OK", @"OK button") + alternateButton:nil + otherButton:nil + informativeTextWithFormat:[NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to import a table via: \n%@\n\n\nMySQL said: %@", @"error importing table informative message"), + query, [mySQLConnection getLastErrorMessage]]]; + + [alert setAlertStyle:NSCriticalAlertStyle]; + [alert beginSheetModalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"truncateTableError"]; + return NO; + } + [self updateTables:nil]; + return YES; + } + + return NO; +} + +- (NSDragOperation)tableView:(NSTableView *)aTableView validateDrop:(id < NSDraggingInfo >)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)operation +{ + return NSDragOperationCopy; +} + #pragma mark - #pragma mark TabView delegate methods @@ -1892,6 +1926,11 @@ selector:@selector(endDocumentTaskForTab:) name:SPDocumentTaskEndNotification object:tableDocumentInstance]; + + + [tablesListView registerForDraggedTypes:[NSArray arrayWithObjects:@"SPDragTableDataFromNavigatorPboardType", nil]]; + [tablesListView setDropRow:-1 dropOperation:NSTableViewDropOn]; + } /** |