aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-02-17 10:40:21 +0000
committerBibiko <bibiko@eva.mpg.de>2010-02-17 10:40:21 +0000
commitdc01911fd5987bb4a3213b2c6637326d9dd8c94d (patch)
tree47107a0f02a5320701e48e64ed684761b43c143d
parent72c4522db57b9699e1dc324f62dbeb036405f2c6 (diff)
downloadsequelpro-dc01911fd5987bb4a3213b2c6637326d9dd8c94d.tar.gz
sequelpro-dc01911fd5987bb4a3213b2c6637326d9dd8c94d.tar.bz2
sequelpro-dc01911fd5987bb4a3213b2c6637326d9dd8c94d.zip
• csv file import mapper
- added button "Go Back" ⌥← to go back to the file chooser (mainly for correcting delimiter etc.) - improved selecting csv file columns for the case that column was set as 'Do not import'; now if set to 'Do not import' the value is hidden, click the user on it the popup menu appears and the operator is set to 'Do import' automatically • TableDump now remembers the last chosen csv file name
-rw-r--r--Interfaces/English.lproj/DataMigrationDialog.xib66
-rw-r--r--Source/SPFieldMapperController.h1
-rw-r--r--Source/SPFieldMapperController.m23
-rw-r--r--Source/TableDump.h1
-rw-r--r--Source/TableDump.m14
5 files changed, 90 insertions, 15 deletions
diff --git a/Interfaces/English.lproj/DataMigrationDialog.xib b/Interfaces/English.lproj/DataMigrationDialog.xib
index d0afc212..195ff58d 100644
--- a/Interfaces/English.lproj/DataMigrationDialog.xib
+++ b/Interfaces/English.lproj/DataMigrationDialog.xib
@@ -574,8 +574,8 @@
</object>
<object class="NSTextField" id="186404366">
<reference key="NSNextResponder" ref="78582513"/>
- <int key="NSvFlags">290</int>
- <string key="NSFrame">{{88, 24}, {199, 14}}</string>
+ <int key="NSvFlags">294</int>
+ <string key="NSFrame">{{88, 24}, {105, 14}}</string>
<reference key="NSSuperview" ref="78582513"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="929441265">
@@ -991,7 +991,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA</bytes>
<bytes key="NSRGB">MC45Mjk0MTE4Mjg1IDAuOTI5NDExODI4NSAwLjkyOTQxMTgyODUAA</bytes>
</object>
<object class="NSCursor" key="NSCursor">
- <string key="NSHotSpot">{1, -1}</string>
+ <string key="NSHotSpot">{4, 4}</string>
<int key="NSCursorType">0</int>
</object>
<int key="NScvFlags">6</int>
@@ -1152,6 +1152,26 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA</bytes>
<reference key="NSTextColor" ref="263116164"/>
</object>
</object>
+ <object class="NSButton" id="425457435">
+ <reference key="NSNextResponder" ref="78582513"/>
+ <int key="NSvFlags">289</int>
+ <string key="NSFrame">{{192, 14}, {82, 32}}</string>
+ <reference key="NSSuperview" ref="78582513"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="485421130">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">134217728</int>
+ <string key="NSContents">Go Back</string>
+ <reference key="NSSupport" ref="388072550"/>
+ <reference key="NSControlView" ref="425457435"/>
+ <int key="NSButtonFlags">-2038284033</int>
+ <int key="NSButtonFlags2">134217857</int>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"></string>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
</object>
<string key="NSFrameSize">{465, 405}</string>
<reference key="NSSuperview"/>
@@ -1360,6 +1380,14 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA</bytes>
</object>
<int key="connectionID">156</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">goBackToFileChooser:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="425457435"/>
+ </object>
+ <int key="connectionID">159</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -1420,6 +1448,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA</bytes>
<reference ref="155260473"/>
<reference ref="42651750"/>
<reference ref="746818659"/>
+ <reference ref="425457435"/>
</object>
<reference key="parent" ref="420604405"/>
</object>
@@ -1891,6 +1920,20 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA</bytes>
<reference key="object" ref="950341880"/>
<reference key="parent" ref="221439252"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">157</int>
+ <reference key="object" ref="425457435"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="485421130"/>
+ </object>
+ <reference key="parent" ref="78582513"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">158</int>
+ <reference key="object" ref="485421130"/>
+ <reference key="parent" ref="425457435"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -1937,6 +1980,9 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA</bytes>
<string>15.IBAttributePlaceholdersKey</string>
<string>15.IBPluginDependency</string>
<string>15.ImportedFromIB2</string>
+ <string>157.IBAttributePlaceholdersKey</string>
+ <string>157.IBPluginDependency</string>
+ <string>158.IBPluginDependency</string>
<string>16.IBAttributePlaceholdersKey</string>
<string>16.IBPluginDependency</string>
<string>16.ImportedFromIB2</string>
@@ -2056,6 +2102,16 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA</bytes>
<string key="NS.key.0">ToolTip</string>
<object class="IBToolTipAttribute" key="NS.object.0">
<string key="name">ToolTip</string>
+ <reference key="object" ref="425457435"/>
+ <string key="toolTip">Go back to file chooser (⌥←)</string>
+ </object>
+ </object>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <object class="NSMutableDictionary">
+ <string key="NS.key.0">ToolTip</string>
+ <object class="IBToolTipAttribute" key="NS.object.0">
+ <string key="name">ToolTip</string>
<reference key="object" ref="920273776"/>
<string type="base64-UTF8" key="toolTip">KA/ijospA</string>
</object>
@@ -2163,7 +2219,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA</bytes>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">156</int>
+ <int key="maxID">159</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -2205,6 +2261,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA</bytes>
<string>changeImportMethod:</string>
<string>changeTableTarget:</string>
<string>closeSheet:</string>
+ <string>goBackToFileChooser:</string>
<string>stepRow:</string>
</object>
<object class="NSMutableArray" key="dict.values">
@@ -2216,6 +2273,7 @@ cyAKCQluZXcgcm93cyBSRVBMQUNFIElOVE8g4oCmA</bytes>
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
diff --git a/Source/SPFieldMapperController.h b/Source/SPFieldMapperController.h
index 4b9a3178..8a2caf15 100644
--- a/Source/SPFieldMapperController.h
+++ b/Source/SPFieldMapperController.h
@@ -92,6 +92,7 @@
- (IBAction)stepRow:(id)sender;
- (IBAction)addGlobalSourceVariable:(id)sender;
- (IBAction)closeSheet:(id)sender;
+- (IBAction)goBackToFileChooser:(id)sender;
// Others
- (void)matchHeaderNames;
diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m
index 42ac3b0d..7dc0a3eb 100644
--- a/Source/SPFieldMapperController.m
+++ b/Source/SPFieldMapperController.m
@@ -25,6 +25,7 @@
#import "SPFieldMapperController.h"
#import "SPTableData.h"
+#import "TableDump.h"
#import "TablesList.h"
#import "SPArrayAdditions.h"
#import "SPStringAdditions.h"
@@ -315,7 +316,13 @@
- (IBAction)addGlobalSourceVariable:(id)sender
{
+
+}
+- (IBAction)goBackToFileChooser:(id)sender
+{
+ [NSApp endSheet:[self window] returnCode:[sender tag]];
+ [theDelegate importFile];
}
#pragma mark -
@@ -494,14 +501,10 @@
else if ([[aTableColumn identifier] isEqualToString:@"import_value"]) {
if ([[aTableColumn dataCell] isKindOfClass:[NSPopUpButtonCell class]]) {
[(NSPopUpButtonCell *)[aTableColumn dataCell] removeAllItems];
+ [(NSPopUpButtonCell *)[aTableColumn dataCell] addItemsWithTitles:fieldMappingButtonOptions];
+ // Hide csv file column value if user doesn't want to import it
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"]) {
@@ -518,9 +521,10 @@
{
if ([[aTableColumn identifier] isEqualToString:@"import_value"]) {
[fieldMappingArray replaceObjectAtIndex:rowIndex withObject:anObject];
+ // If user changed the csv file column set the operator to doImport
+ [fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:doImport];
}
else if ([[aTableColumn identifier] isEqualToString:@"operator"]) {
- if([fieldMappingOperatorArray objectAtIndex:rowIndex] == anObject) return;
if([fieldMappingOperatorArray objectAtIndex:rowIndex] == doNotImport) {
[fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:anObject];
[fieldMappingArray replaceObjectAtIndex:rowIndex withObject:lastDisabledCSVFieldcolumn];
@@ -528,8 +532,9 @@
if(anObject == doNotImport) lastDisabledCSVFieldcolumn = [fieldMappingArray objectAtIndex:rowIndex];
[fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:anObject];
}
- [aTableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.01];
}
+ // Refresh table
+ [aTableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.01];
}
@end
diff --git a/Source/TableDump.h b/Source/TableDump.h
index 001b1778..3db8c908 100644
--- a/Source/TableDump.h
+++ b/Source/TableDump.h
@@ -108,6 +108,7 @@ typedef enum _SPExportModes {
NSArray *fieldMapperOperator;
NSString *selectedTableTarget;
NSString *selectedImportMethod;
+ NSString *lastFilename;
NSInteger fieldMapperSheetStatus;
NSUInteger exportMode;
diff --git a/Source/TableDump.m b/Source/TableDump.m
index 9e42e105..4854aad3 100644
--- a/Source/TableDump.m
+++ b/Source/TableDump.m
@@ -496,7 +496,7 @@
// Show openPanel
[openPanel beginSheetForDirectory:[prefs objectForKey:@"openPath"]
- file:nil
+ file:[lastFilename lastPathComponent]
modalForWindow:tableWindow
modalDelegate:self
didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:)
@@ -1089,8 +1089,16 @@
// Reset progress cancelled from any previous runs
progressCancelled = NO;
+ if(lastFilename) [lastFilename release]; lastFilename = nil;
+ lastFilename = [[NSString stringWithString:[sheet filename]] retain];
+
+ if(lastFilename == nil || ![lastFilename length]) {
+ NSBeep();
+ return;
+ }
+
// begin import process
- [NSThread detachNewThreadSelector:@selector(importBackgroundProcess:) toTarget:self withObject:[sheet filename]];
+ [NSThread detachNewThreadSelector:@selector(importBackgroundProcess:) toTarget:self withObject:lastFilename];
}
- (void)startSQLImportProcessWithFile:(NSString *)filename
@@ -2797,6 +2805,7 @@
fieldMappingImportArray = nil;
fieldMappingImportArrayIsPreview = NO;
prefs = nil;
+ lastFilename = nil;
return self;
}
@@ -2805,6 +2814,7 @@
{
[tables release];
if (fieldMappingImportArray) [fieldMappingImportArray release];
+ if (lastFilename) [lastFilename release];
if (prefs) [prefs release];
[super dealloc];