diff options
author | stuconnolly <stuart02@gmail.com> | 2012-04-01 13:56:59 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2012-04-01 13:56:59 +0000 |
commit | d951d5bcd6a86736c09863af98bef18cbb41eef5 (patch) | |
tree | 7563cc520b5c4570df7f4b818dc0378abbe6a06f /Source/SPExportControllerDelegate.m | |
parent | e0c3c7e6d7eb9748245d2e75759fdc6141890929 (diff) | |
download | sequelpro-d951d5bcd6a86736c09863af98bef18cbb41eef5.tar.gz sequelpro-d951d5bcd6a86736c09863af98bef18cbb41eef5.tar.bz2 sequelpro-d951d5bcd6a86736c09863af98bef18cbb41eef5.zip |
Improve the availability of the table name token on the custom export filename selection.
It's now no longer available during the following situations:
- Exporting more than one table during an SQL export
- Exporting more than one table during a CSV or XML, but only if the export to multiple files is not checked
Diffstat (limited to 'Source/SPExportControllerDelegate.m')
-rw-r--r-- | Source/SPExportControllerDelegate.m | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/Source/SPExportControllerDelegate.m b/Source/SPExportControllerDelegate.m index e8e9f1c6..23821d12 100644 --- a/Source/SPExportControllerDelegate.m +++ b/Source/SPExportControllerDelegate.m @@ -31,6 +31,7 @@ @interface SPExportController (SPExportControllerPrivateAPI) - (void)_toggleExportButtonOnBackgroundThread; +- (void)_toggleSQLExportTableNameTokenAvailability; - (void)_updateExportFormatInformation; - (void)_switchTab; @@ -55,6 +56,7 @@ { [[tables objectAtIndex:rowIndex] replaceObjectAtIndex:[exportTableList columnWithIdentifier:[tableColumn identifier]] withObject:anObject]; + [self updateAvailableExportFilenameTokens]; [self _toggleExportButtonOnBackgroundThread]; [self _updateExportFormatInformation]; } @@ -67,9 +69,9 @@ return (tableView == exportTableList); } -- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex +- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex { - [aCell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [cell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } #pragma mark - @@ -102,23 +104,29 @@ */ - (NSArray *)tokenField:(NSTokenField *)tokenField shouldAddObjects:(NSArray *)tokens atIndex:(NSUInteger)index { - NSMutableArray *processedTokens = [NSMutableArray array]; NSUInteger i, j; + NSMutableArray *processedTokens = [NSMutableArray array]; NSCharacterSet *alphanumericSet = [NSCharacterSet alphanumericCharacterSet]; - for (NSString *inputToken in tokens) { + for (NSString *inputToken in tokens) + { j = 0; - for (i = 0; i < [inputToken length]; i++) { + + for (i = 0; i < [inputToken length]; i++) + { if (![alphanumericSet characterIsMember:[inputToken characterAtIndex:i]]) { if (i > j) { - [processedTokens addObject:[self tokenObjectForString:[inputToken substringWithRange:NSMakeRange(j, i-j)]]]; + [processedTokens addObject:[self tokenObjectForString:[inputToken substringWithRange:NSMakeRange(j, i - j)]]]; } + [processedTokens addObject:[inputToken substringWithRange:NSMakeRange(i, 1)]]; - j = i+1; + + j = i + 1; } } + if (j < i) { - [processedTokens addObject:[self tokenObjectForString:[inputToken substringWithRange:NSMakeRange(j, i-j)]]]; + [processedTokens addObject:[self tokenObjectForString:[inputToken substringWithRange:NSMakeRange(j, i - j)]]]; } } @@ -146,9 +154,9 @@ * During text entry into the token field, update the displayed filename and also * trigger tokenization after a short delay. */ -- (void)controlTextDidChange:(NSNotification *)aNotification +- (void)controlTextDidChange:(NSNotification *)notification { - if ([aNotification object] == exportCustomFilenameTokenField) { + if ([notification object] == exportCustomFilenameTokenField) { [self updateDisplayedExportFilename]; [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(tokenizeCustomFilenameTokenField) object:nil]; [self performSelector:@selector(tokenizeCustomFilenameTokenField) withObject:nil afterDelay:0.5]; |