diff options
author | rowanbeentje <rowan@beent.je> | 2009-11-05 00:00:23 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2009-11-05 00:00:23 +0000 |
commit | 4cc035fd625bc2ee76927cf9e7649af829ce8482 (patch) | |
tree | 170a8ac6da319e002f48e1ca561f55f5177d4209 /Source | |
parent | 97fd0957cef34210caece133fee16a370e5b9f5d (diff) | |
download | sequelpro-4cc035fd625bc2ee76927cf9e7649af829ce8482.tar.gz sequelpro-4cc035fd625bc2ee76927cf9e7649af829ce8482.tar.bz2 sequelpro-4cc035fd625bc2ee76927cf9e7649af829ce8482.zip |
- Alter query start/stop notifications to apply to only the originating window, regardless of key state, by passing in and looking for the table document instance
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CustomQuery.m | 10 | ||||
-rw-r--r-- | Source/TableContent.m | 14 | ||||
-rw-r--r-- | Source/TableDocument.m | 20 | ||||
-rw-r--r-- | Source/TableSource.m | 8 | ||||
-rw-r--r-- | Source/TablesList.m | 4 |
5 files changed, 22 insertions, 34 deletions
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index c05d87f7..93567aa5 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -389,7 +389,7 @@ [tableDocumentInstance setQueryMode:SP_QUERYMODE_CUSTOMQUERY]; // Notify listeners that a query has started - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:tableDocumentInstance]; // Start the notification timer to allow notifications to be shown even if frontmost for long queries [[SPGrowlController sharedGrowlController] setVisibilityForNotificationName:@"Query Finished"]; @@ -688,7 +688,7 @@ [streamingResult release]; // Notify any listeners that the query has completed - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; // Perform the Growl notification for query completion [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Query Finished" @@ -734,7 +734,7 @@ [customQueryView setTableInstance:self withTableData:fullResult withColumns:cqColumnDefinition withTableName:resultTableName withConnection:mySQLConnection]; //query finished - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; // Query finished Growl notification [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Query Finished" @@ -1376,7 +1376,7 @@ // Check if the IDstring identifies the current field bijectively int numberOfPossibleUpdateRows = [[[[mySQLConnection queryString:[NSString stringWithFormat:@"SELECT COUNT(*) FROM %@.%@ %@", [[columnDefinition objectForKey:@"db"] backtickQuotedString], [tableForColumn backtickQuotedString], fieldIDQueryString]] fetchRowAsArray] objectAtIndex:0] intValue]; if(numberOfPossibleUpdateRows == 1) { - // [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:self]; + // [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:tableDocumentInstance]; NSString *newObject = nil; if ( [anObject isKindOfClass:[NSCalendarDate class]] ) { @@ -1405,7 +1405,7 @@ [columnDefinition objectForKey:@"db"], [tableForColumn backtickQuotedString], [columnDefinition objectForKey:@"db"], [tableForColumn backtickQuotedString], [columnName backtickQuotedString], newObject, fieldIDQueryString]]; - // [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; + // [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; // Check for errors while UPDATE if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { diff --git a/Source/TableContent.m b/Source/TableContent.m index 29b92a73..6130c5c5 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -239,7 +239,7 @@ } // Post a notification that a query will be performed - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:tableDocumentInstance]; // Retrieve the field names and types for this table from the data cache. This is used when requesting all data as part // of the fieldListForQuery method, and also to decide whether or not to preserve the current filter/sort settings. @@ -459,7 +459,7 @@ [tableContentView setTableInstance:self withTableData:tableValues withColumns:dataColumns withTableName:selectedTable withConnection:mySQLConnection]; // Post the notification that the query is finished - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; // Clear any details to restore now that they have been restored [self clearDetailsToRestore]; @@ -486,7 +486,7 @@ [countText setStringValue:NSLocalizedString(@"Loading table data...", @"Loading table data string")]; // Notify any listeners that a query has started - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:tableDocumentInstance]; // Start construction of the query string queryString = [NSMutableString stringWithFormat:@"SELECT %@ FROM %@", [self fieldListForQuery], [selectedTable backtickQuotedString]]; @@ -562,7 +562,7 @@ [self updateCountText]; // Notify listenters that the query has finished - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; } /* @@ -1488,13 +1488,13 @@ return YES; } - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:tableDocumentInstance]; // If editing, compare the new row to the old row and if they are identical finish editing without saving. if (!isEditingNewRow && [oldRow isEqualToArray:[tableValues objectAtIndex:currentlyEditingRow]]) { isEditingRow = NO; currentlyEditingRow = -1; - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; return YES; } @@ -1574,7 +1574,7 @@ } [mySQLConnection queryString:queryString]; [fieldValues release]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; // If no rows have been changed, show error if appropriate. if ( ![mySQLConnection affectedRows] && ![mySQLConnection getLastErrorMessage] && ![[mySQLConnection getLastErrorMessage] length]) { diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 089c6306..211c37c0 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -2148,17 +2148,7 @@ */ - (void)willPerformQuery:(NSNotification *)notification { - // Only start the progress indicator if this document window is key. - // Because we are starting the progress indicator based on the notification - // of a query being started, we have to prevent other windows from - // starting theirs. The same is also true for the below hasPerformedQuery: - // method. - // - // This code should be removed. Updating user interface elements based on - // notifications is bad practice as notifications are global to the application. - if ([tableWindow isKeyWindow]) { - [queryProgressBar startAnimation:self]; - } + [queryProgressBar startAnimation:self]; } /** @@ -2166,9 +2156,7 @@ */ - (void)hasPerformedQuery:(NSNotification *)notification { - if ([tableWindow isKeyWindow]) { - [queryProgressBar stopAnimation:self]; - } + [queryProgressBar stopAnimation:self]; } /** @@ -3273,9 +3261,9 @@ //register for notifications [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willPerformQuery:) - name:@"SMySQLQueryWillBePerformed" object:nil]; + name:@"SMySQLQueryWillBePerformed" object:self]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(hasPerformedQuery:) - name:@"SMySQLQueryHasBeenPerformed" object:nil]; + name:@"SMySQLQueryHasBeenPerformed" object:self]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:@"NSApplicationWillTerminateNotification" object:nil]; diff --git a/Source/TableSource.m b/Source/TableSource.m index 2111a498..3eb87932 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -86,7 +86,7 @@ loads aTable, put it in an array, update the tableViewColumns and reload the tab [editTableButton setEnabled:enableInteraction]; //query started - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:tableDocumentInstance]; //perform queries and load results in array (each row as a dictionary) tableSourceResult = [[mySQLConnection queryString:[NSString stringWithFormat:@"SHOW COLUMNS FROM %@", [selectedTable backtickQuotedString]]] retain]; @@ -245,7 +245,7 @@ loads aTable, put it in an array, update the tableViewColumns and reload the tab [copyFieldButton setEnabled:NO]; //query finished - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; } /* @@ -1218,7 +1218,7 @@ would result in a position change. originalRowIndex = [[[info draggingPasteboard] stringForType:@"SequelProPasteboard"] intValue]; originalRow = [[NSDictionary alloc] initWithDictionary:[tableFields objectAtIndex:originalRowIndex]]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:tableDocumentInstance]; // Begin construction of the reordering query queryString = [NSMutableString stringWithFormat:@"ALTER TABLE %@ MODIFY COLUMN %@ %@", [selectedTable backtickQuotedString], @@ -1300,7 +1300,7 @@ would result in a position change. } } - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; [originalRow release]; return YES; diff --git a/Source/TablesList.m b/Source/TablesList.m index c2dcd4a7..7bb5ae48 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -83,7 +83,7 @@ if ([tableDocumentInstance database]) { // Notify listeners that a query has started - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:tableDocumentInstance]; // Select the table list for the current database. On MySQL versions after 5 this will include // views; on MySQL versions >= 5.0.02 select the "full" list to also select the table type column. @@ -200,7 +200,7 @@ } */ // Notify listeners that the query has finished - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; } // Add the table headers even if no tables were found |