diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-01-11 21:21:41 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-01-11 21:21:41 +0000 |
commit | 68bc7f791adc43728e09ea2c4744c129b96d66af (patch) | |
tree | 5298dfd03183ab95c68bcfa5e0283f52b313f152 /Source/CMTextView.m | |
parent | 3381e9f906edc5c1bfd6ed14fba8f9aa689848b7 (diff) | |
download | sequelpro-68bc7f791adc43728e09ea2c4744c129b96d66af.tar.gz sequelpro-68bc7f791adc43728e09ea2c4744c129b96d66af.tar.bz2 sequelpro-68bc7f791adc43728e09ea2c4744c129b96d66af.zip |
• further developments for the F5 completion
Note: not yet finished!
Diffstat (limited to 'Source/CMTextView.m')
-rw-r--r-- | Source/CMTextView.m | 23 |
1 files changed, 21 insertions, 2 deletions
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"]) |