aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPNavigatorController.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-03-25 08:59:35 +0000
committerBibiko <bibiko@eva.mpg.de>2010-03-25 08:59:35 +0000
commit74cb1152eeb0dcc83f12ea6cf040eacc4e15c551 (patch)
tree71ff5a4d8a069b3f2c8d46be4fe2a4854e42f9fc /Source/SPNavigatorController.m
parent32e858b26923b371a93e800687a13edf1254e445 (diff)
downloadsequelpro-74cb1152eeb0dcc83f12ea6cf040eacc4e15c551.tar.gz
sequelpro-74cb1152eeb0dcc83f12ea6cf040eacc4e15c551.tar.bz2
sequelpro-74cb1152eeb0dcc83f12ea6cf040eacc4e15c551.zip
• Navigator
- make usage of a notification sent by the [MCPConnection queryDbStructure] to update the navigator, and this decouples a doc window and MCPConnection from the navigator - minimized the tree update - now connectionID-based - any tree update will be now performed on main thread and waits until done to avoid 'overlapping' updates triggered by different notifications which normally ended up in an inchoate tree display
Diffstat (limited to 'Source/SPNavigatorController.m')
-rw-r--r--Source/SPNavigatorController.m45
1 files changed, 33 insertions, 12 deletions
diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m
index 6295058c..64e54053 100644
--- a/Source/SPNavigatorController.m
+++ b/Source/SPNavigatorController.m
@@ -82,6 +82,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
- (void)dealloc
{
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
if(schemaData) [schemaData release];
if(schemaDataUnFiltered) [schemaDataUnFiltered release];
if(infoArray) [infoArray release];
@@ -117,6 +118,9 @@ static SPNavigatorController *sharedNavigatorController = nil;
[outlineSchema2 setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES];
[outlineSchema2 setDraggingSourceOperationMask:NSDragOperationEvery forLocal:NO];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateNavigator:)
+ name:@"SPDBStructureWasUpdated" object:nil];
+
}
- (NSString *)windowFrameAutosaveName
@@ -285,7 +289,9 @@ static SPNavigatorController *sharedNavigatorController = nil;
if(schemaData && [schemaData objectForKey:connectionID]) {
NSInteger docCounter = 0;
-
+
+ // Detect if more than one connection windows with the connectionID are open.
+ // If so, don't remove it.
if ([[[NSDocumentController sharedDocumentController] documents] count]) {
for(id doc in [[NSDocumentController sharedDocumentController] documents]) {
if(![[doc valueForKeyPath:@"mySQLConnection"] isConnected]) continue;
@@ -342,10 +348,17 @@ static SPNavigatorController *sharedNavigatorController = nil;
}
}
-#pragma mark -
-#pragma mark IBActions
+- (void)updateNavigator:(NSNotification *)aNotification
+{
+ id object = [aNotification object];
+
+ if([object isKindOfClass:[TableDocument class]])
+ [self performSelectorOnMainThread:@selector(updateEntriesForConnection:) withObject:[object connectionID] waitUntilDone:YES];
+ else
+ [self performSelectorOnMainThread:@selector(updateEntriesForConnection:) withObject:nil waitUntilDone:YES];
+}
-- (IBAction)updateEntries:(id)sender;
+- (void)updateEntriesForConnection:(NSString*)connectionID
{
if(ignoreUpdate) {
@@ -356,7 +369,10 @@ static SPNavigatorController *sharedNavigatorController = nil;
[self saveSelectedItems];
[infoArray removeAllObjects];
- [schemaData removeAllObjects];
+ if(connectionID)
+ [schemaData removeObjectForKey:connectionID];
+ else
+ [schemaData removeAllObjects];
[outlineSchema1 reloadData];
[outlineSchema2 reloadData];
@@ -364,19 +380,21 @@ static SPNavigatorController *sharedNavigatorController = nil;
if ([[[NSDocumentController sharedDocumentController] documents] count]) {
for(id doc in [[NSDocumentController sharedDocumentController] documents]) {
- if(![[doc valueForKeyPath:@"mySQLConnection"] isConnected]) continue;
+ id theConnection = [doc valueForKeyPath:@"mySQLConnection"];
+
+ if(!theConnection || ![theConnection isConnected]) continue;
NSString *connectionName = [doc connectionID];
- if(!connectionName || [connectionName isEqualToString:@"_"]) continue;
+ if(!connectionName || [connectionName isEqualToString:@"_"] || (connectionID && ![connectionName isEqualToString:connectionID]) ) continue;
if(![schemaData objectForKey:connectionName]) {
- if([[doc valueForKeyPath:@"mySQLConnection"] getDbStructure] && [[[doc valueForKeyPath:@"mySQLConnection"] getDbStructure] objectForKey:connectionName]) {
- [schemaData setObject:[[[doc valueForKeyPath:@"mySQLConnection"] getDbStructure] objectForKey:connectionName] forKey:connectionName];
+ if([theConnection getDbStructure] && [[theConnection getDbStructure] objectForKey:connectionName]) {
+ [schemaData setObject:[[theConnection getDbStructure] objectForKey:connectionName] forKey:connectionName];
} else {
- if([[doc valueForKeyPath:@"mySQLConnection"] serverMajorVersion] > 4) {
+ if([theConnection serverMajorVersion] > 4) {
[schemaData setObject:[NSDictionary dictionary] forKey:[NSString stringWithFormat:@"%@&DEL&no data loaded yet", connectionName]];
} else {
[schemaData setObject:[NSDictionary dictionary] forKey:[NSString stringWithFormat:@"%@&DEL&no data for this server version", connectionName]];
@@ -391,7 +409,6 @@ static SPNavigatorController *sharedNavigatorController = nil;
[self restoreExpandStatus];
[self restoreSelectedItems];
-
}
[self syncButtonAction:self];
@@ -399,6 +416,10 @@ static SPNavigatorController *sharedNavigatorController = nil;
}
+#pragma mark -
+#pragma mark IBActions
+
+
- (IBAction)reloadAllStructures:(id)sender
{
@@ -793,7 +814,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row
{
// Use first row as dummy to increase the distance between content and header
- return (row == 0) ? 5.0 : 15; //[tableView rowHeight];
+ return (row == 0) ? 5.0 : 16.0;
}
- (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(NSInteger)rowIndex