aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMTextView.m53
-rw-r--r--Source/SPNarrowDownCompletion.h14
-rw-r--r--Source/SPNarrowDownCompletion.m118
-rw-r--r--Source/SPNavigatorController.h4
-rw-r--r--Source/SPNavigatorController.m64
-rw-r--r--Source/TableDocument.m5
6 files changed, 197 insertions, 61 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 2b9879b6..91be7257 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -309,13 +309,12 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
else
connectionID = @"_";
- // NSDictionary *dbs = [NSDictionary dictionaryWithDictionary:[[mySQLConnection getDbStructure] objectForKey:connectionID]];
+ // Try to get structure data
NSDictionary *dbs = [NSDictionary dictionaryWithDictionary:[[SPNavigatorController sharedNavigatorController] dbStructureForConnection:connectionID]];
if(dbs != nil && [dbs isKindOfClass:[NSDictionary class]] && [dbs count]) {
NSMutableArray *allDbs = [NSMutableArray array];
- @try { [allDbs addObjectsFromArray:[dbs allKeys]]; }
- @catch(id ae) { ; }
+ [allDbs addObjectsFromArray:[dbs allKeys]];
NSSortDescriptor *desc = [[NSSortDescriptor alloc] initWithKey:nil ascending:YES selector:@selector(localizedCompare:)];
NSMutableArray *sortedDbs = [NSMutableArray array];
@@ -520,11 +519,17 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
- (void) doAutoCompletion
{
+ // Cancel autocompletion trigger
+ if([prefs boolForKey:SPCustomQueryAutoComplete])
+ [NSObject cancelPreviousPerformRequestsWithTarget:self
+ selector:@selector(doAutoCompletion)
+ object:nil];
+
if(completionIsOpen) return;
NSRange r = [self selectedRange];
- if(![[self delegate] isKindOfClass:[CustomQuery class]] || r.length || snippetControlCounter > -1) return;
+ if(![self delegate] || ![[self delegate] isKindOfClass:[CustomQuery class]] || r.length || snippetControlCounter > -1) return;
if(r.location) {
if([[[self textStorage] attribute:kQuote atIndex:r.location-1 effectiveRange:nil] isEqualToString:kQuoteValue])
@@ -539,14 +544,16 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
- (void) doCompletionByUsingSpellChecker:(BOOL)isDictMode fuzzyMode:(BOOL)fuzzySearch autoCompleteMode:(BOOL)autoCompleteMode
{
- if(![self isEditable] || (completionIsOpen && !completionWasReinvokedAutomatically)) return;
-
// Cancel autocompletion trigger
if([prefs boolForKey:SPCustomQueryAutoComplete])
[NSObject cancelPreviousPerformRequestsWithTarget:self
selector:@selector(doAutoCompletion)
object:nil];
+ if(![self isEditable] || (completionIsOpen && !completionWasReinvokedAutomatically)) {
+ return;
+ }
+
[self breakUndoCoalescing];
NSUInteger caretPos = NSMaxRange([self selectedRange]);
@@ -728,6 +735,12 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
completionIsOpen = YES;
+ // Cancel autocompletion trigger again if user typed something in while parsing
+ if([prefs boolForKey:SPCustomQueryAutoComplete])
+ [NSObject cancelPreviousPerformRequestsWithTarget:self
+ selector:@selector(doAutoCompletion)
+ object:nil];
+
SPNarrowDownCompletion* completionPopUp = [[SPNarrowDownCompletion alloc] initWithItems:[self suggestionsForSQLCompletionWith:currentWord dictMode:isDictMode browseMode:dbBrowseMode withTableName:tableName withDbName:dbName]
alreadyTyped:filter
staticPrefix:prefix
@@ -746,7 +759,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
selectedDb:currentDb
caretMovedLeft:caretMovedLeft
autoComplete:autoCompleteMode
- oneColumn:isDictMode];
+ oneColumn:isDictMode
+ isQueryingDBStructure:[mySQLConnection isQueryingDatabaseStructure]];
completionParseRangeLocation = parseRange.location;
@@ -1275,6 +1289,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
return;
}
+ completionIsOpen = YES;
+
SPNarrowDownCompletion* completionPopUp = [[SPNarrowDownCompletion alloc] initWithItems:possibleCompletions
alreadyTyped:@""
staticPrefix:@""
@@ -1293,7 +1309,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
selectedDb:@""
caretMovedLeft:NO
autoComplete:NO
- oneColumn:NO];
+ oneColumn:NO
+ isQueryingDBStructure:NO];
//Get the NSPoint of the first character of the current word
NSRange glyphRange = [[self layoutManager] glyphRangeForCharacterRange:NSMakeRange(aRange.location,0) actualCharacterRange:NULL];
@@ -1303,7 +1320,6 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
// Adjust list location to be under the current word or insertion point
pos.y -= [[self font] pointSize]*1.25;
[completionPopUp setCaretPos:pos];
- completionIsOpen = YES;
[completionPopUp orderFront:self];
}
@@ -1438,7 +1454,9 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
NSMutableArray *possibleCompletions = [[[NSMutableArray alloc] initWithCapacity:[list count]] autorelease];
for(id w in list)
[possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:w, @"display", @"dummy-small", @"image", nil]];
-
+
+ completionIsOpen = YES;
+
completionPopUp = [[SPNarrowDownCompletion alloc] initWithItems:possibleCompletions
alreadyTyped:@""
staticPrefix:@""
@@ -1457,7 +1475,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
selectedDb:@""
caretMovedLeft:NO
autoComplete:NO
- oneColumn:YES];
+ oneColumn:YES
+ isQueryingDBStructure:NO];
//Get the NSPoint of the first character of the current word
NSRange glyphRange = [[self layoutManager] glyphRangeForCharacterRange:NSMakeRange(r2.location,0) actualCharacterRange:NULL];
NSRect boundingRect = [[self layoutManager] boundingRectForGlyphRange:glyphRange inTextContainer:[self textContainer]];
@@ -1466,7 +1485,6 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
// Adjust list location to be under the current word or insertion point
pos.y -= [[self font] pointSize]*1.25;
[completionPopUp setCaretPos:pos];
- completionIsOpen = YES;
[completionPopUp orderFront:self];
}
}
@@ -3252,6 +3270,17 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
- (void) dealloc
{
+ if([prefs boolForKey:SPCustomQueryUpdateAutoHelp])
+ [NSObject cancelPreviousPerformRequestsWithTarget:self
+ selector:@selector(autoHelp)
+ object:nil];
+
+ if([prefs boolForKey:SPCustomQueryAutoComplete])
+ [NSObject cancelPreviousPerformRequestsWithTarget:self
+ selector:@selector(doAutoCompletion)
+ object:nil];
+
+
// Remove observers
[[NSNotificationCenter defaultCenter] removeObserver:self];
[prefs removeObserver:self forKeyPath:SPCustomQueryEditorFont];
diff --git a/Source/SPNarrowDownCompletion.h b/Source/SPNarrowDownCompletion.h
index e2aaed5e..fc8bd942 100644
--- a/Source/SPNarrowDownCompletion.h
+++ b/Source/SPNarrowDownCompletion.h
@@ -49,12 +49,19 @@
BOOL commaInsertionMode;
BOOL autoCompletionMode;
BOOL oneColumnMode;
+ BOOL isQueryingDatabaseStructure;
NSInteger backtickMode;
NSFont *tableFont;
NSRange theCharRange;
NSRange theParseRange;
NSString *theDbName;
+ NSTimer *stateTimer;
+ NSArray *syncArrowImages;
+ NSInteger currentSyncImage;
+
+ NSUInteger timeCounter;
+
id theView;
NSInteger maxWindowWidth;
@@ -71,10 +78,15 @@
charRange:(NSRange)initRange parseRange:(NSRange)parseRange inView:(id)aView
dictMode:(BOOL)mode dbMode:(BOOL)theDbMode tabTriggerMode:(BOOL)tabTriggerMode fuzzySearch:(BOOL)fuzzySearch
backtickMode:(NSInteger)theBackTickMode withDbName:(NSString*)dbName withTableName:(NSString*)tableName
- selectedDb:(NSString*)selectedDb caretMovedLeft:(BOOL)caretMovedLeft autoComplete:(BOOL)autoComplete oneColumn:(BOOL)oneColumn;
+ selectedDb:(NSString*)selectedDb caretMovedLeft:(BOOL)caretMovedLeft autoComplete:(BOOL)autoComplete oneColumn:(BOOL)oneColumn
+ isQueryingDBStructure:(BOOL)isQueryingDBStructure;
- (void)setCaretPos:(NSPoint)aPos;
- (void)insert_text:(NSString* )aString;
- (void)insertCommonPrefix;
- (void)adjustWorkingRangeByDelta:(NSInteger)delta;
+- (void)updateSyncArrowStatus;
+- (void)reInvokeCompletion;
+
+
@end
diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m
index cf5abb49..287fe98d 100644
--- a/Source/SPNarrowDownCompletion.m
+++ b/Source/SPNarrowDownCompletion.m
@@ -39,6 +39,7 @@
#import "CMTextView.h"
#import "SPConstants.h"
+
@interface NSTableView (MovingSelectedRow)
- (BOOL)SP_NarrowDownCompletion_canHandleEvent:(NSEvent*)anEvent;
@@ -113,17 +114,32 @@
caseSensitive = YES;
filtered = nil;
spaceCounter = 0;
-
+ currentSyncImage = 0;
prefs = [NSUserDefaults standardUserDefaults];
tableFont = [NSUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] dataForKey:SPCustomQueryEditorFont]];
[self setupInterface];
+
+ syncArrowImages = [[NSArray alloc] initWithObjects:
+ [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"sync_arrows_01" ofType:@"tiff"]],
+ [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"sync_arrows_02" ofType:@"tiff"]],
+ [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"sync_arrows_03" ofType:@"tiff"]],
+ [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"sync_arrows_04" ofType:@"tiff"]],
+ [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"sync_arrows_05" ofType:@"tiff"]],
+ [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"sync_arrows_06" ofType:@"tiff"]],
+ nil];
+
}
return self;
}
- (void)dealloc
{
+ if(stateTimer != nil) {
+ [stateTimer invalidate];
+ [stateTimer release];
+ }
+ stateTimer = nil;
[staticPrefix release];
[mutablePrefix release];
[textualInputCharacters release];
@@ -135,12 +151,45 @@
[super dealloc];
}
+- (void)updateSyncArrowStatus
+{
+ currentSyncImage++;
+ timeCounter++;
+ if(currentSyncImage >= [syncArrowImages count]) currentSyncImage = 0;
+ if(timeCounter > 20) {
+ timeCounter = 0;
+ if(![[theView valueForKeyPath:@"mySQLConnection"] isQueryingDatabaseStructure]) {
+ isQueryingDatabaseStructure = NO;
+ if(stateTimer) {
+ [stateTimer invalidate];
+ [stateTimer release];
+ stateTimer = nil;
+ if(syncArrowImages) [syncArrowImages release];
+ usleep(1000);
+ [self performSelectorOnMainThread:@selector(reInvokeCompletion) withObject:nil waitUntilDone:NO];
+ return;
+ }
+ }
+ }
+
+ [theTableView setNeedsDisplay:YES];
+
+}
+
+- (void)reInvokeCompletion
+{
+ [theView setCompletionWasReinvokedAutomatically:YES];
+ closeMe = YES;
+ [theView doCompletionByUsingSpellChecker:dictMode fuzzyMode:fuzzyMode autoCompleteMode:NO];
+}
+
- (id)initWithItems:(NSArray*)someSuggestions alreadyTyped:(NSString*)aUserString staticPrefix:(NSString*)aStaticPrefix
additionalWordCharacters:(NSString*)someAdditionalWordCharacters caseSensitive:(BOOL)isCaseSensitive
charRange:(NSRange)initRange parseRange:(NSRange)parseRange inView:(id)aView
dictMode:(BOOL)mode dbMode:(BOOL)theDbMode tabTriggerMode:(BOOL)tabTriggerMode fuzzySearch:(BOOL)fuzzySearch
backtickMode:(NSInteger)theBackTickMode withDbName:(NSString*)dbName withTableName:(NSString*)tableName
selectedDb:(NSString*)selectedDb caretMovedLeft:(BOOL)caretMovedLeft autoComplete:(BOOL)autoComplete oneColumn:(BOOL)oneColumn
+ isQueryingDBStructure:(BOOL)isQueryingDBStructure
{
if(self = [self init])
{
@@ -151,6 +200,10 @@
autoCompletionMode = autoComplete;
oneColumnMode = oneColumn;
+ isQueryingDatabaseStructure = isQueryingDBStructure;
+
+ if(isQueryingDatabaseStructure)
+ stateTimer = [[NSTimer scheduledTimerWithTimeInterval:0.07f target:self selector:@selector(updateSyncArrowStatus) userInfo:nil repeats:YES] retain];
fuzzyMode = fuzzySearch;
if(fuzzyMode)
@@ -258,8 +311,8 @@
[theTableView setDelegate:self];
NSTableColumn *column0 = [[[NSTableColumn alloc] initWithIdentifier:@"image"] autorelease];
- [column0 setDataCell:[[ImageAndTextCell new] autorelease]];
- [column0 setEditable:NO];
+ [column0 setDataCell:[NSImageCell new]];
+ // [column0 setEditable:NO];
[theTableView addTableColumn:column0];
[column0 setMinWidth:0];
[column0 setWidth:20];
@@ -301,7 +354,10 @@
- (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(id)aCell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex mouseLocation:(NSPoint)mouseLocation
{
+ if(isQueryingDatabaseStructure) rowIndex--;
+
if([[aTableColumn identifier] isEqualToString:@"image"]) {
+ if(rowIndex == -1) return NSLocalizedString(@"fetching database structure in progress", @"fetching database structure in progress");
if(!dictMode) {
NSString *imageName = [[filtered objectAtIndex:rowIndex] objectForKey:@"image"];
if([imageName hasPrefix:@"dummy"])
@@ -321,8 +377,10 @@
}
return @"";
} else if([[aTableColumn identifier] isEqualToString:@"name"]) {
+ if(rowIndex == -1) return NSLocalizedString(@"fetching database structure in progress", @"fetching database structure in progress");
return [[filtered objectAtIndex:rowIndex] objectForKey:@"display"];
} else if ([[aTableColumn identifier] isEqualToString:@"list"] || [[aTableColumn identifier] isEqualToString:@"type"]) {
+ if(rowIndex == -1) return NSLocalizedString(@"fetching database structure data in progress", @"fetching database structure data in progress");
if(dictMode) {
return @"";
} else {
@@ -341,6 +399,7 @@
}
} else if ([[aTableColumn identifier] isEqualToString:@"path"]) {
+ if(rowIndex == -1) return NSLocalizedString(@"fetching database structure in progress", @"fetching database structure in progress");
if(dictMode) {
return @"";
} else {
@@ -360,26 +419,43 @@
return @"";
}
+- (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(NSInteger)rowIndex
+{
+ if(rowIndex == 0 && isQueryingDatabaseStructure)
+ return NO;
+
+ return YES;
+}
+
+
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
NSImage* image = nil;
NSString* imageName = nil;
+ if(isQueryingDatabaseStructure) rowIndex--;
+
if([[aTableColumn identifier] isEqualToString:@"image"]) {
if(!dictMode) {
- imageName = [[filtered objectAtIndex:rowIndex] objectForKey:@"image"];
- if(imageName)
- image = [NSImage imageNamed:imageName];
- [[aTableColumn dataCell] setImage:image];
+ if(rowIndex == -1) {
+ return [syncArrowImages objectAtIndex:currentSyncImage];
+ } else {
+ imageName = [[filtered objectAtIndex:rowIndex] objectForKey:@"image"];
+ if(imageName)
+ image = [NSImage imageNamed:imageName];
+ return image;
+ }
}
return @"";
} else if([[aTableColumn identifier] isEqualToString:@"name"]) {
- // NSTextFieldCell *b = [[[NSTextFieldCell new] initTextCell:[[filtered objectAtIndex:rowIndex] objectForKey:@"display"]] autorelease];
+ if(rowIndex == -1) return @"fetching structure…";
+
[[aTableColumn dataCell] setFont:[NSFont systemFontOfSize:12]];
return [[filtered objectAtIndex:rowIndex] objectForKey:@"display"];
} else if ([[aTableColumn identifier] isEqualToString:@"list"]) {
+ if(rowIndex == -1) return @"";
if(dictMode) {
return @"";
} else {
@@ -407,11 +483,10 @@
}
} else if([[aTableColumn identifier] isEqualToString:@"type"]) {
+ if(rowIndex == -1) return @"";
if(dictMode) {
return @"";
} else {
- // [[aTableColumn dataCell] setTextColor:([aTableView selectedRow] == rowIndex)?[NSColor whiteColor]:[NSColor darkGrayColor]];
- // return ([[filtered objectAtIndex:rowIndex] objectForKey:@"type"]) ? [[filtered objectAtIndex:rowIndex] objectForKey:@"type"] : @"";
NSTokenFieldCell *b = [[[NSTokenFieldCell alloc] initTextCell:([[filtered objectAtIndex:rowIndex] objectForKey:@"type"]) ? [[filtered objectAtIndex:rowIndex] objectForKey:@"type"] : @""] autorelease];
[b setEditable:NO];
[b setAlignment:NSRightTextAlignment];
@@ -421,6 +496,7 @@
}
} else if ([[aTableColumn identifier] isEqualToString:@"path"]) {
+ if(rowIndex == -1) return @"";
if(dictMode) {
return @"";
} else {
@@ -461,7 +537,7 @@
if(autoCompletionMode) return;
if(spaceCounter < 1)
for(id w in filtered){
- if([[w objectForKey:@"match"] ?: [w objectForKey:@"display"] rangeOfString:@" "].length) {
+ if([[w objectForKey:@"match"] ?: [w objectForKey:@"display"] rangeOfString:@" "].length && ![w objectForKey:@"noCompletion"]) {
[textualInputCharacters addCharactersInString:@" "];
break;
}
@@ -615,6 +691,9 @@
- (void)watchUserEvents
{
+
+ [theView setCompletionIsOpen:YES];
+
closeMe = NO;
while(!closeMe)
{
@@ -797,9 +876,22 @@
{
if([theTableView selectedRow] == -1) return;
- NSDictionary* selectedItem = [filtered objectAtIndex:[theTableView selectedRow]];
+ NSDictionary* selectedItem;
+ NSInteger selectedRowNumber = [theTableView selectedRow];
+ if(isQueryingDatabaseStructure) {
+ if(selectedRowNumber < 1) {
+ closeMe = YES;
+ return;
+ }
+ selectedItem = [filtered objectAtIndex:selectedRowNumber-1];
+ } else {
+ selectedItem = [filtered objectAtIndex:selectedRowNumber];
+ }
- if([selectedItem objectForKey:@"noCompletion"]) return;
+ if([selectedItem objectForKey:@"noCompletion"]) {
+ closeMe = YES;
+ return;
+ }
if(dictMode){
[self insert_text:[selectedItem objectForKey:@"match"] ?: [selectedItem objectForKey:@"display"]];
diff --git a/Source/SPNavigatorController.h b/Source/SPNavigatorController.h
index 6c31b013..2833cd99 100644
--- a/Source/SPNavigatorController.h
+++ b/Source/SPNavigatorController.h
@@ -45,7 +45,7 @@
NSMutableDictionary *schemaDataFiltered;
NSMutableDictionary *allSchemaKeys;
NSMutableArray *infoArray;
- NSMutableSet *updatingConnections;
+ NSMutableArray *updatingConnections;
NSMutableDictionary *expandStatus1;
NSMutableDictionary *expandStatus2;
@@ -80,13 +80,13 @@
- (NSString*)tableInfoLabelForIndex:(NSInteger)index ofType:(NSInteger)type;
- (void)updateNavigator:(NSNotification *)aNotification;
-- (void)isUpdatingNavigator:(NSNotification *)aNotification;
- (NSDictionary *)dbStructureForConnection:(NSString*)connectionID;
- (NSArray *)allSchemaKeysForConnection:(NSString*)connectionID;
- (NSArray *)getUniqueDbIdentifierFor:(NSString*)term andConnection:(NSString*)connectionID;
- (BOOL)isUpdatingConnection:(NSString*)connectionID;
+- (BOOL)isUpdating;
- (void)restoreSelectedItems;
- (void)setIgnoreUpdate:(BOOL)flag;
diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m
index 439b4d5c..0bb723ba 100644
--- a/Source/SPNavigatorController.m
+++ b/Source/SPNavigatorController.m
@@ -70,7 +70,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
expandStatus1 = [[NSMutableDictionary alloc] init];
expandStatus2 = [[NSMutableDictionary alloc] init];
infoArray = [[NSMutableArray alloc] init];
- updatingConnections = [[NSMutableSet alloc] initWithCapacity:1];
+ updatingConnections = [[NSMutableArray alloc] init];
selectedKey1 = @"";
selectedKey2 = @"";
ignoreUpdate = NO;
@@ -143,9 +143,6 @@ static SPNavigatorController *sharedNavigatorController = nil;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateNavigator:)
name:@"SPDBStructureWasUpdated" object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(isUpdatingNavigator:)
- name:@"SPDBStructureIsUpdating" object:nil];
-
}
- (NSString *)windowFrameAutosaveName
@@ -349,12 +346,14 @@ static SPNavigatorController *sharedNavigatorController = nil;
[schemaData removeObjectForKey:connectionID];
if(allSchemaKeys)
[allSchemaKeys removeObjectForKey:connectionID];
-
- [outlineSchema1 reloadData];
- [outlineSchema2 reloadData];
- [self restoreSelectedItems];
- if(isFiltered)
- [self filterTree:self];
+
+ if([[self window] isVisible]) {
+ [outlineSchema1 reloadData];
+ [outlineSchema2 reloadData];
+ [self restoreSelectedItems];
+ if(isFiltered)
+ [self filterTree:self];
+ }
}
}
@@ -418,15 +417,6 @@ static SPNavigatorController *sharedNavigatorController = nil;
[self performSelectorOnMainThread:@selector(updateEntriesForConnection:) withObject:nil waitUntilDone:YES];
}
-- (void)isUpdatingNavigator:(NSNotification *)aNotification
-{
- // id object = [aNotification object];
- //
- // if([object isKindOfClass:[TableDocument class]])
- // [updatingConnections addObject:[object connectionID]];
-
-}
-
- (void)updateEntriesForConnection:(NSString*)connectionID
{
@@ -435,13 +425,16 @@ static SPNavigatorController *sharedNavigatorController = nil;
return;
}
- [self saveSelectedItems];
+ if([[self window] isVisible]) {
+ [self saveSelectedItems];
+ [infoArray removeAllObjects];
+ }
- [infoArray removeAllObjects];
+ id doc = nil;
if ([[[NSDocumentController sharedDocumentController] documents] count]) {
- id doc = [[NSDocumentController sharedDocumentController] currentDocument];
+ doc = [[NSDocumentController sharedDocumentController] currentDocument];
id theConnection = [doc valueForKeyPath:@"mySQLConnection"];
if(!theConnection || ![theConnection isConnected]) return;
@@ -449,7 +442,6 @@ static SPNavigatorController *sharedNavigatorController = nil;
NSString *connectionName = [doc connectionID];
if(!connectionName || [connectionName isEqualToString:@"_"] || (connectionID && ![connectionName isEqualToString:connectionID]) ) {
-// NSLog(@"navigator update skipped %@", connectionName);
return;
}
@@ -481,21 +473,27 @@ static SPNavigatorController *sharedNavigatorController = nil;
[allSchemaKeys setObject:[NSArray array] forKey:connectionName];
}
- [outlineSchema1 reloadData];
- [outlineSchema2 reloadData];
+ [updatingConnections removeObject:connectionName];
- [self restoreExpandStatus];
- [self restoreSelectedItems];
+ if([[self window] isVisible]) {
+ [outlineSchema1 reloadData];
+ [outlineSchema2 reloadData];
- [updatingConnections removeObject:connectionName];
+ [self restoreExpandStatus];
+ [self restoreSelectedItems];
+ }
}
- [self syncButtonAction:self];
+ if([[self window] isVisible])
+ [self syncButtonAction:self];
if(isFiltered && [[self window] isVisible])
[self filterTree:self];
-
+
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"SPNavigatorStructureWasUpdated" object:doc];
+
+
}
- (BOOL)schemaPathExistsForConnection:(NSString*)connectionID andDatabase:(NSString*)dbname
@@ -575,6 +573,11 @@ static SPNavigatorController *sharedNavigatorController = nil;
return ([updatingConnections containsObject:connectionID]) ? YES : NO;
}
+- (BOOL)isUpdating
+{
+ return ([updatingConnections count]) ? YES : NO;
+}
+
#pragma mark -
#pragma mark IBActions
@@ -824,6 +827,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
return [item objectAtIndex:index];
}
return nil;
+
}
- (BOOL)outlineView:(id)outlineView isItemExpandable:(id)item
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index 4ef781e3..b2da29af 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -3690,9 +3690,8 @@
*/
- (void)windowWillClose:(NSNotification *)aNotification
{
- if ([[[SPNavigatorController sharedNavigatorController] window] isVisible]) {
- [[SPNavigatorController sharedNavigatorController] removeConnection:[self connectionID]];
- }
+
+ [[SPNavigatorController sharedNavigatorController] removeConnection:[self connectionID]];
[mySQLConnection setDelegate:nil];
if (_isConnected) [self closeConnection];