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/SPTablesList.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/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]; + } /** |