diff options
author | stuconnolly <stuart02@gmail.com> | 2009-11-14 13:23:17 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2009-11-14 13:23:17 +0000 |
commit | ffab593752dd8fbd56f7eeb0f7fa666a938ba774 (patch) | |
tree | 692fb5c1a551bda9e9289725382de3fc0a71c706 /Source | |
parent | a4a502eedaf862dce9f22108a5f9a1454b76d72c (diff) | |
download | sequelpro-ffab593752dd8fbd56f7eeb0f7fa666a938ba774.tar.gz sequelpro-ffab593752dd8fbd56f7eeb0f7fa666a938ba774.tar.bz2 sequelpro-ffab593752dd8fbd56f7eeb0f7fa666a938ba774.zip |
Bunch of improvements to the query console, including:
- New connection column (been meaning to add this for a while)
- Display table view column headers
- Enable table view text cell line truncating
- Allow table view columns to be re-ordered
- The table view now respects the display table view vertical grid lines preference
- Support for including the connection when saving messages to a file
- Support for showing/hiding the connection column
- Increase table view row height to match that of all others
- Display message time stamps using the user's system wide medium time format
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPConnectionDelegate.m | 4 | ||||
-rw-r--r-- | Source/SPConsoleMessage.h | 7 | ||||
-rw-r--r-- | Source/SPConsoleMessage.m | 20 | ||||
-rw-r--r-- | Source/SPConstants.h | 1 | ||||
-rw-r--r-- | Source/SPConstants.m | 1 | ||||
-rw-r--r-- | Source/SPProcessListController.m | 2 | ||||
-rw-r--r-- | Source/SPQueryController.h | 13 | ||||
-rw-r--r-- | Source/SPQueryController.m | 247 | ||||
-rw-r--r-- | Source/SPServerVariablesController.m | 2 | ||||
-rw-r--r-- | Source/TableContent.m | 2 | ||||
-rw-r--r-- | Source/TableDocument.h | 2 | ||||
-rw-r--r-- | Source/TableDocument.m | 3 |
12 files changed, 182 insertions, 122 deletions
diff --git a/Source/SPConnectionDelegate.m b/Source/SPConnectionDelegate.m index e306c497..ca0378b3 100644 --- a/Source/SPConnectionDelegate.m +++ b/Source/SPConnectionDelegate.m @@ -44,7 +44,7 @@ || (_queryMode == SPCustomQueryQueryMode && [prefs boolForKey:SPConsoleEnableCustomQueryLogging]) || (_queryMode == SPImportExportQueryMode && [prefs boolForKey:SPConsoleEnableImportExportLogging])) { - [[SPQueryController sharedQueryController] showMessageInConsole:query]; + [[SPQueryController sharedQueryController] showMessageInConsole:query connection:[self name]]; } } } @@ -55,7 +55,7 @@ - (void)queryGaveError:(NSString *)error connection:(id)connection { if ([prefs boolForKey:SPConsoleEnableLogging] && [prefs boolForKey:SPConsoleEnableErrorLogging]) { - [[SPQueryController sharedQueryController] showErrorInConsole:error]; + [[SPQueryController sharedQueryController] showErrorInConsole:error connection:[self name]]; } } diff --git a/Source/SPConsoleMessage.h b/Source/SPConsoleMessage.h index fff96276..d78c4f09 100644 --- a/Source/SPConsoleMessage.h +++ b/Source/SPConsoleMessage.h @@ -29,15 +29,18 @@ { BOOL isError; NSDate *messageDate; + NSString *message; + NSString *messageConnection; } @property (readwrite, assign) BOOL isError; @property (readwrite, retain) NSDate *messageDate; @property (readwrite, retain) NSString *message; +@property (readwrite, retain) NSString *messageConnection; -+ (SPConsoleMessage *)consoleMessageWithMessage:(NSString *)consoleMessage date:(NSDate *)date; ++ (SPConsoleMessage *)consoleMessageWithMessage:(NSString *)consoleMessage date:(NSDate *)date connection:(NSString *)connection; -- (id)initWithMessage:(NSString *)message date:(NSDate *)date; +- (id)initWithMessage:(NSString *)message date:(NSDate *)date connection:(NSString *)connection; @end diff --git a/Source/SPConsoleMessage.m b/Source/SPConsoleMessage.m index 25a00e9b..e851a9ef 100644 --- a/Source/SPConsoleMessage.m +++ b/Source/SPConsoleMessage.m @@ -30,26 +30,38 @@ @synthesize isError; @synthesize messageDate; @synthesize message; +@synthesize messageConnection; -+ (SPConsoleMessage *)consoleMessageWithMessage:(NSString *)message date:(NSDate *)date +/** + * + */ ++ (SPConsoleMessage *)consoleMessageWithMessage:(NSString *)message date:(NSDate *)date connection:(NSString *)connection { - return [[[SPConsoleMessage alloc] initWithMessage:message date:date] autorelease]; + return [[[SPConsoleMessage alloc] initWithMessage:message date:date connection:connection] autorelease]; } -- (id)initWithMessage:(NSString *)consoleMessage date:(NSDate *)date +/** + * + */ +- (id)initWithMessage:(NSString *)consoleMessage date:(NSDate *)date connection:(NSString *)connection { if ((self = [super init])) { - [self setMessage:consoleMessage]; [self setMessageDate:date]; + [self setMessage:consoleMessage]; + [self setMessageConnection:connection]; } return self; } +/** + * Dealloc. + */ - (void)dealloc { [message release], message = nil; [messageDate release], messageDate = nil; + [messageConnection release], messageConnection = nil; [super dealloc]; } diff --git a/Source/SPConstants.h b/Source/SPConstants.h index fa5e0e85..3c40fc66 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -143,6 +143,7 @@ extern NSString *SPLastUsedVersion; // GUI Prefs extern NSString *SPConsoleShowTimestamps; +extern NSString *SPConsoleShowConnections; extern NSString *SPConsoleShowSelectsAndShows; extern NSString *SPConsoleShowHelps; extern NSString *SPEditInSheetEnabled; diff --git a/Source/SPConstants.m b/Source/SPConstants.m index 188a6282..4cafc02e 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -96,6 +96,7 @@ NSString *SPLastUsedVersion = @"LastUsedVersion"; NSString *SPConsoleShowHelps = @"ConsoleShowHelps"; NSString *SPConsoleShowSelectsAndShows = @"ConsoleShowSelectsAndShows"; NSString *SPConsoleShowTimestamps = @"ConsoleShowTimestamps"; +NSString *SPConsoleShowConnections = @"ConsoleShowConnections"; NSString *SPEditInSheetEnabled = @"EditInSheetEnabled"; NSString *SPTableInformationPanelCollapsed = @"TableInformationPanelCollapsed"; NSString *SPTableColumnWidths = @"tableColumnWidths"; diff --git a/Source/SPProcessListController.m b/Source/SPProcessListController.m index af160177..864bccc3 100644 --- a/Source/SPProcessListController.m +++ b/Source/SPProcessListController.m @@ -487,7 +487,7 @@ [processListTableView reloadData]; - [processesCountTextField setStringValue:[NSString stringWithFormat:NSLocalizedString(@"%d of %d", "filtered server processes count"), [processesFiltered count], [processes count]]]; + [processesCountTextField setStringValue:[NSString stringWithFormat:NSLocalizedString(@"%d of %d", "filtered item count"), [processesFiltered count], [processes count]]]; [processesCountTextField setHidden:NO]; if ([processesFiltered count] == 0) return; diff --git a/Source/SPQueryController.h b/Source/SPQueryController.h index 79d1ea8c..2a7af9ca 100644 --- a/Source/SPQueryController.h +++ b/Source/SPQueryController.h @@ -33,8 +33,7 @@ IBOutlet NSSearchField *consoleSearchField; IBOutlet NSTextField *loggingDisabledTextField; IBOutlet NSProgressIndicator *progressIndicator; - IBOutlet NSButton *includeTimeStampsButton, *saveConsoleButton, *clearConsoleButton; - IBOutlet NSMenuItem *showTimeStampsMenuItem, *showSelectShowStatementsMenuItem, *showHelpMenuItem; + IBOutlet NSButton *includeTimeStampsButton, *includeConnectionButton, *saveConsoleButton, *clearConsoleButton; NSFont *consoleFont; NSMutableArray *messagesFullSet, *messagesFilteredSet, *messagesVisibleSet; @@ -53,6 +52,7 @@ NSUInteger numberOfMaxAllowedHistory; NSUserDefaults *prefs; + NSDateFormatter *dateFormatter; } @property (readwrite, retain) NSFont *consoleFont; @@ -64,16 +64,17 @@ - (IBAction)clearConsole:(id)sender; - (IBAction)saveConsoleAs:(id)sender; - (IBAction)toggleShowTimeStamps:(id)sender; +- (IBAction)toggleShowConnections:(id)sender; - (IBAction)toggleShowSelectShowStatements:(id)sender; - (IBAction)toggleShowHelpStatements:(id)sender; - (void)updateEntries; -- (BOOL) allowConsoleUpdate; -- (void) setAllowConsoleUpdate:(BOOL)allowUpdate; +- (BOOL)allowConsoleUpdate; +- (void)setAllowConsoleUpdate:(BOOL)allowUpdate; -- (void)showMessageInConsole:(NSString *)message; -- (void)showErrorInConsole:(NSString *)error; +- (void)showMessageInConsole:(NSString *)message connection:(NSString *)connection; +- (void)showErrorInConsole:(NSString *)error connection:(NSString *)connection; - (NSUInteger)consoleMessageCount; diff --git a/Source/SPQueryController.m b/Source/SPQueryController.m index eeca9323..f951e582 100644 --- a/Source/SPQueryController.m +++ b/Source/SPQueryController.m @@ -32,20 +32,19 @@ #define MESSAGE_TIME_STAMP_FORMAT @"%H:%M:%S" #define DEFAULT_CONSOLE_LOG_FILENAME @"untitled" - #define CONSOLE_WINDOW_AUTO_SAVE_NAME @"QueryConsole" // Table view column identifiers -#define TABLEVIEW_MESSAGE_COLUMN_IDENTIFIER @"message" -#define TABLEVIEW_DATE_COLUMN_IDENTIFIER @"messageDate" +#define TABLEVIEW_MESSAGE_COLUMN_IDENTIFIER @"message" +#define TABLEVIEW_DATE_COLUMN_IDENTIFIER @"messageDate" +#define TABLEVIEW_CONNECTION_COLUMN_IDENTIFIER @"messageConnection" @interface SPQueryController (PrivateAPI) -- (NSString *)_getConsoleStringWithTimeStamps:(BOOL)timeStamps; - - (void)_updateFilterState; -- (void)_addMessageToConsole:(NSString *)message isError:(BOOL)error; - (BOOL)_messageMatchesCurrentFilters:(NSString *)message; +- (NSString *)_getConsoleStringWithTimeStamps:(BOOL)timeStamps connections:(BOOL)connections; +- (void)_addMessageToConsole:(NSString *)message connection:(NSString *)connection isError:(BOOL)error; @end @@ -131,37 +130,34 @@ static SPQueryController *sharedQueryController = nil; prefs = [NSUserDefaults standardUserDefaults]; [self setWindowFrameAutosaveName:CONSOLE_WINDOW_AUTO_SAVE_NAME]; + + // Show/hide table columns [[consoleTableView tableColumnWithIdentifier:TABLEVIEW_DATE_COLUMN_IDENTIFIER] setHidden:![prefs boolForKey:SPConsoleShowTimestamps]]; + [[consoleTableView tableColumnWithIdentifier:TABLEVIEW_CONNECTION_COLUMN_IDENTIFIER] setHidden:![prefs boolForKey:SPConsoleShowConnections]]; + showSelectStatementsAreDisabled = ![prefs boolForKey:SPConsoleShowSelectsAndShows]; showHelpStatementsAreDisabled = ![prefs boolForKey:SPConsoleShowHelps]; [self _updateFilterState]; - [loggingDisabledTextField setStringValue:([prefs boolForKey:SPConsoleEnableLogging]) ? @"" : @"Query logging is currently disabled"]; -} - -/** - * Standard dealloc. - */ -- (void)dealloc -{ - messagesVisibleSet = nil; - - [messagesFullSet release], messagesFullSet = nil; - [messagesFilteredSet release], messagesFilteredSet = nil; - [activeFilterString release], activeFilterString = nil; + [loggingDisabledTextField setStringValue:([prefs boolForKey:SPConsoleEnableLogging]) ? @"" : NSLocalizedString(@"Query logging is currently disabled", @"query logging disabled label")]; + + // Setup data formatter + dateFormatter = [[NSDateFormatter alloc] init]; + + [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; + + [dateFormatter setDateStyle:NSDateFormatterNoStyle]; + [dateFormatter setTimeStyle:NSDateFormatterMediumStyle]; - [favoritesContainer release]; - [historyContainer release]; - [contentFilterContainer release]; + // Set the process table view's vertical gridlines if required + [consoleTableView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; - [super dealloc]; } #pragma mark - #pragma mark QueryConsoleController - /** * Copy implementation for console table view. */ @@ -177,6 +173,7 @@ static SPQueryController *sharedQueryController = nil; NSUInteger i = [rows firstIndex]; BOOL dateColumnIsHidden = [[consoleTableView tableColumnWithIdentifier:TABLEVIEW_DATE_COLUMN_IDENTIFIER] isHidden]; + BOOL connectionColumnIsHidden = [[consoleTableView tableColumnWithIdentifier:TABLEVIEW_CONNECTION_COLUMN_IDENTIFIER] isHidden]; [string setString:@""]; @@ -184,18 +181,21 @@ static SPQueryController *sharedQueryController = nil; { if (i < [messagesVisibleSet count]) { SPConsoleMessage *message = NSArrayObjectAtIndex(messagesVisibleSet, i); - - NSString *consoleMessage = [message message]; - + // If the timestamp column is not hidden we need to include them in the copy if (!dateColumnIsHidden) { - - NSString *dateString = [[message messageDate] descriptionWithCalendarFormat:MESSAGE_TIME_STAMP_FORMAT timeZone:nil locale:nil]; - - consoleMessage = [NSString stringWithFormat:@"/* MySQL %@ */ %@", dateString, consoleMessage]; + [string appendString:[dateFormatter stringFromDate:[message messageDate]]]; + [string appendString:@" "]; } - [string appendFormat:@"%@\n", consoleMessage]; + // If the connection column is not hidden we need to include them in the copy + if (!connectionColumnIsHidden) { + [string appendString:[message messageConnection]]; + [string appendString:@" "]; + } + + [string appendString:[message message]]; + [string appendString:@"\n"]; } i = [rows indexGreaterThanIndex:i]; @@ -247,6 +247,14 @@ static SPQueryController *sharedQueryController = nil; } /** + * Toggles the display of message connections column in the table view. + */ +- (IBAction)toggleShowConnections:(id)sender +{ + [[consoleTableView tableColumnWithIdentifier:TABLEVIEW_CONNECTION_COLUMN_IDENTIFIER] setHidden:([sender state])]; +} + +/** * Toggles the hiding of messages containing SELECT and SHOW statements */ - (IBAction)toggleShowSelectShowStatements:(id)sender @@ -269,19 +277,19 @@ static SPQueryController *sharedQueryController = nil; } /** - * Shows the supplied message in the console. + * Shows the supplied message from the supplied connection in the console. */ -- (void)showMessageInConsole:(NSString *)message +- (void)showMessageInConsole:(NSString *)message connection:(NSString *)connection { - [self _addMessageToConsole:message isError:NO]; + [self _addMessageToConsole:message connection:connection isError:NO]; } /** - * Shows the supplied error in the console. + * Shows the supplied error from the supplied connection in the console. */ -- (void)showErrorInConsole:(NSString *)error +- (void)showErrorInConsole:(NSString *)error connection:(NSString *)connection { - [self _addMessageToConsole:error isError:YES]; + [self _addMessageToConsole:error connection:connection isError:YES]; } /** @@ -298,7 +306,7 @@ static SPQueryController *sharedQueryController = nil; - (void)savePanelDidEnd:(NSSavePanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { if (returnCode == NSOKButton) { - [[self _getConsoleStringWithTimeStamps:[includeTimeStampsButton intValue]] writeToFile:[sheet filename] atomically:YES encoding:NSUTF8StringEncoding error:NULL]; + [[self _getConsoleStringWithTimeStamps:[includeTimeStampsButton intValue] connections:[includeConnectionButton intValue]] writeToFile:[sheet filename] atomically:YES encoding:NSUTF8StringEncoding error:NULL]; } } @@ -324,9 +332,11 @@ static SPQueryController *sharedQueryController = nil; if ([[tableColumn identifier] isEqualToString:TABLEVIEW_DATE_COLUMN_IDENTIFIER]) { - NSString *dateString = [(NSDate *)object descriptionWithCalendarFormat:MESSAGE_TIME_STAMP_FORMAT timeZone:nil locale:nil]; + //NSString *dateString = [(NSDate *)object descriptionWithCalendarFormat:MESSAGE_TIME_STAMP_FORMAT timeZone:nil locale:nil]; + + returnValue = [dateFormatter stringFromDate:(NSDate *)object]; - returnValue = [NSString stringWithFormat:@"/* MySQL %@ */", dateString]; + //returnValue = dateString; } else { if ([(NSString *)object length] > MESSAGE_TRUNCATE_CHARACTER_LENGTH) { @@ -381,9 +391,14 @@ static SPQueryController *sharedQueryController = nil; */ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + // Show/hide logging disabled label if ([keyPath isEqualToString:SPConsoleEnableLogging]) { [loggingDisabledTextField setStringValue:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? @"" : @"Query logging is currently disabled"]; } + // Show/hide vertical grid lines in console table view + else if ([keyPath isEqualToString:SPDisplayTableViewVerticalGridlines]) { + [consoleTableView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; + } } /** @@ -403,10 +418,13 @@ static SPQueryController *sharedQueryController = nil; return [[self window] validateMenuItem:menuItem]; } -- (BOOL) allowConsoleUpdate { +- (BOOL) allowConsoleUpdate +{ return allowConsoleUpdate; } -- (void) setAllowConsoleUpdate:(BOOL)allowUpdate { + +- (void) setAllowConsoleUpdate:(BOOL)allowUpdate +{ allowConsoleUpdate = allowUpdate; if (allowUpdate && [[self window] isVisible]) [self updateEntries]; } @@ -427,7 +445,6 @@ static SPQueryController *sharedQueryController = nil; - (NSURL *)registerDocumentWithFileURL:(NSURL *)fileURL andContextInfo:(NSMutableDictionary *)contextInfo { - // Register a new untiled document and return its URL if(fileURL == nil) { NSURL *new = [NSURL URLWithString:[[NSString stringWithFormat:@"Untitled %d", untitledDocumentCounter] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; @@ -476,6 +493,7 @@ static SPQueryController *sharedQueryController = nil; [arr release]; } } + if(![historyContainer objectForKey:[fileURL absoluteString]]) { if(contextInfo != nil && [contextInfo objectForKey:SPQueryHistory] && [[contextInfo objectForKey:SPQueryHistory] count]) { NSMutableArray *arr = [[NSMutableArray alloc] init]; @@ -488,6 +506,7 @@ static SPQueryController *sharedQueryController = nil; [arr release]; } } + if(![contentFilterContainer objectForKey:[fileURL absoluteString]]) { if(contextInfo != nil && [contextInfo objectForKey:SPContentFilters]) { [contentFilterContainer setObject:[contextInfo objectForKey:SPContentFilters] forKey:[fileURL absoluteString]]; @@ -499,12 +518,10 @@ static SPQueryController *sharedQueryController = nil; } return fileURL; - } - (void)removeRegisteredDocumentWithFileURL:(NSURL *)fileURL { - // Check for multiple instance of the same document. // Remove it if only one instance was registerd. NSArray *allDocs = [[NSDocumentController sharedDocumentController] documents]; @@ -523,12 +540,10 @@ static SPQueryController *sharedQueryController = nil; [historyContainer removeObjectForKey:[fileURL absoluteString]]; if([contentFilterContainer objectForKey:[fileURL absoluteString]]) [contentFilterContainer removeObjectForKey:[fileURL absoluteString]]; - } - (void)replaceContentFilterByArray:(NSArray *)contentFilterArray ofType:(NSString *)filterType forFileURL:(NSURL *)fileURL { - if([contentFilterContainer objectForKey:[fileURL absoluteString]]) { NSMutableDictionary *c = [[NSMutableDictionary alloc] init]; [c setDictionary:[contentFilterContainer objectForKey:[fileURL absoluteString]]]; @@ -536,7 +551,6 @@ static SPQueryController *sharedQueryController = nil; [contentFilterContainer setObject:c forKey:[fileURL absoluteString]]; [c release]; } - } - (void)replaceFavoritesByArray:(NSArray *)favoritesArray forFileURL:(NSURL *)fileURL @@ -559,7 +573,6 @@ static SPQueryController *sharedQueryController = nil; - (void)addHistory:(NSString *)history forFileURL:(NSURL *)fileURL { - NSUInteger maxHistoryItems = [[prefs objectForKey:SPCustomQueryMaxHistoryItems] intValue]; // Save each history item due to its document source @@ -575,7 +588,6 @@ static SPQueryController *sharedQueryController = nil; [self replaceHistoryByArray:[uniquifier itemTitles] forFileURL:fileURL]; [uniquifier release]; - } // Save history items coming from each Untitled document in the global Preferences successively @@ -592,9 +604,7 @@ static SPQueryController *sharedQueryController = nil; [prefs setObject:[uniquifier itemTitles] forKey:SPQueryHistory]; [uniquifier release]; - } - } - (NSMutableArray *)favoritesForFileURL:(NSURL *)fileURL @@ -603,7 +613,6 @@ static SPQueryController *sharedQueryController = nil; return [favoritesContainer objectForKey:[fileURL absoluteString]]; return [NSMutableArray array]; - } - (NSMutableArray *)historyForFileURL:(NSURL *)fileURL @@ -612,7 +621,6 @@ static SPQueryController *sharedQueryController = nil; return [historyContainer objectForKey:[fileURL absoluteString]]; return [NSMutableArray array]; - } - (NSMutableDictionary *)contentFilterForFileURL:(NSURL *)fileURL @@ -621,12 +629,10 @@ static SPQueryController *sharedQueryController = nil; return [contentFilterContainer objectForKey:[fileURL absoluteString]]; return [NSMutableDictionary dictionary]; - } - (NSArray *)queryFavoritesForFileURL:(NSURL *)fileURL andTabTrigger:(NSString *)tabTrigger includeGlobals:(BOOL)includeGlobals { - if(![tabTrigger length]) return [NSArray array]; NSMutableArray *result = [[NSMutableArray alloc] init]; @@ -655,33 +661,31 @@ static SPQueryController *sharedQueryController = nil; [[favoritesContainer objectForKey:[fileURL absoluteString]] insertObject:favorite atIndex:index]; } - -@end - -@implementation SPQueryController (PrivateAPI) +#pragma mark - /** - * Creates and returns a string made entirely of all of the console's messages and includes the message - * time stamps if specified. + * Dealloc. */ -- (NSString *)_getConsoleStringWithTimeStamps:(BOOL)timeStamps +- (void)dealloc { - NSMutableString *consoleString = [[[NSMutableString alloc] init] autorelease]; + messagesVisibleSet = nil; - for (SPConsoleMessage *message in messagesVisibleSet) - { - if (timeStamps) { - NSString *dateString = [[message messageDate] descriptionWithCalendarFormat:MESSAGE_TIME_STAMP_FORMAT timeZone:nil locale:nil]; - - [consoleString appendString:[NSString stringWithFormat:@"/* MySQL %@ */ ", dateString]]; - } - - [consoleString appendString:[NSString stringWithFormat:@"%@\n", [message message]]]; - } + [dateFormatter release], dateFormatter = nil; - return consoleString; + [messagesFullSet release], messagesFullSet = nil; + [messagesFilteredSet release], messagesFilteredSet = nil; + [activeFilterString release], activeFilterString = nil; + + [favoritesContainer release], favoritesContainer = nil; + [historyContainer release], historyContainer = nil; + [contentFilterContainer release], contentFilterContainer = nil; + + [super dealloc]; } +@end + +@implementation SPQueryController (PrivateAPI) /** * Updates the filtered result set based on any filter string and whether or not @@ -752,33 +756,6 @@ static SPQueryController *sharedQueryController = nil; } /** - * Adds the supplied message to the query console. - */ -- (void)_addMessageToConsole:(NSString *)message isError:(BOOL)error -{ - SPConsoleMessage *consoleMessage = [SPConsoleMessage consoleMessageWithMessage:[[[message stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] stringByReplacingOccurrencesOfString:@"\n" withString:@" "] stringByAppendingString:@";"] date:[NSDate date]]; - - [consoleMessage setIsError:error]; - - [messagesFullSet addObject:consoleMessage]; - - // If filtering is active, determine whether to add a reference to the filtered set - if ((showSelectStatementsAreDisabled || showHelpStatementsAreDisabled || filterIsActive) - && [self _messageMatchesCurrentFilters:[consoleMessage message]]) - { - [messagesFilteredSet addObject:[messagesFullSet lastObject]]; - [saveConsoleButton setEnabled:YES]; - [clearConsoleButton setEnabled:YES]; - } - - // Reload the table and scroll to the new message if it's visible (for speed) - if ( allowConsoleUpdate && [[self window] isVisible] ) { - [consoleTableView reloadData]; - [consoleTableView scrollRowToVisible:([messagesVisibleSet count] - 1)]; - } -} - -/** * Checks whether the supplied message text matches the current filter text, if any, * and whether it should be hidden if the SELECT/SHOW toggle is off. */ @@ -800,6 +777,7 @@ static SPQueryController *sharedQueryController = nil; { messageMatchesCurrentFilters = NO; } + // If hiding HELP is toggled to on, check whether the message is a HELP if (messageMatchesCurrentFilters && showHelpStatementsAreDisabled @@ -811,4 +789,67 @@ static SPQueryController *sharedQueryController = nil; return messageMatchesCurrentFilters; } +/** + * Creates and returns a string made entirely of all of the console's messages and includes the message + * time stamp and connection if specified. + */ +- (NSString *)_getConsoleStringWithTimeStamps:(BOOL)timeStamps connections:(BOOL)connections +{ + NSMutableString *consoleString = [NSMutableString string]; + + for (SPConsoleMessage *message in messagesVisibleSet) + { + // As we are going to save the messages as an SQL file we need to comment + // the timestamps and connections if included. + if (timeStamps || connections) [consoleString appendString:@"/* "]; + + // If the timestamp column is not hidden we need to include them in the copy + if (timeStamps) { + [consoleString appendString:[dateFormatter stringFromDate:[message messageDate]]]; + [consoleString appendString:@" "]; + } + + // If the connection column is not hidden we need to include them in the copy + if (connections) { + [consoleString appendString:[message messageConnection]]; + [consoleString appendString:@" "]; + } + + // Close the comment + if (timeStamps || connections) [consoleString appendString:@"*/ "]; + + [consoleString appendString:[message message]]; + [consoleString appendString:@"\n"]; + } + + return consoleString; +} + +/** + * Adds the supplied message to the query console. + */ +- (void)_addMessageToConsole:(NSString *)message connection:(NSString *)connection isError:(BOOL)error +{ + SPConsoleMessage *consoleMessage = [SPConsoleMessage consoleMessageWithMessage:[[[message stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] stringByReplacingOccurrencesOfString:@"\n" withString:@" "] stringByAppendingString:@";"] date:[NSDate date] connection:connection]; + + [consoleMessage setIsError:error]; + + [messagesFullSet addObject:consoleMessage]; + + // If filtering is active, determine whether to add a reference to the filtered set + if ((showSelectStatementsAreDisabled || showHelpStatementsAreDisabled || filterIsActive) + && [self _messageMatchesCurrentFilters:[consoleMessage message]]) + { + [messagesFilteredSet addObject:[messagesFullSet lastObject]]; + [saveConsoleButton setEnabled:YES]; + [clearConsoleButton setEnabled:YES]; + } + + // Reload the table and scroll to the new message if it's visible (for speed) + if (allowConsoleUpdate && [[self window] isVisible]) { + [consoleTableView reloadData]; + [consoleTableView scrollRowToVisible:([messagesVisibleSet count] - 1)]; + } +} + @end diff --git a/Source/SPServerVariablesController.m b/Source/SPServerVariablesController.m index ca4f53b1..17bb5ba0 100644 --- a/Source/SPServerVariablesController.m +++ b/Source/SPServerVariablesController.m @@ -317,7 +317,7 @@ [variablesTableView reloadData]; [variablesCountTextField setHidden:NO]; - [variablesCountTextField setStringValue:[NSString stringWithFormat:NSLocalizedString(@"%d of %d", "filtered server variables count"), [variablesFiltered count], [variables count]]]; + [variablesCountTextField setStringValue:[NSString stringWithFormat:NSLocalizedString(@"%d of %d", "filtered item count"), [variablesFiltered count], [variables count]]]; if ([variablesFiltered count] == 0) return; diff --git a/Source/TableContent.m b/Source/TableContent.m index 6d1c4a54..d479a3a3 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -1628,7 +1628,7 @@ isEditingRow = NO; isEditingNewRow = NO; currentlyEditingRow = -1; - [[SPQueryController sharedQueryController] showErrorInConsole:[NSString stringWithFormat:NSLocalizedString(@"/* WARNING %@ No rows have been affected */\n", @"warning shown in the console when no rows have been affected after writing to the db"), currentTime]]; + [[SPQueryController sharedQueryController] showErrorInConsole:[NSString stringWithFormat:NSLocalizedString(@"/* WARNING %@ No rows have been affected */\n", @"warning shown in the console when no rows have been affected after writing to the db"), currentTime] connection:[tableDocumentInstance name]]; return YES; // On success... diff --git a/Source/TableDocument.h b/Source/TableDocument.h index 2aae4da5..f9e96730 100644 --- a/Source/TableDocument.h +++ b/Source/TableDocument.h @@ -231,7 +231,7 @@ - (IBAction)backForwardInHistory:(id)sender; - (IBAction)showUserManager:(id)sender; -// Getter methods +// Accessor methods - (NSString *)host; - (NSString *)name; - (NSString *)database; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 8d1bca5f..df856d33 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -172,6 +172,7 @@ [prefs addObserver:tableContentInstance forKeyPath:SPDisplayTableViewVerticalGridlines options:NSKeyValueObservingOptionNew context:NULL]; [prefs addObserver:customQueryInstance forKeyPath:SPDisplayTableViewVerticalGridlines options:NSKeyValueObservingOptionNew context:NULL]; [prefs addObserver:tableRelationsInstance forKeyPath:SPDisplayTableViewVerticalGridlines options:NSKeyValueObservingOptionNew context:NULL]; + [prefs addObserver:[SPQueryController sharedQueryController] forKeyPath:SPDisplayTableViewVerticalGridlines options:NSKeyValueObservingOptionNew context:NULL]; // Register observers for when the logging preference changes [prefs addObserver:[SPQueryController sharedQueryController] forKeyPath:SPConsoleEnableLogging options:NSKeyValueObservingOptionNew context:NULL]; @@ -2142,7 +2143,7 @@ } #pragma mark - -#pragma mark Getter methods +#pragma mark Accessor methods /** * Returns the host |