From efdcfb17f87863fef42f209f72eb4c4ccd888d35 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 13 Aug 2010 13:11:07 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed=20bug=20while=20closing=20a=20tab=20t?= =?UTF-8?q?o=20remove=20the=20connection=20from=20Navigator=20=E2=80=A2=20?= =?UTF-8?q?FIRST=20implementation=20to=20allow=20to=20drag=20a=20table=20f?= =?UTF-8?q?rom=20the=20Navigator=20to=20the=20connection=20window's=20tabl?= =?UTF-8?q?e=20list=20to=20copy=20this=20table=20with=20content=20(it=20wo?= =?UTF-8?q?rks=20but=20needs=20to=20be=20improved!)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPTablesList.m | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'Source/SPTablesList.m') 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 )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]; + } /** -- cgit v1.2.3