aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-01-11 21:21:41 +0000
committerBibiko <bibiko@eva.mpg.de>2010-01-11 21:21:41 +0000
commit68bc7f791adc43728e09ea2c4744c129b96d66af (patch)
tree5298dfd03183ab95c68bcfa5e0283f52b313f152 /Source
parent3381e9f906edc5c1bfd6ed14fba8f9aa689848b7 (diff)
downloadsequelpro-68bc7f791adc43728e09ea2c4744c129b96d66af.tar.gz
sequelpro-68bc7f791adc43728e09ea2c4744c129b96d66af.tar.bz2
sequelpro-68bc7f791adc43728e09ea2c4744c129b96d66af.zip
• further developments for the F5 completion
Note: not yet finished!
Diffstat (limited to 'Source')
-rw-r--r--Source/CMTextView.m23
-rw-r--r--Source/SPNarrowDownCompletion.m6
-rw-r--r--Source/TableDocument.m2
-rw-r--r--Source/TablesList.h1
-rw-r--r--Source/TablesList.m5
5 files changed, 32 insertions, 5 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"])
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
*/