aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPBundleHTMLOutputController.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-12-12 21:10:10 +0000
committerstuconnolly <stuart02@gmail.com>2010-12-12 21:10:10 +0000
commitdc7d9981ad828d4caec28c378f743ddf7e61db96 (patch)
tree3f100e8dc474798bf5da064f6a29fcf1874ff490 /Source/SPBundleHTMLOutputController.m
parent1ddca4732c3aa46698b8fad25ce1294db3cd32fb (diff)
parentb2015bc3974c04557492bb4a698776824ab6689d (diff)
downloadsequelpro-dc7d9981ad828d4caec28c378f743ddf7e61db96.tar.gz
sequelpro-dc7d9981ad828d4caec28c378f743ddf7e61db96.tar.bz2
sequelpro-dc7d9981ad828d4caec28c378f743ddf7e61db96.zip
Bring outline view branch up to date with trunk (r3007:3010).
Diffstat (limited to 'Source/SPBundleHTMLOutputController.m')
-rw-r--r--Source/SPBundleHTMLOutputController.m71
1 files changed, 56 insertions, 15 deletions
diff --git a/Source/SPBundleHTMLOutputController.m b/Source/SPBundleHTMLOutputController.m
index 365c15a3..a632a51a 100644
--- a/Source/SPBundleHTMLOutputController.m
+++ b/Source/SPBundleHTMLOutputController.m
@@ -304,19 +304,28 @@
- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
{
- SPBeginAlertSheet(NSLocalizedString(@"JavaScript Alert", @"javascript alert"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [self window], self, nil, nil,
- [message description]);
+ NSAlert *alert = [[NSAlert alloc] init];
+ [alert addButtonWithTitle:NSLocalizedString(@"OK", @"OK button")];
+ [alert setInformativeText:(message)?:@""];
+ [alert setMessageText:@"JavaScript"];
+ [alert runModal];
+ [alert release];
}
- (BOOL)webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
{
- NSLog(@"confirm");
- return NO;
-}
+ NSAlert *alert = [[NSAlert alloc] init];
+ [alert addButtonWithTitle:NSLocalizedString(@"OK", @"OK button")];
+ [alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"cancel button")];
+ [alert setInformativeText:(message)?:@""];
+ [alert setMessageText:@"JavaScript"];
-- (NSString *)webView:(WebView *)sender runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WebFrame *)frame
-{
- return @"be patient";
+ NSUInteger returnCode = [alert runModal];
+
+ [alert release];
+
+ if(returnCode == NSAlertFirstButtonReturn) return YES;
+ return NO;
}
- (void)webView:(WebView *)sender windowScriptObjectAvailable: (WebScriptObject *)windowScriptObject
@@ -328,6 +337,10 @@
{
if (aSelector == @selector(run:))
return @"run";
+ if (aSelector == @selector(getShellEnvironmentForName:))
+ return @"getShellEnvironmentForName";
+ if (aSelector == @selector(makeHTMLOutputWindowKeyWindow))
+ return @"makeHTMLOutputWindowKeyWindow";
return @"";
}
@@ -335,6 +348,12 @@
if (selector == @selector(run:)) {
return NO;
}
+ if (selector == @selector(getShellEnvironmentForName:)) {
+ return NO;
+ }
+ if (selector == @selector(makeHTMLOutputWindowKeyWindow)) {
+ return NO;
+ }
return YES;
}
@@ -342,13 +361,41 @@
if (strcmp(property, "run") == 0) {
return NO;
}
+ if (strcmp(property, "getShellEnvironmentForName") == 0) {
+ return NO;
+ }
+ if (strcmp(property, "makeHTMLOutputWindowKeyWindow") == 0) {
+ return NO;
+ }
return YES;
}
-- (void) windowScriptObjectAvailable:(WebScriptObject*)webScriptObject {
+- (void)windowScriptObjectAvailable:(WebScriptObject*)webScriptObject {
[webScriptObject setValue:self forKey:@"system"];
}
+/**
+ * JavaScript window.system.getShellEnvironmentForName('a_key') function to
+ * return the value for key keyName
+ */
+- (NSString *)getShellEnvironmentForName:(NSString*)keyName
+{
+ return [[[NSApp delegate] shellEnvironment] objectForKey:keyName];
+}
+
+/**
+ * JavaScript window.system.makeHTMLOutputWindowKeyWindow() function
+ * to make the HTML output window the first responder
+ */
+- (void)makeHTMLOutputWindowKeyWindow
+{
+ [[self window] makeKeyAndOrderFront:nil];
+}
+
+/**
+ * JavaScript window.system.run('a_command'|new Array('a_command', 'uuid')) function
+ * to return the result of the BASH command a_command
+ */
- (NSString *)run:(id)call
{
@@ -376,12 +423,6 @@
if(!command) return @"No JavaScript command found.";
- // Check for internal commands passed via JavaScript
- if([command isEqualToString:@"_SP_self_makeKeyWindow"]) {
- [[self window] makeKeyAndOrderFront:nil];
- return @"";
- }
-
NSString *output = nil;
if(uuid == nil)
output = [command runBashCommandWithEnvironment:nil atCurrentDirectoryPath:nil error:&err];