From 7788e16c9997159bec64f443d069a070abcab474 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Thu, 12 Aug 2010 12:21:27 +0000 Subject: =?UTF-8?q?=E2=80=A2=C2=A0Navigator=20-=20searches=20only=20for=20?= =?UTF-8?q?pattern=20length=20greater=20than=201=20-=20improved=20connecti?= =?UTF-8?q?on=20detection=20for=20search=20if=20connection=20itself=20is?= =?UTF-8?q?=20selected=20-=20improved=20exceptions=20handling=20-=20improv?= =?UTF-8?q?ed=20first=20display=20refresh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPNavigatorController.m | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'Source/SPNavigatorController.m') 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]; } -- cgit v1.2.3