diff options
author | Bibiko <bibiko@eva.mpg.de> | 2011-02-03 11:26:55 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2011-02-03 11:26:55 +0000 |
commit | 77ce5576f42812f079fec088f969716eb5eba371 (patch) | |
tree | 27dbc9517f5d2d34a61280d4fa5b7874db6583c1 /Source/SPFieldMapperController.m | |
parent | 0a5e51795bde1f4d6dd3ff49b5af0829c2fdbcdd (diff) | |
download | sequelpro-77ce5576f42812f079fec088f969716eb5eba371.tar.gz sequelpro-77ce5576f42812f079fec088f969716eb5eba371.tar.bz2 sequelpro-77ce5576f42812f079fec088f969716eb5eba371.zip |
• CSV field mapper
- reset import operators after each change of the chosen alignment
- double-click at PathControl performs goBackToFileChooser delayed in order to avoid time racing issues
Diffstat (limited to 'Source/SPFieldMapperController.m')
-rw-r--r-- | Source/SPFieldMapperController.m | 33 |
1 files changed, 22 insertions, 11 deletions
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<possibleImports; i++) + for(i=0; i<possibleImports; i++) { [fieldMappingArray replaceObjectAtIndex:i withObject:[NSNumber numberWithInteger:i]]; + [fieldMappingOperatorArray replaceObjectAtIndex:i withObject:doImport]; + } break; case 1: // reversed file order possibleImports--; - for(i=possibleImports; 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]; |