aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-02-16 20:20:12 +0000
committerBibiko <bibiko@eva.mpg.de>2010-02-16 20:20:12 +0000
commitbcce99ec7a994cabf1fd686bad27845b0fed7272 (patch)
tree5715a89fdcccd36977f9b3a0b88628c5983a04f8 /Source
parentd400bb1391e366e123366668565080df350b18c5 (diff)
downloadsequelpro-bcce99ec7a994cabf1fd686bad27845b0fed7272.tar.gz
sequelpro-bcce99ec7a994cabf1fd686bad27845b0fed7272.tar.bz2
sequelpro-bcce99ec7a994cabf1fd686bad27845b0fed7272.zip
• csv field mapper
- added target table field type and default info - disable Import button if no target table fields are available
Diffstat (limited to 'Source')
-rw-r--r--Source/SPFieldMapperController.h3
-rw-r--r--Source/SPFieldMapperController.m48
2 files changed, 45 insertions, 6 deletions
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]]) {