From 68bc7f791adc43728e09ea2c4744c129b96d66af Mon Sep 17 00:00:00 2001 From: Bibiko Date: Mon, 11 Jan 2010 21:21:41 +0000 Subject: =?UTF-8?q?=E2=80=A2=20further=20developments=20for=20the=20F5=20c?= =?UTF-8?q?ompletion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note: not yet finished! --- Source/CMTextView.m | 23 +++++++++++++++++++++-- Source/SPNarrowDownCompletion.m | 6 ++++-- Source/TableDocument.m | 2 +- Source/TablesList.h | 1 + Source/TablesList.m | 5 +++++ 5 files changed, 32 insertions(+), 5 deletions(-) (limited to 'Source') diff --git a/Source/CMTextView.m b/Source/CMTextView.m index e05ceefb..6ae7d211 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -180,7 +180,24 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) if(dbs != nil && [dbs count]) { NSArray *allDbs = [dbs allKeys]; NSSortDescriptor *desc = [[NSSortDescriptor alloc] initWithKey:nil ascending:YES selector:@selector(localizedCompare:)]; - NSArray *sortedDbs = [allDbs sortedArrayUsingDescriptors:[NSArray arrayWithObject:desc]]; + NSMutableArray *sortedDbs = [NSMutableArray array]; + [sortedDbs addObjectsFromArray:[allDbs sortedArrayUsingDescriptors:[NSArray arrayWithObject:desc]]]; + NSString *currentDb = nil; + // Put current selected db at the top + if ([[[[self window] delegate] valueForKeyPath:@"tablesListInstance"] valueForKey:@"selectedDatabase"] != nil) { + currentDb = [[[[self window] delegate] valueForKeyPath:@"tablesListInstance"] valueForKeyPath:@"selectedDatabase"]; + [sortedDbs removeObject:currentDb]; + [sortedDbs insertObject:currentDb atIndex:0]; + } + // Put information_schema and mysql db at the end + if(currentDb && ![currentDb isEqualToString:@"mysql"]) { + [sortedDbs removeObject:@"mysql"]; + [sortedDbs addObject:@"mysql"]; + } + if(currentDb && ![currentDb isEqualToString:@"information_schema"]) { + [sortedDbs removeObject:@"information_schema"]; + [sortedDbs addObject:@"information_schema"]; + } for(id db in sortedDbs) { NSArray *allTables = [[dbs objectForKey:db] allKeys]; [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:db, @"display", @"database-small", @"image", nil]]; @@ -217,7 +234,9 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) } } } else { - // [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"updating data…", @"updating table data for completion in progress message"), @"path", nil]]; + // Fallback for MySQL < 5 and if the data gathering is slow + if(mySQLmajorVersion > 4) + [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"updating data…", @"updating table data for completion in progress message"), @"path", nil]]; // Add all database names to completions list for (id obj in [[[[self window] delegate] valueForKeyPath:@"tablesListInstance"] valueForKey:@"allDatabaseNames"]) diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m index 0724d722..f47baeab 100644 --- a/Source/SPNarrowDownCompletion.m +++ b/Source/SPNarrowDownCompletion.m @@ -222,13 +222,13 @@ NSTableColumn *column2 = [[[NSTableColumn alloc] initWithIdentifier:@"type"] autorelease]; [column2 setEditable:NO]; // [[column2 dataCell] setFont:[NSFont systemFontOfSize:11]]; - [[column2 dataCell] setTextColor:[NSColor grayColor]]; + [[column2 dataCell] setTextColor:[NSColor darkGrayColor]]; [theTableView addTableColumn:column2]; [column2 setWidth:120]; NSTableColumn *column3 = [[[NSTableColumn alloc] initWithIdentifier:@"path"] autorelease]; [column3 setEditable:NO]; // [[column3 dataCell] setFont:[NSFont systemFontOfSize:11]]; - [[column3 dataCell] setTextColor:[NSColor grayColor]]; + [[column3 dataCell] setTextColor:[NSColor darkGrayColor]]; [theTableView addTableColumn:column3]; [column3 setWidth:130]; @@ -261,8 +261,10 @@ } else if([[aTableColumn identifier] isEqualToString:@"name"]) { return [[filtered objectAtIndex:rowIndex] objectForKey:@"display"]; } else if([[aTableColumn identifier] isEqualToString:@"type"]) { + [[aTableColumn dataCell] setTextColor:([aTableView selectedRow] == rowIndex)?[NSColor whiteColor]:[NSColor darkGrayColor]]; return ([[filtered objectAtIndex:rowIndex] objectForKey:@"type"])?[[filtered objectAtIndex:rowIndex] objectForKey:@"type"]:@""; } else if ([[aTableColumn identifier] isEqualToString:@"path"]) { + [[aTableColumn dataCell] setTextColor:([aTableView selectedRow] == rowIndex)?[NSColor whiteColor]:[NSColor darkGrayColor]]; return ([[filtered objectAtIndex:rowIndex] objectForKey:@"path"])?[[filtered objectAtIndex:rowIndex] objectForKey:@"path"]:@""; } return [filtered objectAtIndex:rowIndex]; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 2bd178e7..3b8f67b6 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -681,7 +681,7 @@ notificationName:@"Connected"]; // Query the structure of all databases in the background (mainly for completion) - // [mySQLConnection performSelector:@selector(queryDbStructure) withObject:nil afterDelay:2]; + [mySQLConnection performSelector:@selector(queryDbStructure) withObject:nil afterDelay:0.5]; // Init Custom Query editor with the stored queries in a spf file if given. [spfDocData setObject:[NSNumber numberWithBool:NO] forKey:@"save_editor_content"]; diff --git a/Source/TablesList.h b/Source/TablesList.h index 911945eb..1318108b 100644 --- a/Source/TablesList.h +++ b/Source/TablesList.h @@ -140,6 +140,7 @@ enum sp_table_types - (NSArray *)allProcedureNames; - (NSArray *)allDatabaseNames; - (NSArray *)allSystemDatabaseNames; +- (NSString *)selectedDatabase; - (BOOL)structureLoaded; - (BOOL)contentLoaded; - (BOOL)statusLoaded; diff --git a/Source/TablesList.m b/Source/TablesList.m index b5490e7a..97e2ec2c 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -1064,6 +1064,11 @@ return [tableDocumentInstance allDatabaseNames]; } +- (NSString *)selectedDatabase +{ + return [tableDocumentInstance database]; +} + /** * Returns an array of all available database names */ -- cgit v1.2.3