diff options
author | rowanbeentje <rowan@beent.je> | 2010-08-01 19:32:27 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2010-08-01 19:32:27 +0000 |
commit | 43a9629aecaf21c37348c81a88f249fc8afe04dd (patch) | |
tree | 745d60716a9e748dfdaa436ea51c72fcb0851f26 /Source/SPTableTriggers.m | |
parent | c2f2a6d1d126e8cb658b745bf5a534ca7307476d (diff) | |
download | sequelpro-43a9629aecaf21c37348c81a88f249fc8afe04dd.tar.gz sequelpro-43a9629aecaf21c37348c81a88f249fc8afe04dd.tar.bz2 sequelpro-43a9629aecaf21c37348c81a88f249fc8afe04dd.zip |
Merge in a range of bugfixes from trunk:
r2201, r2470 (Table trigger improvements, and fixes for MySQL <3.23.5x)
r2211, r2214, r2232, r2245, r2247, r2265, r2266, r2267, r2280 (User manager fixes)
r2213 (Incorrect count display)
r2215, r2270, r2283, r2285, r2471 (Thread-safety fixes)
r2216 (Task progress indicator fixes)
r2217 (CSV import field mapping fix)
r2218, r2219 (Custom queries fixes)
r2222 (Fix issues when opening files)
r2223 (Fixes problems copying binary data as tab-delimited strings)
r2224 (Fixes 10.5 not appending correct extension on export)
r2225, r2324 (Fixes to background database structure querying, extend structure querying to MySQL 3 & 4)
r2227 (Fixes to table saving on right-clicking)
r2228 (Memory use fixes)
r2272, r2279, r2286, r2398, r2399, r2420 (Favourites sorting)
r2275 (Improved handling of corrupt tables, disabled storage engines etc)
r2278 (Custom query autocomplete tab snippets not working under 10.5)
r2297 (Fix structure editing errors)
r2307 (Make return key behaviour in structure view consistent with content view)
r2335 (Fix crashes when cancelling/stopping queries on MySQL 3 & 4)
r2345 (Import from clipboard improvements)
r2362 (Improve robustness when closing windows quickly)
r2384 (Respect "Reload after editing" preference when editing custom query results)
r2385 (Prevent custom query uppercasing of reserved keywords which are quoted)
r2396 (Improve reordering of TIMESTAMP fields)
r2411, r2444, r2446 (Improve Xcode 3.2.3 project compatibility)
r2438 (Fix exceptions printing extended table info)
r2441 (Fix resizing table information after initial collapsed state)
r2445 (Improve default socket search paths)
r2463 (Fix custom query capturing up/down arrow when autocomplete finds no matches)
r2479, r2482 (Replace Core Animation with custom code to fix hangs)
r2486 (Improve data storage exceptions)
Diffstat (limited to 'Source/SPTableTriggers.m')
-rw-r--r-- | Source/SPTableTriggers.m | 103 |
1 files changed, 50 insertions, 53 deletions
diff --git a/Source/SPTableTriggers.m b/Source/SPTableTriggers.m index 5c4f13ad..9f3b948c 100644 --- a/Source/SPTableTriggers.m +++ b/Source/SPTableTriggers.m @@ -77,12 +77,7 @@ selector:@selector(triggerStatementTextDidChange:) name:NSTextStorageDidProcessEditingNotification object:[triggerStatementTextView textStorage]]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(tableSelectionChanged:) - name:SPTableChangedNotification - object:tableDocumentInstance]; - + // Add observers for document task activity [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startDocumentTaskForTab:) @@ -94,6 +89,46 @@ object:tableDocumentInstance]; } +/** + * Called whenever the user selects the triggers tab for the first time, + * or switches between tables with the triggers tab active. + */ +- (void)loadTriggers +{ + BOOL enableInteraction = ((![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableTriggers]) || (![tableDocumentInstance isWorking])); + + // Disable all interface elements by default + [addTriggerButton setEnabled:NO]; + [refreshTriggersButton setEnabled:NO]; + [triggersTableView setEnabled:NO]; + [labelTextField setStringValue:@""]; + + // Show a warning if the version of MySQL is too low to support triggers + if ([connection serverMajorVersion] < 5 + || ([connection serverMajorVersion] == 5 + && [connection serverMinorVersion] == 0 + && [connection serverReleaseVersion] < 2)) + { + [labelTextField setStringValue:NSLocalizedString(@"This version of MySQL does not support triggers. Support for triggers was added in MySQL 5.0.2", @"triggers not supported label")]; + return; + } + + // If no item is selected, or the item selected is not a table, return. + if (![tablesListInstance tableName] || [tablesListInstance tableType] != SPTableTypeTable) + return; + + // Update the text label + [labelTextField setStringValue:[NSString stringWithFormat:NSLocalizedString(@"Triggers for table: %@", @"triggers for table label"), [tablesListInstance tableName]]]; + + // Enable interface elements + [addTriggerButton setEnabled:enableInteraction]; + [refreshTriggersButton setEnabled:enableInteraction]; + [triggersTableView setEnabled:YES]; + + // Ensure trigger data is loaded + [self _refreshTriggerDataForcingCacheRefresh:NO]; +} + #pragma mark - #pragma mark IB action methods @@ -131,7 +166,7 @@ if (([connection queryErrored])) { SPBeginAlertSheet(NSLocalizedString(@"Error creating trigger", @"error creating trigger message"), NSLocalizedString(@"OK", @"OK button"), - nil, nil, [NSApp mainWindow], nil, nil, nil, nil, + nil, nil, [NSApp mainWindow], nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"The specified trigger was unable to be created.\n\nMySQL said: %@", @"error creating trigger informative message"), [connection getLastErrorMessage]]); } else { @@ -185,49 +220,6 @@ [self _refreshTriggerDataForcingCacheRefresh:YES]; } -/** - * Called whenever the user selects a different table. - */ -- (void)tableSelectionChanged:(NSNotification *)notification -{ - BOOL enableInteraction = ((![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableTriggers]) || (![tableDocumentInstance isWorking])); - - // To begin enable all interface elements - [addTriggerButton setEnabled:enableInteraction]; - [refreshTriggersButton setEnabled:enableInteraction]; - [triggersTableView setEnabled:YES]; - - if (([connection serverMajorVersion] >= 5) && - ([connection serverMinorVersion] >= 0) && - ([connection serverReleaseVersion] >= 2)) { - - // Update the text label - [labelTextField setStringValue:[NSString stringWithFormat:NSLocalizedString(@"Triggers for table: %@", @"triggers for table label"), [tablesListInstance tableName]]]; - - [addTriggerButton setEnabled:enableInteraction]; - [refreshTriggersButton setEnabled:enableInteraction]; - [triggersTableView setEnabled:YES]; - - [self _refreshTriggerDataForcingCacheRefresh:NO]; - } - else { - [addTriggerButton setEnabled:NO]; - [refreshTriggersButton setEnabled:NO]; - [triggersTableView setEnabled:NO]; - - [labelTextField setStringValue:NSLocalizedString(@"This version of MySQL does not support triggers. Support for triggers was added in MySQL 5.0.2", @"triggers not supported label")]; - } - - // If a proc or function is selected disable everything. - if (([tablesListInstance tableType] == SPTableTypeProc) || ([tablesListInstance tableType] == SPTableTypeFunc)) { - [addTriggerButton setEnabled:NO]; - [refreshTriggersButton setEnabled:NO]; - [triggersTableView setEnabled:NO]; - - [labelTextField setStringValue:@""]; - } -} - #pragma mark - #pragma mark Tableview datasource methods @@ -330,7 +322,7 @@ SPBeginAlertSheet(NSLocalizedString(@"Unable to remove trigger", @"error removing trigger message"), NSLocalizedString(@"OK", @"OK button"), - nil, nil, [NSApp mainWindow], nil, nil, nil, nil, + nil, nil, [NSApp mainWindow], nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"The selected trigger couldn't be removed.\n\nMySQL said: %@", @"error removing trigger informative message"), [connection getLastErrorMessage]]); // Abort loop @@ -479,9 +471,14 @@ if ([tablesListInstance tableType] == SPTableTypeTable) { - if (clearAllCaches) [tableDataInstance updateInformationForCurrentTable]; + if (clearAllCaches) { + [tableDataInstance resetAllData]; + [tableDataInstance updateTriggersForCurrentTable]; + } - NSArray *triggers = [tableDataInstance triggers]; + NSArray *triggers = nil; + if ([connection serverMajorVersion] >= 5 && [connection serverMinorVersion] >= 0) + triggers = [tableDataInstance triggers]; for (NSDictionary *trigger in triggers) { |