aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPFieldMapperController.h6
-rw-r--r--Source/SPFieldMapperController.m31
2 files changed, 34 insertions, 3 deletions
diff --git a/Source/SPFieldMapperController.h b/Source/SPFieldMapperController.h
index 623b052a..62139b7d 100644
--- a/Source/SPFieldMapperController.h
+++ b/Source/SPFieldMapperController.h
@@ -28,14 +28,15 @@
@interface SPFieldMapperController : NSWindowController {
IBOutlet NSTableView *fieldMapperTableView;
- IBOutlet id tableTargetPopup;
+ IBOutlet NSPopUpButton *tableTargetPopup;
IBOutlet NSPathControl *fileSourcePath;
- IBOutlet id importMethodPopup;
+ IBOutlet NSPopUpButton *importMethodPopup;
IBOutlet id rowUpButton;
IBOutlet id rowDownButton;
IBOutlet id recordCountLabel;
IBOutlet id importFieldNamesHeaderSwitch;
IBOutlet id importButton;
+ IBOutlet NSPopUpButton *alignByPopup;
id theDelegate;
id fieldMappingImportArray;
@@ -85,6 +86,7 @@
// IBAction methods
- (IBAction)changeTableTarget:(id)sender;
- (IBAction)changeImportMethod:(id)sender;
+- (IBAction)changeFieldAlignment:(id)sender;
- (IBAction)stepRow:(id)sender;
- (IBAction)closeSheet:(id)sender;
diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m
index 916d8903..84dfc4c8 100644
--- a/Source/SPFieldMapperController.m
+++ b/Source/SPFieldMapperController.m
@@ -202,7 +202,9 @@
[type appendFormat:@"(%@)", [column objectForKey:@"length"]];
if([column objectForKey:@"values"])
[type appendFormat:@"(%@)", [[column objectForKey:@"values"] componentsJoinedByString:@"¦"]];
- if([column objectForKey:@"default"])
+ if([column objectForKey:@"autoincrement"] && [[column objectForKey:@"autoincrement"] integerValue] == 1)
+ [type appendFormat:@",%@",@"PRIMARY KEY"];
+ else if ([column objectForKey:@"default"])
[type appendFormat:@",%@",[column objectForKey:@"default"]];
[fieldMappingTableTypes addObject:[NSString stringWithString:type]];
}
@@ -235,6 +237,9 @@
// Disable Import button if no fields are available
[importButton setEnabled:([fieldMappingTableColumnNames count] > 0)];
+
+ [alignByPopup selectItemWithTag:0];
+
[fieldMapperTableView reloadData];
}
@@ -254,6 +259,30 @@
[fieldMapperTableView reloadData];
}
+- (IBAction)changeFieldAlignment:(id)sender
+{
+
+ if(![fieldMappingImportArray count]) return;
+
+ NSInteger i;
+ NSInteger possibleImports = ([NSArrayObjectAtIndex(fieldMappingImportArray, 0) count] > [fieldMappingTableColumnNames count]) ? [fieldMappingTableColumnNames count] : [NSArrayObjectAtIndex(fieldMappingImportArray, 0) count];
+
+ if(possibleImports < 1) return;
+
+ switch([[alignByPopup selectedItem] tag]) {
+ case 0: // file order
+ for(i=0; i<possibleImports; i++)
+ [fieldMappingArray replaceObjectAtIndex:i withObject:[NSNumber numberWithInteger:i]];
+ break;
+ case 1: // reversed file order
+ possibleImports--;
+ for(i=possibleImports; i>=0; i--)
+ [fieldMappingArray replaceObjectAtIndex:possibleImports-i withObject:[NSNumber numberWithInteger:i]];
+ break;
+
+ }
+ [fieldMapperTableView reloadData];
+}
/*
* Displays next/previous row in fieldMapping tableView
*/