From c6d9ccf48dcc12c907fd6e86035b5964972ab881 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Thu, 30 Apr 2009 21:28:40 +0000 Subject: =?UTF-8?q?=E2=80=A2=20added=20"MySQL=20Help"=20to=20the=20MainMen?= =?UTF-8?q?u=20>=20Help=20submenu=20-=20it=20shows=20the=20MySQL=20Help=20?= =?UTF-8?q?TOC=20of=20the=20front=20most=20tableDocument=20mysql=20connect?= =?UTF-8?q?ion,=20i.e.=20each=20tableDocument=20has=20its=20own=20Help=20w?= =?UTF-8?q?indow=20(due=20to=20the=20fact=20that=20the=20Help=20is=20versi?= =?UTF-8?q?on=20specific),=20and=20makes=20it=20the=20keyWindow=20-=20chan?= =?UTF-8?q?ged=20the=20way=20for=20getting=20the=20mySQLversion=20into=20t?= =?UTF-8?q?he=20CustomQuery;=20now=20a=20new=20tableDocument=20set=20it=20?= =?UTF-8?q?via=20[customQueryInstance=20setMySQLversion:foo];=20the=20othe?= =?UTF-8?q?r=20way=20was=20to=20unsafe=20regarding=20to=20get=20the=20vers?= =?UTF-8?q?ion=20if=20MySQL=20Help=20was=20invoked=20via=20MainMenu=20?= =?UTF-8?q?=E2=80=A2=20Help=20window=20and=20Create=20Table=20Syntax=20win?= =?UTF-8?q?dow=20will=20be=20released=20while=20closing=20the=20tableDocum?= =?UTF-8?q?ent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/CustomQuery.h | 4 ++++ Source/CustomQuery.m | 31 ++++++++++++++++++++++--------- Source/TableDocument.h | 1 + Source/TableDocument.m | 18 ++++++++++++++++-- 4 files changed, 43 insertions(+), 11 deletions(-) (limited to 'Source') diff --git a/Source/CustomQuery.h b/Source/CustomQuery.h index 1fae3b5d..72cc749c 100644 --- a/Source/CustomQuery.h +++ b/Source/CustomQuery.h @@ -31,6 +31,8 @@ #import "CMMCPResult.h" #import "RegexKitLite.h" +#define SP_HELP_TOC_SEARCH_STRING @"contents" + @interface CustomQuery : NSObject { IBOutlet id tableWindow; @@ -123,6 +125,8 @@ - (void)showHelpFor:(NSString *)aString addToHistory:(BOOL)addToHistory; - (void)helpTargetValidation; - (void)openMySQLonlineDocumentationWithString:(NSString *)searchString; +- (NSWindow *)helpWebViewWindow; +- (void)setMySQLversion:(NSString *)theVersion; // Other diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index 10cf95f7..755b980f 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -37,7 +37,6 @@ #define SP_HELP_SHOW_TOC_BUTTON 1 #define SP_HELP_GOFORWARD_BUTTON 2 #define SP_HELP_NOT_AVAILABLE @"__no_help_available" -#define SP_HELP_TOC_SEARCH_STRING @"contents" @implementation CustomQuery @@ -1383,6 +1382,21 @@ traps enter key and #pragma mark - #pragma mark MySQL Help +/* + * Set the MySQL version as X.Y for Help window title and online search + */ +- (void)setMySQLversion:(NSString *)theVersion +{ + mySQLversion = [[theVersion substringToIndex:3] retain]; +} + +/* + * Return the Help window. + */ +- (NSWindow *)helpWebViewWindow +{ + return helpWebViewWindow; +} /* * Show the data for "HELP 'searchString'". @@ -1390,18 +1404,13 @@ traps enter key and - (void)showHelpFor:(NSString *)searchString addToHistory:(BOOL)addToHistory { NSString * helpString = [self getHTMLformattedMySQLHelpFor:searchString]; + // Order out resp. init the Help window if not visible if(![helpWebViewWindow isVisible]) { - // get current MySQL version for title and online search - mySQLversion = [[[(TableDocument *)[[textView window] delegate] mySQLVersion] substringToIndex:3] retain]; - + // set title of the Help window [helpWebViewWindow setTitle:[NSString stringWithFormat:@"%@ (%@ %@)", NSLocalizedString(@"MySQL Help", @"mysql help"), NSLocalizedString(@"version", @"version"), mySQLversion]]; - - // init search history - [helpWebView setMaintainsBackForwardList:YES]; - [[helpWebView backForwardList] setCapacity:20]; - + // init goback/forward buttons if([[helpWebView backForwardList] backListCount] < 1) { @@ -1872,6 +1881,10 @@ traps enter key and NSBeep(); } + // init search history + [helpWebView setMaintainsBackForwardList:YES]; + [[helpWebView backForwardList] setCapacity:20]; + return self; } diff --git a/Source/TableDocument.h b/Source/TableDocument.h index fb35d612..94e95047 100644 --- a/Source/TableDocument.h +++ b/Source/TableDocument.h @@ -134,6 +134,7 @@ - (IBAction)addDatabase:(id)sender; - (IBAction)closeDatabaseSheet:(id)sender; - (IBAction)removeDatabase:(id)sender; +- (IBAction)showMySQLHelp:(id)sender; //encoding methods - (void)setConnectionEncoding:(NSString *)mysqlEncoding reloadingViews:(BOOL)reloadViews; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 3acb53b4..ecbe6d86 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -339,6 +339,7 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum [tableSourceInstance setConnection:mySQLConnection]; [tableContentInstance setConnection:mySQLConnection]; [customQueryInstance setConnection:mySQLConnection]; + [customQueryInstance setMySQLversion:mySQLVersion]; [tableDumpInstance setConnection:mySQLConnection]; [spExportControllerInstance setConnection:mySQLConnection]; [tableStatusInstance setConnection:mySQLConnection]; @@ -1436,11 +1437,22 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum return [self export:sender]; } +/* + * Show the MySQL Help TOC of the current MySQL connection + * Invoked by the MainMenu > Help > MySQL Help + */ +- (IBAction)showMySQLHelp:(id)sender +{ + [customQueryInstance showHelpFor:SP_HELP_TOC_SEARCH_STRING addToHistory:YES]; + [[customQueryInstance helpWebViewWindow] makeKeyWindow]; +} + + /** * Menu validation */ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem -{ +{ if ([menuItem action] == @selector(import:) || [menuItem action] == @selector(export:) || [menuItem action] == @selector(exportMultipleTables:) || @@ -1816,7 +1828,7 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum //set up toolbar [self setupToolbar]; - // [self connectToDB:nil]; + // [self connectToDB:nil]; [self performSelector:@selector(connectToDB:) withObject:tableWindow afterDelay:0.0f]; if([prefs boolForKey:@"SelectLastFavoriteUsed"] == YES){ @@ -1835,6 +1847,8 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum { if ([mySQLConnection isConnected]) [self closeConnection]; if ([[[SPQueryConsole sharedQueryConsole] window] isVisible]) [self toggleConsole:self]; + [[customQueryInstance helpWebViewWindow] release]; + [createTableSyntaxWindow release]; [[NSNotificationCenter defaultCenter] removeObserver:self]; } -- cgit v1.2.3