aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-02-15 10:16:13 +0000
committerBibiko <bibiko@eva.mpg.de>2010-02-15 10:16:13 +0000
commitc64877be105019508234b9ee867d710de3b8160c (patch)
tree469ba2cace13daa4643d40934fcf43b9b78fe638 /Source
parente3d1b3567632352decc184d64b3e0fed82e11554 (diff)
downloadsequelpro-c64877be105019508234b9ee867d710de3b8160c.tar.gz
sequelpro-c64877be105019508234b9ee867d710de3b8160c.tar.bz2
sequelpro-c64877be105019508234b9ee867d710de3b8160c.zip
• some further progress for the new csv import field mapper sheet
Diffstat (limited to 'Source')
-rw-r--r--Source/SPFieldMapperController.h6
-rw-r--r--Source/SPFieldMapperController.m45
2 files changed, 45 insertions, 6 deletions
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;
}