aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-03-19 22:41:33 +0000
committerBibiko <bibiko@eva.mpg.de>2010-03-19 22:41:33 +0000
commitca77ea4aa4972ddda817485b2f301f6b39ed14e3 (patch)
treecd20c5028cf55d4820f404f0e43637cbe15cf5da /Source
parent8a7621ee68c7de9a08bbd1552c6006e4fa3aaaa9 (diff)
downloadsequelpro-ca77ea4aa4972ddda817485b2f301f6b39ed14e3.tar.gz
sequelpro-ca77ea4aa4972ddda817485b2f301f6b39ed14e3.tar.bz2
sequelpro-ca77ea4aa4972ddda817485b2f301f6b39ed14e3.zip
• some improvements for navigator
Diffstat (limited to 'Source')
-rw-r--r--Source/CMTextView.m2
-rw-r--r--Source/SPNavigatorController.m104
2 files changed, 66 insertions, 40 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 27de550f..6d6befc8 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -307,7 +307,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
connectionID = [[[self window] delegate] connectionID];
else
connectionID = @"_";
-NSLog(@"cid %@", connectionID);
+
NSDictionary *dbs = [NSDictionary dictionaryWithDictionary:[[mySQLConnection getDbStructure] objectForKey:connectionID]];
if(dbs != nil && [dbs count]) {
diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m
index 1445f433..1dc53bcd 100644
--- a/Source/SPNavigatorController.m
+++ b/Source/SPNavigatorController.m
@@ -104,8 +104,13 @@ static SPNavigatorController *sharedNavigatorController = nil;
- (IBAction)updateEntries:(id)sender;
{
-
- if(schemaData) [schemaData release]; schemaData = nil;
+ id selectedItem1 = nil;
+ id selectedItem2 = nil;
+ if(schemaData) {
+ selectedItem1 = [outlineSchema1 itemAtRow:[outlineSchema1 selectedRow]];
+ selectedItem2 = [outlineSchema2 itemAtRow:[outlineSchema2 selectedRow]];
+ [schemaData release]; schemaData = nil;
+ }
schemaData = [[NSMutableDictionary alloc] init];
if ([[[NSDocumentController sharedDocumentController] documents] count]) {
for(id doc in [[NSDocumentController sharedDocumentController] documents]) {
@@ -117,11 +122,9 @@ static SPNavigatorController *sharedNavigatorController = nil;
if(!connectionName || [connectionName isEqualToString:@"_"]) continue;
if(![schemaData objectForKey:connectionName]) {
-
- id data = [[doc valueForKeyPath:@"mySQLConnection"] getDbStructure];
-
- if(data && [data objectForKey:connectionName]) {
- [schemaData setObject:[data objectForKey:connectionName] forKey:connectionName];
+
+ if([[doc valueForKeyPath:@"mySQLConnection"] getDbStructure] && [[[doc valueForKeyPath:@"mySQLConnection"] getDbStructure] objectForKey:connectionName]) {
+ [schemaData setObject:[[[doc valueForKeyPath:@"mySQLConnection"] getDbStructure] objectForKey:connectionName] forKey:connectionName];
} else {
if([[doc valueForKeyPath:@"mySQLConnection"] serverMajorVersion] > 4) {
@@ -136,6 +139,26 @@ static SPNavigatorController *sharedNavigatorController = nil;
[outlineSchema1 reloadData];
[outlineSchema2 reloadData];
+ if(selectedItem1) {
+ NSInteger itemIndex = [outlineSchema1 rowForItem:selectedItem1];
+ if (itemIndex < 0) {
+ // You need to decide what happens if the item doesn't exist
+ NSLog(@"1");
+ return;
+ }
+
+ [outlineSchema1 selectRowIndexes:[NSIndexSet indexSetWithIndex:itemIndex] byExtendingSelection:NO];
+ }
+ if(selectedItem2) {
+ NSInteger itemIndex = [outlineSchema2 rowForItem:selectedItem2];
+ if (itemIndex < 0) {
+ // You need to decide what happens if the item doesn't exist
+ NSLog(@"2");
+ return;
+ }
+
+ [outlineSchema2 selectRowIndexes:[NSIndexSet indexSetWithIndex:itemIndex] byExtendingSelection:NO];
+ }
}
}
@@ -155,10 +178,13 @@ static SPNavigatorController *sharedNavigatorController = nil;
NSSortDescriptor *desc = [[NSSortDescriptor alloc] initWithKey:nil ascending:YES selector:@selector(localizedCompare:)];
NSArray *sortedItems = [[item allKeys] sortedArrayUsingDescriptors:[NSArray arrayWithObject:desc]];
[desc release];
- if(index < [sortedItems count])
+ // if(index < [sortedItems count])
return [item objectForKey:[sortedItems objectAtIndex:index]];
}
-
+ else if ([item isKindOfClass:[NSArray class]])
+ {
+ return [item objectAtIndex:index];
+ }
return nil;
}
@@ -181,7 +207,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
if(item == nil)
return [schemaData count];
- if([item isKindOfClass:[NSDictionary class]])
+ if([item isKindOfClass:[NSDictionary class]] || [item isKindOfClass:[NSArray class]])
return [item count];
return 0;
@@ -201,41 +227,41 @@ static SPNavigatorController *sharedNavigatorController = nil;
}
if ([parentObject isKindOfClass:[NSDictionary class]]) {
- if([outlineView parentForItem:item]) {
- if([item isKindOfClass:[NSDictionary class]]) {
- if([item objectForKey:@" struct_type "]) {
- NSInteger type = [[item objectForKey:@" struct_type "] intValue];
- switch(type) {
- case 0:
- [[tableColumn dataCell] setImage:[NSImage imageNamed:@"table-small-square"]];
- break;
- case 1:
- [[tableColumn dataCell] setImage:[NSImage imageNamed:@"table-view-small-square"]];
- break;
- case 2:
- [[tableColumn dataCell] setImage:[NSImage imageNamed:@"proc-small"]];
- break;
- case 3:
- [[tableColumn dataCell] setImage:[NSImage imageNamed:@"func-small"]];
- break;
- }
- } else {
- [[tableColumn dataCell] setImage:[NSImage imageNamed:@"database-small"]];
+ if([item isKindOfClass:[NSDictionary class]]) {
+ if([item objectForKey:@" struct_type "]) {
+
+ NSInteger type = [[item objectForKey:@" struct_type "] intValue];
+ switch(type) {
+ case 0:
+ [[tableColumn dataCell] setImage:[NSImage imageNamed:@"table-small-square"]];
+ break;
+ case 1:
+ [[tableColumn dataCell] setImage:[NSImage imageNamed:@"table-view-small-square"]];
+ break;
+ case 2:
+ [[tableColumn dataCell] setImage:[NSImage imageNamed:@"proc-small"]];
+ break;
+ case 3:
+ [[tableColumn dataCell] setImage:[NSImage imageNamed:@"func-small"]];
+ break;
}
} else {
- // It's a field and use the key " struct_type " to increase the distance between node and first child
- if(![[[parentObject allKeysForObject:item] objectAtIndex:0] hasPrefix:@" "]) {
- [[tableColumn dataCell] setImage:[NSImage imageNamed:@"field-small-square"]];
- } else {
- [[tableColumn dataCell] setImage:[NSImage imageNamed:@"dummy-small"]];
- }
+ [[tableColumn dataCell] setImage:[NSImage imageNamed:@"database-small"]];
}
- }
- if([[parentObject allKeysForObject:item] count] && ![[[parentObject allKeysForObject:item] objectAtIndex:0] hasPrefix:@" "]) {
return [[[[parentObject allKeysForObject:item] objectAtIndex:0] componentsSeparatedByString:SPUniqueSchemaDelimiter] lastObject];
+
+ } else {
+ // It's a field and use the key " struct_type " to increase the distance between node and first child
+ if(![[[parentObject allKeysForObject:item] objectAtIndex:0] hasPrefix:@" "]) {
+ [[tableColumn dataCell] setImage:[NSImage imageNamed:@"field-small-square"]];
+ return [[[[parentObject allKeysForObject:item] objectAtIndex:0] componentsSeparatedByString:SPUniqueSchemaDelimiter] lastObject];
+ } else {
+ [[tableColumn dataCell] setImage:[NSImage imageNamed:@"dummy-small"]];
+ return nil;
+ }
}
}
- return nil;
+ return [item description];
}
else if ([[tableColumn identifier] isEqualToString:@"type"]) {