diff options
-rw-r--r-- | Interfaces/English.lproj/DataMigrationDialog.xib | 148 | ||||
-rw-r--r-- | Source/SPFieldMapperController.h | 6 | ||||
-rw-r--r-- | Source/SPFieldMapperController.m | 45 |
3 files changed, 118 insertions, 81 deletions
diff --git a/Interfaces/English.lproj/DataMigrationDialog.xib b/Interfaces/English.lproj/DataMigrationDialog.xib index cf6b044b..a6a2b81e 100644 --- a/Interfaces/English.lproj/DataMigrationDialog.xib +++ b/Interfaces/English.lproj/DataMigrationDialog.xib @@ -491,7 +491,7 @@ <object class="NSPopUpButton" id="549705971"> <reference key="NSNextResponder" ref="78582513"/> <int key="NSvFlags">267</int> - <string key="NSFrame">{{298, 237}, {160, 22}}</string> + <string key="NSFrame">{{238, 237}, {220, 22}}</string> <reference key="NSSuperview" ref="78582513"/> <bool key="NSEnabled">YES</bool> <object class="NSPopUpButtonCell" key="NSCell" id="107647973"> @@ -607,38 +607,6 @@ <reference key="NSTextColor" ref="263116164"/> </object> </object> - <object class="NSTextField" id="433188989"> - <reference key="NSNextResponder" ref="78582513"/> - <int key="NSvFlags">265</int> - <string key="NSFrame">{{246, 243}, {43, 14}}</string> - <reference key="NSSuperview" ref="78582513"/> - <bool key="NSEnabled">YES</bool> - <object class="NSTextFieldCell" key="NSCell" id="899426596"> - <int key="NSCellFlags">68288064</int> - <int key="NSCellFlags2">272761856</int> - <string key="NSContents">Target:</string> - <reference key="NSSupport" ref="26"/> - <reference key="NSControlView" ref="433188989"/> - <reference key="NSBackgroundColor" ref="19028295"/> - <reference key="NSTextColor" ref="263116164"/> - </object> - </object> - <object class="NSTextField" id="850405204"> - <reference key="NSNextResponder" ref="78582513"/> - <int key="NSvFlags">268</int> - <string key="NSFrame">{{6, 244}, {44, 14}}</string> - <reference key="NSSuperview" ref="78582513"/> - <bool key="NSEnabled">YES</bool> - <object class="NSTextFieldCell" key="NSCell" id="1027920750"> - <int key="NSCellFlags">68288064</int> - <int key="NSCellFlags2">272761856</int> - <string key="NSContents">Source:</string> - <reference key="NSSupport" ref="26"/> - <reference key="NSControlView" ref="850405204"/> - <reference key="NSBackgroundColor" ref="19028295"/> - <reference key="NSTextColor" ref="263116164"/> - </object> - </object> <object class="NSPathControl" id="697948389"> <reference key="NSNextResponder" ref="78582513"/> <int key="NSvFlags">270</int> @@ -650,7 +618,7 @@ <string>NSFilenamesPboardType</string> </object> </object> - <string key="NSFrame">{{51, 240}, {188, 20}}</string> + <string key="NSFrame">{{5, 239}, {212, 20}}</string> <reference key="NSSuperview" ref="78582513"/> <bool key="NSEnabled">YES</bool> <object class="NSPathCell" key="NSCell" id="183652084"> @@ -696,6 +664,38 @@ <reference key="NSDelegate" ref="697948389"/> </object> </object> + <object class="NSTextField" id="661467962"> + <reference key="NSNextResponder" ref="78582513"/> + <int key="NSvFlags">267</int> + <string key="NSFrame">{{322, 261}, {43, 14}}</string> + <reference key="NSSuperview" ref="78582513"/> + <bool key="NSEnabled">YES</bool> + <object class="NSTextFieldCell" key="NSCell" id="471642953"> + <int key="NSCellFlags">68288064</int> + <int key="NSCellFlags2">272761856</int> + <string key="NSContents">Target:</string> + <reference key="NSSupport" ref="26"/> + <reference key="NSControlView" ref="661467962"/> + <reference key="NSBackgroundColor" ref="19028295"/> + <reference key="NSTextColor" ref="263116164"/> + </object> + </object> + <object class="NSTextField" id="158244936"> + <reference key="NSNextResponder" ref="78582513"/> + <int key="NSvFlags">270</int> + <string key="NSFrame">{{88, 261}, {44, 14}}</string> + <reference key="NSSuperview" ref="78582513"/> + <bool key="NSEnabled">YES</bool> + <object class="NSTextFieldCell" key="NSCell" id="149253930"> + <int key="NSCellFlags">68288064</int> + <int key="NSCellFlags2">272761856</int> + <string key="NSContents">Source:</string> + <reference key="NSSupport" ref="26"/> + <reference key="NSControlView" ref="158244936"/> + <reference key="NSBackgroundColor" ref="19028295"/> + <reference key="NSTextColor" ref="263116164"/> + </object> + </object> </object> <string key="NSFrameSize">{465, 311}</string> <reference key="NSSuperview"/> @@ -889,12 +889,12 @@ <reference ref="116285743"/> <reference ref="186404366"/> <reference ref="228203205"/> - <reference ref="697948389"/> <reference ref="599385609"/> - <reference ref="433188989"/> <reference ref="549705971"/> <reference ref="495172082"/> - <reference ref="850405204"/> + <reference ref="697948389"/> + <reference ref="158244936"/> + <reference ref="661467962"/> </object> <reference key="parent" ref="420604405"/> </object> @@ -983,24 +983,6 @@ <reference key="parent" ref="78582513"/> </object> <object class="IBObjectRecord"> - <int key="objectID">22</int> - <reference key="object" ref="433188989"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="899426596"/> - </object> - <reference key="parent" ref="78582513"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">23</int> - <reference key="object" ref="850405204"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="1027920750"/> - </object> - <reference key="parent" ref="78582513"/> - </object> - <object class="IBObjectRecord"> <int key="objectID">24</int> <reference key="object" ref="599385609"/> <object class="NSMutableArray" key="children"> @@ -1059,16 +1041,6 @@ <reference key="parent" ref="519018523"/> </object> <object class="IBObjectRecord"> - <int key="objectID">32</int> - <reference key="object" ref="1027920750"/> - <reference key="parent" ref="850405204"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">33</int> - <reference key="object" ref="899426596"/> - <reference key="parent" ref="433188989"/> - </object> - <object class="IBObjectRecord"> <int key="objectID">34</int> <reference key="object" ref="869323357"/> <reference key="parent" ref="228203205"/> @@ -1212,6 +1184,34 @@ <reference key="parent" ref="0"/> <string key="objectName">TableDump</string> </object> + <object class="IBObjectRecord"> + <int key="objectID">85</int> + <reference key="object" ref="661467962"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="471642953"/> + </object> + <reference key="parent" ref="78582513"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">86</int> + <reference key="object" ref="471642953"/> + <reference key="parent" ref="661467962"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">87</int> + <reference key="object" ref="158244936"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="149253930"/> + </object> + <reference key="parent" ref="78582513"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">88</int> + <reference key="object" ref="149253930"/> + <reference key="parent" ref="158244936"/> + </object> </object> </object> <object class="NSMutableDictionary" key="flattenedProperties"> @@ -1244,8 +1244,6 @@ <string>19.IBPluginDependency</string> <string>20.IBPluginDependency</string> <string>21.IBPluginDependency</string> - <string>22.IBPluginDependency</string> - <string>23.IBPluginDependency</string> <string>24.IBPluginDependency</string> <string>25.IBPluginDependency</string> <string>26.IBPluginDependency</string> @@ -1255,8 +1253,6 @@ <string>29.IBPluginDependency</string> <string>30.IBPluginDependency</string> <string>31.IBPluginDependency</string> - <string>32.IBPluginDependency</string> - <string>33.IBPluginDependency</string> <string>34.IBPluginDependency</string> <string>35.IBPluginDependency</string> <string>36.IBEditorWindowLastContentRect</string> @@ -1286,7 +1282,10 @@ <string>52.IBPluginDependency</string> <string>56.IBPluginDependency</string> <string>57.IBPluginDependency</string> - <string>80.IBPluginDependency</string> + <string>85.IBPluginDependency</string> + <string>86.IBPluginDependency</string> + <string>87.IBPluginDependency</string> + <string>88.IBPluginDependency</string> </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -1320,8 +1319,6 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>{{302, 438}, {126, 54}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -1329,8 +1326,6 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>{{611, 880}, {113, 4}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -1359,6 +1354,9 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> </object> </object> <object class="NSMutableDictionary" key="unlocalizedProperties"> @@ -1377,7 +1375,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">84</int> + <int key="maxID">88</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> diff --git a/Source/SPFieldMapperController.h b/Source/SPFieldMapperController.h index 67dc381d..d48585e0 100644 --- a/Source/SPFieldMapperController.h +++ b/Source/SPFieldMapperController.h @@ -31,7 +31,7 @@ IBOutlet id fieldMapperTableView; IBOutlet id tableTargetPopup; - IBOutlet id fileSourcePath; + IBOutlet NSPathControl *fileSourcePath; IBOutlet id importMethodPopup; IBOutlet id rowUpButton; IBOutlet id rowDownButton; @@ -42,13 +42,17 @@ NSInteger fieldMappingCurrentRow; NSArray *fieldMappingImportArray; NSArray *fieldMappingArray; + NSMutableArray *fieldMappingTableColumnNames; BOOL fieldMappingImportArrayIsPreview; MCPConnection *mySQLConnection; + NSString *sourcePath; } +@property(retain) NSString* sourcePath; + - (id)initWithDelegate:(id)managerDelegate; - (void)setConnection:(MCPConnection *)theConnection; diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index 92d0c935..3ed30270 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -25,9 +25,12 @@ #import "SPFieldMapperController.h" #import "SPTableData.h" +#import "TablesList.h" @implementation SPFieldMapperController +@synthesize sourcePath; + #pragma mark - #pragma mark Initialization @@ -46,11 +49,27 @@ return nil; } theDelegate = managerDelegate; + fieldMappingTableColumnNames = [[NSMutableArray alloc] initWithCapacity:1]; } return self; } +- (void)awakeFromNib +{ + [fileSourcePath setURL:[NSURL URLWithString:sourcePath]]; + [tableTargetPopup removeAllItems]; + [tableTargetPopup addItemsWithTitles:[[theDelegate valueForKeyPath:@"tablesListInstance"] allTableNames]]; + + // Select either the currently selected table, or the first item in the list + if ([[theDelegate valueForKeyPath:@"tableDocumentInstance"] table] != nil && ![[[theDelegate valueForKeyPath:@"tablesListInstance"] tableName] isEqualToString:@""]) { + [tableTargetPopup selectItemWithTitle:[[theDelegate valueForKeyPath:@"tablesListInstance"] tableName]]; + } else { + [tableTargetPopup selectItemAtIndex:0]; + } + + [self changeTableTarget:self]; +} /* * Set the connection for use. * Called by the connect sheet methods. @@ -64,6 +83,8 @@ - (void)dealloc { if (mySQLConnection) [mySQLConnection release]; + if (sourcePath) [sourcePath release]; + if (fieldMappingTableColumnNames) [fieldMappingTableColumnNames release]; [super dealloc]; } @@ -79,17 +100,18 @@ { // Remove all the current columns - // [fieldMappingTableColumnNames removeAllObjects]; + [fieldMappingTableColumnNames 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"]]]; - // } + for (NSDictionary *column in [tableDetails objectForKey:@"columns"]) { + [fieldMappingTableColumnNames addObject:[NSString stringWithString:[column objectForKey:@"name"]]]; + } } + NSLog(@"f %@", [fieldMappingTableColumnNames description]); [selectedTableData release]; // Update the table view @@ -135,7 +157,7 @@ - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView; { - return 0; + return [fieldMappingTableColumnNames count]; } - (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex @@ -145,6 +167,19 @@ - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex { + if ([[aTableColumn identifier] isEqualToString:@"target_field"]) { + return [fieldMappingTableColumnNames objectAtIndex:rowIndex]; + + } + // else if ([[aTableColumn identifier] isEqualToString:@"value"]) { + // if ([[[aTableColumn dataCell] class] isEqualTo:[NSPopUpButtonCell class]]) { + // [(NSPopUpButtonCell *)[aTableColumn dataCell] removeAllItems]; + // [(NSPopUpButtonCell *)[aTableColumn dataCell] addItemWithTitle:NSLocalizedString(@"Do not import", @"text for csv import drop downs")]; + // [(NSPopUpButtonCell *)[aTableColumn dataCell] addItemsWithTitles:fieldMappingButtonOptions]; + // } + // + // returnObject = [fieldMappingArray objectAtIndex:rowIndex]; + // } return nil; } |