aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPFieldMapperController.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-03-03 19:49:20 +0000
committerBibiko <bibiko@eva.mpg.de>2010-03-03 19:49:20 +0000
commita10a86f1326aff47e4b045c987ec8159181ad4ff (patch)
tree2bb04ee1644b7f582f561908d47ce29d4482b549 /Source/SPFieldMapperController.m
parent0c303c40066f65fa0739f43b46aecca1172d2ddc (diff)
downloadsequelpro-a10a86f1326aff47e4b045c987ec8159181ad4ff.tar.gz
sequelpro-a10a86f1326aff47e4b045c987ec8159181ad4ff.tar.bz2
sequelpro-a10a86f1326aff47e4b045c987ec8159181ad4ff.zip
• CSV Import Field Mapper
- further work on UPDATE (not yet activated)
Diffstat (limited to 'Source/SPFieldMapperController.m')
-rw-r--r--Source/SPFieldMapperController.m44
1 files changed, 41 insertions, 3 deletions
diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m
index 514d031a..8f13b6bb 100644
--- a/Source/SPFieldMapperController.m
+++ b/Source/SPFieldMapperController.m
@@ -97,6 +97,8 @@
}
[importFieldNamesHeaderSwitch setState:importFieldNamesHeader];
+ [addRemainingDataSwitch setHidden:YES];
+ [addRemainingDataSwitch setState:NSOffState];
[self changeHasHeaderCheckbox:self];
[self changeTableTarget:self];
@@ -193,6 +195,11 @@
return ([importFieldNamesHeaderSwitch state] == NSOnState)?YES:NO;
}
+- (BOOL)insertRemainingRowsAfterUpdate
+{
+ return ([addRemainingDataSwitch state] == NSOnState)?YES:NO;
+}
+
- (NSString*)importHeaderString
{
if([[importMethodPopup titleOfSelectedItem] isEqualToString:@"INSERT"]) {
@@ -310,17 +317,23 @@
- (IBAction)changeImportMethod:(id)sender
{
NSInteger i;
+
// If operator is set to = for UPDATE method replace it by doNotImport
if(![[importMethodPopup titleOfSelectedItem] isEqualToString:@"UPDATE"]) {
[advancedButton setEnabled:YES];
+ [addRemainingDataSwitch setHidden:YES];
for(i=0; i<[fieldMappingTableColumnNames count]; i++) {
- if([fieldMappingOperatorArray objectAtIndex:i] == isEqual)
+ if([fieldMappingOperatorArray objectAtIndex:i] == isEqual) {
[fieldMappingOperatorArray replaceObjectAtIndex:i withObject:doNotImport];
+ }
}
} else {
[advancedButton setEnabled:NO];
+ [addRemainingDataSwitch setHidden:NO];
}
+ [self validateImportButton];
+
[self updateFieldMappingOperatorOptions];
[fieldMapperTableView reloadData];
}
@@ -667,6 +680,22 @@
}
+- (void)validateImportButton
+{
+ BOOL enableImportButton = YES;
+ if([[self selectedImportMethod] isEqualToString:@"UPDATE"]) {
+ enableImportButton = NO;
+ for(id op in fieldMappingOperatorArray) {
+ if(op == isEqual) {
+ enableImportButton = YES;
+ break;
+ }
+ }
+ enableImportButton = NO; // TODO HansJB WIP
+ }
+ [importButton setEnabled:enableImportButton];
+}
+
#pragma mark -
#pragma mark Table view datasource methods
@@ -699,6 +728,7 @@
[fieldMappingOperatorArray removeAllObjects];
for(i=0; i < [fieldMappingTableColumnNames count]; i++)
[fieldMappingOperatorArray addObject:globalValue];
+ [self validateImportButton];
[fieldMapperTableView reloadData];
}
}
@@ -786,10 +816,11 @@
[c addItemWithTitle:[NSString stringWithFormat:@"DEFAULT: %@", [fieldMappingTableDefaultValues objectAtIndex:rowIndex]]];
[[m itemAtIndex:[c numberOfItems]-1] setEnabled:NO];
- // If user doesn't want to import it show its DEFAULT value otherwise hide it.
+ // If user doesn't want to import it show its DEFAULT value if not
+ // UPDATE was chosen otherwise hide it.
if([fieldMappingOperatorArray objectAtIndex:rowIndex] != doNotImport)
return [fieldMappingArray objectAtIndex:rowIndex];
- else
+ else if(![[self selectedImportMethod] isEqualToString:@"UPDATE"])
return [NSNumber numberWithInteger:[c numberOfItems]-1];
}
@@ -854,6 +885,9 @@
[aTableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.0];
[self addGlobalSourceVariable:nil];
}
+
+ [self validateImportButton];
+
return;
}
@@ -866,6 +900,9 @@
// If user _changed_ the csv file column set the operator to doImport
if([(NSNumber*)anObject integerValue] > -1)
[fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:doImport];
+
+ [self validateImportButton];
+
}
else if ([[aTableColumn identifier] isEqualToString:@"operator"]) {
@@ -876,6 +913,7 @@
if(anObject == doNotImport) lastDisabledCSVFieldcolumn = [fieldMappingArray objectAtIndex:rowIndex];
[fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:anObject];
}
+ [self validateImportButton];
}
// Refresh table
[aTableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.01];