diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-09-02 12:21:00 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-09-02 12:21:00 +0000 |
commit | b66f9afbcd48b62d8adc3cfc5f27da099b129646 (patch) | |
tree | 0daf7965e82cc7b4cdc53e3f28312ce51dbc5473 | |
parent | 0bab4c7a36a409639ff9b419ef8a5e57f527e474 (diff) | |
download | sequelpro-b66f9afbcd48b62d8adc3cfc5f27da099b129646.tar.gz sequelpro-b66f9afbcd48b62d8adc3cfc5f27da099b129646.tar.bz2 sequelpro-b66f9afbcd48b62d8adc3cfc5f27da099b129646.zip |
• first preparations to support a CSV import into a new table (not yet executable)
- changed order of target tables: New Table, Refresh List, separator, list of all names
- cleaned code a bit
* removed check for available tables in SPDataImport, now if no table in db the CSV Field Mapper opens in "New Table" mode
-rw-r--r-- | Interfaces/English.lproj/DataMigrationDialog.xib | 559 | ||||
-rw-r--r-- | Source/SPDataImport.m | 22 | ||||
-rw-r--r-- | Source/SPFieldMapperController.h | 5 | ||||
-rw-r--r-- | Source/SPFieldMapperController.m | 273 |
4 files changed, 787 insertions, 72 deletions
diff --git a/Interfaces/English.lproj/DataMigrationDialog.xib b/Interfaces/English.lproj/DataMigrationDialog.xib index 668120a0..9306af15 100644 --- a/Interfaces/English.lproj/DataMigrationDialog.xib +++ b/Interfaces/English.lproj/DataMigrationDialog.xib @@ -12,7 +12,7 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="12"/> + <integer value="144"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -393,6 +393,7 @@ </object> <int key="NSResizingMask">3</int> <bool key="NSIsResizeable">YES</bool> + <bool key="NSIsEditable">YES</bool> <reference key="NSTableView" ref="678921094"/> </object> <object class="NSTableColumn" id="221439252"> @@ -409,7 +410,7 @@ <reference key="NSTextColor" ref="186205954"/> </object> <object class="NSTextFieldCell" key="NSDataCell" id="950341880"> - <int key="NSCellFlags">67239488</int> + <int key="NSCellFlags">337772096</int> <int key="NSCellFlags2">272761856</int> <string key="NSContents">Text</string> <reference key="NSSupport" ref="219022499"/> @@ -1389,6 +1390,44 @@ <int key="NSPeriodicInterval">75</int> </object> </object> + <object class="NSTextField" id="806234307"> + <reference key="NSNextResponder" ref="78582513"/> + <int key="NSvFlags">265</int> + <string key="NSFrame">{{375, 280}, {129, 19}}</string> + <reference key="NSSuperview" ref="78582513"/> + <bool key="NSEnabled">YES</bool> + <object class="NSTextFieldCell" key="NSCell" id="752604777"> + <int key="NSCellFlags">-1804468671</int> + <int key="NSCellFlags2">272761856</int> + <string key="NSContents"/> + <reference key="NSSupport" ref="26"/> + <reference key="NSControlView" ref="806234307"/> + <bool key="NSDrawsBackground">YES</bool> + <reference key="NSBackgroundColor" ref="105487286"/> + <object class="NSColor" key="NSTextColor"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">textColor</string> + <reference key="NSColor" ref="938074100"/> + </object> + </object> + </object> + <object class="NSTextField" id="426092195"> + <reference key="NSNextResponder" ref="78582513"/> + <int key="NSvFlags">265</int> + <string key="NSFrame">{{290, 283}, {80, 14}}</string> + <reference key="NSSuperview" ref="78582513"/> + <bool key="NSEnabled">YES</bool> + <object class="NSTextFieldCell" key="NSCell" id="696977787"> + <int key="NSCellFlags">68288064</int> + <int key="NSCellFlags2">71435264</int> + <string key="NSContents">Name:</string> + <reference key="NSSupport" ref="26"/> + <reference key="NSControlView" ref="426092195"/> + <reference key="NSBackgroundColor" ref="19028295"/> + <reference key="NSTextColor" ref="263116164"/> + </object> + </object> </object> <string key="NSFrameSize">{522, 348}</string> <reference key="NSSuperview"/> @@ -2300,6 +2339,30 @@ </object> <int key="connectionID">399</int> </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">newTableNameTextField</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="806234307"/> + </object> + <int key="connectionID">407</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">newTableNameLabel</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="426092195"/> + </object> + <int key="connectionID">408</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">delegate</string> + <reference key="source" ref="806234307"/> + <reference key="destination" ref="1001"/> + </object> + <int key="connectionID">409</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -2364,6 +2427,8 @@ <reference ref="892658687"/> <reference ref="219742831"/> <reference ref="317672858"/> + <reference ref="806234307"/> + <reference ref="426092195"/> </object> <reference key="parent" ref="420604405"/> </object> @@ -3229,6 +3294,34 @@ <reference key="object" ref="536255044"/> <reference key="parent" ref="221711496"/> </object> + <object class="IBObjectRecord"> + <int key="objectID">403</int> + <reference key="object" ref="806234307"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="752604777"/> + </object> + <reference key="parent" ref="78582513"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">404</int> + <reference key="object" ref="752604777"/> + <reference key="parent" ref="806234307"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">405</int> + <reference key="object" ref="426092195"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="696977787"/> + </object> + <reference key="parent" ref="78582513"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">406</int> + <reference key="object" ref="696977787"/> + <reference key="parent" ref="426092195"/> + </object> </object> </object> <object class="NSMutableDictionary" key="flattenedProperties"> @@ -3373,6 +3466,10 @@ <string>40.IBPluginDependency</string> <string>400.IBPluginDependency</string> <string>402.IBPluginDependency</string> + <string>403.IBPluginDependency</string> + <string>404.IBPluginDependency</string> + <string>405.IBPluginDependency</string> + <string>406.IBPluginDependency</string> <string>41.IBPluginDependency</string> <string>42.IBPluginDependency</string> <string>42.ImportedFromIB2</string> @@ -3404,9 +3501,9 @@ <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{51, 107}, {522, 348}}</string> + <string>{{827, 351}, {522, 348}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{51, 107}, {522, 348}}</string> + <string>{{827, 351}, {522, 348}}</string> <integer value="1"/> <string>{{387, 725}, {432, 282}}</string> <boolean value="NO"/> @@ -3602,7 +3699,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{611, 880}, {113, 4}}</string> + <string>{{1106, 645}, {215, 6}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -3630,6 +3727,10 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> @@ -3673,7 +3774,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">402</int> + <int key="maxID">409</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -4328,6 +4429,452 @@ </object> </object> </object> + <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.1+"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBPartialClassDescription"> + <string key="className">SPFieldMapperController</string> + <string key="superclassName">NSWindowController</string> + <object class="NSMutableDictionary" key="actions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>addGlobalSourceVariable:</string> + <string>addGlobalValue:</string> + <string>advancedCheckboxValidation:</string> + <string>changeFieldAlignment:</string> + <string>changeHasHeaderCheckbox:</string> + <string>changeImportMethod:</string> + <string>changeTableTarget:</string> + <string>closeGlobalValuesSheet:</string> + <string>closeSheet:</string> + <string>goBackToFileChooser:</string> + <string>insertNULLValue:</string> + <string>openAdvancedSheet:</string> + <string>removeGlobalValue:</string> + <string>stepRow:</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + </object> + </object> + <object class="NSMutableDictionary" key="actionInfosByName"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>addGlobalSourceVariable:</string> + <string>addGlobalValue:</string> + <string>advancedCheckboxValidation:</string> + <string>changeFieldAlignment:</string> + <string>changeHasHeaderCheckbox:</string> + <string>changeImportMethod:</string> + <string>changeTableTarget:</string> + <string>closeGlobalValuesSheet:</string> + <string>closeSheet:</string> + <string>goBackToFileChooser:</string> + <string>insertNULLValue:</string> + <string>openAdvancedSheet:</string> + <string>removeGlobalValue:</string> + <string>stepRow:</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBActionInfo"> + <string key="name">addGlobalSourceVariable:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">addGlobalValue:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">advancedCheckboxValidation:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">changeFieldAlignment:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">changeHasHeaderCheckbox:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">changeImportMethod:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">changeTableTarget:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">closeGlobalValuesSheet:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">closeSheet:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">goBackToFileChooser:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">insertNULLValue:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">openAdvancedSheet:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">removeGlobalValue:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">stepRow:</string> + <string key="candidateClassName">id</string> + </object> + </object> + </object> + <object class="NSMutableDictionary" key="outlets"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>addGlobalValueButton</string> + <string>addRemainingDataSwitch</string> + <string>advancedBox</string> + <string>advancedButton</string> + <string>advancedInsertView</string> + <string>advancedLabel</string> + <string>advancedReplaceView</string> + <string>advancedUpdateView</string> + <string>alignByPopup</string> + <string>alignByPopupLabel</string> + <string>customQueryInstance</string> + <string>delayedCheckBox</string> + <string>delayedReplaceCheckBox</string> + <string>fieldMapperTableScrollView</string> + <string>fieldMapperTableView</string> + <string>fieldMappingImportArray</string> + <string>fileSourcePath</string> + <string>globalValuesSheet</string> + <string>globalValuesTableView</string> + <string>highPriorityCheckBox</string> + <string>ignoreCheckBox</string> + <string>ignoreUpdateCheckBox</string> + <string>importButton</string> + <string>importFieldNamesHeaderSwitch</string> + <string>importMethodLabel</string> + <string>importMethodPopup</string> + <string>insertNULLValueButton</string> + <string>lowPriorityCheckBox</string> + <string>lowPriorityReplaceCheckBox</string> + <string>lowPriorityUpdateCheckBox</string> + <string>matchingNameMenuItem</string> + <string>newTableNameLabel</string> + <string>newTableNameTextField</string> + <string>onupdateCheckBox</string> + <string>onupdateTextView</string> + <string>recordCountLabel</string> + <string>removeGlobalValueButton</string> + <string>replaceAfterSavingCheckBox</string> + <string>rowDownButton</string> + <string>rowUpButton</string> + <string>skipexistingRowsCheckBox</string> + <string>tableTargetPopup</string> + <string>theDelegate</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>NSButton</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>NSPopUpButton</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>NSTableView</string> + <string>id</string> + <string>NSPathControl</string> + <string>id</string> + <string>NSTableView</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>NSPopUpButton</string> + <string>NSButton</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>NSMenuItem</string> + <string>NSTextField</string> + <string>NSTextField</string> + <string>id</string> + <string>SPTextView</string> + <string>id</string> + <string>NSButton</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>NSPopUpButton</string> + <string>id</string> + </object> + </object> + <object class="NSMutableDictionary" key="toOneOutletInfosByName"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>addGlobalValueButton</string> + <string>addRemainingDataSwitch</string> + <string>advancedBox</string> + <string>advancedButton</string> + <string>advancedInsertView</string> + <string>advancedLabel</string> + <string>advancedReplaceView</string> + <string>advancedUpdateView</string> + <string>alignByPopup</string> + <string>alignByPopupLabel</string> + <string>customQueryInstance</string> + <string>delayedCheckBox</string> + <string>delayedReplaceCheckBox</string> + <string>fieldMapperTableScrollView</string> + <string>fieldMapperTableView</string> + <string>fieldMappingImportArray</string> + <string>fileSourcePath</string> + <string>globalValuesSheet</string> + <string>globalValuesTableView</string> + <string>highPriorityCheckBox</string> + <string>ignoreCheckBox</string> + <string>ignoreUpdateCheckBox</string> + <string>importButton</string> + <string>importFieldNamesHeaderSwitch</string> + <string>importMethodLabel</string> + <string>importMethodPopup</string> + <string>insertNULLValueButton</string> + <string>lowPriorityCheckBox</string> + <string>lowPriorityReplaceCheckBox</string> + <string>lowPriorityUpdateCheckBox</string> + <string>matchingNameMenuItem</string> + <string>newTableNameLabel</string> + <string>newTableNameTextField</string> + <string>onupdateCheckBox</string> + <string>onupdateTextView</string> + <string>recordCountLabel</string> + <string>removeGlobalValueButton</string> + <string>replaceAfterSavingCheckBox</string> + <string>rowDownButton</string> + <string>rowUpButton</string> + <string>skipexistingRowsCheckBox</string> + <string>tableTargetPopup</string> + <string>theDelegate</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBToOneOutletInfo"> + <string key="name">addGlobalValueButton</string> + <string key="candidateClassName">NSButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">addRemainingDataSwitch</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">advancedBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">advancedButton</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">advancedInsertView</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">advancedLabel</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">advancedReplaceView</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">advancedUpdateView</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">alignByPopup</string> + <string key="candidateClassName">NSPopUpButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">alignByPopupLabel</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">customQueryInstance</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">delayedCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">delayedReplaceCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">fieldMapperTableScrollView</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">fieldMapperTableView</string> + <string key="candidateClassName">NSTableView</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">fieldMappingImportArray</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">fileSourcePath</string> + <string key="candidateClassName">NSPathControl</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">globalValuesSheet</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">globalValuesTableView</string> + <string key="candidateClassName">NSTableView</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">highPriorityCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">ignoreCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">ignoreUpdateCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">importButton</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">importFieldNamesHeaderSwitch</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">importMethodLabel</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">importMethodPopup</string> + <string key="candidateClassName">NSPopUpButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">insertNULLValueButton</string> + <string key="candidateClassName">NSButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">lowPriorityCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">lowPriorityReplaceCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">lowPriorityUpdateCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">matchingNameMenuItem</string> + <string key="candidateClassName">NSMenuItem</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">newTableNameLabel</string> + <string key="candidateClassName">NSTextField</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">newTableNameTextField</string> + <string key="candidateClassName">NSTextField</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">onupdateCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">onupdateTextView</string> + <string key="candidateClassName">SPTextView</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">recordCountLabel</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">removeGlobalValueButton</string> + <string key="candidateClassName">NSButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">replaceAfterSavingCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">rowDownButton</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">rowUpButton</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">skipexistingRowsCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">tableTargetPopup</string> + <string key="candidateClassName">NSPopUpButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">theDelegate</string> + <string key="candidateClassName">id</string> + </object> + </object> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBDocumentRelativeSource</string> + <string key="minorKey">../../Source/SPFieldMapperController.h</string> + </object> + </object> + </object> <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBPartialClassDescription"> diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m index 98129f19..c9b5664b 100644 --- a/Source/SPDataImport.m +++ b/Source/SPDataImport.m @@ -1123,17 +1123,17 @@ fieldMappingImportArrayIsPreview = dataIsPreviewData; // If there's no tables to select, error - if (![[tablesListInstance allTableNames] count]) { - [self closeAndStopProgressSheet]; - SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), - NSLocalizedString(@"OK", @"OK button"), - nil, nil, - [tableDocumentInstance parentWindow], self, - nil, nil, - NSLocalizedString(@"Can't import CSV data into a database without any tables!", @"error text when trying to import csv data, but we have no tables in the db") - ); - return FALSE; - } + // if (![[tablesListInstance allTableNames] count]) { + // [self closeAndStopProgressSheet]; + // SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), + // NSLocalizedString(@"OK", @"OK button"), + // nil, nil, + // [tableDocumentInstance parentWindow], self, + // nil, nil, + // NSLocalizedString(@"Can't import CSV data into a database without any tables!", @"error text when trying to import csv data, but we have no tables in the db") + // ); + // return FALSE; + // } // Set the import array if (fieldMappingImportArray) [fieldMappingImportArray release]; diff --git a/Source/SPFieldMapperController.h b/Source/SPFieldMapperController.h index 266986f4..15efd595 100644 --- a/Source/SPFieldMapperController.h +++ b/Source/SPFieldMapperController.h @@ -48,6 +48,9 @@ IBOutlet id advancedLabel; IBOutlet NSMenuItem *matchingNameMenuItem; + IBOutlet NSTextField *newTableNameTextField; + IBOutlet NSTextField *newTableNameLabel; + IBOutlet id globalValuesSheet; IBOutlet NSButton *addGlobalValueButton; IBOutlet NSButton *removeGlobalValueButton; @@ -75,6 +78,7 @@ id theDelegate; id customQueryInstance; id fieldMappingImportArray; + id tablesListInstance; NSInteger fieldMappingCurrentRow; NSMutableArray *fieldMappingArray; @@ -100,6 +104,7 @@ BOOL importFieldNamesHeader; BOOL showAdvancedView; BOOL targetTableHasPrimaryKey; + BOOL newTableMode; NSString *primaryKeyField; NSNumber *lastDisabledCSVFieldcolumn; diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index 14a9b7f1..1018ff4e 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -53,6 +53,7 @@ return nil; } theDelegate = managerDelegate; + fieldMappingTableColumnNames = [[NSMutableArray alloc] init]; fieldMappingTableDefaultValues = [[NSMutableArray alloc] init]; fieldMappingTableTypes = [[NSMutableArray alloc] init]; @@ -71,10 +72,14 @@ doImportString = @"―"; doNotImportString = @" "; isEqualString = @"="; + newTableMode = NO; prefs = [NSUserDefaults standardUserDefaults]; + + tablesListInstance = [theDelegate valueForKeyPath:@"tablesListInstance"]; + } - + return self; } @@ -95,22 +100,33 @@ windowMinWidth = [[self window] minSize].width; windowMinHeigth = [[self window] minSize].height; + [newTableNameTextField setHidden:YES]; + [newTableNameLabel setHidden:YES]; + // Init table target popup menu [tableTargetPopup removeAllItems]; - if([[theDelegate valueForKeyPath:@"tablesListInstance"] allTableNames]) { - [tableTargetPopup addItemsWithTitles:[[theDelegate valueForKeyPath:@"tablesListInstance"] allTableNames]]; - [[tableTargetPopup menu] addItem:[NSMenuItem separatorItem]]; - [tableTargetPopup addItemWithTitle:NSLocalizedString(@"Refresh List", @"refresh list menu item")]; - - // 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]]; + [tableTargetPopup addItemWithTitle:NSLocalizedString(@"New Table", @"new table menu item")]; + [tableTargetPopup addItemWithTitle:NSLocalizedString(@"Refresh List", @"refresh list menu item")]; + [[tableTargetPopup menu] addItem:[NSMenuItem separatorItem]]; + NSArray *allTableNames = [tablesListInstance allTableNames]; + if(allTableNames) { + [tableTargetPopup addItemsWithTitles:allTableNames]; + + // Select either the currently selected table, or the first item in the list, or if no table in db switch to "New Table" mode + if ([[theDelegate valueForKeyPath:@"tableDocumentInstance"] table] != nil + && ![[tablesListInstance tableName] isEqualToString:@""] + && [allTableNames containsObject:[tablesListInstance tableName]]) { + [tableTargetPopup selectItemWithTitle:[tablesListInstance tableName]]; } else { - [tableTargetPopup selectItemAtIndex:0]; + if([allTableNames count]) + [tableTargetPopup selectItemAtIndex:3]; + else + [tableTargetPopup selectItemAtIndex:0]; + [newTableNameTextField selectText:nil]; } } - + [importFieldNamesHeaderSwitch setState:importFieldNamesHeader]; [addRemainingDataSwitch setState:NO]; @@ -266,7 +282,7 @@ - (NSString*)importHeaderString { if([[importMethodPopup titleOfSelectedItem] isEqualToString:@"INSERT"]) { - return [NSString stringWithFormat:@"INSERT %@%@%@%@INTO ", + return [NSString stringWithFormat:@"INSERT %@%@%@%@INTO ", ([lowPriorityCheckBox state] == NSOnState) ? @"LOW_PRIORITY " : @"", ([delayedCheckBox state] == NSOnState) ? @"DELAYED " : @"", ([highPriorityCheckBox state] == NSOnState) ? @"HIGH_PRIORITY " : @"", @@ -274,13 +290,13 @@ ]; } else if([[importMethodPopup titleOfSelectedItem] isEqualToString:@"REPLACE"]) { - return [NSString stringWithFormat:@"REPLACE %@%@INTO ", + return [NSString stringWithFormat:@"REPLACE %@%@INTO ", ([lowPriorityReplaceCheckBox state] == NSOnState) ? @"LOW_PRIORITY " : @"", ([delayedReplaceCheckBox state] == NSOnState) ? @"DELAYED " : @"" ]; } else if([[importMethodPopup titleOfSelectedItem] isEqualToString:@"UPDATE"]) { - return [NSString stringWithFormat:@"UPDATE %@%@%@ SET ", + return [NSString stringWithFormat:@"UPDATE %@%@%@ SET ", ([lowPriorityUpdateCheckBox state] == NSOnState) ? @"LOW_PRIORITY " : @"", ([ignoreUpdateCheckBox state] == NSOnState) ? @"IGNORE " : @"", [[self selectedTableTarget] backtickQuotedString] @@ -313,19 +329,86 @@ - (IBAction)changeTableTarget:(id)sender { + NSArray *allTableNames = [tablesListInstance allTableNames]; + NSInteger i; + // Is Refresh List chosen? - if([tableTargetPopup selectedItem] == [tableTargetPopup lastItem]) { + if([tableTargetPopup selectedItem] == [tableTargetPopup itemAtIndex:1]) { [tableTargetPopup removeAllItems]; + [tableTargetPopup addItemWithTitle:NSLocalizedString(@"New Table", @"new table menu item")]; + [tableTargetPopup addItemWithTitle:NSLocalizedString(@"Refresh List", @"refresh list menu item")]; + [[tableTargetPopup menu] addItem:[NSMenuItem separatorItem]]; + // Update tables list - [[theDelegate valueForKeyPath:@"tablesListInstance"] updateTables:nil]; - if([[theDelegate valueForKeyPath:@"tablesListInstance"] allTableNames]) { - [tableTargetPopup addItemsWithTitles:[[theDelegate valueForKeyPath:@"tablesListInstance"] allTableNames]]; - [[tableTargetPopup menu] addItem:[NSMenuItem separatorItem]]; - [tableTargetPopup addItemWithTitle:NSLocalizedString(@"Refresh List", @"refresh list menu item")]; + [tablesListInstance updateTables:nil]; + if(allTableNames) { + [tableTargetPopup addItemsWithTitles:allTableNames]; } + + // Select either the currently selected table, or the first item in the list, or if no table in db switch to "New Table" mode + if ([[theDelegate valueForKeyPath:@"tableDocumentInstance"] table] != nil + && ![[tablesListInstance tableName] isEqualToString:@""] + && [allTableNames containsObject:[tablesListInstance tableName]]) { + [tableTargetPopup selectItemWithTitle:[tablesListInstance tableName]]; + } else { + if([allTableNames count]) + [tableTargetPopup selectItemAtIndex:3]; + else + [tableTargetPopup selectItemAtIndex:0]; + } + + return; + } - NSInteger i; + // New Table was chosen + else if([tableTargetPopup selectedItem] == [tableTargetPopup itemAtIndex:0]) { + + newTableMode = YES; + + [tableTargetPopup setHidden:YES]; + [newTableNameTextField setHidden:NO]; + [newTableNameLabel setHidden:NO]; + [newTableNameTextField selectText:nil]; + [fieldMappingTableColumnNames removeAllObjects]; + [fieldMappingTableDefaultValues removeAllObjects]; + [fieldMappingTableTypes removeAllObjects]; + if([importFieldNamesHeaderSwitch state] == NSOnState) { + for(id h in NSArrayObjectAtIndex(fieldMappingImportArray, 0)) { + [fieldMappingTableColumnNames addObject:h]; + [fieldMappingTableDefaultValues addObject:@""]; + [fieldMappingTableTypes addObject:@"varchar(255)"]; + } + } else { + i = 0; + for(id h in NSArrayObjectAtIndex(fieldMappingImportArray, 0)) { + [fieldMappingTableColumnNames addObject:[NSString stringWithFormat:@"col_%ld", i++]]; + [fieldMappingTableDefaultValues addObject:@""]; + [fieldMappingTableTypes addObject:@"varchar(255)"]; + } + } + + // Update the table view + NSInteger i; + fieldMappingCurrentRow = 0; + if (fieldMappingArray) [fieldMappingArray release], fieldMappingArray = nil; + [self setupFieldMappingArray]; + [rowDownButton setEnabled:NO]; + [rowUpButton setEnabled:([fieldMappingImportArray count] > 1)]; + [recordCountLabel setStringValue:[NSString stringWithFormat:@"%ld of %@%lu records", (long)(fieldMappingCurrentRow+1), fieldMappingImportArrayIsPreview?@"first ":@"", (unsigned long)[fieldMappingImportArray count]]]; + + [self updateFieldMappingButtonCell]; + [self updateFieldMappingOperatorOptions]; + + // Set all operators to doNotImport + [fieldMappingOperatorArray removeAllObjects]; + for(i=0; i < [fieldMappingTableColumnNames count]; i++) + [fieldMappingOperatorArray addObject:doImport]; + + [fieldMapperTableView reloadData]; + [self validateImportButton]; + return; + } // Remove all the current columns [fieldMappingTableColumnNames removeAllObjects]; @@ -338,7 +421,7 @@ NSDictionary *tableDetails = [selectedTableData informationForTable:[tableTargetPopup titleOfSelectedItem]]; targetTableHasPrimaryKey = NO; BOOL isReplacePossible = NO; - // NSLog(@"d %@", tableDetails); + if (tableDetails) { for (NSDictionary *column in [tableDetails objectForKey:@"columns"]) { [fieldMappingTableColumnNames addObject:[NSString stringWithString:[column objectForKey:@"name"]]]; @@ -531,11 +614,11 @@ fieldMappingCurrentRow++; } [self updateFieldMappingButtonCell]; - + [fieldMapperTableView reloadData]; - + [recordCountLabel setStringValue:[NSString stringWithFormat:NSLocalizedString(@"%ld of %@%lu records", @"%ld of %@%lu records"), (long)(fieldMappingCurrentRow+1), fieldMappingImportArrayIsPreview?@"first ":@"", (unsigned long)[fieldMappingImportArray count]]]; - + // enable/disable buttons [rowDownButton setEnabled:(fieldMappingCurrentRow != 0)]; [rowUpButton setEnabled:(fieldMappingCurrentRow != ([fieldMappingImportArray count]-1))]; @@ -544,6 +627,22 @@ - (IBAction)changeHasHeaderCheckbox:(id)sender { [matchingNameMenuItem setEnabled:([importFieldNamesHeaderSwitch state] == NSOnState)?YES:NO]; + + // In New Table mode reset new field name according to importFieldNamesHeaderSwitch's state + if(newTableMode) { + [fieldMappingTableColumnNames removeAllObjects]; + if([importFieldNamesHeaderSwitch state] == NSOnState) { + for(id h in NSArrayObjectAtIndex(fieldMappingImportArray, 0)) { + [fieldMappingTableColumnNames addObject:h]; + } + } else { + NSInteger i = 0; + for(id h in NSArrayObjectAtIndex(fieldMappingImportArray, 0)) { + [fieldMappingTableColumnNames addObject:[NSString stringWithFormat:@"col_%ld", i++]]; + } + } + [fieldMapperTableView reloadData]; + } } - (IBAction)goBackToFileChooser:(id)sender @@ -561,9 +660,9 @@ - (IBAction)addGlobalSourceVariable:(id)sender { - [NSApp beginSheet:globalValuesSheet - modalForWindow:[self window] - modalDelegate:self + [NSApp beginSheet:globalValuesSheet + modalForWindow:[self window] + modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:nil]; [self addGlobalValue:nil]; } @@ -616,7 +715,7 @@ // Ensure all changes are stored before ordering out [globalValuesTableView validateEditing]; - if ([globalValuesTableView numberOfSelectedRows] == 1) + if ([globalValuesTableView numberOfSelectedRows] == 1) [globalValuesSheet makeFirstResponder:globalValuesTableView]; // Replace the current map pair with the last selected global value @@ -668,7 +767,7 @@ [lowPriorityReplaceCheckBox setState:NO]; return; } - if(sender == skipexistingRowsCheckBox) { + if(sender == skipexistingRowsCheckBox) { if([skipexistingRowsCheckBox state] == NSOnState) { [delayedCheckBox setState:NO]; [delayedCheckBox setEnabled:NO]; @@ -713,7 +812,7 @@ [onupdateCheckBox setEnabled:YES]; } } - + if(sender == onupdateCheckBox && [onupdateCheckBox state] == NSOnState) { [onupdateTextView setBackgroundColor:[NSColor whiteColor]]; [onupdateTextView setEditable:YES]; @@ -840,13 +939,13 @@ if (!fieldMappingArray) { fieldMappingArray = [[NSMutableArray alloc] init]; for (i = 0; i < [fieldMappingTableColumnNames count]; i++) { - if (i < [NSArrayObjectAtIndex(fieldMappingImportArray, fieldMappingCurrentRow) count] + if (i < [NSArrayObjectAtIndex(fieldMappingImportArray, fieldMappingCurrentRow) count] && ![NSArrayObjectAtIndex(NSArrayObjectAtIndex(fieldMappingImportArray, fieldMappingCurrentRow), i) isKindOfClass:[NSNull class]]) { value = i; } else { value = 0; } - + [fieldMappingArray addObject:[NSNumber numberWithInteger:value]]; } } @@ -881,7 +980,7 @@ } [fieldMapperTableView reloadData]; - + } /* @@ -925,6 +1024,17 @@ - (void)validateImportButton { BOOL enableImportButton = YES; + + if(newTableMode) { + [importButton setTitle:@"Not Yet"]; + [importButton setEnabled:NO]; + return; + if(![tablesListInstance isTableNameValid:[newTableNameTextField stringValue] forType:SPTableTypeTable ignoringSelectedTable:NO]) { + [importButton setEnabled:NO]; + return; + } + } + if([[self selectedImportMethod] isEqualToString:@"UPDATE"]) { enableImportButton = NO; for(id op in fieldMappingOperatorArray) { @@ -934,7 +1044,9 @@ } } } + [importButton setEnabled:enableImportButton]; + } #pragma mark - @@ -958,7 +1070,7 @@ if(aTableView == fieldMapperTableView) { // A click at the operator column's header toggle all operators - if ([[aTableColumn identifier] isEqualToString:@"operator"] + if ([[aTableColumn identifier] isEqualToString:@"operator"] && [self numberOfRowsInTableView:aTableView] && [fieldMappingOperatorArray count] && [fieldMappingTableColumnNames count]) { @@ -971,7 +1083,7 @@ [fieldMappingOperatorArray addObject:globalValue]; [self validateImportButton]; [fieldMapperTableView reloadData]; - } + } } } @@ -988,7 +1100,7 @@ return [NSString stringWithFormat:@"%@: %@", NSLocalizedString(@"Global value", @"global value"), NSArrayObjectAtIndex(fieldMappingGlobalValues, [NSArrayObjectAtIndex(fieldMappingArray, rowIndex) integerValue])]; if(fieldMappingCurrentRow) - return [NSString stringWithFormat:@"%@: %@", + return [NSString stringWithFormat:@"%@: %@", [NSArrayObjectAtIndex(NSArrayObjectAtIndex(fieldMappingImportArray, 0), [NSArrayObjectAtIndex(fieldMappingArray, rowIndex) integerValue]) description], [NSArrayObjectAtIndex(NSArrayObjectAtIndex(fieldMappingImportArray, fieldMappingCurrentRow), [NSArrayObjectAtIndex(fieldMappingArray, rowIndex) integerValue]) description]]; else @@ -1025,26 +1137,42 @@ if(aTableView == fieldMapperTableView) { if ([[aTableColumn identifier] isEqualToString:@"target_field"]) { - if ([[aTableColumn dataCell] isKindOfClass:[NSPopUpButtonCell class]]) { - [(NSPopUpButton *)[aTableColumn dataCell] removeAllItems]; - [(NSPopUpButtonCell *)[aTableColumn dataCell] addItemWithTitle:[fieldMappingTableColumnNames objectAtIndex:rowIndex]]; + if(newTableMode) { + NSTextFieldCell *b = [[[NSTextFieldCell alloc] initTextCell:[fieldMappingTableColumnNames objectAtIndex:rowIndex]] autorelease]; + [b setEditable:YES]; + [b setFont:[NSFont systemFontOfSize:12]]; + [aTableColumn setDataCell:b]; + return b; + } else { + if ([[aTableColumn dataCell] isKindOfClass:[NSPopUpButtonCell class]]) { + [(NSPopUpButton *)[aTableColumn dataCell] removeAllItems]; + [(NSPopUpButtonCell *)[aTableColumn dataCell] addItemWithTitle:[fieldMappingTableColumnNames objectAtIndex:rowIndex]]; + } + return [fieldMappingTableColumnNames objectAtIndex:rowIndex]; } - 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 setWraps:NO]; - [b setFont:[NSFont systemFontOfSize:9]]; - [b setDelegate:self]; - return b; + if(newTableMode) { + NSTextFieldCell *b = [[[NSTextFieldCell alloc] initTextCell:[fieldMappingTableTypes objectAtIndex:rowIndex]] autorelease]; + [b setEditable:YES]; + [b setFont:[NSFont systemFontOfSize:12]]; + [aTableColumn setDataCell:b]; + return b; + } else { + NSTokenFieldCell *b = [[[NSTokenFieldCell alloc] initTextCell:[fieldMappingTableTypes objectAtIndex:rowIndex]] autorelease]; + [b setEditable:NO]; + [b setAlignment:NSLeftTextAlignment]; + [b setWraps:NO]; + [b setFont:[NSFont systemFontOfSize:9]]; + [b setDelegate:self]; + return b; + } } else if ([[aTableColumn identifier] isEqualToString:@"import_value"]) { if ([[aTableColumn dataCell] isKindOfClass:[NSPopUpButtonCell class]]) { - NSPopUpButtonCell *c = [aTableColumn dataCell]; + NSPopUpButtonCell *c = [aTableColumn dataCell]; NSMenu *m = [c menu]; [m setAutoenablesItems:NO]; [c removeAllItems]; @@ -1068,7 +1196,7 @@ return [NSNumber numberWithInteger:[c numberOfItems]-1]; } - } + } else if ([[aTableColumn identifier] isEqualToString:@"operator"]) { if ([[aTableColumn dataCell] isKindOfClass:[NSPopUpButtonCell class]]) { @@ -1076,10 +1204,10 @@ [(NSPopUpButtonCell *)[aTableColumn dataCell] addItemsWithTitles:fieldMappingOperatorOptions]; } return [fieldMappingOperatorArray objectAtIndex:rowIndex]; - } + } } - - + + else if(aTableView == globalValuesTableView) { if ([[aTableColumn identifier] isEqualToString:@"value_index"]) { return [NSString stringWithFormat:@"%ld.", numberOfImportColumns + rowIndex + 1]; @@ -1093,11 +1221,20 @@ return [fieldMappingGlobalValuesSQLMarked objectAtIndex:numberOfImportColumns + rowIndex]; } - - + + return nil; } +- (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex +{ + + if(!newTableMode) return NO; + + return YES; + +} + - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex { @@ -1156,6 +1293,18 @@ } + else if (newTableMode && [[aTableColumn identifier] isEqualToString:@"target_field"]) { + if([(NSString*)anObject length]) { + [fieldMappingTableColumnNames replaceObjectAtIndex:rowIndex withObject:anObject]; + } + } + + else if (newTableMode && [[aTableColumn identifier] isEqualToString:@"type"]) { + if([(NSString*)anObject length]) { + [fieldMappingTableTypes replaceObjectAtIndex:rowIndex withObject:anObject]; + } + } + else if ([[aTableColumn identifier] isEqualToString:@"operator"]) { if([fieldMappingOperatorArray objectAtIndex:rowIndex] == doNotImport) { [fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:anObject]; @@ -1188,4 +1337,18 @@ } +#pragma mark - +#pragma mark NSTextField delegates + +- (void)controlTextDidChange:(NSNotification *)notification +{ + + id object = [notification object]; + + if (object == newTableNameTextField) { + [self validateImportButton]; + } + +} + @end |