aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2014-12-26 20:37:39 +0100
committerMax <post@wickenrode.com>2014-12-26 20:37:39 +0100
commitc7362cc8c6d3c02d8e9b5f5a31735bb3fbbf0b02 (patch)
tree3c22d79aa7532f80999d77236ccca0970c44c3ab
parent03d11e5d82a7c2a0c5db624020632a7d10b5a13a (diff)
downloadsequelpro-c7362cc8c6d3c02d8e9b5f5a31735bb3fbbf0b02.tar.gz
sequelpro-c7362cc8c6d3c02d8e9b5f5a31735bb3fbbf0b02.tar.bz2
sequelpro-c7362cc8c6d3c02d8e9b5f5a31735bb3fbbf0b02.zip
************** IMPORTANT: SEE BELOW **************
This change should fix the "slow CSV import dialog" issue on 10.10 (details below). To accomplish that, some major changes had to be made to the CSV import code. PLEASE VERIFY THE CORRECTNESS OF THE NEXT FEW CSV IMPORTS YOU DO! * Renamed some variables for better search visibility * Changed some instances where NSNumbers were being compared using "==" instead of "isEqual…" (does not work with object literals!) * The CSV import dialog would recreate the popup menus on *every* call to "tableView:objectValueFor…". However Instruments suggests that [NSMenu removeAllItems] and [NSMenu addItemsWithTitles:] are **really** expensive, esp. when called multiple times per second (e.g. when scrolling in the table view). This commit moves the popup menu setup into its own method and only calls it when the data actually changes. * The 'destination table column' was for some reason a NSPopupButtonCell which only ever had one item and sometimes got changed to a NSTextFieldCell in code. I didn't see any need to keep the popup cell and replaced it with a simple text cell.
-rw-r--r--Interfaces/English.lproj/DataMigrationDialog.xib220
-rw-r--r--Source/SPFieldMapperController.h9
-rw-r--r--Source/SPFieldMapperController.m234
3 files changed, 268 insertions, 195 deletions
diff --git a/Interfaces/English.lproj/DataMigrationDialog.xib b/Interfaces/English.lproj/DataMigrationDialog.xib
index c6afb178..740dedcb 100644
--- a/Interfaces/English.lproj/DataMigrationDialog.xib
+++ b/Interfaces/English.lproj/DataMigrationDialog.xib
@@ -78,11 +78,13 @@
<string key="NSFrame">{{1, 1}, {656, 0}}</string>
<reference key="NSSuperview" ref="412235166"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="834757891"/>
</object>
</array>
<string key="NSFrame">{{-12, 53}, {658, 2}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="196610401"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67108864</int>
@@ -131,6 +133,7 @@
<string key="NSFrame">{{14, 12}, {604, 17}}</string>
<reference key="NSSuperview" ref="297364507"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="863317681"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="922239869">
<int key="NSCellFlags">68157504</int>
@@ -170,6 +173,7 @@
<string key="NSFrame">{{512, 51}, {226, 32}}</string>
<reference key="NSSuperview" ref="297364507"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="1052916804"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="712024433">
<int key="NSCellFlags">67108864</int>
@@ -192,6 +196,7 @@
<string key="NSFrame">{{664, 1}, {226, 32}}</string>
<reference key="NSSuperview" ref="297364507"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="1021918763"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="240320447">
<int key="NSCellFlags">67108864</int>
@@ -214,6 +219,7 @@
<string key="NSFrame">{{668, 1}, {226, 32}}</string>
<reference key="NSSuperview" ref="297364507"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="697948389"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="760384053">
<int key="NSCellFlags">67108864</int>
@@ -234,11 +240,13 @@
<string key="NSFrame">{{1, 1}, {634, 39}}</string>
<reference key="NSSuperview" ref="617902336"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="436297995"/>
</object>
</array>
<string key="NSFrame">{{-1, 308}, {636, 41}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="297364507"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67108864</int>
@@ -275,6 +283,7 @@
<string key="NSFrameSize">{634, 126}</string>
<reference key="NSSuperview" ref="929465390"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="59350381"/>
<bool key="NSEnabled">YES</bool>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
<bool key="NSControlAllowsExpansionToolTips">YES</bool>
@@ -284,6 +293,7 @@
<string key="NSFrameSize">{634, 17}</string>
<reference key="NSSuperview" ref="622202999"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="929465390"/>
<reference key="NSTableView" ref="678921094"/>
</object>
<object class="_NSCornerView" key="NSCornerView" id="1064192022">
@@ -292,6 +302,7 @@
<string key="NSFrame">{{-22, 0}, {12, 17}}</string>
<reference key="NSSuperview" ref="495172082"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="622202999"/>
</object>
<array class="NSMutableArray" key="NSTableColumns">
<object class="NSTableColumn" id="790992768">
@@ -326,32 +337,32 @@
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">400</int>
<int key="NSPeriodicInterval">75</int>
- <object class="NSMenuItem" key="NSMenuItem" id="922650264">
- <reference key="NSMenu" ref="318206101"/>
- <string key="NSTitle">Pop Up</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <int key="NSState">1</int>
- <object class="NSCustomResource" key="NSOnImage" id="884724275">
- <string key="NSClassName">NSImage</string>
- <string key="NSResourceName">NSMenuCheckmark</string>
- </object>
- <object class="NSCustomResource" key="NSMixedImage" id="1071040955">
- <string key="NSClassName">NSImage</string>
- <string key="NSResourceName">NSMenuMixedState</string>
- </object>
- <string key="NSAction">_popUpItemAction:</string>
- <reference key="NSTarget" ref="130736119"/>
- </object>
+ <nil key="NSMenuItem"/>
<bool key="NSMenuItemRespectAlignment">YES</bool>
<object class="NSMenu" key="NSMenu" id="318206101">
<string key="NSTitle">OtherViews</string>
<array class="NSMutableArray" key="NSMenuItems">
- <reference ref="922650264"/>
+ <object class="NSMenuItem" id="922650264">
+ <reference key="NSMenu" ref="318206101"/>
+ <string key="NSTitle">Pop Up</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <object class="NSCustomResource" key="NSOnImage" id="884724275">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">NSMenuCheckmark</string>
+ </object>
+ <object class="NSCustomResource" key="NSMixedImage" id="1071040955">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">NSMenuMixedState</string>
+ </object>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="130736119"/>
+ </object>
</array>
<reference key="NSMenuFont" ref="26"/>
</object>
+ <int key="NSSelectedIndex">-1</int>
<int key="NSPreferredEdge">3</int>
<bool key="NSUsesItemFromMenu">YES</bool>
<bool key="NSAltersState">YES</bool>
@@ -429,42 +440,15 @@
</object>
<reference key="NSTextColor" ref="186205954"/>
</object>
- <object class="NSPopUpButtonCell" key="NSDataCell" id="201096656">
- <int key="NSCellFlags">-2076180416</int>
- <int key="NSCellFlags2">133120</int>
+ <object class="NSTextFieldCell" key="NSDataCell" id="852180472">
+ <int key="NSCellFlags">337641537</int>
+ <int key="NSCellFlags2">272762880</int>
+ <string key="NSContents">Text</string>
<reference key="NSSupport" ref="26"/>
+ <string key="NSCellIdentifier">_NS:9</string>
<reference key="NSControlView" ref="678921094"/>
- <int key="NSButtonFlags">100679680</int>
- <int key="NSButtonFlags2">129</int>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">400</int>
- <int key="NSPeriodicInterval">75</int>
- <object class="NSMenuItem" key="NSMenuItem" id="683769208">
- <reference key="NSMenu" ref="920630540"/>
- <bool key="NSIsHidden">YES</bool>
- <string key="NSTitle">Pop Up</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <int key="NSState">1</int>
- <reference key="NSOnImage" ref="884724275"/>
- <reference key="NSMixedImage" ref="1071040955"/>
- <string key="NSAction">_popUpItemAction:</string>
- <reference key="NSTarget" ref="201096656"/>
- </object>
- <bool key="NSMenuItemRespectAlignment">YES</bool>
- <object class="NSMenu" key="NSMenu" id="920630540">
- <string key="NSTitle">OtherViews</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <reference ref="683769208"/>
- </array>
- <reference key="NSMenuFont" ref="26"/>
- </object>
- <bool key="NSPullDown">YES</bool>
- <int key="NSPreferredEdge">3</int>
- <bool key="NSUsesItemFromMenu">YES</bool>
- <bool key="NSAltersState">YES</bool>
+ <reference key="NSBackgroundColor" ref="19028295"/>
+ <reference key="NSTextColor" ref="263116164"/>
</object>
<int key="NSResizingMask">3</int>
<bool key="NSIsResizeable">YES</bool>
@@ -570,6 +554,7 @@
<string key="NSFrame">{{413, 18}, {11, 140}}</string>
<reference key="NSSuperview" ref="495172082"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="397227507"/>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
<int key="NSsFlags">256</int>
<reference key="NSTarget" ref="495172082"/>
@@ -582,6 +567,7 @@
<string key="NSFrame">{{-100, -100}, {227, 11}}</string>
<reference key="NSSuperview" ref="495172082"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="1064192022"/>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
<int key="NSsFlags">257</int>
<reference key="NSTarget" ref="495172082"/>
@@ -594,7 +580,7 @@
<string key="NSFrame">{{-1, 129}, {636, 144}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="929465390"/>
+ <reference key="NSNextKeyView" ref="1043729154"/>
<int key="NSsFlags">133650</int>
<reference key="NSVScroller" ref="59350381"/>
<reference key="NSHScroller" ref="1043729154"/>
@@ -612,6 +598,7 @@
<string key="NSFrame">{{415, 12}, {102, 32}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="341819846"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="977848648">
<int key="NSCellFlags">67108864</int>
@@ -664,6 +651,7 @@
<string key="NSFrame">{{20, 19}, {32, 24}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="116285743"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="87458302">
<int key="NSCellFlags">603979776</int>
@@ -690,6 +678,7 @@
<string key="NSFrame">{{51, 19}, {32, 24}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="186404366"/>
<int key="NSTag">1</int>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="809975974">
@@ -718,6 +707,7 @@
<string key="NSFrame">{{88, 23}, {195, 14}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="219742831"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="929441265">
<int key="NSCellFlags">67108928</int>
@@ -737,6 +727,7 @@
<string key="NSFrame">{{361, 278}, {200, 22}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="426092195"/>
<bool key="NSEnabled">YES</bool>
<object class="NSPopUpButtonCell" key="NSCell" id="107647973">
<int key="NSCellFlags">-2076180416</int>
@@ -769,6 +760,7 @@
<string key="NSFrame">{{484, 97}, {133, 22}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="42651750"/>
<bool key="NSEnabled">YES</bool>
<object class="NSPopUpButtonCell" key="NSCell" id="1033308908">
<int key="NSCellFlags">-2076180416</int>
@@ -834,6 +826,7 @@
<string key="NSFrame">{{302, 102}, {180, 14}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="599385609"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="869323357">
<int key="NSCellFlags">68157504</int>
@@ -857,6 +850,7 @@
<string key="NSFrame">{{5, 280}, {316, 20}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="549705971"/>
<bool key="NSEnabled">YES</bool>
<object class="NSPathCell" key="NSCell" id="183652084">
<int key="NSCellFlags">69206081</int>
@@ -879,6 +873,7 @@
<string key="NSFrame">{{17, 100}, {275, 18}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="228203205"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="413696615">
<int key="NSCellFlags">-2080374784</int>
@@ -908,6 +903,7 @@
<string key="NSFrame">{{484, 73}, {133, 22}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="412235166"/>
<bool key="NSEnabled">YES</bool>
<object class="NSPopUpButtonCell" key="NSCell" id="940205369">
<int key="NSCellFlags">-2076180416</int>
@@ -991,6 +987,7 @@
<string key="NSFrame">{{302, 79}, {180, 14}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="573115956"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="498123343">
<int key="NSCellFlags">68157504</int>
@@ -1010,6 +1007,7 @@
<string key="NSFrame">{{326, 12}, {82, 32}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="920273776"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="538595338">
<int key="NSCellFlags">67108864</int>
@@ -1032,6 +1030,7 @@
<string key="NSFrame">{{11, 56}, {29, 26}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="317672858"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="1001034034">
<int key="NSCellFlags">67108864</int>
@@ -1059,6 +1058,7 @@
<string key="NSFrame">{{17, 8}, {100, 18}}</string>
<reference key="NSSuperview" ref="892658687"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="367476938"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="385836359">
<int key="NSCellFlags">67108864</int>
@@ -1083,6 +1083,7 @@
<string key="NSFrame">{{132, 8}, {80, 18}}</string>
<reference key="NSSuperview" ref="892658687"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="148795893"/>
<int key="NSTag">1</int>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="767775548">
@@ -1106,6 +1107,7 @@
<string key="NSFrame">{{200, 20}, {230, 44}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="799122111"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSCustomView" id="219742831">
@@ -1118,6 +1120,7 @@
<string key="NSFrame">{{227, 62}, {335, 18}}</string>
<reference key="NSSuperview" ref="219742831"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="952580067"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="843921917">
<int key="NSCellFlags">-2080374784</int>
@@ -1169,6 +1172,7 @@
<string key="NSFrameSize">{400, 37}</string>
<reference key="NSSuperview" ref="396898918"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="24215372"/>
<object class="NSTextContainer" key="NSTextContainer" id="510363477">
<object class="NSLayoutManager" key="NSLayoutManager">
<object class="NSTextStorage" key="NSTextStorage">
@@ -1257,6 +1261,7 @@
<string key="NSFrame">{{386, 1}, {15, 37}}</string>
<reference key="NSSuperview" ref="952580067"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="471578497"/>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
<int key="NSsFlags">512</int>
<reference key="NSTarget" ref="952580067"/>
@@ -1270,6 +1275,7 @@
<string key="NSFrame">{{-100, -100}, {87, 15}}</string>
<reference key="NSSuperview" ref="952580067"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="396898918"/>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
<int key="NSsFlags">513</int>
<reference key="NSTarget" ref="952580067"/>
@@ -1281,7 +1287,7 @@
<string key="NSFrame">{{20, 20}, {402, 39}}</string>
<reference key="NSSuperview" ref="219742831"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="396898918"/>
+ <reference key="NSNextKeyView" ref="475133483"/>
<int key="NSsFlags">133650</int>
<reference key="NSVScroller" ref="24215372"/>
<reference key="NSHScroller" ref="475133483"/>
@@ -1296,6 +1302,7 @@
<string key="NSFrame">{{227, 85}, {104, 18}}</string>
<reference key="NSSuperview" ref="219742831"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="403613444"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="776859395">
<int key="NSCellFlags">67108864</int>
@@ -1320,6 +1327,7 @@
<string key="NSFrame">{{17, 85}, {100, 18}}</string>
<reference key="NSSuperview" ref="219742831"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="1014387480"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="666818493">
<int key="NSCellFlags">67108864</int>
@@ -1344,6 +1352,7 @@
<string key="NSFrame">{{17, 62}, {181, 18}}</string>
<reference key="NSSuperview" ref="219742831"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="80724644"/>
<int key="NSTag">2</int>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="265447544">
@@ -1369,6 +1378,7 @@
<string key="NSFrame">{{137, 85}, {80, 18}}</string>
<reference key="NSSuperview" ref="219742831"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="16766984"/>
<int key="NSTag">1</int>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="548754049">
@@ -1394,6 +1404,7 @@
<string key="NSFrame">{{354, 85}, {70, 18}}</string>
<reference key="NSSuperview" ref="219742831"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="630547726"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="115350738">
<int key="NSCellFlags">67108864</int>
@@ -1416,6 +1427,7 @@
<string key="NSFrame">{{93, -57}, {442, 121}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="796449267"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSCustomView" id="471578497">
@@ -1428,6 +1440,7 @@
<string key="NSFrame">{{212, 8}, {335, 18}}</string>
<reference key="NSSuperview" ref="471578497"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="892658687"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="450486129">
<int key="NSCellFlags">67108864</int>
@@ -1452,6 +1465,7 @@
<string key="NSFrame">{{17, 8}, {100, 18}}</string>
<reference key="NSSuperview" ref="471578497"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="446881673"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="162288118">
<int key="NSCellFlags">67108864</int>
@@ -1476,6 +1490,7 @@
<string key="NSFrame">{{132, 8}, {70, 18}}</string>
<reference key="NSSuperview" ref="471578497"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="346675130"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="591185810">
<int key="NSCellFlags">67108864</int>
@@ -1498,6 +1513,7 @@
<string key="NSFrame">{{110, 20}, {390, 44}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="388473976"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSButton" id="317672858">
@@ -1506,6 +1522,7 @@
<string key="NSFrame">{{34, 58}, {58, 23}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="155260473"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="365850666">
<int key="NSCellFlags">-2080374784</int>
@@ -1528,6 +1545,7 @@
<string key="NSFrame">{{487, 280}, {106, 19}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="720243489"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="752604777">
<int key="NSCellFlags">-1804599231</int>
@@ -1553,6 +1571,7 @@
<string key="NSFrame">{{402, 283}, {80, 14}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="806234307"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="696977787">
<int key="NSCellFlags">68157504</int>
@@ -1572,6 +1591,7 @@
<string key="NSFrame">{{599, 280}, {20, 20}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="495172082"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="544229418">
<int key="NSCellFlags">67108864</int>
@@ -1598,6 +1618,7 @@
<string key="NSFrame">{{566, 281}, {61, 17}}</string>
<reference key="NSSuperview" ref="78582513"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="584318360"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="1019413032">
<int key="NSCellFlags">-2080374784</int>
@@ -1618,8 +1639,9 @@
<string key="NSFrameSize">{634, 348}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="617902336"/>
</object>
- <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
+ <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
<string key="NSMinSize">{634, 370}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<string key="NSFrameAutosaveName">SPCSVFieldMappingSheet</string>
@@ -2031,7 +2053,7 @@
</array>
<string key="NSFrameSize">{311, 210}</string>
</object>
- <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
+ <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
<string key="NSMinSize">{311, 208}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<string key="NSFrameAutosaveName"/>
@@ -2339,7 +2361,7 @@
</array>
<string key="NSFrameSize">{269, 120}</string>
</object>
- <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
+ <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
<string key="NSMinSize">{269, 142}</string>
<string key="NSMaxSize">{269, 142}</string>
<bool key="NSWindowIsRestorable">YES</bool>
@@ -3071,6 +3093,14 @@
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
+ <reference key="source" ref="318206101"/>
+ <reference key="destination" ref="1001"/>
+ </object>
+ <string key="id">9Jp-DU-vql</string>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">delegate</string>
<reference key="source" ref="280523396"/>
<reference key="destination" ref="1001"/>
</object>
@@ -4156,7 +4186,7 @@
<string key="id">48</string>
<reference key="object" ref="185178480"/>
<array class="NSMutableArray" key="children">
- <reference ref="201096656"/>
+ <reference ref="852180472"/>
</array>
<reference key="parent" ref="678921094"/>
</object>
@@ -4174,27 +4204,6 @@
<reference key="parent" ref="221439252"/>
</object>
<object class="IBObjectRecord">
- <string key="id">92</string>
- <reference key="object" ref="201096656"/>
- <array class="NSMutableArray" key="children">
- <reference ref="920630540"/>
- </array>
- <reference key="parent" ref="185178480"/>
- </object>
- <object class="IBObjectRecord">
- <string key="id">93</string>
- <reference key="object" ref="920630540"/>
- <array class="NSMutableArray" key="children">
- <reference ref="683769208"/>
- </array>
- <reference key="parent" ref="201096656"/>
- </object>
- <object class="IBObjectRecord">
- <string key="id">94</string>
- <reference key="object" ref="683769208"/>
- <reference key="parent" ref="920630540"/>
- </object>
- <object class="IBObjectRecord">
<string key="id">89</string>
<reference key="object" ref="130736119"/>
<array class="NSMutableArray" key="children">
@@ -4290,6 +4299,11 @@
<reference key="object" ref="249839159"/>
<reference key="parent" ref="952580067"/>
</object>
+ <object class="IBObjectRecord">
+ <string key="id">1SY-mK-knt</string>
+ <reference key="object" ref="852180472"/>
+ <reference key="parent" ref="185178480"/>
+ </object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
@@ -4405,6 +4419,7 @@
<string key="19.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="190.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="191.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="1SY-mK-knt.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableDictionary" key="20.IBAttributePlaceholdersKey">
<string key="NS.key.0">ToolTip</string>
<object class="IBToolTipAttribute" key="NS.object.0">
@@ -4600,9 +4615,6 @@
<string key="89.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="90.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="91.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="92.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="93.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="94.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="95.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="96.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="97.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -7445,6 +7457,7 @@
<string key="duplicateButton">id</string>
<string key="fieldField">NSPopUpButton</string>
<string key="filterButton">id</string>
+ <string key="filterControllerInstance">SPTableContentFilterController</string>
<string key="filterTableClearButton">NSButton</string>
<string key="filterTableDistinctCheckbox">NSButton</string>
<string key="filterTableFilterButton">NSButton</string>
@@ -7524,6 +7537,10 @@
<string key="name">filterButton</string>
<string key="candidateClassName">id</string>
</object>
+ <object class="IBToOneOutletInfo" key="filterControllerInstance">
+ <string key="name">filterControllerInstance</string>
+ <string key="candidateClassName">SPTableContentFilterController</string>
+ </object>
<object class="IBToOneOutletInfo" key="filterTableClearButton">
<string key="name">filterTableClearButton</string>
<string key="candidateClassName">NSButton</string>
@@ -7775,6 +7792,43 @@
</object>
</object>
<object class="IBPartialClassDescription">
+ <string key="className">SPTableContentFilterController</string>
+ <string key="superclassName">NSObject</string>
+ <dictionary class="NSMutableDictionary" key="outlets">
+ <string key="contentSplitView">SPSplitView</string>
+ <string key="filterRuleEditor">NSRuleEditor</string>
+ <string key="tableDataInstance">SPTableData</string>
+ <string key="tableDocumentInstance">SPDatabaseDocument</string>
+ <string key="tablesListInstance">SPTablesList</string>
+ </dictionary>
+ <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
+ <object class="IBToOneOutletInfo" key="contentSplitView">
+ <string key="name">contentSplitView</string>
+ <string key="candidateClassName">SPSplitView</string>
+ </object>
+ <object class="IBToOneOutletInfo" key="filterRuleEditor">
+ <string key="name">filterRuleEditor</string>
+ <string key="candidateClassName">NSRuleEditor</string>
+ </object>
+ <object class="IBToOneOutletInfo" key="tableDataInstance">
+ <string key="name">tableDataInstance</string>
+ <string key="candidateClassName">SPTableData</string>
+ </object>
+ <object class="IBToOneOutletInfo" key="tableDocumentInstance">
+ <string key="name">tableDocumentInstance</string>
+ <string key="candidateClassName">SPDatabaseDocument</string>
+ </object>
+ <object class="IBToOneOutletInfo" key="tablesListInstance">
+ <string key="name">tablesListInstance</string>
+ <string key="candidateClassName">SPTablesList</string>
+ </object>
+ </dictionary>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">../Source/SPTableContentFilterController.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">SPTableData</string>
<string key="superclassName">NSObject</string>
<dictionary class="NSMutableDictionary" key="outlets">
diff --git a/Source/SPFieldMapperController.h b/Source/SPFieldMapperController.h
index a12adcb8..76b65c49 100644
--- a/Source/SPFieldMapperController.h
+++ b/Source/SPFieldMapperController.h
@@ -33,7 +33,7 @@
@class SPTablesList;
@class SPMySQLConnection;
-@interface SPFieldMapperController : NSWindowController <NSTokenFieldCellDelegate>
+@interface SPFieldMapperController : NSWindowController <NSTokenFieldCellDelegate, NSMenuDelegate>
{
IBOutlet SPTableView *fieldMapperTableView;
IBOutlet NSScrollView *fieldMapperTableScrollView;
@@ -110,9 +110,9 @@
NSMutableArray *fieldMappingTableDefaultValues;
NSMutableArray *defaultFieldTypesForComboBox;
- NSNumber *doImport;
- NSNumber *doNotImport;
- NSNumber *isEqual;
+ NSNumber *doImportKey;
+ NSNumber *doNotImportKey;
+ NSNumber *isEqualKey;
NSString *doImportString;
NSString *doNotImportString;
NSString *isEqualString;
@@ -135,6 +135,7 @@
NSUInteger windowMinHeigth;
NSInteger numberOfImportColumns;
NSInteger fieldMappingCurrentRow;
+ NSInteger firstDefaultItemOffset;
BOOL fieldMappingImportArrayIsPreview;
BOOL importFieldNamesHeader;
diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m
index a79c8a40..2fcf4c9e 100644
--- a/Source/SPFieldMapperController.m
+++ b/Source/SPFieldMapperController.m
@@ -53,6 +53,10 @@ static NSString *SPTableViewSqlColumnID = @"sql";
static NSUInteger SPSourceColumnTypeText = 0;
static NSUInteger SPSourceColumnTypeInteger = 1;
+@interface SPFieldMapperController (Private)
+- (void)_setupFieldMappingPopUpMenus;
+@end
+
@implementation SPFieldMapperController
@synthesize sourcePath;
@@ -85,9 +89,9 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
lastDisabledCSVFieldcolumn = @0;
- doImport = @0;
- doNotImport = @1;
- isEqual = @2;
+ doImportKey = @0;
+ doNotImportKey = @1;
+ isEqualKey = @2;
doImportString = @"―";
doNotImportString = @" ";
isEqualString = @"=";
@@ -215,20 +219,20 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
- (void)dealloc
{
- if (mySQLConnection) [mySQLConnection release];
- if (sourcePath) [sourcePath release];
- if (fieldMappingTableColumnNames) [fieldMappingTableColumnNames release];
- if (defaultFieldTypesForComboBox) [defaultFieldTypesForComboBox release];
- if (fieldMappingTableTypes) [fieldMappingTableTypes release];
- if (fieldMappingArray) [fieldMappingArray release];
- if (fieldMappingButtonOptions) [fieldMappingButtonOptions release];
- if (fieldMappingOperatorOptions) [fieldMappingOperatorOptions release];
- if (fieldMappingOperatorArray) [fieldMappingOperatorArray release];
- if (fieldMappingGlobalValues) [fieldMappingGlobalValues release];
- if (fieldMappingGlobalValuesSQLMarked) [fieldMappingGlobalValuesSQLMarked release];
- if (fieldMappingTableDefaultValues) [fieldMappingTableDefaultValues release];
- if (primaryKeyFields) [primaryKeyFields release];
- if (toBeEditedRowIndexes) [toBeEditedRowIndexes release];
+ if (mySQLConnection) [mySQLConnection release], mySQLConnection = nil;
+ if (sourcePath) [sourcePath release], sourcePath = nil;
+ if (fieldMappingTableColumnNames) [fieldMappingTableColumnNames release], fieldMappingTableColumnNames = nil;
+ if (defaultFieldTypesForComboBox) [defaultFieldTypesForComboBox release], defaultFieldTypesForComboBox = nil;
+ if (fieldMappingTableTypes) [fieldMappingTableTypes release], fieldMappingTableTypes = nil;
+ if (fieldMappingArray) [fieldMappingArray release], fieldMappingArray = nil;
+ if (fieldMappingButtonOptions) [fieldMappingButtonOptions release], fieldMappingButtonOptions = nil;
+ if (fieldMappingOperatorOptions) [fieldMappingOperatorOptions release], fieldMappingOperatorOptions = nil;
+ if (fieldMappingOperatorArray) [fieldMappingOperatorArray release], fieldMappingOperatorArray = nil;
+ if (fieldMappingGlobalValues) [fieldMappingGlobalValues release], fieldMappingGlobalValues = nil;
+ if (fieldMappingGlobalValuesSQLMarked) [fieldMappingGlobalValuesSQLMarked release], fieldMappingGlobalValuesSQLMarked = nil;
+ if (fieldMappingTableDefaultValues) [fieldMappingTableDefaultValues release], fieldMappingTableDefaultValues = nil;
+ if (primaryKeyFields) [primaryKeyFields release], primaryKeyFields = nil;
+ if (toBeEditedRowIndexes) [toBeEditedRowIndexes release], toBeEditedRowIndexes = nil;
[super dealloc];
}
@@ -309,7 +313,7 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
{
NSInteger i = 0;
for(id item in fieldMappingArray) {
- if([item intValue] >= numberOfImportColumns && NSArrayObjectAtIndex(fieldMappingOperatorArray, i) != doNotImport)
+ if([item intValue] >= numberOfImportColumns && ![doNotImportKey isEqualToNumber:NSArrayObjectAtIndex(fieldMappingOperatorArray, i)])
return YES;
i++;
}
@@ -455,7 +459,7 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
for(columnIndex = 0; columnIndex < numberOfColumns; columnIndex++) {
// Skip fields which aren't marked as imported
- if ([fieldMappingOperatorArray objectAtIndex:columnIndex] != doImport) {
+ if (![doImportKey isEqualToNumber:[fieldMappingOperatorArray objectAtIndex:columnIndex]]) {
continue;
}
@@ -610,16 +614,16 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
[self updateFieldMappingButtonCell];
[self updateFieldMappingOperatorOptions];
- // Set all operators to doNotImport
+ // Set all operators to doNotImportKey
[fieldMappingOperatorArray removeAllObjects];
for(i=0; i < [fieldMappingTableColumnNames count]; i++)
- [fieldMappingOperatorArray addObject:doNotImport];
+ [fieldMappingOperatorArray addObject:doNotImportKey];
// Set the first n operators to doImport
if([fieldMappingImportArray count]) {
NSUInteger possibleImports = ([NSArrayObjectAtIndex(fieldMappingImportArray, 0) count] > [fieldMappingTableColumnNames count]) ? [fieldMappingTableColumnNames count] : [NSArrayObjectAtIndex(fieldMappingImportArray, 0) count];
for(i=0; i < possibleImports; i++)
- [fieldMappingOperatorArray replaceObjectAtIndex:i withObject:doImport];
+ [fieldMappingOperatorArray replaceObjectAtIndex:i withObject:doImportKey];
}
// Disable Import button if no fields are available
@@ -638,6 +642,7 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
[self updateFieldNameAlignment];
+ [self _setupFieldMappingPopUpMenus];
[fieldMapperTableView reloadData];
}
@@ -686,12 +691,12 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
[advancedBox setHidden:YES];
}
- // If operator is set to = for UPDATE method replace it by doNotImport
+ // If operator is set to = for UPDATE method replace it by doNotImportKey
if(![[importMethodPopup titleOfSelectedItem] isEqualToString:@"UPDATE"]) {
[advancedButton setEnabled:YES];
for(i=0; i<[fieldMappingTableColumnNames count]; i++) {
- if([fieldMappingOperatorArray objectAtIndex:i] == isEqual) {
- [fieldMappingOperatorArray replaceObjectAtIndex:i withObject:doNotImport];
+ if([isEqualKey isEqualToNumber:[fieldMappingOperatorArray objectAtIndex:i]]) {
+ [fieldMappingOperatorArray replaceObjectAtIndex:i withObject:doNotImportKey];
}
}
} else {
@@ -701,6 +706,8 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
[self validateImportButton];
[self updateFieldMappingOperatorOptions];
+
+ [self _setupFieldMappingPopUpMenus];
[fieldMapperTableView reloadData];
}
@@ -715,23 +722,23 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
if(possibleImports < 1) return;
- // Set all operators to doNotImport
+ // Set all operators to doNotImportKey
[fieldMappingOperatorArray removeAllObjects];
for(i=0; i < [fieldMappingTableColumnNames count]; i++)
- [fieldMappingOperatorArray addObject:doNotImport];
+ [fieldMappingOperatorArray addObject:doNotImportKey];
switch([[alignByPopup selectedItem] tag]) {
case 0: // file order
for(j=0; j<possibleImports; j++) {
[fieldMappingArray replaceObjectAtIndex:j withObject:[NSNumber numberWithInteger:j]];
- [fieldMappingOperatorArray replaceObjectAtIndex:j withObject:doImport];
+ [fieldMappingOperatorArray replaceObjectAtIndex:j withObject:doImportKey];
}
break;
case 1: // reversed file order
possibleImports--;
for(j=possibleImports; j>=0; j--) {
[fieldMappingArray replaceObjectAtIndex:possibleImports-j withObject:[NSNumber numberWithInteger:j]];
- [fieldMappingOperatorArray replaceObjectAtIndex:possibleImports-j withObject:doImport];
+ [fieldMappingOperatorArray replaceObjectAtIndex:possibleImports - j withObject:doImportKey];
}
break;
case 2: // try to align header and table target field names via Levenshtein distance
@@ -914,11 +921,12 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
[self updateFieldMappingButtonCell];
[self updateFieldMappingOperatorOptions];
- // Set all operators to doNotImport
+ // Set all operators to doNotImportKey
[fieldMappingOperatorArray removeAllObjects];
for (i=0; i < [fieldMappingTableColumnNames count]; i++)
- [fieldMappingOperatorArray addObject:doImport];
+ [fieldMappingOperatorArray addObject:doImportKey];
+ [self _setupFieldMappingPopUpMenus];
[fieldMapperTableView reloadData];
[self validateImportButton];
}
@@ -929,7 +937,7 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
- (IBAction)addNewColumn:(id)sender
{
- [fieldMappingOperatorArray addObject:doNotImport];
+ [fieldMappingOperatorArray addObject:doNotImportKey];
[fieldMappingTableColumnNames addObject:NSLocalizedString(@"New Column Name", @"new column name placeholder string")];
[fieldMappingTableTypes addObject:@"VARCHAR(255)"];
[fieldMappingTableDefaultValues addObject:@""];
@@ -939,6 +947,7 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
[fieldMappingArray addObject:[NSNumber numberWithInteger:newIndex]];
[toBeEditedRowIndexes addIndex:newIndex];
+ [self _setupFieldMappingPopUpMenus];
[fieldMapperTableView reloadData];
[fieldMapperTableView editColumn:2 row:newIndex withEvent:nil select:YES];
@@ -977,6 +986,7 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
currentIndex = [toBeEditedRowIndexes indexGreaterThanIndex:currentIndex];
}
+ [self _setupFieldMappingPopUpMenus];
[fieldMapperTableView reloadData];
}
@@ -1175,9 +1185,9 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
[fieldMappingArray replaceObjectAtIndex:[fieldMapperTableView selectedRow] withObject:[NSNumber numberWithInteger:[globalValuesTableView selectedRow]+numberOfImportColumns]];
- // Set corresponding operator to doImport if not set to isEqual
- if([fieldMappingOperatorArray objectAtIndex:[fieldMapperTableView selectedRow]] != isEqual)
- [fieldMappingOperatorArray replaceObjectAtIndex:[fieldMapperTableView selectedRow] withObject:doImport];
+ // Set corresponding operator to doImport if not set to isEqualKey
+ if(![isEqualKey isEqualToNumber:[fieldMappingOperatorArray objectAtIndex:[fieldMapperTableView selectedRow]]])
+ [fieldMappingOperatorArray replaceObjectAtIndex:[fieldMapperTableView selectedRow] withObject:doImportKey];
[fieldMapperTableView reloadData];
@@ -1444,7 +1454,7 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
// Set best match
[fieldMappingArray replaceObjectAtIndex:match.location withObject:[NSNumber numberWithInteger:match.length]];
- [fieldMappingOperatorArray replaceObjectAtIndex:match.location withObject:doImport];
+ [fieldMappingOperatorArray replaceObjectAtIndex:match.location withObject:doImportKey];
// Remember matched pair
[matchedTable addObject:[m objectForKey:@"table"]];
@@ -1508,6 +1518,7 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
[fieldMappingButtonOptions addObject:[NSString stringWithFormat:@"%li. %@", (long)i+1, NSArrayObjectAtIndex(fieldMappingGlobalValues, i)]];
}
+ [self _setupFieldMappingPopUpMenus];
[fieldMapperTableView reloadData];
}
@@ -1562,7 +1573,7 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
return;
}
for (NSUInteger i = 0; i < [fieldMappingTableColumnNames count]; i++) {
- if (![[fieldMappingTableColumnNames objectAtIndex:i] length] && [fieldMappingOperatorArray objectAtIndex:i] == doImport) {
+ if (![[fieldMappingTableColumnNames objectAtIndex:i] length] && [doImportKey isEqualToNumber:[fieldMappingOperatorArray objectAtIndex:i]]) {
[importButton setEnabled:NO];
return;
}
@@ -1578,7 +1589,7 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
if ([[self selectedImportMethod] isEqualToString:@"UPDATE"]) {
enableImportButton = NO;
for(id op in fieldMappingOperatorArray) {
- if(op == isEqual) {
+ if([isEqualKey isEqualToNumber:op]) {
enableImportButton = YES;
break;
}
@@ -1654,9 +1665,9 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
&& [fieldMappingOperatorArray count]
&& [fieldMappingTableColumnNames count]) {
NSUInteger i;
- NSNumber *globalValue = doImport;
- if([fieldMappingOperatorArray objectAtIndex:0] == doImport)
- globalValue = doNotImport;
+ NSNumber *globalValue = doImportKey;
+ if([doImportKey isEqualToNumber:[fieldMappingOperatorArray objectAtIndex:0]])
+ globalValue = doNotImportKey;
[fieldMappingOperatorArray removeAllObjects];
for(i=0; i < [fieldMappingTableColumnNames count]; i++)
[fieldMappingOperatorArray addObject:globalValue];
@@ -1671,7 +1682,7 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
if(aTableView == fieldMapperTableView) {
- if ([fieldMappingOperatorArray objectAtIndex:rowIndex] == doNotImport) return [NSString stringWithFormat:@"DEFAULT: %@", [fieldMappingTableDefaultValues objectAtIndex:rowIndex]];
+ if ([doNotImportKey isEqual:[fieldMappingOperatorArray objectAtIndex:rowIndex]]) return [NSString stringWithFormat:@"DEFAULT: %@", [fieldMappingTableDefaultValues objectAtIndex:rowIndex]];
if([[aTableColumn identifier] isEqualToString:SPTableViewImportValueColumnID] && [importFieldNamesHeaderSwitch state] == NSOnState) {
@@ -1695,11 +1706,11 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
}
else if([[aTableColumn identifier] isEqualToString:SPTableViewOperatorColumnID]) {
- if([aCell objectValue] == doImport)
+ if([doImportKey isEqual:[aCell objectValue]])
return NSLocalizedString(@"Import field", @"import field operator tooltip");
- else if([aCell objectValue] == doNotImport)
+ else if([doNotImportKey isEqual:[aCell objectValue]])
return NSLocalizedString(@"Ignore field", @"ignore field label");
- else if([aCell objectValue] == isEqual)
+ else if([isEqualKey isEqual:[aCell objectValue]])
return NSLocalizedString(@"Do UPDATE where field contents match", @"do update operator tooltip");
else
return @"";
@@ -1715,32 +1726,64 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
return @"";
}
+- (void)menuNeedsUpdate:(NSMenu *)aMenu
+{
+ // Note: matching aMenu with "==" will most likely not work, as NSTableView copies it.
+ // This technique is based on: http://www.corbinstreehouse.com/blog/2005/07/dynamically-populating-an-nspopupbuttoncell-in-an-nstableview/
+
+ NSInteger rowIndex = [fieldMapperTableView selectedRow];
+ if(rowIndex < 0)
+ return;
+
+ NSInteger rowIndexInMenu = firstDefaultItemOffset + rowIndex;
+ for (NSInteger i = firstDefaultItemOffset; i < [aMenu numberOfItems]; i++) {
+ [[aMenu itemAtIndex:i] setHidden:(i != rowIndexInMenu)];
+ }
+}
+
+- (void)_setupFieldMappingPopUpMenus
+{
+ NSPopUpButtonCell *c = [[fieldMapperTableView tableColumnWithIdentifier:SPTableViewImportValueColumnID] dataCell];
+ NSMenu *m = [c menu];
+ [m setAutoenablesItems:NO];
+ [c removeAllItems];
+ [c addItemsWithTitles:fieldMappingButtonOptions];
+
+ [m addItem:[NSMenuItem separatorItem]];
+
+ [c addItemWithTitle:NSLocalizedString(@"Ignore Field", @"ignore field label")];
+ [c addItemWithTitle:NSLocalizedString(@"Ignore all Fields", @"ignore all fields menu item")];
+ [c addItemWithTitle:NSLocalizedString(@"Import all Fields", @"import all fields menu item")];
+ if([[self selectedImportMethod] isEqualToString:@"UPDATE"])
+ [c addItemWithTitle:NSLocalizedString(@"Match Field", @"match field menu item")];
+
+ [m addItem:[NSMenuItem separatorItem]];
+
+ NSMenuItem *menuItem = [m addItemWithTitle:NSLocalizedString(@"Add Value or Expression…", @"add global value or expression menu item") action:@selector(addGlobalSourceVariable:) keyEquivalent:@"g"];
+ [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
+
+ //create all menu items for the "DEFAULT" rows. We will use menuNeedsUpdate: to hide all items that are not needed.
+ //This works because NSTableView will copy the menu before showing it, so menuNeedsUpdate: will work on a disposable copy
+ //while the full menu is never shown (but it's items are displayed in the table view)
+ firstDefaultItemOffset = [m numberOfItems];
+ for (id item in fieldMappingTableDefaultValues) {
+ NSString *label = [NSString stringWithFormat:NSLocalizedString(@"Default: %@",@"import : csv field mapping : field default value"), item];
+ NSMenuItem *defaultItem = [m addItemWithTitle:label action:NULL keyEquivalent:@""];
+ [defaultItem setEnabled:NO];
+ }
+
+ NSPopUpButtonCell *optsCell = [[fieldMapperTableView tableColumnWithIdentifier:SPTableViewOperatorColumnID] dataCell];
+ [optsCell removeAllItems];
+ [optsCell addItemsWithTitles:fieldMappingOperatorOptions];
+}
+
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
if(aTableView == fieldMapperTableView) {
if ([[aTableColumn identifier] isEqualToString:SPTableViewTargetFieldColumnID]) {
- if([toBeEditedRowIndexes containsIndex:rowIndex]) {
- NSTextFieldCell *b = [[[NSTextFieldCell alloc] initTextCell:[fieldMappingTableColumnNames objectAtIndex:rowIndex]] autorelease];
- [b setEditable:YES];
- [b setFont:[NSFont systemFontOfSize:12]];
- [aTableColumn setDataCell:b];
- return b;
- }
- 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:SPTableViewTypeColumnID]) {
@@ -1765,45 +1808,20 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
else if ([[aTableColumn identifier] isEqualToString:SPTableViewImportValueColumnID]) {
- // Check if all global value was deleted, if so set assigned field as doNotImport
+ // Check if all global value was deleted, if so set assigned field as doNotImportKey
if([[fieldMappingArray objectAtIndex:rowIndex] unsignedIntegerValue] >= [fieldMappingButtonOptions count]) {
- [fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:doNotImport];
+ [fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:doNotImportKey];
}
- if ([[aTableColumn dataCell] isKindOfClass:[NSPopUpButtonCell class]]) {
-
- NSPopUpButtonCell *c = [aTableColumn dataCell];
- NSMenu *m = [c menu];
- [m setAutoenablesItems:NO];
- [c removeAllItems];
- [c addItemsWithTitles:fieldMappingButtonOptions];
- [m addItem:[NSMenuItem separatorItem]];
- [c addItemWithTitle:NSLocalizedString(@"Ignore Field", @"ignore field label")];
- [c addItemWithTitle:NSLocalizedString(@"Ignore all Fields", @"ignore all fields menu item")];
- [c addItemWithTitle:NSLocalizedString(@"Import all Fields", @"import all fields menu item")];
- if([[self selectedImportMethod] isEqualToString:@"UPDATE"])
- [c addItemWithTitle:NSLocalizedString(@"Match Field", @"match field menu item")];
- [m addItem:[NSMenuItem separatorItem]];
- NSMenuItem *menuItem = [m addItemWithTitle:NSLocalizedString(@"Add Value or Expression…", @"add global value or expression menu item") action:@selector(addGlobalSourceVariable:) keyEquivalent:@"g"];
- [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
- [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 if not
- // UPDATE was chosen otherwise hide it.
- if([fieldMappingOperatorArray objectAtIndex:rowIndex] != doNotImport)
- return [fieldMappingArray objectAtIndex:rowIndex];
- else if(![[self selectedImportMethod] isEqualToString:@"UPDATE"])
- return [NSNumber numberWithInteger:[c numberOfItems]-1];
-
- }
+ // If user doesn't want to import it show its DEFAULT value if not
+ // UPDATE was chosen otherwise hide it.
+ if(![doNotImportKey isEqualToNumber:[fieldMappingOperatorArray objectAtIndex:rowIndex]])
+ return [fieldMappingArray objectAtIndex:rowIndex];
+ else if(![[self selectedImportMethod] isEqualToString:@"UPDATE"])
+ return [NSNumber numberWithInteger:firstDefaultItemOffset+rowIndex];
}
else if ([[aTableColumn identifier] isEqualToString:SPTableViewOperatorColumnID]) {
- if ([[aTableColumn dataCell] isKindOfClass:[NSPopUpButtonCell class]]) {
- [(NSPopUpButtonCell *)[aTableColumn dataCell] removeAllItems];
- [(NSPopUpButtonCell *)[aTableColumn dataCell] addItemsWithTitles:fieldMappingOperatorOptions];
- }
return [fieldMappingOperatorArray objectAtIndex:rowIndex];
}
}
@@ -1845,16 +1863,16 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
if(aTableView == fieldMapperTableView) {
if ([[aTableColumn identifier] isEqualToString:SPTableViewImportValueColumnID]) {
if([anObject integerValue] > (NSInteger)[fieldMappingButtonOptions count]) {
- // Ignore field - set operator to doNotImport
+ // Ignore field - set operator to doNotImportKey
if([anObject integerValue] == (NSInteger)[fieldMappingButtonOptions count]+1) {
lastDisabledCSVFieldcolumn = [fieldMappingArray objectAtIndex:rowIndex];
- [fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:doNotImport];
+ [fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:doNotImportKey];
[aTableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.0];
}
- // Ignore all field - set all operator to doNotImport
+ // Ignore all field - set all operator to doNotImportKey
else if([anObject integerValue] == (NSInteger)[fieldMappingButtonOptions count]+2) {
NSUInteger i;
- NSNumber *globalValue = doNotImport;
+ NSNumber *globalValue = doNotImportKey;
[fieldMappingOperatorArray removeAllObjects];
for(i=0; i < [fieldMappingTableColumnNames count]; i++)
[fieldMappingOperatorArray addObject:globalValue];
@@ -1863,14 +1881,14 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
// Import all field - set all operator to doImport
else if([anObject integerValue] == (NSInteger)[fieldMappingButtonOptions count]+3) {
NSUInteger i;
- NSNumber *globalValue = doImport;
+ NSNumber *globalValue = doImportKey;
[fieldMappingOperatorArray removeAllObjects];
for(i=0; i < [fieldMappingTableColumnNames count]; i++)
[fieldMappingOperatorArray addObject:globalValue];
[aTableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.0];
}
else if([[self selectedImportMethod] isEqualToString:@"UPDATE"] && [anObject integerValue] == (NSInteger)[fieldMappingButtonOptions count]+4) {
- [fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:isEqual];
+ [fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:isEqualKey];
[aTableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.0];
}
// Add global value
@@ -1890,8 +1908,8 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
[fieldMappingArray replaceObjectAtIndex:rowIndex withObject:anObject];
// If user _changed_ the csv file column set the operator to doImport if not set to =
- if([(NSNumber*)anObject integerValue] > -1 && NSArrayObjectAtIndex(fieldMappingOperatorArray, rowIndex) != isEqual)
- [fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:doImport];
+ if([(NSNumber*)anObject integerValue] > -1 && ![isEqualKey isEqualToNumber:NSArrayObjectAtIndex(fieldMappingOperatorArray, rowIndex)])
+ [fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:doImportKey];
[self validateImportButton];
@@ -1918,11 +1936,11 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
}
else if ([[aTableColumn identifier] isEqualToString:SPTableViewOperatorColumnID]) {
- if([fieldMappingOperatorArray objectAtIndex:rowIndex] == doNotImport) {
+ if([doNotImportKey isEqualToNumber:[fieldMappingOperatorArray objectAtIndex:rowIndex]]) {
[fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:anObject];
[fieldMappingArray replaceObjectAtIndex:rowIndex withObject:lastDisabledCSVFieldcolumn];
} else {
- if(anObject == doNotImport) lastDisabledCSVFieldcolumn = [fieldMappingArray objectAtIndex:rowIndex];
+ if([doNotImportKey isEqual:anObject]) lastDisabledCSVFieldcolumn = [fieldMappingArray objectAtIndex:rowIndex];
[fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:anObject];
}
[self validateImportButton];