From c486a4033c121a5e836600857a7db3977b94d160 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 21 Dec 2010 10:29:03 +0000 Subject: =?UTF-8?q?=E2=80=A2=20added=20sequelpro=20URL=20scheme=20command?= =?UTF-8?q?=20sequelpro://$SP=5FPROCESS=5FID@chooseItemFromList/a/b/c/d=20?= =?UTF-8?q?to=20come=20up=20with=20a=20menu=20to=20let=20the=20user=20choo?= =?UTF-8?q?se=20an=20item=20from=20a=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPAppController.m | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'Source') 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; -- cgit v1.2.3