diff options
-rw-r--r-- | Source/CMTextView.m | 13 | ||||
-rw-r--r-- | Source/SPProcessListController.m | 7 | ||||
-rw-r--r-- | Source/TableDocument.m | 9 | ||||
-rw-r--r-- | Source/TableSource.m | 9 | ||||
-rw-r--r-- | Source/TablesList.m | 23 |
5 files changed, 51 insertions, 10 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m index 1359b8d8..06ada98e 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -216,6 +216,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) 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) @@ -257,12 +258,18 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) for(id db in sortedDbs) { NSArray *allTables = [[dbs objectForKey:db] allKeys]; - NSArray *sortedTables; + NSMutableArray *sortedTables = [NSMutableArray array]; if(aTableNameExists) { - sortedTables = [NSArray arrayWithObject:aTableName]; + [sortedTables addObject:aTableName]; } else { [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:db, @"display", @"database-small", @"image", nil]]; - sortedTables= [allTables sortedArrayUsingDescriptors:[NSArray arrayWithObject:desc]]; + [sortedTables addObjectsFromArray:[allTables sortedArrayUsingDescriptors:[NSArray arrayWithObject:desc]]]; + // if(aDbName == nil && aTableName) { + if([sortedTables count] > 1 && [sortedTables containsObject:currentTable]) { + [sortedTables removeObject:currentTable]; + [sortedTables insertObject:currentTable atIndex:0]; + } + // } } for(id table in sortedTables) { NSDictionary * theTable = [[dbs objectForKey:db] objectForKey:table]; diff --git a/Source/SPProcessListController.m b/Source/SPProcessListController.m index fb3dec5d..98137fb4 100644 --- a/Source/SPProcessListController.m +++ b/Source/SPProcessListController.m @@ -274,6 +274,13 @@ */ - (void)sheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { + + // Order out current sheet to suppress overlapping of sheets + if ([sheet respondsToSelector:@selector(orderOut:)]) + [sheet orderOut:nil]; + else if ([sheet respondsToSelector:@selector(window)]) + [[sheet window] orderOut:nil]; + if (returnCode == NSAlertDefaultReturn) { NSUInteger processId = [[[processes objectAtIndex:[processListTableView selectedRow]] valueForKey:@"Id"] integerValue]; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 88578b08..f61ead71 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -1130,8 +1130,15 @@ * if contextInfo == removeDatabase -> Remove the selected database * if contextInfo == addDatabase -> Add a new database */ -- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo +- (void)sheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { + + // Order out current sheet to suppress overlapping of sheets + if ([sheet respondsToSelector:@selector(orderOut:)]) + [sheet orderOut:nil]; + else if ([sheet respondsToSelector:@selector(window)]) + [[sheet window] orderOut:nil]; + // Remove the current database if ([contextInfo isEqualToString:@"removeDatabase"]) { if (returnCode == NSAlertDefaultReturn) { diff --git a/Source/TableSource.m b/Source/TableSource.m index 4feadddb..7f943850 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -872,10 +872,13 @@ fetches the result as an array with a dictionary for each row in it * if contextInfo == addIndex: adds and index to the mysql-db if user hits ok * if contextInfo == cannotremovefield: do nothing */ -- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo -{ +- (void)sheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo +{ // Order out current sheet to suppress overlapping of sheets - if ([sheet respondsToSelector:@selector(orderOut:)]) [sheet orderOut:nil]; + if ([sheet respondsToSelector:@selector(orderOut:)]) + [sheet orderOut:nil]; + else if ([sheet respondsToSelector:@selector(window)]) + [[sheet window] orderOut:nil]; if ([contextInfo isEqualToString:@"addrow"]) { diff --git a/Source/TablesList.m b/Source/TablesList.m index 742ac458..baca3e8a 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -510,6 +510,8 @@ // Order out current sheet to suppress overlapping of sheets if ([sheet respondsToSelector:@selector(orderOut:)]) [sheet orderOut:nil]; + else if ([sheet respondsToSelector:@selector(window)]) + [[sheet window] orderOut:nil]; if ([contextInfo isEqualToString:@"addRow"]) { alertSheetOpened = NO; @@ -1886,9 +1888,24 @@ // Couldn't truncate table if (![[mySQLConnection getLastErrorMessage] isEqualTo:@""]) { - NSBeginAlertSheet(NSLocalizedString(@"Error truncating table", @"error truncating table message"), - NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, - [NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to truncate the table '%@'.\n\nMySQL said: %@", @"error truncating table informative message"), [filteredTables objectAtIndex:currentIndex], [mySQLConnection getLastErrorMessage]]); + // NSBeginAlertSheet(NSLocalizedString(@"Error truncating table", @"error truncating table message"), + // NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), nil, nil, + // [NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to truncate the table '%@'.\n\nMySQL said: %@", @"error truncating table informative message"), [filteredTables objectAtIndex:currentIndex], [mySQLConnection getLastErrorMessage]]); + + NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error truncating table", @"error truncating table message") + defaultButton:NSLocalizedString(@"OK", @"OK button") + alternateButton:nil + otherButton:nil + informativeTextWithFormat:[NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to truncate the table '%@'.\n\nMySQL said: %@", @"error truncating table informative message"), + [filteredTables objectAtIndex:currentIndex], [mySQLConnection getLastErrorMessage]]]; + + [alert setAlertStyle:NSCriticalAlertStyle]; + // NSArray *buttons = [alert buttons]; + // // Change the alert's cancel button to have the key equivalent of return + // [[buttons objectAtIndex:0] setKeyEquivalent:@"t"]; + // [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; + // [[buttons objectAtIndex:1] setKeyEquivalent:@"\r"]; + [alert beginSheetModalForWindow:tableWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"truncateTableError"]; } // Get next index (beginning from the end) |