diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-02-16 21:31:03 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-02-16 21:31:03 +0000 |
commit | 429e77d0512d3d36a4ca8e9aa994be48906c1445 (patch) | |
tree | 9e18783b768dae92162acdf6decfd45d9ed17197 /Source | |
parent | bcce99ec7a994cabf1fd686bad27845b0fed7272 (diff) | |
download | sequelpro-429e77d0512d3d36a4ca8e9aa994be48906c1445.tar.gz sequelpro-429e77d0512d3d36a4ca8e9aa994be48906c1445.tar.bz2 sequelpro-429e77d0512d3d36a4ca8e9aa994be48906c1445.zip |
• csv field mapper
- added target table field primary key info
- added to align the csv fields by 'file order' and 'reversed file order'
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPFieldMapperController.h | 6 | ||||
-rw-r--r-- | Source/SPFieldMapperController.m | 31 |
2 files changed, 34 insertions, 3 deletions
diff --git a/Source/SPFieldMapperController.h b/Source/SPFieldMapperController.h index 623b052a..62139b7d 100644 --- a/Source/SPFieldMapperController.h +++ b/Source/SPFieldMapperController.h @@ -28,14 +28,15 @@ @interface SPFieldMapperController : NSWindowController { IBOutlet NSTableView *fieldMapperTableView; - IBOutlet id tableTargetPopup; + IBOutlet NSPopUpButton *tableTargetPopup; IBOutlet NSPathControl *fileSourcePath; - IBOutlet id importMethodPopup; + IBOutlet NSPopUpButton *importMethodPopup; IBOutlet id rowUpButton; IBOutlet id rowDownButton; IBOutlet id recordCountLabel; IBOutlet id importFieldNamesHeaderSwitch; IBOutlet id importButton; + IBOutlet NSPopUpButton *alignByPopup; id theDelegate; id fieldMappingImportArray; @@ -85,6 +86,7 @@ // IBAction methods - (IBAction)changeTableTarget:(id)sender; - (IBAction)changeImportMethod:(id)sender; +- (IBAction)changeFieldAlignment:(id)sender; - (IBAction)stepRow:(id)sender; - (IBAction)closeSheet:(id)sender; diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index 916d8903..84dfc4c8 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -202,7 +202,9 @@ [type appendFormat:@"(%@)", [column objectForKey:@"length"]]; if([column objectForKey:@"values"]) [type appendFormat:@"(%@)", [[column objectForKey:@"values"] componentsJoinedByString:@"¦"]]; - if([column objectForKey:@"default"]) + if([column objectForKey:@"autoincrement"] && [[column objectForKey:@"autoincrement"] integerValue] == 1) + [type appendFormat:@",%@",@"PRIMARY KEY"]; + else if ([column objectForKey:@"default"]) [type appendFormat:@",%@",[column objectForKey:@"default"]]; [fieldMappingTableTypes addObject:[NSString stringWithString:type]]; } @@ -235,6 +237,9 @@ // Disable Import button if no fields are available [importButton setEnabled:([fieldMappingTableColumnNames count] > 0)]; + + [alignByPopup selectItemWithTag:0]; + [fieldMapperTableView reloadData]; } @@ -254,6 +259,30 @@ [fieldMapperTableView reloadData]; } +- (IBAction)changeFieldAlignment:(id)sender +{ + + if(![fieldMappingImportArray count]) return; + + NSInteger i; + NSInteger possibleImports = ([NSArrayObjectAtIndex(fieldMappingImportArray, 0) count] > [fieldMappingTableColumnNames count]) ? [fieldMappingTableColumnNames count] : [NSArrayObjectAtIndex(fieldMappingImportArray, 0) count]; + + if(possibleImports < 1) return; + + switch([[alignByPopup selectedItem] tag]) { + case 0: // file order + for(i=0; i<possibleImports; i++) + [fieldMappingArray replaceObjectAtIndex:i withObject:[NSNumber numberWithInteger:i]]; + break; + case 1: // reversed file order + possibleImports--; + for(i=possibleImports; i>=0; i--) + [fieldMappingArray replaceObjectAtIndex:possibleImports-i withObject:[NSNumber numberWithInteger:i]]; + break; + + } + [fieldMapperTableView reloadData]; +} /* * Displays next/previous row in fieldMapping tableView */ |