aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-08-12 12:21:27 +0000
committerBibiko <bibiko@eva.mpg.de>2010-08-12 12:21:27 +0000
commit7788e16c9997159bec64f443d069a070abcab474 (patch)
tree54b982173056e6c8ce126d9eceb41d5823d1cae0
parent2e69aacd95a1991c73e59f71a3f3809e64eb3fe3 (diff)
downloadsequelpro-7788e16c9997159bec64f443d069a070abcab474.tar.gz
sequelpro-7788e16c9997159bec64f443d069a070abcab474.tar.bz2
sequelpro-7788e16c9997159bec64f443d069a070abcab474.zip
• Navigator
- searches only for pattern length greater than 1 - improved connection detection for search if connection itself is selected - improved exceptions handling - improved first display refresh
-rw-r--r--Source/SPNavigatorController.m29
1 files changed, 18 insertions, 11 deletions
diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m
index 24fafee2..e4037c95 100644
--- a/Source/SPNavigatorController.m
+++ b/Source/SPNavigatorController.m
@@ -345,7 +345,7 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte
if(docCounter > 1) return;
- if(schemaData && [schemaData objectForKey:connectionID])
+ if(schemaData && [schemaData objectForKey:connectionID] && [[NSApp delegate] frontDocument] && [[[NSApp delegate] orderedDocuments] count])
[self saveSelectedItems];
if(schemaDataFiltered)
@@ -484,7 +484,6 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte
[updatingConnections removeObject:connectionName];
if([[self window] isVisible] || wasNotShown) {
- wasNotShown = NO;
[outlineSchema1 reloadData];
[outlineSchema2 reloadData];
@@ -494,8 +493,10 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte
}
- if([[self window] isVisible])
+ if([[self window] isVisible]) {
+ wasNotShown = NO;
[self syncButtonAction:self];
+ }
if(isFiltered && [[self window] isVisible])
[self filterTree:self];
@@ -631,17 +632,17 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte
NSString *pattern = [[[searchField stringValue] stringByReplacingOccurrencesOfString:@"." withString:SPUniqueSchemaDelimiter] lowercaseString];
- // Suppress search for '.' since this matches everything
- if([pattern isEqualToString:SPUniqueSchemaDelimiter]) return;
-
[self saveSelectedItems];
id currentItem = [outlineSchema2 selectedItem];
id parentObject = nil;
- if(isFiltered)
- parentObject = [outlineSchema2 parentForItem:currentItem] ? [outlineSchema2 parentForItem:currentItem] : schemaDataFiltered;
+ if([outlineSchema2 levelForItem:currentItem] == 0 && !isFiltered)
+ parentObject = currentItem;
else
- parentObject = [outlineSchema2 parentForItem:currentItem] ? [outlineSchema2 parentForItem:currentItem] : schemaData;
+ if(isFiltered)
+ parentObject = [outlineSchema2 parentForItem:currentItem] ? [outlineSchema2 parentForItem:currentItem] : schemaDataFiltered;
+ else
+ parentObject = [outlineSchema2 parentForItem:currentItem] ? [outlineSchema2 parentForItem:currentItem] : schemaData;
@try{
@@ -661,7 +662,7 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte
return;
}
- if(isFiltering) return;
+ if(isFiltering || [pattern length] < 2) return;
isFiltered = YES;
@@ -674,7 +675,7 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF CONTAINS[c] %@", pattern];
NSArray *filteredItems = [[allSchemaKeys objectForKey:connectionID] filteredArrayUsingPredicate:predicate];
- BOOL searchFailed = NO;
+ BOOL searchFailed = YES;
for(NSString* item in filteredItems) {
NSArray *a = [item componentsSeparatedByString:SPUniqueSchemaDelimiter];
@@ -684,6 +685,7 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte
if(!a || [a count] < 2) continue;
if(![[structure valueForKey:connectionID] valueForKey:db_id]) {
+ searchFailed = NO;
[[structure valueForKey:connectionID] setObject:[NSMutableDictionary dictionary] forKey:db_id];
}
if([a count] > 2) {
@@ -691,6 +693,7 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte
NSString *table_id = [NSString stringWithFormat:@"%@%@%@", db_id,SPUniqueSchemaDelimiter,[a objectAtIndex:2]];
if(![[[structure valueForKey:connectionID] valueForKey:db_id] valueForKey:table_id]) {
+ searchFailed = NO;
[[[structure valueForKey:connectionID] valueForKey:db_id] setObject:[NSMutableDictionary dictionary] forKey:table_id];
}
@@ -709,7 +712,11 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte
}
}
}
+ if(searchFailed)
+ NSBeep();
+
[schemaDataFiltered setDictionary:structure];
+
[NSThread detachNewThreadSelector:@selector(reloadAfterFiltering) toTarget:self withObject:nil];
}