From bcce99ec7a994cabf1fd686bad27845b0fed7272 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 16 Feb 2010 20:20:12 +0000 Subject: =?UTF-8?q?=E2=80=A2=20csv=20field=20mapper=20-=20added=20target?= =?UTF-8?q?=20table=20field=20type=20and=20default=20info=20-=20disable=20?= =?UTF-8?q?Import=20button=20if=20no=20target=20table=20fields=20are=20ava?= =?UTF-8?q?ilable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/DataMigrationDialog.xib | 105 +++++++++++++++++------ Source/SPFieldMapperController.h | 3 + Source/SPFieldMapperController.m | 48 +++++++++-- 3 files changed, 125 insertions(+), 31 deletions(-) diff --git a/Interfaces/English.lproj/DataMigrationDialog.xib b/Interfaces/English.lproj/DataMigrationDialog.xib index 34ffec6c..560eb5fb 100644 --- a/Interfaces/English.lproj/DataMigrationDialog.xib +++ b/Interfaces/English.lproj/DataMigrationDialog.xib @@ -12,7 +12,7 @@ YES - + YES @@ -41,7 +41,7 @@ 15 2 - {{262, 369}, {465, 394}} + {{262, 358}, {465, 405}} 1886912512 CSV Field Mapping NSWindow @@ -106,7 +106,7 @@ - {{-1, 354}, {467, 41}} + {{-1, 365}, {467, 41}} {0, 0} @@ -155,7 +155,7 @@ 256 - {465, 141} + {465, 144} YES @@ -296,7 +296,7 @@ target_field - 216 + 148 10 3.4028234663852886e+38 @@ -304,7 +304,7 @@ 2048 Table Target Fields - + 6 System headerColor @@ -354,6 +354,33 @@ YES + + type + 65 + 10 + 3.4028234663852886e+38 + + 75628096 + 2048 + + + + + + + 67239488 + 272761856 + Text + + + + + + 3 + YES + YES + + 3 2 @@ -375,11 +402,10 @@ MC41AA - 20 - 1379958784 + 16 + 1388347392 - 1 1 15 0 @@ -388,7 +414,7 @@ 1 - {{1, 17}, {465, 141}} + {{1, 17}, {465, 144}} @@ -437,7 +463,7 @@ - {{-1, 160}, {467, 159}} + {{-1, 168}, {467, 162}} 530 @@ -446,7 +472,7 @@ - QSAAAEEgAABBsAAAQbAAAA + QSAAAEEgAABBkAAAQZAAAA @@ -565,7 +591,7 @@ 267 - {{244, 324}, {215, 22}} + {{244, 335}, {215, 22}} YES @@ -686,7 +712,7 @@ NSFilenamesPboardType - {{5, 326}, {212, 20}} + {{5, 337}, {212, 20}} YES @@ -778,7 +804,7 @@ - CeKAkwlEbyBpbXBvcnQgZmllbGQKCQlEbyBub3QgaW1wb3J0IGZpZWxkCglJTlNFUlQJQWRkIGFzIG5l + CeKAlQlEbyBpbXBvcnQgZmllbGQKCQlEbyBub3QgaW1wb3J0IGZpZWxkCglJTlNFUlQJQWRkIGFzIG5l dyByb3dzIElOU0VSVCBJTlRPIOKApglSRVBMQUNFCVVwZGF0ZSBleGlzdGluZyByb3dzIG9yIGFkZCBh cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA @@ -896,7 +922,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA 1 - 2309 + 2308 0 @@ -965,8 +991,8 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA MC45Mjk0MTE4Mjg1IDAuOTI5NDExODI4NSAwLjkyOTQxMTgyODUAA - {4, -5} - 1 + {1, -1} + 0 6 @@ -1104,7 +1130,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA 269 - {{218, 329}, {23, 17}} + {{218, 340}, {23, 17}} YES @@ -1122,7 +1148,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA - {465, 394} + {465, 405} {{0, 0}, {1280, 1002}} @@ -1281,6 +1307,14 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA 119 + + + importButton + + + + 150 + @@ -1538,6 +1572,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA + @@ -1797,6 +1832,20 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA + + 144 + + + YES + + + + + + 149 + + + @@ -1838,6 +1887,8 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA 141.IBPluginDependency 142.IBPluginDependency 143.IBPluginDependency + 144.IBPluginDependency + 149.IBPluginDependency 15.IBAttributePlaceholdersKey 15.IBPluginDependency 15.ImportedFromIB2 @@ -1903,9 +1954,9 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA YES com.apple.InterfaceBuilder.CocoaPlugin - {{180, 282}, {465, 394}} + {{180, 271}, {465, 405}} com.apple.InterfaceBuilder.CocoaPlugin - {{180, 282}, {465, 394}} + {{180, 271}, {465, 405}} {{387, 725}, {432, 282}} @@ -1944,6 +1995,8 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin ToolTip @@ -2040,7 +2093,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{128, 372}, {465, 20}} + {{169, 564}, {465, 20}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -2065,7 +2118,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA - 143 + 150 @@ -2121,6 +2174,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA fieldMapperTableView fieldMappingImportArray fileSourcePath + importButton importFieldNamesHeaderSwitch importMethodPopup recordCountLabel @@ -2131,7 +2185,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA YES - id + NSTableView id NSPathControl id @@ -2141,6 +2195,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA id id id + id diff --git a/Source/SPFieldMapperController.h b/Source/SPFieldMapperController.h index 138c765a..623b052a 100644 --- a/Source/SPFieldMapperController.h +++ b/Source/SPFieldMapperController.h @@ -35,6 +35,7 @@ IBOutlet id rowDownButton; IBOutlet id recordCountLabel; IBOutlet id importFieldNamesHeaderSwitch; + IBOutlet id importButton; id theDelegate; id fieldMappingImportArray; @@ -42,6 +43,8 @@ NSInteger fieldMappingCurrentRow; NSMutableArray *fieldMappingArray; NSMutableArray *fieldMappingTableColumnNames; + // NSMutableArray *fieldMappingTableDefaultValues; + NSMutableArray *fieldMappingTableTypes; NSMutableArray *fieldMappingButtonOptions; NSMutableArray *fieldMappingOperatorOptions; NSMutableArray *fieldMappingOperatorArray; diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index 77c4c335..916d8903 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -50,10 +50,12 @@ return nil; } theDelegate = managerDelegate; - fieldMappingTableColumnNames = [[NSMutableArray alloc] init]; - fieldMappingButtonOptions = [[NSMutableArray alloc] init]; - fieldMappingOperatorOptions = [[NSMutableArray alloc] init]; - fieldMappingOperatorArray = [[NSMutableArray alloc] init]; + fieldMappingTableColumnNames = [[NSMutableArray alloc] init]; + // fieldMappingTableDefaultValues = [[NSMutableArray alloc] init]; + fieldMappingTableTypes = [[NSMutableArray alloc] init]; + fieldMappingButtonOptions = [[NSMutableArray alloc] init]; + fieldMappingOperatorOptions = [[NSMutableArray alloc] init]; + fieldMappingOperatorArray = [[NSMutableArray alloc] init]; fieldMappingArray = nil; lastDisabledCSVFieldcolumn = [NSNumber numberWithInteger:0]; @@ -61,7 +63,7 @@ doImport = [NSNumber numberWithInteger:0]; doNotImport = [NSNumber numberWithInteger:1]; isEqual = [NSNumber numberWithInteger:2]; - doImportString = @"─"; + doImportString = @"―"; doNotImportString = @" "; isEqualString = @"="; @@ -105,6 +107,8 @@ if (mySQLConnection) [mySQLConnection release]; if (sourcePath) [sourcePath release]; if (fieldMappingTableColumnNames) [fieldMappingTableColumnNames release]; + // if (fieldMappingTableDefaultValues) [fieldMappingTableDefaultValues release]; + if (fieldMappingTableTypes) [fieldMappingTableTypes release]; if (fieldMappingArray) [fieldMappingArray release]; if (fieldMappingButtonOptions) [fieldMappingButtonOptions release]; if (fieldMappingOperatorOptions) [fieldMappingOperatorOptions release]; @@ -176,14 +180,31 @@ // Remove all the current columns [fieldMappingTableColumnNames removeAllObjects]; + // [fieldMappingTableDefaultValues removeAllObjects]; + [fieldMappingTableTypes removeAllObjects]; // Retrieve the information for the newly selected table using a SPTableData instance SPTableData *selectedTableData = [[SPTableData alloc] init]; [selectedTableData setConnection:mySQLConnection]; NSDictionary *tableDetails = [selectedTableData informationForTable:[tableTargetPopup titleOfSelectedItem]]; + if (tableDetails) { for (NSDictionary *column in [tableDetails objectForKey:@"columns"]) { [fieldMappingTableColumnNames addObject:[NSString stringWithString:[column objectForKey:@"name"]]]; + // if([column objectForKey:@"default"]) + // [fieldMappingTableDefaultValues addObject:[NSString stringWithString:[column objectForKey:@"default"]]]; + // else + // [fieldMappingTableDefaultValues addObject:@""]; + NSMutableString *type = [NSMutableString string]; + if([column objectForKey:@"type"]) + [type appendString:[column objectForKey:@"type"]]; + if([column objectForKey:@"length"]) + [type appendFormat:@"(%@)", [column objectForKey:@"length"]]; + if([column objectForKey:@"values"]) + [type appendFormat:@"(%@)", [[column objectForKey:@"values"] componentsJoinedByString:@"¦"]]; + if([column objectForKey:@"default"]) + [type appendFormat:@",%@",[column objectForKey:@"default"]]; + [fieldMappingTableTypes addObject:[NSString stringWithString:type]]; } } @@ -212,6 +233,8 @@ [fieldMappingOperatorArray replaceObjectAtIndex:i withObject:doImport]; } + // Disable Import button if no fields are available + [importButton setEnabled:([fieldMappingTableColumnNames count] > 0)]; [fieldMapperTableView reloadData]; } @@ -387,13 +410,26 @@ } return [fieldMappingTableColumnNames objectAtIndex:rowIndex]; } + else if ([[aTableColumn identifier] isEqualToString:@"type"]) { + NSTokenFieldCell *b = [[[NSTokenFieldCell alloc] initTextCell:[fieldMappingTableTypes objectAtIndex:rowIndex]] autorelease]; + [b setEditable:NO]; + [b setAlignment:NSLeftTextAlignment]; + [b setFont:[NSFont systemFontOfSize:9]]; + [b setDelegate:self]; + return b; + } else if ([[aTableColumn identifier] isEqualToString:@"import_value"]) { if ([[aTableColumn dataCell] isKindOfClass:[NSPopUpButtonCell class]]) { [(NSPopUpButtonCell *)[aTableColumn dataCell] removeAllItems]; if([fieldMappingOperatorArray objectAtIndex:rowIndex] != doNotImport) [(NSPopUpButtonCell *)[aTableColumn dataCell] addItemsWithTitles:fieldMappingButtonOptions]; + return [fieldMappingArray objectAtIndex:rowIndex]; + // } else { + // NSString *defaultValue = [fieldMappingTableDefaultValues objectAtIndex:[[fieldMappingArray objectAtIndex:rowIndex] integerValue]]; + // [(NSPopUpButtonCell *)[aTableColumn dataCell] addItemWithTitle:defaultValue]; + // return defaultValue; + // } } - return [fieldMappingArray objectAtIndex:rowIndex]; } else if ([[aTableColumn identifier] isEqualToString:@"operator"]) { if ([[aTableColumn dataCell] isKindOfClass:[NSPopUpButtonCell class]]) { -- cgit v1.2.3