From f7164f1f962fb732ea38383150a3bc28a3ae8caf Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Mon, 30 Apr 2012 18:39:40 +0000 Subject: When opening the add index sheet make sure we're using the correct table reload call, so the correct validation is done. Fixes issue #1292. --- Source/SPIndexesController.m | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'Source/SPIndexesController.m') diff --git a/Source/SPIndexesController.m b/Source/SPIndexesController.m index 39abaf81..9db491ae 100644 --- a/Source/SPIndexesController.m +++ b/Source/SPIndexesController.m @@ -225,7 +225,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; // initial key has a required size [indexSizeTableColumn setHidden:![requiresLength containsObject:[[initialField objectForKey:@"type"] uppercaseString]]]; - [indexedColumnsTableView reloadData]; + [self _reloadIndexedColumnsTableData]; [addIndexedColumnButton setEnabled:([indexedFields count] < [fields count])]; @@ -385,7 +385,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; [self _reloadIndexedColumnsTableData]; // Select new added row - [indexedColumnsTableView selectRowIndexes:[NSIndexSet indexSetWithIndex:[indexedFields count]-1] byExtendingSelection:NO]; + [indexedColumnsTableView selectRowIndexes:[NSIndexSet indexSetWithIndex:[indexedFields count] - 1] byExtendingSelection:NO]; [addIndexedColumnButton setEnabled:([indexedFields count] < [fields count])]; } @@ -446,9 +446,11 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; } else { id object = [[indexedFields objectAtIndex:rowIndex] objectForKey:[tableColumn identifier]]; + if ([[tableColumn identifier] isEqualToString:@"Size"] && object) { object = [NSNumber numberWithLongLong:[object longLongValue]]; } + return object; } } @@ -474,9 +476,11 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; if ([object isKindOfClass:[NSNumber class]]) { object = [NSString stringWithFormat:@"%llu", [object unsignedLongLongValue]]; } + if (object) { [[indexedFields objectAtIndex:rowIndex] setObject:object forKey:[tableColumn identifier]]; - } else { + } + else { [[indexedFields objectAtIndex:rowIndex] removeObjectForKey:[tableColumn identifier]]; } } @@ -775,22 +779,25 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; NSUInteger sizeRequiredFieldAndNotYetSet = 0; NSUInteger sizeRequired = 0; - for (NSDictionary *field in indexedFields) { + for (NSDictionary *field in indexedFields) + { if ([requiresLength containsObject:[[field objectForKey:@"type"] uppercaseString]]) { sizeRequired++; sizeRequiredFieldAndNotYetSet++; - if([field objectForKey:@"Size"] && [(NSString *)[field objectForKey:@"Size"] length]) + + if ([field objectForKey:@"Size"] && [(NSString *)[field objectForKey:@"Size"] length]) { sizeRequiredFieldAndNotYetSet--; + } } } #ifndef SP_REFACTOR // Only toggle the sizes column if the advanced view is hidden and at least one field requires a size - if (!showAdvancedView) [indexSizeTableColumn setHidden:(!sizeRequired)]; + if (!showAdvancedView) [indexSizeTableColumn setHidden:!sizeRequired]; #endif // Validate Add Button - [confirmAddIndexButton setEnabled:(!sizeRequiredFieldAndNotYetSet)]; + [confirmAddIndexButton setEnabled:!sizeRequiredFieldAndNotYetSet]; [indexedColumnsTableView reloadData]; } -- cgit v1.2.3