From cc5aa6c295b6072b5feedc1b912df264c34a9edb Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 23 Nov 2010 14:20:26 +0000 Subject: =?UTF-8?q?=E2=80=A2=20Bundle=20Editor=20-=20fixed=20gui=20arragem?= =?UTF-8?q?ent=20-=20suppress=20error=20message=20if=20no=20ouptut=20key?= =?UTF-8?q?=20found=20in=20command.plist=20=E2=80=A2=20added=20sequelpro:/?= =?UTF-8?q?/ID@/passToDoc/SelectTableRows/1/3/4/..=20scheme=20command=20wh?= =?UTF-8?q?ich=20selects=20given=20rows=20in=20current=20table=20if=20a=20?= =?UTF-8?q?SPCopyTable=20is=20the=20first=20responder;=20not=20valid=20giv?= =?UTF-8?q?en=20rows=20are=20ignored=20=E2=80=A2=20added=20SP=5FSELECTED?= =?UTF-8?q?=5FROW=5FINDICES=20as=20passed=20shell=20variable=20for=20Data?= =?UTF-8?q?=20Table=20scope?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/MainMenu.xib | 3 +-- Source/SPAppController.m | 20 +++++++++++++++++--- Source/SPCopyTable.h | 2 ++ Source/SPCopyTable.m | 35 +++++++++++++++++++++++++++++++++-- Source/SPDatabaseDocument.m | 7 +++++++ Source/SPTextViewAdditions.m | 4 ++-- 6 files changed, 62 insertions(+), 9 deletions(-) diff --git a/Interfaces/English.lproj/MainMenu.xib b/Interfaces/English.lproj/MainMenu.xib index 9699fc03..768bc1c0 100644 --- a/Interfaces/English.lproj/MainMenu.xib +++ b/Interfaces/English.lproj/MainMenu.xib @@ -12,7 +12,7 @@ YES - + YES @@ -1760,7 +1760,6 @@ - YES Bundles 2147483647 diff --git a/Source/SPAppController.m b/Source/SPAppController.m index 9a4e23e6..609593a8 100644 --- a/Source/SPAppController.m +++ b/Source/SPAppController.m @@ -573,17 +573,31 @@ } } + BOOL userTerminated = NO; + while(1) { NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES]; - // if(!event) continue; + + if ([event type] == NSKeyDown) { + unichar key = [[event characters] length] == 1 ? [[event characters] characterAtIndex:0] : 0; + if (([event modifierFlags] & NSCommandKeyMask) && key == '.') { + userTerminated = YES; + break; + } + } [NSApp sendEvent:event]; if(![processDocument isWorking]) break; usleep(1000); } + if(userTerminated) { + NSBeep(); + return; + } + if(processDocument && command && [command isEqualToString:@"passToDoc"]) { NSMutableDictionary *cmdDict = [NSMutableDictionary dictionary]; [cmdDict setObject:parameter forKey:@"parameter"]; @@ -693,8 +707,8 @@ [[NSFileManager defaultManager] removeItemAtPath:bundleInputFilePath error:nil]; - if(err == nil && output && [cmdData objectForKey:SPBundleFileOutputActionKey]) { - if([[cmdData objectForKey:SPBundleFileOutputActionKey] length] + if(err == nil && output) { + if([cmdData objectForKey:SPBundleFileOutputActionKey] && [[cmdData objectForKey:SPBundleFileOutputActionKey] length] && ![[cmdData objectForKey:SPBundleFileOutputActionKey] isEqualToString:SPBundleOutputActionNone]) { NSString *action = [[cmdData objectForKey:SPBundleFileOutputActionKey] lowercaseString]; NSPoint pos = [NSEvent mouseLocation]; diff --git a/Source/SPCopyTable.h b/Source/SPCopyTable.h index d46caf02..89030976 100644 --- a/Source/SPCopyTable.h +++ b/Source/SPCopyTable.h @@ -167,6 +167,8 @@ - (IBAction)executeBundleItemForDataTable:(id)sender; +- (void)selectTableRows:(NSArray*)rowIndices; + @end extern NSInteger MENU_EDIT_COPY; diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m index 28fcb476..4de00d00 100644 --- a/Source/SPCopyTable.m +++ b/Source/SPCopyTable.m @@ -802,6 +802,26 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003; } +- (void)selectTableRows:(NSArray*)rowIndices +{ + + if(!rowIndices || ![rowIndices count]) return; + + NSMutableIndexSet *selection = [NSMutableIndexSet indexSet]; + NSInteger rows = [[self delegate] numberOfRowsInTableView:self]; + NSUInteger i; + if(rows > 0) { + for(NSString* idx in rowIndices) { + i = [idx longLongValue]; + if(i >= 0 && i < rows) + [selection addIndex:i]; + } + + [self selectRowIndexes:selection byExtendingSelection:NO]; + } + +} + - (IBAction)executeBundleItemForDataTable:(id)sender { NSInteger idx = [sender tag] - 1000000; @@ -857,6 +877,17 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003; if([[self delegate] respondsToSelector:@selector(usedQuery)] && [[self delegate] usedQuery]) [env setObject:[[self delegate] usedQuery] forKey:@"SP_USED_QUERY_FOR_TABLE"]; + if([self numberOfSelectedRows]) { + NSMutableArray *sel = [NSMutableArray array]; + NSIndexSet *selectedRows = [self selectedRowIndexes]; + NSUInteger rowIndex = [selectedRows firstIndex]; + while ( rowIndex != NSNotFound ) { + [sel addObject:[NSString stringWithFormat:@"%ld", rowIndex]]; + rowIndex = [selectedRows indexGreaterThanIndex:rowIndex]; + } + [env setObject:[sel componentsJoinedByString:@"\t"] forKey:@"SP_SELECTED_ROW_INDICES"]; + } + NSError *inputFileError = nil; NSString *input = @""; if([inputAction isEqualToString:SPBundleInputSourceSelectedTableRowsAsTab]) { @@ -896,8 +927,8 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003; [[NSFileManager defaultManager] removeItemAtPath:bundleInputFilePath error:nil]; - if(err == nil && output && [cmdData objectForKey:SPBundleFileOutputActionKey]) { - if([[cmdData objectForKey:SPBundleFileOutputActionKey] length] + if(err == nil && output) { + if([cmdData objectForKey:SPBundleFileOutputActionKey] && [[cmdData objectForKey:SPBundleFileOutputActionKey] length] && ![[cmdData objectForKey:SPBundleFileOutputActionKey] isEqualToString:SPBundleOutputActionNone]) { NSString *action = [[cmdData objectForKey:SPBundleFileOutputActionKey] lowercaseString]; NSPoint pos = [NSEvent mouseLocation]; diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 4626f031..270892f0 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -4563,6 +4563,13 @@ return; } + if([command isEqualToString:@"SelectTableRows"]) { + if([params count] > 1 && [[[NSApp mainWindow] firstResponder] respondsToSelector:@selector(selectTableRows:)]) { + [[[NSApp mainWindow] firstResponder] selectTableRows:[params subarrayWithRange:NSMakeRange(1, [params count]-1)]]; + } + return; + } + if([command isEqualToString:@"ReloadContentTable"]) { [tableContentInstance reloadTable:self]; return; diff --git a/Source/SPTextViewAdditions.m b/Source/SPTextViewAdditions.m index 1bc45aad..4afea05f 100644 --- a/Source/SPTextViewAdditions.m +++ b/Source/SPTextViewAdditions.m @@ -607,8 +607,8 @@ [[NSFileManager defaultManager] removeItemAtPath:bundleInputFilePath error:nil]; - if(err == nil && output && [cmdData objectForKey:SPBundleFileOutputActionKey]) { - if([[cmdData objectForKey:SPBundleFileOutputActionKey] length] + if(err == nil && output) { + if([cmdData objectForKey:SPBundleFileOutputActionKey] && [[cmdData objectForKey:SPBundleFileOutputActionKey] length] && ![[cmdData objectForKey:SPBundleFileOutputActionKey] isEqualToString:SPBundleOutputActionNone]) { NSString *action = [[cmdData objectForKey:SPBundleFileOutputActionKey] lowercaseString]; -- cgit v1.2.3