diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-12-10 19:21:09 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-12-10 19:21:09 +0000 |
commit | 31a6e2c7d4f6503a00d24a75c820123c1cce7562 (patch) | |
tree | bb5d4278ad384542ffdbf1d9e87dac4edc6a6cc1 | |
parent | 9f7545289ce2d8eda170baa14d740540cf25188f (diff) | |
download | sequelpro-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)
-rw-r--r-- | Source/SPBundleEditorController.m | 3 | ||||
-rw-r--r-- | Source/SPBundleHTMLOutputController.m | 64 | ||||
-rw-r--r-- | Source/SPStringAdditions.m | 2 |
3 files changed, 64 insertions, 5 deletions
diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m index 99da4bc4..272221d4 100644 --- a/Source/SPBundleEditorController.m +++ b/Source/SPBundleEditorController.m @@ -1086,7 +1086,8 @@ } if(newKeyCombo.flags & NSCommandKeyMask) [keyEq appendString:@"@"]; - [keyEq appendString:theChar]; + if(theChar) + [keyEq appendString:theChar]; } [[self _currentSelectedObject] setObject:keyEq forKey:SPBundleFileKeyEquivalentKey]; 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 - diff --git a/Source/SPStringAdditions.m b/Source/SPStringAdditions.m index 4b06a028..a3098750 100644 --- a/Source/SPStringAdditions.m +++ b/Source/SPStringAdditions.m @@ -462,7 +462,7 @@ NSMutableArray *scriptHeaderArguments = [NSMutableArray array]; NSString *scriptPath = @""; - NSString *uuid = (contextInfo && [contextInfo objectForKey:SPBundleFileInternalexecutionUUID]) ? [contextInfo objectForKey:@"exeUUID"] : [NSString stringWithNewUUID]; + NSString *uuid = (contextInfo && [contextInfo objectForKey:SPBundleFileInternalexecutionUUID]) ? [contextInfo objectForKey:SPBundleFileInternalexecutionUUID] : [NSString stringWithNewUUID]; NSString *stdoutFilePath = [NSString stringWithFormat:@"%@_%@", SPBundleTaskOutputFilePath, uuid]; NSString *scriptFilePath = [NSString stringWithFormat:@"%@_%@", SPBundleTaskScriptCommandFilePath, uuid]; |