From 429e77d0512d3d36a4ca8e9aa994be48906c1445 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 16 Feb 2010 21:31:03 +0000 Subject: =?UTF-8?q?=E2=80=A2=20csv=20field=20mapper=20-=20added=20target?= =?UTF-8?q?=20table=20field=20primary=20key=20info=20-=20added=20to=20alig?= =?UTF-8?q?n=20the=20csv=20fields=20by=20'file=20order'=20and=20'reversed?= =?UTF-8?q?=20file=20order'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/DataMigrationDialog.xib | 54 +++++++++++++++++------- Source/SPFieldMapperController.h | 6 ++- Source/SPFieldMapperController.m | 31 +++++++++++++- 3 files changed, 73 insertions(+), 18 deletions(-) diff --git a/Interfaces/English.lproj/DataMigrationDialog.xib b/Interfaces/English.lproj/DataMigrationDialog.xib index 560eb5fb..f908ed52 100644 --- a/Interfaces/English.lproj/DataMigrationDialog.xib +++ b/Interfaces/English.lproj/DataMigrationDialog.xib @@ -12,7 +12,7 @@ YES - + YES @@ -991,7 +991,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA MC45Mjk0MTE4Mjg1IDAuOTI5NDExODI4NSAwLjkyOTQxMTgyODUAA - {1, -1} + {4, 4} 0 6 @@ -1033,7 +1033,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA YES - -1539178944 + -2076049856 133120 @@ -1043,9 +1043,9 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA 400 75 - + - matching names + file order 1048576 2147483647 @@ -1060,29 +1060,33 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA OtherViews YES - - + + - file order + reversed file order - 1048576 2147483647 _popUpItemAction: + 1 - + - reversed file order + YES + matching names + 1048576 2147483647 _popUpItemAction: + 2 + YES 1 @@ -1315,6 +1319,22 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA 150 + + + alignByPopup + + + + 151 + + + + changeFieldAlignment: + + + + 152 + @@ -1954,9 +1974,9 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA YES com.apple.InterfaceBuilder.CocoaPlugin - {{180, 271}, {465, 405}} + {{164, 144}, {465, 405}} com.apple.InterfaceBuilder.CocoaPlugin - {{180, 271}, {465, 405}} + {{164, 144}, {465, 405}} {{387, 725}, {432, 282}} @@ -1975,7 +1995,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{186, 334}, {161, 54}} + {{170, 196}, {161, 54}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -2118,7 +2138,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA - 150 + 152 @@ -2154,6 +2174,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA YES YES + changeFieldAlignment: changeImportMethod: changeTableTarget: closeSheet: @@ -2165,12 +2186,14 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA id id id + id YES YES + alignByPopup fieldMapperTableView fieldMappingImportArray fileSourcePath @@ -2185,6 +2208,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA YES + id NSTableView id NSPathControl 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=0; i--) + [fieldMappingArray replaceObjectAtIndex:possibleImports-i withObject:[NSNumber numberWithInteger:i]]; + break; + + } + [fieldMapperTableView reloadData]; +} /* * Displays next/previous row in fieldMapping tableView */ -- cgit v1.2.3