diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-12-21 10:29:03 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-12-21 10:29:03 +0000 |
commit | c486a4033c121a5e836600857a7db3977b94d160 (patch) | |
tree | 4b0619a09fb1ec1d968e32a8e40c5f26b0094454 /Source | |
parent | 71ca21ef73cd58d2c18e11329b68d89350dca0fd (diff) | |
download | sequelpro-c486a4033c121a5e836600857a7db3977b94d160.tar.gz sequelpro-c486a4033c121a5e836600857a7db3977b94d160.tar.bz2 sequelpro-c486a4033c121a5e836600857a7db3977b94d160.zip |
• added sequelpro URL scheme command sequelpro://$SP_PROCESS_ID@chooseItemFromList/a/b/c/d to come up with a menu to let the user choose an item from a list
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPAppController.m | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Source/SPAppController.m b/Source/SPAppController.m index 4677f098..a974ebf1 100644 --- a/Source/SPAppController.m +++ b/Source/SPAppController.m @@ -635,6 +635,31 @@ else parameter = [NSArray array]; + + // Handle commands which don't need a connection window + if([command isEqualToString:@"chooseItemFromList"]) { + NSString *statusFileName = [NSString stringWithFormat:@"%@%@", SPURLSchemeQueryResultStatusPathHeader, (passedProcessID && [passedProcessID length]) ? passedProcessID : @""]; + NSString *resultFileName = [NSString stringWithFormat:@"%@%@", SPURLSchemeQueryResultPathHeader, (passedProcessID && [passedProcessID length]) ? passedProcessID : @""]; + [[NSFileManager defaultManager] removeItemAtPath:statusFileName error:nil]; + [[NSFileManager defaultManager] removeItemAtPath:resultFileName error:nil]; + NSString *result = @""; + NSString *status = @"0"; + if([parameter count]) { + NSInteger idx = [SPChooseMenuItemDialog withItems:parameter atPosition:[NSEvent mouseLocation]]; + if(idx > -1) { + result = [parameter objectAtIndex:idx]; + } + } + if(![status writeToFile:statusFileName atomically:YES encoding:NSUTF8StringEncoding error:nil]) { + NSBeep(); + SPBeginAlertSheet(NSLocalizedString(@"BASH Error", @"bash error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [self parentWindow], self, nil, nil, + NSLocalizedString(@"Status file for sequelpro url scheme command couldn't be written!", @"status file for sequelpro url scheme command couldn't be written error message")); + } + [result writeToFile:resultFileName atomically:YES encoding:NSUTF8StringEncoding error:nil]; + return; + } + + NSString *activeProcessID = [[[[self frontDocumentWindow] delegate] selectedTableDocument] processID]; SPDatabaseDocument *processDocument = nil; @@ -769,6 +794,8 @@ [env setObject:[infoPath stringByDeletingLastPathComponent] forKey:SPBundleShellVariableBundlePath]; [env setObject:bundleInputFilePath forKey:SPBundleShellVariableInputFilePath]; [env setObject:SPBundleScopeGeneral forKey:SPBundleShellVariableBundleScope]; + [env setObject:SPURLSchemeQueryResultPathHeader forKey:SPBundleShellVariableQueryResultFile]; + [env setObject:SPURLSchemeQueryResultStatusPathHeader forKey:SPBundleShellVariableQueryResultStatusFile]; NSString *input = @""; NSError *inputFileError = nil; |