From e0e594cf921768218f19d9596f3214419482ff09 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 19 Feb 2010 10:50:26 +0000 Subject: =?UTF-8?q?=E2=80=A2=20CSV=20Import=20Field=20Mapper=20-=20added?= =?UTF-8?q?=20to=20csv=20field=20popup=20menu:=20"Ignore=20all=20fields",?= =?UTF-8?q?=20"Import=20all=20fields"=20-=20if=20user=20changed=20a=20matc?= =?UTF-8?q?hing=20pair=20field=20change=20the=20"Align=20fields=20by:"=20t?= =?UTF-8?q?o=20"custom=20order"=20to=20make=20it=20more=20transparent=20-?= =?UTF-8?q?=20if=20user=20inserts=20a=20just=20added=20global=20var=20to?= =?UTF-8?q?=20a=20field=20which=20was=20set=20to=20"Ignore=20field"=20set?= =?UTF-8?q?=20it=20to=20"Import=20field"=20-=20unified=20some=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPFieldMapperController.m | 52 ++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 7 deletions(-) (limited to 'Source/SPFieldMapperController.m') diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index 3c365dcf..a44f5ca2 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -108,6 +108,7 @@ [insertNULLValueButton setEnabled:([globalValuesTableView numberOfSelectedRows] == 1)]; [self updateFieldNameAlignment]; + } - (void)dealloc @@ -311,8 +312,9 @@ } [fieldMapperTableView reloadData]; - // Remember last field alignment - [prefs setInteger:[[alignByPopup selectedItem] tag] forKey:SPCSVFieldImportMappingAlignment]; + // Remember last field alignment if not "custom order" + if([[alignByPopup selectedItem] tag] != 3) + [prefs setInteger:[[alignByPopup selectedItem] tag] forKey:SPCSVFieldImportMappingAlignment]; } /* @@ -411,8 +413,17 @@ // Replace the current map pair with the last selected global value if([replaceAfterSavingCheckBox state] == NSOnState && [globalValuesTableView numberOfSelectedRows] == 1) { + [fieldMappingArray replaceObjectAtIndex:[fieldMapperTableView selectedRow] withObject:[NSNumber numberWithInteger:[globalValuesTableView selectedRow]+numberOfImportColumns]]; + + // Set corresponding operator to doImport + [fieldMappingOperatorArray replaceObjectAtIndex:[fieldMapperTableView selectedRow] withObject:doImport]; + [fieldMapperTableView reloadData]; + + // Set alignment popup to "custom order" + [alignByPopup selectItemWithTag:3]; + } [NSApp endSheet:[globalValuesSheet window] returnCode:[sender tag]]; @@ -539,7 +550,7 @@ if([prefs integerForKey:SPCSVFieldImportMappingAlignment] && [prefs integerForKey:SPCSVFieldImportMappingAlignment] >= 0 - && [prefs integerForKey:SPCSVFieldImportMappingAlignment] < 3) { + && [prefs integerForKey:SPCSVFieldImportMappingAlignment] < 4) { alignment = [prefs integerForKey:SPCSVFieldImportMappingAlignment]; } @@ -618,11 +629,11 @@ else if([[aTableColumn identifier] isEqualToString:@"operator"]) { if([aCell objectValue] == doImport) - return NSLocalizedString(@"Do import", @"import operator"); + return NSLocalizedString(@"Import field", @"import field operator tooltip"); else if([aCell objectValue] == doNotImport) - return NSLocalizedString(@"Do not import", @"do not import operator"); + return NSLocalizedString(@"Ignore field", @"ignore field operator tooltip"); else if([aCell objectValue] == isEqual) - return NSLocalizedString(@"Do UPDATE where field contents match", @"do update operator"); + return NSLocalizedString(@"Do UPDATE where field contents match", @"do update operator tooltip"); else return @""; } @@ -666,6 +677,9 @@ [c addItemsWithTitles:fieldMappingButtonOptions]; [m addItem:[NSMenuItem separatorItem]]; [c addItemWithTitle:NSLocalizedString(@"Ignore field", @"ignore field menu item")]; + [c addItemWithTitle:NSLocalizedString(@"Ignore all fields", @"ignore all fields menu item")]; + [c addItemWithTitle:NSLocalizedString(@"Import all fields", @"import all fields menu item")]; + [m addItem:[NSMenuItem separatorItem]]; [c addItemWithTitle:NSLocalizedString(@"Add global value…", @"add global value menu item")]; // Hide csv file column value if user doesn't want to import it @@ -710,14 +724,38 @@ [fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:doNotImport]; [aTableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.0]; } - // Add global value + // Ignore all field - set all operator to doNotImport else if([anObject integerValue] == [fieldMappingButtonOptions count]+2) { + NSInteger i; + NSNumber *globalValue = doNotImport; + [fieldMappingOperatorArray removeAllObjects]; + for(i=0; i < [fieldMappingTableColumnNames count]; i++) + [fieldMappingOperatorArray addObject:globalValue]; + [aTableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.0]; + } + // Import all field - set all operator to doImport + else if([anObject integerValue] == [fieldMappingButtonOptions count]+3) { + NSInteger i; + NSNumber *globalValue = doImport; + [fieldMappingOperatorArray removeAllObjects]; + for(i=0; i < [fieldMappingTableColumnNames count]; i++) + [fieldMappingOperatorArray addObject:globalValue]; + [aTableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.0]; + } + // Add global value + else if([anObject integerValue] == [fieldMappingButtonOptions count]+5) { [aTableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.0]; [self addGlobalSourceVariable:nil]; } return; } + + // If user changed the order set alignment popup to "custom order" + if([fieldMappingArray objectAtIndex:rowIndex] != anObject) + [alignByPopup selectItemWithTag:3]; + [fieldMappingArray replaceObjectAtIndex:rowIndex withObject:anObject]; + // If user _changed_ the csv file column set the operator to doImport if([(NSNumber*)anObject integerValue] > -1) [fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:doImport]; -- cgit v1.2.3