From 7d2238af04e18999b4dc83a92d82ac1944c0916d Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 11 Jan 2011 19:24:52 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed=20several=20issues=20for=20validation?= =?UTF-8?q?=20and=20other=20stuff=20while=20editing=20of=20MySQL=20data=20?= =?UTF-8?q?tables=20if=20user=20re-ordered=20columns?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPConstants.m | 2 +- Source/SPCustomQuery.h | 2 +- Source/SPCustomQuery.m | 9 +++++---- Source/SPTableContent.h | 2 +- Source/SPTableContent.m | 15 ++++++++++++--- 5 files changed, 20 insertions(+), 10 deletions(-) (limited to 'Source') diff --git a/Source/SPConstants.m b/Source/SPConstants.m index 52d2ccca..fcecb432 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -331,7 +331,7 @@ NSString *SPBundleShellVariableExitShowAsHTML = @"SP_BUNDLE_EXIT_S NSString *SPBundleShellVariableExitShowAsHTMLTooltip = @"SP_BUNDLE_EXIT_SHOW_AS_HTML_TOOLTIP"; NSString *SPBundleShellVariableExitInsertAsSnippet = @"SP_BUNDLE_EXIT_INSERT_AS_SNIPPET"; NSString *SPBundleShellVariableExitInsertAsText = @"SP_BUNDLE_EXIT_INSERT_AS_TEXT"; -NSString *SPBundleShellVariableExitShowAsTextTooltip = @"SP_BUNDLE_EXIT_SHOW_AS_TEXT_TOOLTIP"; +NSString *SPBundleShellVariableExitShowAsTextTooltip = @"SP_BUNDLE_EXIT_SHOW_AS_TEXT_TOOLTIP"; NSString *SPBundleShellVariableExitNone = @"SP_BUNDLE_EXIT_NONE"; NSString *SPBundleShellVariableExitReplaceContent = @"SP_BUNDLE_EXIT_REPLACE_CONTENT"; NSString *SPBundleShellVariableExitReplaceSelection = @"SP_BUNDLE_EXIT_REPLACE_SELECTION"; diff --git a/Source/SPCustomQuery.h b/Source/SPCustomQuery.h index f4c2440d..7a8601a8 100644 --- a/Source/SPCustomQuery.h +++ b/Source/SPCustomQuery.h @@ -245,7 +245,7 @@ - (void)commentOutCurrentQueryTakingSelection:(BOOL)takeSelection; - (NSString *)usedQuery; - (NSString *)argumentForRow:(NSUInteger)rowIndex ofTable:(NSString *)tableForColumn andDatabase:(NSString *)database includeBlobs:(BOOL)includeBlobs; -- (NSArray*)fieldEditStatusForRow:(NSInteger)rowIndex andColumn:(NSInteger)columnIndex; +- (NSArray*)fieldEditStatusForRow:(NSInteger)rowIndex andColumn:(NSNumber *)columnIndex; - (NSUInteger)numberOfQueries; - (NSRange)currentQueryRange; - (NSString *)buildHistoryString; diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index e8420b7c..fa54790d 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -1634,7 +1634,7 @@ * -2 for other errors * and the used WHERE clause to identify */ -- (NSArray*)fieldEditStatusForRow:(NSInteger)rowIndex andColumn:(NSInteger)columnIndex +- (NSArray*)fieldEditStatusForRow:(NSInteger)rowIndex andColumn:(NSNumber*)columnIndex { NSDictionary *columnDefinition = nil; @@ -3679,8 +3679,9 @@ column = [customQueryView editedColumn]; // Retrieve the column defintion + NSNumber *colIdentifier = [NSArrayObjectAtIndex([customQueryView tableColumns], column) identifier]; for(id c in cqColumnDefinition) { - if([[c objectForKey:@"datacolumnindex"] isEqualToNumber:[NSNumber numberWithInteger:column]]) { + if([[c objectForKey:@"datacolumnindex"] isEqualToNumber:colIdentifier]) { columnDefinition = [NSDictionary dictionaryWithDictionary:c]; break; } @@ -3688,8 +3689,8 @@ if(!columnDefinition) return NO; - NSArray *editStatus = [self fieldEditStatusForRow:row andColumn:[NSArrayObjectAtIndex([customQueryView tableColumns], column) identifier]]; - NSInteger numberOfPossibleUpdateRows = [[editStatus objectAtIndex:0] integerValue]; + NSArray *editStatus = [self fieldEditStatusForRow:row andColumn:colIdentifier]; + NSInteger numberOfPossibleUpdateRows = [NSArrayObjectAtIndex(editStatus, 0) integerValue]; NSPoint pos = [[tableDocumentInstance parentWindow] convertBaseToScreen:[customQueryView convertPoint:[customQueryView frameOfCellAtColumn:column row:row].origin toView:nil]]; pos.y -= 20; switch(numberOfPossibleUpdateRows) { diff --git a/Source/SPTableContent.h b/Source/SPTableContent.h index e3fd8a53..597c695d 100644 --- a/Source/SPTableContent.h +++ b/Source/SPTableContent.h @@ -231,7 +231,7 @@ - (void)openContentFilterManager; - (void)makeContentFilterHaveFocus; -- (NSArray*)fieldEditStatusForRow:(NSInteger)rowIndex andColumn:(NSInteger)columnIndex; +- (NSArray*)fieldEditStatusForRow:(NSInteger)rowIndex andColumn:(NSNumber *)columnIndex; - (void)updateFilterTableClause:(id)currentValue; - (NSString*)escapeFilterTableDefaultOperator:(NSString*)anOperator; diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 3db3917b..6213549d 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -2792,7 +2792,7 @@ * -2 for other errors * and the used WHERE clause to identify */ -- (NSArray*)fieldEditStatusForRow:(NSInteger)rowIndex andColumn:(NSInteger)columnIndex +- (NSArray*)fieldEditStatusForRow:(NSInteger)rowIndex andColumn:(NSNumber *)columnIndex { NSDictionary *columnDefinition = nil; @@ -2927,10 +2927,12 @@ NSInteger row = -1; NSInteger column = -1; + NSInteger editedColumn = -1; if(contextInfo) { row = [[contextInfo objectForKey:@"row"] integerValue]; column = [[contextInfo objectForKey:@"column"] integerValue]; + editedColumn = [[contextInfo objectForKey:@"editedColumn"] integerValue]; } if (data && contextInfo) { @@ -2966,8 +2968,8 @@ [[tableDocumentInstance parentWindow] makeFirstResponder:tableContentView]; - if(row > -1 && column > -1) - [tableContentView editColumn:column row:row withEvent:nil select:YES]; + if(row > -1 && editedColumn > -1) + [tableContentView editColumn:editedColumn row:row withEvent:nil select:YES]; } #pragma mark - @@ -4058,6 +4060,12 @@ if ([cellValue isNSNull]) cellValue = [NSString stringWithString:[prefs objectForKey:SPNullValue]]; + NSInteger editedColumn = 0; + for(NSTableColumn* col in [tableContentView tableColumns]) { + if([[col identifier] isEqualToNumber:[aTableColumn identifier]]) break; + editedColumn++; + } + [fieldEditor editWithObject:cellValue fieldName:[[aTableColumn headerCell] stringValue] usingEncoding:[mySQLConnection stringEncoding] @@ -4068,6 +4076,7 @@ contextInfo:[NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInteger:rowIndex], @"row", [aTableColumn identifier], @"column", + [NSNumber numberWithInteger:editedColumn], @"editedColumn", [NSNumber numberWithBool:isFieldEditable], @"isFieldEditable", nil]]; -- cgit v1.2.3