From 3187b984cc76491bf1aabacdf8b2deb5046eaf0a Mon Sep 17 00:00:00 2001 From: Bibiko Date: Thu, 9 Dec 2010 20:54:16 +0000 Subject: =?UTF-8?q?=E2=80=A2=20Bundle=20Commands=20-=20added=20shell=20var?= =?UTF-8?q?s=20SP=5FCURRENT=5FEDITED=5FCOLUMN=5FNAME,=20SP=5FCURRENT=5FEDI?= =?UTF-8?q?TED=5FTABLE=20for=20Input=20Field=20scoped=20commands=20if=20in?= =?UTF-8?q?voked=20from=20a=20table=20cell=20field=20editor=20-=20added=20?= =?UTF-8?q?shell=20var=20SP=5FTABLE=5FDATA=5FSOURCE=20(content=20or=20quer?= =?UTF-8?q?y)=20-=20fixed=20table=20row=20change=20trigger=20for=20custom?= =?UTF-8?q?=20query=20tableView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPCustomQuery.m | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'Source/SPCustomQuery.m') diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index ef38461c..c313edaf 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -2385,6 +2385,54 @@ #pragma mark - #pragma mark TableView notifications +/** + * Check triggering of Bundle command for row selection changes + */ +- (void)tableViewSelectionDidChange:(NSNotification *)aNotification +{ + + // Check our notification object is our table content view + if ([aNotification object] != customQueryView) return; + + NSArray *triggeredCommands = [[NSApp delegate] bundleCommandsForTrigger:SPBundleTriggerActionTableRowChanged]; + for(NSString* cmdPath in triggeredCommands) { + NSArray *data = [cmdPath componentsSeparatedByString:@"|"]; + NSMenuItem *aMenuItem = [[[NSMenuItem alloc] init] autorelease]; + [aMenuItem setTag:0]; + [aMenuItem setToolTip:[data objectAtIndex:0]]; + + // For HTML output check if corresponding window already exists + BOOL stopTrigger = NO; + if([[data objectAtIndex:2] length]) { + BOOL correspondingWindowFound = NO; + NSString *uuid = [data objectAtIndex:2]; + for(id win in [NSApp windows]) { + if([[[[win delegate] class] description] isEqualToString:@"SPBundleHTMLOutputController"]) { + if([[[win delegate] windowUUID] isEqualToString:uuid]) { + correspondingWindowFound = YES; + break; + } + } + } + if(!correspondingWindowFound) stopTrigger = YES; + } + if(!stopTrigger) { + if([[data objectAtIndex:1] isEqualToString:SPBundleScopeGeneral]) { + [[[NSApp delegate] onMainThread] executeBundleItemForApp:aMenuItem]; + } + else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeDataTable]) { + if([[[[[NSApp mainWindow] firstResponder] class] description] isEqualToString:@"SPCopyTable"]) + [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForDataTable:aMenuItem]; + } + else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeInputField]) { + if([[[NSApp mainWindow] firstResponder] isKindOfClass:[NSTextView class]]) + [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForInputField:aMenuItem]; + } + } + } + +} + /** * Saves the new column size in the preferences for columns which map to fields */ -- cgit v1.2.3