From 77ce5576f42812f079fec088f969716eb5eba371 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Thu, 3 Feb 2011 11:26:55 +0000 Subject: =?UTF-8?q?=E2=80=A2=20CSV=20field=20mapper=20-=20reset=20import?= =?UTF-8?q?=20operators=20after=20each=20change=20of=20the=20chosen=20alig?= =?UTF-8?q?nment=20-=20double-click=20at=20PathControl=20performs=20goBack?= =?UTF-8?q?ToFileChooser=20delayed=20in=20order=20to=20avoid=20time=20raci?= =?UTF-8?q?ng=20issues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPFieldMapperController.h | 2 ++ Source/SPFieldMapperController.m | 33 ++++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) (limited to 'Source') diff --git a/Source/SPFieldMapperController.h b/Source/SPFieldMapperController.h index 8a70df90..813a3b3e 100644 --- a/Source/SPFieldMapperController.h +++ b/Source/SPFieldMapperController.h @@ -76,6 +76,7 @@ IBOutlet id highPriorityCheckBox; IBOutlet id skipexistingRowsCheckBox; IBOutlet SPTextView *onupdateTextView; + IBOutlet id gobackButton; IBOutlet id advancedButton; @@ -171,6 +172,7 @@ - (IBAction)openAdvancedSheet:(id)sender; - (IBAction)closeSheet:(id)sender; - (IBAction)goBackToFileChooser:(id)sender; +- (IBAction)goBackToFileChooserFromPathControl:(id)sender; - (IBAction)addGlobalValue:(id)sender; - (IBAction)removeGlobalValue:(id)sender; diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index 221a8e75..b77ca98e 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -121,7 +121,7 @@ static const NSString *SPTableViewSqlColumnID = @"sql"; [pc setURL:[NSURL fileURLWithPath:sourcePath]]; if([pc pathComponentCells]) [fileSourcePath setPathComponentCells:[pc pathComponentCells]]; - [fileSourcePath setDoubleAction:@selector(goBackToFileChooser:)]; + [fileSourcePath setDoubleAction:@selector(goBackToFileChooserFromPathControl:)]; [onupdateTextView setDelegate:theDelegate]; windowMinWidth = [[self window] minSize].width; @@ -701,15 +701,24 @@ static const NSString *SPTableViewSqlColumnID = @"sql"; if(possibleImports < 1) return; + // Set all operators to doNotImport + [fieldMappingOperatorArray removeAllObjects]; + for(i=0; i < [fieldMappingTableColumnNames count]; i++) + [fieldMappingOperatorArray addObject:doNotImport]; + switch([[alignByPopup selectedItem] tag]) { case 0: // file order - for(i=0; i=0; i--) + for(i=possibleImports; i>=0; i--) { [fieldMappingArray replaceObjectAtIndex:possibleImports-i withObject:[NSNumber numberWithInteger:i]]; + [fieldMappingOperatorArray replaceObjectAtIndex:possibleImports-i withObject:doImport]; + } break; case 2: // try to align header and table target field names via Levenshtein distance [self matchHeaderNames]; @@ -764,14 +773,21 @@ static const NSString *SPTableViewSqlColumnID = @"sql"; } } +- (IBAction)goBackToFileChooserFromPathControl:(id)sender +{ + [gobackButton performSelector:@selector(performClick:) withObject:nil afterDelay:0.0f]; +} + - (IBAction)goBackToFileChooser:(id)sender { + [NSApp endSheet:[self window] returnCode:[sender tag]]; - if([sourcePath hasPrefix:SPImportClipboardTempFileNamePrefix]) { + + if([sourcePath hasPrefix:SPImportClipboardTempFileNamePrefix]) [theDelegate importFromClipboard]; - } else { + else [theDelegate importFile]; - } + } - (IBAction)newTable:(id)sender @@ -1361,11 +1377,6 @@ static const NSString *SPTableViewSqlColumnID = @"sql"; { if(![fieldMappingImportArray count]) return; - // Set all operators to doNotImport - [fieldMappingOperatorArray removeAllObjects]; - for(NSInteger i=0; i < [fieldMappingTableColumnNames count]; i++) - [fieldMappingOperatorArray addObject:doNotImport]; - NSMutableArray *fileHeaderNames = [NSMutableArray array]; [fileHeaderNames setArray:NSArrayObjectAtIndex(fieldMappingImportArray, 0)]; NSMutableArray *tableHeaderNames = [NSMutableArray array]; -- cgit v1.2.3