aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPBundleHTMLOutputController.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-12-10 19:21:09 +0000
committerBibiko <bibiko@eva.mpg.de>2010-12-10 19:21:09 +0000
commit31a6e2c7d4f6503a00d24a75c820123c1cce7562 (patch)
treebb5d4278ad384542ffdbf1d9e87dac4edc6a6cc1 /Source/SPBundleHTMLOutputController.m
parent9f7545289ce2d8eda170baa14d740540cf25188f (diff)
downloadsequelpro-31a6e2c7d4f6503a00d24a75c820123c1cce7562.tar.gz
sequelpro-31a6e2c7d4f6503a00d24a75c820123c1cce7562.tar.bz2
sequelpro-31a6e2c7d4f6503a00d24a75c820123c1cce7562.zip
• Bundle command support
- fix issue for shortcut recorder for Asian language input - finished JavaScript support inside the HTML output window to run BASH system commands via "var returnValue = window.system.run(cmd)" whereby cmd is either a normal string or an array of the dimension of 2 (command, processID)
Diffstat (limited to 'Source/SPBundleHTMLOutputController.m')
-rw-r--r--Source/SPBundleHTMLOutputController.m64
1 files changed, 61 insertions, 3 deletions
diff --git a/Source/SPBundleHTMLOutputController.m b/Source/SPBundleHTMLOutputController.m
index e675e9f5..c57c79f4 100644
--- a/Source/SPBundleHTMLOutputController.m
+++ b/Source/SPBundleHTMLOutputController.m
@@ -22,7 +22,6 @@
//
// More info at <http://code.google.com/p/sequel-pro/>
-
#import "SPBundleHTMLOutputController.h"
#import "SPAlertSheets.h"
@@ -359,9 +358,68 @@
[webScriptObject setValue:self forKey:@"system"];
}
-- (NSString *)run:(NSString*)command
+- (NSString *)run:(id)call
{
- return [NSString stringWithFormat:@"Hallo-%@", [command description]];
+
+ NSError *err = nil;
+ NSString *command = nil;
+ NSString *uuid = nil;
+
+ if([call isKindOfClass:[NSString class]])
+ command = [NSString stringWithString:call];
+ else if([[[call class] description] isEqualToString:@"WebScriptObject"]){
+ command = [call webScriptValueAtIndex:0];
+ uuid = [call webScriptValueAtIndex:1];
+ }
+ else {
+ NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error while executing JavaScript BASH command", @"error while executing javascript bash command")
+ defaultButton:NSLocalizedString(@"OK", @"OK button")
+ alternateButton:nil
+ otherButton:nil
+ informativeTextWithFormat:NSLocalizedString(@"Passed parameter couldn't be interpreted. Only string or array (with 2 elements) are allowed.", @"Passed parameter couldn't be interpreted. Only string or array (with 2 elements) are allowed.")];
+
+ [alert setAlertStyle:NSCriticalAlertStyle];
+ [alert runModal];
+ return @"";
+ }
+
+ if(!command) return @"No JavaScript command found.";
+
+ NSString *output = nil;
+ if(uuid == nil)
+ output = [command runBashCommandWithEnvironment:nil atCurrentDirectoryPath:nil error:&err];
+ else
+ output = [command runBashCommandWithEnvironment:nil
+ atCurrentDirectoryPath:nil
+ callerInstance:[NSApp delegate]
+ contextInfo:[NSDictionary dictionaryWithObjectsAndKeys:
+ @"JavaScript", @"name",
+ NSLocalizedString(@"General", @"general menu item label"), @"scope",
+ uuid, SPBundleFileInternalexecutionUUID,
+ nil]
+ error:&err];
+
+
+ if(err != nil) {
+ NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error while executing JavaScript BASH command", @"error while executing javascript bash command")
+ defaultButton:NSLocalizedString(@"OK", @"OK button")
+ alternateButton:nil
+ otherButton:nil
+ informativeTextWithFormat:[err localizedDescription]];
+
+ [alert setAlertStyle:NSCriticalAlertStyle];
+ [alert runModal];
+ return @"";
+ }
+
+ if(output)
+ return output;
+ else {
+ NSLog(@"No valid output for JavaScript command found.");
+ NSBeep();
+ return @"";
+ }
+
}
#pragma mark -