From af81a0dfbad3e68ae0a5e6cb40e86303d6bd744c Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 28 Apr 2009 09:00:15 +0000 Subject: =?UTF-8?q?=E2=80=A2=20added=20"Show=20HELP=20statements"=20to=20M?= =?UTF-8?q?ySQL=20Console?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPQueryConsole.h | 5 ++++- Source/SPQueryConsole.m | 24 ++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) (limited to 'Source') diff --git a/Source/SPQueryConsole.h b/Source/SPQueryConsole.h index 8b1d912d..c3211f18 100644 --- a/Source/SPQueryConsole.h +++ b/Source/SPQueryConsole.h @@ -29,11 +29,12 @@ IBOutlet NSSearchField *consoleSearchField; IBOutlet NSProgressIndicator *progressIndicator; IBOutlet NSButton *includeTimeStampsButton, *saveConsoleButton, *clearConsoleButton; - IBOutlet NSMenuItem *showTimeStampsMenuItem, *showSelectShowStatementsMenuItem; + IBOutlet NSMenuItem *showTimeStampsMenuItem, *showSelectShowStatementsMenuItem, *showHelpMenuItem; NSFont *consoleFont; NSMutableArray *messagesFullSet, *messagesFilteredSet, *messagesVisibleSet; BOOL showSelectStatementsAreDisabled; + BOOL showHelpStatementsAreDisabled; BOOL filterIsActive; NSMutableString *activeFilterString; } @@ -47,6 +48,8 @@ - (IBAction)saveConsoleAs:(id)sender; - (IBAction)toggleShowTimeStamps:(id)sender; - (IBAction)toggleShowSelectShowStatements:(id)sender; +- (IBAction)toggleShowHelpStatements:(id)sender; + - (void)showMessageInConsole:(NSString *)message; - (void)showErrorInConsole:(NSString *)error; diff --git a/Source/SPQueryConsole.m b/Source/SPQueryConsole.m index 6e65b3a2..5314028b 100644 --- a/Source/SPQueryConsole.m +++ b/Source/SPQueryConsole.m @@ -85,6 +85,7 @@ static SPQueryConsole *sharedQueryConsole = nil; messagesFilteredSet = [[NSMutableArray alloc] init]; showSelectStatementsAreDisabled = NO; + showHelpStatementsAreDisabled = NO; filterIsActive = NO; activeFilterString = [[NSMutableString alloc] init]; @@ -117,6 +118,7 @@ static SPQueryConsole *sharedQueryConsole = nil; [self setWindowFrameAutosaveName:CONSOLE_WINDOW_AUTO_SAVE_NAME]; [[consoleTableView tableColumnWithIdentifier:TABLEVIEW_DATE_COLUMN_IDENTIFIER] setHidden:![[NSUserDefaults standardUserDefaults] boolForKey:@"ConsoleShowTimestamps"]]; showSelectStatementsAreDisabled = ![[NSUserDefaults standardUserDefaults] boolForKey:@"ConsoleShowSelectsAndShows"]; + showHelpStatementsAreDisabled = ![[NSUserDefaults standardUserDefaults] boolForKey:@"ConsoleShowHelps"]; [self _updateFilterState]; } @@ -217,6 +219,17 @@ static SPQueryConsole *sharedQueryConsole = nil; [self _updateFilterState]; } +/** + * Toggles the hiding of messages containing HELP statements + */ +- (IBAction)toggleShowHelpStatements:(id)sender +{ + // Store the state of the toggle for later quick reference + showHelpStatementsAreDisabled = [sender state]; + + [self _updateFilterState]; +} + /** * Shows the supplied message in the console. */ @@ -400,7 +413,7 @@ static SPQueryConsole *sharedQueryConsole = nil; // If filtering is disabled and all show/selects are shown, empty the filtered // result set and set the full set to visible. - if (!filterIsActive && !showSelectStatementsAreDisabled) { + if (!filterIsActive && !showSelectStatementsAreDisabled && !showHelpStatementsAreDisabled) { messagesVisibleSet = messagesFullSet; [consoleTableView reloadData]; @@ -461,7 +474,7 @@ static SPQueryConsole *sharedQueryConsole = nil; [messagesFullSet addObject:consoleMessage]; // If filtering is active, determine whether to add a reference to the filtered set - if ((showSelectStatementsAreDisabled || filterIsActive) + if ((showSelectStatementsAreDisabled || showHelpStatementsAreDisabled || filterIsActive) && [self _messageMatchesCurrentFilters:[consoleMessage message]]) { [messagesFilteredSet addObject:[messagesFullSet lastObject]]; @@ -496,6 +509,13 @@ static SPQueryConsole *sharedQueryConsole = nil; { messageMatchesCurrentFilters = NO; } + // If hiding HELP is toggled to on, check whether the message is a HELP + if (messageMatchesCurrentFilters + && showHelpStatementsAreDisabled + && ([[message uppercaseString] hasPrefix:@"HELP"])) + { + messageMatchesCurrentFilters = NO; + } return messageMatchesCurrentFilters; } -- cgit v1.2.3