aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-12-03 16:21:50 +0000
committerBibiko <bibiko@eva.mpg.de>2009-12-03 16:21:50 +0000
commit73ed762bceaf6244d00486c183f83639915dfe32 (patch)
treecaffcaae0e521036185241d46c2ebcc2369c2f8c /Source
parentcbafa5a85f87ce883f6be5cf75b19544560b750f (diff)
downloadsequelpro-73ed762bceaf6244d00486c183f83639915dfe32.tar.gz
sequelpro-73ed762bceaf6244d00486c183f83639915dfe32.tar.bz2
sequelpro-73ed762bceaf6244d00486c183f83639915dfe32.zip
• fixed issue for "Update Help while typing" to suppress opening the MySQL documentation periodically if no internal help can be found
Diffstat (limited to 'Source')
-rw-r--r--Source/CMTextView.m4
-rw-r--r--Source/CustomQuery.h5
-rw-r--r--Source/CustomQuery.m49
-rw-r--r--Source/TableDocument.m2
4 files changed, 40 insertions, 20 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index ae526221..ed032400 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -2005,14 +2005,14 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
// If selection show Help for it
if([self selectedRange].length)
{
- [[[[self window] delegate] valueForKeyPath:@"customQueryInstance"] performSelector:@selector(showHelpForCurrentWord:) withObject:self afterDelay:0.1];
+ [[[[self window] delegate] valueForKeyPath:@"customQueryInstance"] performSelector:@selector(showAutoHelpForCurrentWord:) withObject:self afterDelay:0.1];
return;
}
// Otherwise show Help if caret is not inside quotes
long cursorPosition = [self selectedRange].location;
if (cursorPosition >= [[self string] length]) cursorPosition--;
if(cursorPosition > -1 && (![[self textStorage] attribute:kQuote atIndex:cursorPosition effectiveRange:nil]||[[self textStorage] attribute:kSQLkeyword atIndex:cursorPosition effectiveRange:nil]))
- [[[[self window] delegate] valueForKeyPath:@"customQueryInstance"] performSelector:@selector(showHelpForCurrentWord:) withObject:self afterDelay:0.1];
+ [[[[self window] delegate] valueForKeyPath:@"customQueryInstance"] performSelector:@selector(showAutoHelpForCurrentWord:) withObject:self afterDelay:0.1];
}
diff --git a/Source/CustomQuery.h b/Source/CustomQuery.h
index 0cbb6c0c..ba0e456d 100644
--- a/Source/CustomQuery.h
+++ b/Source/CustomQuery.h
@@ -171,8 +171,9 @@
- (void)processResultIntoDataStorage:(MCPStreamingResult *)theResult;
// MySQL Help
-- (NSString *)getHTMLformattedMySQLHelpFor:(NSString *)aString;
-- (void)showHelpFor:(NSString *)aString addToHistory:(BOOL)addToHistory;
+- (void)showAutoHelpForCurrentWord:(id)sender;
+- (NSString *)getHTMLformattedMySQLHelpFor:(NSString *)searchString calledByAutoHelp:(BOOL)autoHelp;
+- (void)showHelpFor:(NSString *)aString addToHistory:(BOOL)addToHistory calledByAutoHelp:(BOOL)autoHelp;
- (void)helpTargetValidation;
- (void)openMySQLonlineDocumentationWithString:(NSString *)searchString;
- (NSWindow *)helpWebViewWindow;
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index 522fb5d0..69f3beb7 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -2131,10 +2131,17 @@
/*
* Show the data for "HELP 'searchString'".
*/
-- (void)showHelpFor:(NSString *)searchString addToHistory:(BOOL)addToHistory
+- (void)showHelpFor:(NSString *)searchString addToHistory:(BOOL)addToHistory calledByAutoHelp:(BOOL)autoHelp
{
-
- NSString * helpString = [self getHTMLformattedMySQLHelpFor:searchString];
+
+ if(![searchString length]) return;
+
+ NSString *helpString = [self getHTMLformattedMySQLHelpFor:searchString calledByAutoHelp:autoHelp];
+
+ if(autoHelp && [helpString isEqualToString:SP_HELP_NOT_AVAILABLE]) {
+ [helpWebViewWindow orderOut:nil];
+ return;
+ }
// Order out resp. init the Help window if not visible
if(![helpWebViewWindow isVisible])
@@ -2163,7 +2170,7 @@
}
- // close Help window if no Help avaiable
+ // close Help window if no Help available
if([helpString isEqualToString:SP_HELP_NOT_AVAILABLE])
[helpWebViewWindow close];
@@ -2205,7 +2212,7 @@
[self openMySQLonlineDocumentationWithString:searchString];
break;
case SP_HELP_SEARCH_IN_MYSQL:
- [self showHelpFor:searchString addToHistory:YES];
+ [self showHelpFor:searchString addToHistory:YES calledByAutoHelp:NO];
break;
}
}
@@ -2215,7 +2222,7 @@
*/
- (IBAction)showHelpForWebViewSelection:(id)sender
{
- [self showHelpFor:[[helpWebView selectedDOMRange] text] addToHistory:YES];
+ [self showHelpFor:[[helpWebView selectedDOMRange] text] addToHistory:YES calledByAutoHelp:NO];
}
/*
@@ -2239,7 +2246,7 @@
- (IBAction)showHelpForCurrentWord:(id)sender
{
NSString *searchString = [[sender string] substringWithRange:[sender getRangeForCurrentWord]];
- [self showHelpFor:searchString addToHistory:YES];
+ [self showHelpFor:searchString addToHistory:YES calledByAutoHelp:NO];
}
/*
@@ -2269,7 +2276,7 @@
[helpWebView goBack];
break;
case SP_HELP_SHOW_TOC_BUTTON:
- [self showHelpFor:SP_HELP_TOC_SEARCH_STRING addToHistory:YES];
+ [self showHelpFor:SP_HELP_TOC_SEARCH_STRING addToHistory:YES calledByAutoHelp:NO];
break;
case SP_HELP_GOFORWARD_BUTTON:
[helpWebView goForward];
@@ -2309,6 +2316,15 @@
}
/*
+ * Show the data for "HELP 'currentWord' invoked by autohelp"
+ */
+- (void)showAutoHelpForCurrentWord:(id)sender
+{
+ NSString *searchString = [[sender string] substringWithRange:[sender getRangeForCurrentWord]];
+ [self showHelpFor:searchString addToHistory:YES calledByAutoHelp:YES];
+}
+
+/*
* Control the help search field behaviour.
*/
- (void)helpTargetValidation
@@ -2339,7 +2355,7 @@
* Return the help string HTML formatted from executing "HELP 'searchString'".
* If more than one help topic was found return a link list.
*/
-- (NSString *)getHTMLformattedMySQLHelpFor:(NSString *)searchString
+- (NSString *)getHTMLformattedMySQLHelpFor:(NSString *)searchString calledByAutoHelp:(BOOL)autoHelp
{
if(![searchString length]) return @"";
@@ -2353,11 +2369,14 @@
// search via: HELP 'searchString'
theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"HELP '%@'", [searchString stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"]]];
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""])
+ if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""])
{
- // if an error or HELP is not supported fall back to online search
- NSLog(@"Error in HELP statement for '%@'", searchString);
- [self openMySQLonlineDocumentationWithString:searchString];
+ // if an error or HELP is not supported fall back to online search but
+ // don't open it if autoHelp is enabled
+ if(!autoHelp)
+ [self openMySQLonlineDocumentationWithString:searchString];
+
+ [helpWebViewWindow close];
return SP_HELP_NOT_AVAILABLE;
}
// nothing found?
@@ -2487,7 +2506,7 @@
int navigationType = [[actionInformation objectForKey:WebActionNavigationTypeKey] intValue];
if([[[request URL] scheme] isEqualToString:@"applewebdata"] && navigationType == WebNavigationTypeLinkClicked){
- [self showHelpFor:[[[request URL] path] lastPathComponent] addToHistory:YES];
+ [self showHelpFor:[[[request URL] path] lastPathComponent] addToHistory:YES calledByAutoHelp:NO];
[listener ignore];
} else {
if (navigationType == WebNavigationTypeOther) {
@@ -2502,7 +2521,7 @@
[listener ignore];
} else if (navigationType == WebNavigationTypeBackForward) {
// catch back/forward events from contextual menu
- [self showHelpFor:[[[[actionInformation objectForKey:WebActionOriginalURLKey] absoluteString] lastPathComponent] stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding] addToHistory:NO];
+ [self showHelpFor:[[[[actionInformation objectForKey:WebActionOriginalURLKey] absoluteString] lastPathComponent] stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding] addToHistory:NO calledByAutoHelp:NO];
[listener ignore];
} else if (navigationType == WebNavigationTypeReload) {
// just in case
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index 0269d1a6..ba98a3d7 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -2822,7 +2822,7 @@
*/
- (IBAction)showMySQLHelp:(id)sender
{
- [customQueryInstance showHelpFor:SP_HELP_TOC_SEARCH_STRING addToHistory:YES];
+ [customQueryInstance showHelpFor:SP_HELP_TOC_SEARCH_STRING addToHistory:YES calledByAutoHelp:NO];
[[customQueryInstance helpWebViewWindow] makeKeyWindow];
}