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/SPFieldMapperController.m | |
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/SPFieldMapperController.m')
-rw-r--r-- | Source/SPFieldMapperController.m | 31 |
1 files changed, 30 insertions, 1 deletions
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 */ |