From 94a35280d5f542211abdef0e8c9de83a4e374d10 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Thu, 11 Jun 2009 08:45:53 +0000 Subject: Add a very basic preference to disable all query logging. This can be expanded upon to disable different types of queries. --- Interfaces/English.lproj/Console.xib | 127 ++++++++++++++----------------- Interfaces/English.lproj/Preferences.xib | 105 ++++++++++++++++++------- Resources/PreferenceDefaults.plist | 2 + Source/SPQueryConsole.h | 1 + Source/SPQueryConsole.m | 21 ++++- Source/TableDocument.m | 7 +- 6 files changed, 164 insertions(+), 99 deletions(-) diff --git a/Interfaces/English.lproj/Console.xib b/Interfaces/English.lproj/Console.xib index 37ed1da0..810fe19c 100644 --- a/Interfaces/English.lproj/Console.xib +++ b/Interfaces/English.lproj/Console.xib @@ -2,13 +2,13 @@ 1050 - 9G55 + 9J61 677 - 949.43 + 949.46 353.00 YES - + YES @@ -237,7 +237,7 @@ 6 System controlBackgroundColor - + 3 MC42NjY2NjY2OQA @@ -451,13 +451,34 @@ - 3 + 1 YES 1 YES YES + + + 290 + {{67, 5}, {375, 14}} + + YES + + 68288064 + 272761856 + + + + + 6 + System + controlColor + + + + + {575, 203} @@ -518,10 +539,6 @@ - - YES - ConsoleShowHelps - YES @@ -752,6 +769,14 @@ 107 + + + loggingDisabledTextField + + + + 110 + @@ -804,6 +829,7 @@ + @@ -1020,6 +1046,20 @@ + + 108 + + + YES + + + + + + 109 + + + @@ -1030,6 +1070,8 @@ -2.IBPluginDependency -3.IBPluginDependency 103.IBPluginDependency + 108.IBPluginDependency + 109.IBPluginDependency 12.IBPluginDependency 13.IBPluginDependency 14.IBPluginDependency @@ -1084,6 +1126,8 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin {{341, 238}, {575, 203}} {{341, 238}, {575, 203}} @@ -1156,7 +1200,7 @@ - 107 + 110 @@ -1182,63 +1226,6 @@ Source/SPWindowAdditions.h - - SPQueryConsole - NSWindowController - - YES - - YES - clearConsole: - copy: - saveConsoleAs: - toggleShowSelectShowStatements: - toggleShowTimeStamps: - - - YES - id - id - id - id - id - - - - YES - - YES - clearConsoleButton - consoleSearchField - consoleTableView - includeTimeStampsButton - progressIndicator - saveConsoleButton - saveLogView - showSelectShowStatementsMenuItem - showTimeStampsMenuItem - - - YES - NSButton - NSSearchField - NSTableView - NSButton - NSProgressIndicator - NSButton - NSView - NSMenuItem - NSMenuItem - - - - IBProjectSource - Source/SPQueryConsole.h - - - - - YES SPQueryConsole NSWindowController @@ -1271,6 +1258,7 @@ consoleSearchField consoleTableView includeTimeStampsButton + loggingDisabledTextField progressIndicator saveConsoleButton saveLogView @@ -1284,6 +1272,7 @@ NSSearchField NSTableView NSButton + NSTextField NSProgressIndicator NSButton NSView @@ -1293,8 +1282,8 @@ - IBDocumentRelativeSource - ../../Source/SPQueryConsole.h + IBProjectSource + Source/SPQueryConsole.h diff --git a/Interfaces/English.lproj/Preferences.xib b/Interfaces/English.lproj/Preferences.xib index 8bbcad15..78716f44 100644 --- a/Interfaces/English.lproj/Preferences.xib +++ b/Interfaces/English.lproj/Preferences.xib @@ -8,7 +8,7 @@ 353.00 YES - + YES @@ -53,14 +53,14 @@ {3.40282e+38, 3.40282e+38} - + 268 YES 268 - {{151, 121}, {254, 26}} + {{151, 141}, {254, 26}} YES @@ -387,7 +387,7 @@ 268 - {{152, 168}, {209, 18}} + {{152, 188}, {209, 18}} YES @@ -414,7 +414,7 @@ 268 - {{40, 196}, {108, 17}} + {{40, 216}, {108, 17}} YES @@ -446,7 +446,7 @@ 268 - {{151, 190}, {254, 26}} + {{151, 210}, {254, 26}} YES @@ -478,7 +478,7 @@ 268 - {{33, 127}, {116, 17}} + {{33, 147}, {116, 17}} YES @@ -494,7 +494,7 @@ 268 - {{152, 82}, {166, 18}} + {{152, 102}, {166, 18}} YES @@ -516,7 +516,7 @@ 268 - {{152, 62}, {254, 18}} + {{152, 82}, {254, 18}} YES @@ -538,7 +538,7 @@ 12 - {{154, 156}, {326, 5}} + {{154, 176}, {326, 5}} {0, 0} @@ -568,7 +568,7 @@ 12 - {{154, 108}, {326, 5}} + {{154, 128}, {326, 5}} {0, 0} @@ -686,8 +686,8 @@ YES YES - , - . + . + , NO YES NO @@ -719,8 +719,31 @@ + + + 268 + {{152, 62}, {300, 18}} + + YES + + 67239424 + 0 + Log all query activity to the console (slower) + + + 1211912703 + 130 + + + + + 200 + 25 + + - {500, 234} + {500, 254} + NSView @@ -921,8 +944,8 @@ YES YES - , - . + . + , NO YES NO @@ -2083,8 +2106,8 @@ AQAAAAA YES YES - , - . + . + , NO YES YES @@ -2139,7 +2162,7 @@ AQAAAAA NSView - + 268 YES @@ -2846,14 +2869,9 @@ AQAAAAA {500, 395} - NSView - - YES - CustomQueryEditorHighlightQueryColor - YES @@ -4467,6 +4485,22 @@ AQAAAAA 1136 + + + value: values.ConsoleEnableLogging + + + + + + value: values.ConsoleEnableLogging + value + values.ConsoleEnableLogging + 2 + + + 1142 + @@ -4530,6 +4564,7 @@ AQAAAAA + General @@ -6257,6 +6292,20 @@ AQAAAAA + + 1137 + + + YES + + + + + + 1138 + + + @@ -6332,6 +6381,8 @@ AQAAAAA 1127.IBPluginDependency 1128.IBPluginDependency 1129.IBPluginDependency + 1137.IBPluginDependency + 1138.IBPluginDependency 117.IBPluginDependency 17.IBEditorWindowLastContentRect 17.IBPluginDependency @@ -6672,7 +6723,9 @@ AQAAAAA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{408, 292}, {500, 234}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{408, 272}, {500, 254}} com.apple.InterfaceBuilder.CocoaPlugin YES @@ -7072,7 +7125,7 @@ AQAAAAA - 1136 + 1142 diff --git a/Resources/PreferenceDefaults.plist b/Resources/PreferenceDefaults.plist index f5825c11..ec642bbd 100644 --- a/Resources/PreferenceDefaults.plist +++ b/Resources/PreferenceDefaults.plist @@ -76,6 +76,8 @@ LastFavoriteIndex 0 + ConsoleEnableLogging + ConsoleShowTimestamps ConsoleShowSelectsAndShows diff --git a/Source/SPQueryConsole.h b/Source/SPQueryConsole.h index 6381bb97..281f2d2e 100644 --- a/Source/SPQueryConsole.h +++ b/Source/SPQueryConsole.h @@ -30,6 +30,7 @@ IBOutlet NSView *saveLogView; IBOutlet NSTableView *consoleTableView; IBOutlet NSSearchField *consoleSearchField; + IBOutlet NSTextField *loggingDisabledTextField; IBOutlet NSProgressIndicator *progressIndicator; IBOutlet NSButton *includeTimeStampsButton, *saveConsoleButton, *clearConsoleButton; IBOutlet NSMenuItem *showTimeStampsMenuItem, *showSelectShowStatementsMenuItem, *showHelpMenuItem; diff --git a/Source/SPQueryConsole.m b/Source/SPQueryConsole.m index 04d031f7..a7c7263d 100644 --- a/Source/SPQueryConsole.m +++ b/Source/SPQueryConsole.m @@ -118,11 +118,16 @@ static SPQueryConsole *sharedQueryConsole = nil; */ - (void)awakeFromNib { + NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; + [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"]; + [[consoleTableView tableColumnWithIdentifier:TABLEVIEW_DATE_COLUMN_IDENTIFIER] setHidden:![prefs boolForKey:@"ConsoleShowTimestamps"]]; + showSelectStatementsAreDisabled = ![prefs boolForKey:@"ConsoleShowSelectsAndShows"]; + showHelpStatementsAreDisabled = ![prefs boolForKey:@"ConsoleShowHelps"]; + [self _updateFilterState]; + + [loggingDisabledTextField setStringValue:([prefs boolForKey:@"ConsoleEnableLogging"]) ? @"" : @"Query logging is currently disabled"]; } /** @@ -334,6 +339,16 @@ static SPQueryConsole *sharedQueryConsole = nil; } } +/** + * This method is called as part of Key Value Observing which is used to watch for prefernce changes which effect the interface. + */ +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context +{ + if ([keyPath isEqualToString:@"ConsoleEnableLogging"]) { + [loggingDisabledTextField setStringValue:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? @"" : @"Query logging is currently disabled"]; + } +} + /** * Menu item validation for console table view contextual menu. */ diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 56ca2422..ef0958ab 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -100,6 +100,9 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum [prefs addObserver:tableContentInstance forKeyPath:@"DisplayTableViewVerticalGridlines" options:NSKeyValueObservingOptionNew context:NULL]; [prefs addObserver:customQueryInstance forKeyPath:@"DisplayTableViewVerticalGridlines" options:NSKeyValueObservingOptionNew context:NULL]; + // Register observers for when the preference changes + [prefs addObserver:[SPQueryConsole sharedQueryConsole] forKeyPath:@"ConsoleEnableLogging" options:NSKeyValueObservingOptionNew context:NULL]; + // Register double click for the favorites view (double click favorite to connect) [connectFavoritesTableView setTarget:self]; [connectFavoritesTableView setDoubleAction:@selector(initiateConnection:)]; @@ -2300,7 +2303,9 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum */ - (void)willQueryString:(NSString *)query { - [[SPQueryConsole sharedQueryConsole] showMessageInConsole:query]; + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"ConsoleEnableLogging"]) { + [[SPQueryConsole sharedQueryConsole] showMessageInConsole:query]; + } } /** -- cgit v1.2.3