diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-02-02 15:25:36 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-02-02 15:25:36 +0000 |
commit | 6e420c763f8f68a42c7f944c3c3e951e46bc7b33 (patch) | |
tree | 32ed4e194c9d1e7c68dbd3de8f9f4474352e1864 /Source/SPFieldMapperController.m | |
parent | 736c95f11116e0be3e516933506034fb6078be72 (diff) | |
download | sequelpro-6e420c763f8f68a42c7f944c3c3e951e46bc7b33.tar.gz sequelpro-6e420c763f8f68a42c7f944c3c3e951e46bc7b33.tar.bz2 sequelpro-6e420c763f8f68a42c7f944c3c3e951e46bc7b33.zip |
• further work on SPFieldMapperController
Diffstat (limited to 'Source/SPFieldMapperController.m')
-rw-r--r-- | Source/SPFieldMapperController.m | 106 |
1 files changed, 105 insertions, 1 deletions
diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index a5729905..70a4b049 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -24,8 +24,112 @@ // #import "SPFieldMapperController.h" - +#import "SPTableData.h" @implementation SPFieldMapperController +#pragma mark - +#pragma mark Initialization + + +/** + * Initialize the field mapper + */ +- (id)initWithDelegate:(id)managerDelegate +{ + if ((self = [super initWithWindowNibName:@"DataMigrationDialog"])) { + + fieldMappingCurrentRow = 0; + if(managerDelegate == nil) { + NSBeep(); + NSLog(@"FieldMapperController was called without a delegate."); + return nil; + } + theDelegate = managerDelegate; + + } + + return self; +} + +- (void)awakeFromNib +{ + +} + +/* + * Set the connection for use. + * Called by the connect sheet methods. + */ +- (void)setConnection:(MCPConnection *)theConnection +{ + mySQLConnection = theConnection; + [mySQLConnection retain]; +} + +- (void)dealloc +{ + if (mySQLConnection) [mySQLConnection release]; + [super dealloc]; +} + +#pragma mark - +#pragma mark IBAction methods + +- (IBAction)changeTableTarget:(id)sender +{ + + // Remove all the current columns + // [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"]]]; + // } + } + [selectedTableData release]; + + // Update the table view + fieldMappingCurrentRow = 0; + if (fieldMappingArray) [fieldMappingArray release], fieldMappingArray = nil; + // [self setupFieldMappingArray]; + [rowDownButton setEnabled:NO]; + [rowUpButton setEnabled:([fieldMappingImportArray count] > 1)]; + [recordCountLabel setStringValue:[NSString stringWithFormat:@"%ld of %@%lu records", (long)(fieldMappingCurrentRow+1), fieldMappingImportArrayIsPreview?@"first ":@"", (unsigned long)[fieldMappingImportArray count]]]; + + // [self updateFieldMappingButtonCell]; + [fieldMapperTableView reloadData]; +} + +- (IBAction)changeImportMethod:(id)sender +{ + +} + +/* + * Displays next/previous row in fieldMapping tableView + */ +- (IBAction)stepRow:(id)sender +{ + if ( [sender tag] == 0 ) { + fieldMappingCurrentRow--; + } else { + fieldMappingCurrentRow++; + } + // [self updateFieldMappingButtonCell]; + + [fieldMapperTableView reloadData]; + + [recordCountLabel setStringValue:[NSString stringWithFormat:@"%ld of %@%lu records", (long)(fieldMappingCurrentRow+1), fieldMappingImportArrayIsPreview?@"first ":@"", (unsigned long)[fieldMappingImportArray count]]]; + + // enable/disable buttons + [rowDownButton setEnabled:(fieldMappingCurrentRow != 0)]; + [rowUpButton setEnabled:(fieldMappingCurrentRow != ([fieldMappingImportArray count]-1))]; +} + + @end |