aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-04-29 12:18:04 +0000
committerBibiko <bibiko@eva.mpg.de>2009-04-29 12:18:04 +0000
commit0d04e4a8cfe9d5a19a1402664d526bece15c00f9 (patch)
tree4ddcd666c5314a42b57d9a90d873bf913b489f81 /Source
parentb82bf9095ac830629be4191da4ac8345f4b1a3d7 (diff)
downloadsequelpro-0d04e4a8cfe9d5a19a1402664d526bece15c00f9.tar.gz
sequelpro-0d04e4a8cfe9d5a19a1402664d526bece15c00f9.tar.bz2
sequelpro-0d04e4a8cfe9d5a19a1402664d526bece15c00f9.zip
• MySQL Help
- managed contextual menus in webview -- added for selection menu "Search in MySQL Help" and "Search in MySQL Documentation" - fixed keyboard short-cuts in webview - corrected tooltip for "Web" button in GUI
Diffstat (limited to 'Source')
-rw-r--r--Source/CustomQuery.m91
1 files changed, 76 insertions, 15 deletions
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index b209409c..2798139d 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -1431,12 +1431,6 @@ traps enter key and
searchTerm,
[mySQLversion stringByReplacingOccurrencesOfString:@"." withString:@""]]
stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]];
- // [[helpWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:
- // [[NSString stringWithFormat:
- // MYSQL_DEV_SEARCH_URL,
- // [[helpSearchField stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]],
- // [[mySQLversion substringToIndex:3] stringByReplacingOccurrencesOfString:@"." withString:@""]]
- // stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]]];
break;
case 2: // MySQL
[self showHelpFor:searchTerm setHistory:YES];
@@ -1445,6 +1439,28 @@ traps enter key and
}
/*
+ * Retrieve and show the Help for the selected text in the webview
+ */
+- (IBAction)showHelpForWebViewSelection:(id)sender
+{
+ [self showHelpFor:[[helpWebView selectedDOMRange] text] setHistory:YES];
+}
+
+/*
+ * Retrieve and show MySQL's online documentation for the selected text in the webview
+ */
+- (IBAction)searchInDocForWebViewSelection:(id)sender
+{
+ [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:
+ [[NSString stringWithFormat:
+ MYSQL_DEV_SEARCH_URL,
+ [[helpWebView selectedDOMRange] text],
+ [mySQLversion stringByReplacingOccurrencesOfString:@"." withString:@""]]
+ stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]];
+}
+
+
+/*
* Retrieve and show the data for "HELP 'currentWord'"
*/
- (IBAction)getHelpForCurrentWord:(id)sender
@@ -1710,39 +1726,84 @@ traps enter key and
/*
* Link detector: If user clicked at an http link open it in the default browser,
- * otherwise search for it in the MySQL help.
+ * otherwise search for it in the MySQL help. Additionally handle back/forward events from
+ * keyboard and context menu.
*/
- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener
{
int navigationType = [[actionInformation objectForKey:WebActionNavigationTypeKey] intValue];
- if([[[request URL] scheme] isEqualToString:@"applewebdata"]){
- [self showHelpFor:[[[request URL] path] substringWithRange:NSMakeRange(1,[[[request URL] path] length]-1)] setHistory:YES];
+ if([[[request URL] scheme] isEqualToString:@"applewebdata"] && navigationType == WebNavigationTypeLinkClicked){
+ // [self showHelpFor:[[[request URL] path] substringWithRange:NSMakeRange(1,[[[request URL] path] length]-1)] setHistory:YES];
+ [self showHelpFor:[[[request URL] path] lastPathComponent] setHistory:YES];
[listener ignore];
- // WebHistoryItem *aWebHistoryItem = [[WebHistoryItem alloc] initWithURLString:[[request URL] absoluteString] title:[[request URL] path] lastVisitedTimeInterval:[[NSDate date] timeIntervalSinceDate:[NSDate distantFuture]]];
- // [[helpWebView backForwardList] addItem:aWebHistoryItem];
-
} else {
if (navigationType == WebNavigationTypeOther) {
+ // catch reload event
+ // if([[[actionInformation objectForKey:WebActionOriginalURLKey] absoluteString] isEqualToString:@"about:blank"])
+ // [listener use];
+ // else
[listener use];
} else if (navigationType == WebNavigationTypeLinkClicked) {
+ // show http in browser
[[NSWorkspace sharedWorkspace] openURL:[actionInformation objectForKey:WebActionOriginalURLKey]];
[listener ignore];
+ } else if (navigationType == WebNavigationTypeBackForward) {
+ // catch back/forward events from contextual menu
+ [self showHelpFor:[[[[actionInformation objectForKey:WebActionOriginalURLKey] absoluteString] lastPathComponent] stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding] setHistory:NO];
+ [listener ignore];
+ } else if (navigationType == WebNavigationTypeReload) {
+ // just in case
+ [listener ignore];
} else {
- // Ignore WebNavigationTypeFormSubmitted, WebNavigationTypeBackForward,
- // WebNavigationTypeReload and WebNavigationTypeFormResubmitted.
+ // Ignore WebNavigationTypeFormSubmitted, WebNavigationTypeFormResubmitted.
[listener ignore];
}
}
}
+
/*
- * Up to now no contextual menu in helpWebView
+ * Manage contextual menu in helpWebView
*/
- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems
{
+ int menuType = [defaultMenuItems count];
+ NSMutableArray *returnArray = [[NSMutableArray array] autorelease];
+ NSMenuItem *searchInMySQL;
+ NSMenuItem *searchInMySQLonline;
+
+ // dispatcher for different context menus via the number of menu items
+ switch(menuType)
+ {
+ case 1: // only reload
+ return nil;
+ break;
+ case 2: // back and reload
+ return [NSArray arrayWithObjects:[defaultMenuItems objectAtIndex:0], nil];
+ break;
+ case 3: // back, forward, and reload
+ return [NSArray arrayWithObjects:[defaultMenuItems objectAtIndex:0], [defaultMenuItems objectAtIndex:1], nil];
+ break;
+ case 4: // cursor over link (only allow copy link)
+ return [NSArray arrayWithObjects:[defaultMenuItems objectAtIndex:3], nil];
+ break;
+ case 6: // menu for a selection, add Search in MySQL Help
+ searchInMySQL = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Search in MySQL Help", @"Search in MySQL Help") action:@selector(showHelpForWebViewSelection:) keyEquivalent:@""];
+ [searchInMySQL setEnabled:YES];
+ [searchInMySQL setTarget:self];
+ [returnArray addObject:searchInMySQL];
+ searchInMySQLonline = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Search in MySQL Documentation", @"Search in MySQL Documentation") action:@selector(searchInDocForWebViewSelection:) keyEquivalent:@""];
+ [searchInMySQLonline setEnabled:YES];
+ [searchInMySQLonline setTarget:self];
+ [returnArray addObject:searchInMySQLonline];
+ [returnArray addObjectsFromArray:defaultMenuItems];
+ return returnArray;
+ break;
+ }
return nil;
}
+
#pragma mark -
// Last but not least