diff options
-rw-r--r-- | Interfaces/English.lproj/ExportDialog.xib | 267 | ||||
-rw-r--r-- | Source/SPBundleEditorController.m | 2 | ||||
-rw-r--r-- | Source/SPConstants.h | 10 | ||||
-rw-r--r-- | Source/SPConstants.m | 1 | ||||
-rw-r--r-- | Source/SPExportController.h | 8 | ||||
-rw-r--r-- | Source/SPExportController.m | 73 | ||||
-rw-r--r-- | Source/SPExportControllerDelegate.m | 18 | ||||
-rw-r--r-- | Source/SPExportFilenameUtilities.h | 1 | ||||
-rw-r--r-- | Source/SPExportFilenameUtilities.m | 12 | ||||
-rw-r--r-- | Source/SPExportSettingsPersistence.h | 20 | ||||
-rw-r--r-- | Source/SPExportSettingsPersistence.m | 427 |
11 files changed, 746 insertions, 93 deletions
diff --git a/Interfaces/English.lproj/ExportDialog.xib b/Interfaces/English.lproj/ExportDialog.xib index e7148f29..7080c27e 100644 --- a/Interfaces/English.lproj/ExportDialog.xib +++ b/Interfaces/English.lproj/ExportDialog.xib @@ -839,6 +839,82 @@ <nil key="NSNextResponder"/> <int key="NSvFlags">268</int> <array class="NSMutableArray" key="NSSubviews"> + <object class="NSPopUpButton" id="745374830"> + <reference key="NSNextResponder" ref="1039688935"/> + <int key="NSvFlags">265</int> + <string key="NSFrame">{{674, 347}, {41, 22}}</string> + <reference key="NSSuperview" ref="1039688935"/> + <reference key="NSNextKeyView" ref="585337816"/> + <string key="NSReuseIdentifierKey">_NS:9</string> + <bool key="NSEnabled">YES</bool> + <object class="NSPopUpButtonCell" key="NSCell" id="949231914"> + <int key="NSCellFlags">71303232</int> + <int key="NSCellFlags2">133120</int> + <reference key="NSSupport" ref="26"/> + <string key="NSCellIdentifier">_NS:9</string> + <reference key="NSControlView" ref="745374830"/> + <int key="NSButtonFlags">109199360</int> + <int key="NSButtonFlags2">129</int> + <object class="NSFont" key="NSAlternateImage"> + <string key="NSName">.LucidaGrandeUI</string> + <double key="NSSize">11</double> + <int key="NSfFlags">16</int> + </object> + <string key="NSAlternateContents"/> + <string key="NSKeyEquivalent"/> + <int key="NSPeriodicDelay">400</int> + <int key="NSPeriodicInterval">75</int> + <object class="NSMenuItem" key="NSMenuItem" id="630979950"> + <reference key="NSMenu" ref="136150039"/> + <bool key="NSIsHidden">YES</bool> + <string key="NSTitle">S</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <int key="NSState">1</int> + <reference key="NSOnImage" ref="626013002"/> + <reference key="NSMixedImage" ref="428837307"/> + <string key="NSAction">_popUpItemAction:</string> + <reference key="NSTarget" ref="949231914"/> + </object> + <bool key="NSMenuItemRespectAlignment">YES</bool> + <object class="NSMenu" key="NSMenu" id="136150039"> + <string key="NSTitle"/> + <array class="NSMutableArray" key="NSMenuItems"> + <reference ref="630979950"/> + <object class="NSMenuItem" id="821214266"> + <reference key="NSMenu" ref="136150039"/> + <string key="NSTitle">Apply saved settings…</string> + <string key="NSKeyEquiv">o</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="626013002"/> + <reference key="NSMixedImage" ref="428837307"/> + <string key="NSAction">_popUpItemAction:</string> + <reference key="NSTarget" ref="949231914"/> + </object> + <object class="NSMenuItem" id="1043233379"> + <reference key="NSMenu" ref="136150039"/> + <string key="NSTitle">Save current settings…</string> + <string key="NSKeyEquiv">s</string> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="626013002"/> + <reference key="NSMixedImage" ref="428837307"/> + <string key="NSAction">_popUpItemAction:</string> + <reference key="NSTarget" ref="949231914"/> + </object> + </array> + </object> + <int key="NSSelectedIndex">-1</int> + <bool key="NSPullDown">YES</bool> + <int key="NSPreferredEdge">1</int> + <bool key="NSUsesItemFromMenu">YES</bool> + <bool key="NSAltersState">YES</bool> + <int key="NSArrowPosition">2</int> + </object> + <bool key="NSAllowsLogicalLayoutDirection">NO</bool> + </object> <object class="NSBox" id="414783283"> <reference key="NSNextResponder" ref="1039688935"/> <int key="NSvFlags">34</int> @@ -860,6 +936,7 @@ </set> <string key="NSFrameSize">{413, 22}</string> <reference key="NSSuperview" ref="627515769"/> + <reference key="NSNextKeyView" ref="465113538"/> <bool key="NSEnabled">YES</bool> <object class="NSImageCell" key="NSCell" id="653271187"> <int key="NSCellFlags">134217728</int> @@ -881,6 +958,7 @@ <int key="NSvFlags">292</int> <string key="NSFrame">{{-1, -1}, {32, 25}}</string> <reference key="NSSuperview" ref="627515769"/> + <reference key="NSNextKeyView" ref="843467514"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="904794169"> <int key="NSCellFlags">67108864</int> @@ -906,6 +984,7 @@ <int key="NSvFlags">289</int> <string key="NSFrame">{{381, -2}, {32, 25}}</string> <reference key="NSSuperview" ref="627515769"/> + <reference key="NSNextKeyView" ref="683006936"/> <int key="NSTag">1</int> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="87312096"> @@ -932,6 +1011,7 @@ <int key="NSvFlags">289</int> <string key="NSFrame">{{350, -2}, {32, 25}}</string> <reference key="NSSuperview" ref="627515769"/> + <reference key="NSNextKeyView" ref="534662798"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="944500450"> <int key="NSCellFlags">67108864</int> @@ -955,10 +1035,12 @@ </array> <string key="NSFrame">{{1, 1}, {412, 21}}</string> <reference key="NSSuperview" ref="414783283"/> + <reference key="NSNextKeyView" ref="638088233"/> </object> </array> <string key="NSFrame">{{21, 20}, {414, 23}}</string> <reference key="NSSuperview" ref="1039688935"/> + <reference key="NSNextKeyView" ref="627515769"/> <string key="NSOffsets">{0, 0}</string> <object class="NSTextFieldCell" key="NSTitleCell"> <int key="NSCellFlags">67108864</int> @@ -987,6 +1069,7 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{17, 285}, {207, 22}}</string> <reference key="NSSuperview" ref="1039688935"/> + <reference key="NSNextKeyView" ref="238794017"/> <bool key="NSEnabled">YES</bool> <object class="NSPopUpButtonCell" key="NSCell" id="176341375"> <int key="NSCellFlags">-2076180416</int> @@ -999,9 +1082,9 @@ <string key="NSKeyEquivalent"/> <int key="NSPeriodicDelay">400</int> <int key="NSPeriodicInterval">75</int> - <object class="NSMenuItem" key="NSMenuItem" id="713988214"> + <object class="NSMenuItem" key="NSMenuItem" id="564853714"> <reference key="NSMenu" ref="516760020"/> - <string key="NSTitle">Tables</string> + <string key="NSTitle">Filtered Results</string> <string key="NSKeyEquiv"/> <int key="NSKeyEquivModMask">1048576</int> <int key="NSMnemonicLoc">2147483647</int> @@ -1015,9 +1098,10 @@ <object class="NSMenu" key="NSMenu" id="516760020"> <string key="NSTitle">OtherViews</string> <array class="NSMutableArray" key="NSMenuItems"> - <object class="NSMenuItem" id="564853714"> + <reference ref="564853714"/> + <object class="NSMenuItem" id="1029240286"> <reference key="NSMenu" ref="516760020"/> - <string key="NSTitle">Filtered Results</string> + <string key="NSTitle">Query Results</string> <string key="NSKeyEquiv"/> <int key="NSKeyEquivModMask">1048576</int> <int key="NSMnemonicLoc">2147483647</int> @@ -1026,9 +1110,9 @@ <string key="NSAction">_popUpItemAction:</string> <reference key="NSTarget" ref="176341375"/> </object> - <object class="NSMenuItem" id="1029240286"> + <object class="NSMenuItem" id="713988214"> <reference key="NSMenu" ref="516760020"/> - <string key="NSTitle">Query Results</string> + <string key="NSTitle">Tables</string> <string key="NSKeyEquiv"/> <int key="NSKeyEquivModMask">1048576</int> <int key="NSMnemonicLoc">2147483647</int> @@ -1037,12 +1121,11 @@ <string key="NSAction">_popUpItemAction:</string> <reference key="NSTarget" ref="176341375"/> </object> - <reference ref="713988214"/> </array> <bool key="NSNoAutoenable">YES</bool> <reference key="NSMenuFont" ref="695505032"/> </object> - <int key="NSSelectedIndex">2</int> + <int key="NSSelectedIndex">-1</int> <int key="NSPreferredEdge">1</int> <bool key="NSUsesItemFromMenu">YES</bool> <bool key="NSAltersState">YES</bool> @@ -1067,6 +1150,7 @@ <int key="NSvFlags">266</int> <string key="NSFrame">{{29, 59}, {699, 19}}</string> <reference key="NSSuperview" ref="814282894"/> + <reference key="NSNextKeyView" ref="134032144"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="1053336717"> <int key="NSCellFlags">-1804599231</int> @@ -1091,6 +1175,7 @@ <int key="NSvFlags">266</int> <string key="NSFrame">{{29, 86}, {702, 14}}</string> <reference key="NSSuperview" ref="814282894"/> + <reference key="NSNextKeyView" ref="369138387"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="136682379"> <int key="NSCellFlags">68157504</int> @@ -1117,6 +1202,7 @@ <int key="NSvFlags">258</int> <string key="NSFrame">{{21, 4}, {667, 22}}</string> <reference key="NSSuperview" ref="197574806"/> + <reference key="NSNextKeyView" ref="429080228"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="872070930"> <int key="NSCellFlags">-2077228991</int> @@ -1133,10 +1219,12 @@ </array> <string key="NSFrame">{{1, 1}, {703, 38}}</string> <reference key="NSSuperview" ref="134032144"/> + <reference key="NSNextKeyView" ref="844630128"/> </object> </array> <string key="NSFrame">{{26, 10}, {705, 40}}</string> <reference key="NSSuperview" ref="814282894"/> + <reference key="NSNextKeyView" ref="197574806"/> <string key="NSOffsets">{0, 0}</string> <object class="NSTextFieldCell" key="NSTitleCell"> <int key="NSCellFlags">67108864</int> @@ -1158,10 +1246,12 @@ </array> <string key="NSFrame">{{1, 1}, {746, 112}}</string> <reference key="NSSuperview" ref="593000452"/> + <reference key="NSNextKeyView" ref="642404234"/> </object> </array> <string key="NSFrame">{{-11, -4}, {748, 114}}</string> <reference key="NSSuperview" ref="185191090"/> + <reference key="NSNextKeyView" ref="814282894"/> <string key="NSOffsets">{0, 0}</string> <object class="NSTextFieldCell" key="NSTitleCell"> <int key="NSCellFlags">67108864</int> @@ -1183,6 +1273,7 @@ </array> <string key="NSFrame">{{0, 207}, {730, 108}}</string> <reference key="NSSuperview" ref="1039688935"/> + <reference key="NSNextKeyView" ref="593000452"/> <string key="NSClassName">NSView</string> </object> <object class="NSButton" id="93580453"> @@ -1190,6 +1281,7 @@ <int key="NSvFlags">266</int> <string key="NSFrame">{{32, 316}, {680, 28}}</string> <reference key="NSSuperview" ref="1039688935"/> + <reference key="NSNextKeyView" ref="185191090"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="704057245"> <int key="NSCellFlags">-2080374720</int> @@ -1212,6 +1304,7 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{9, 318}, {29, 26}}</string> <reference key="NSSuperview" ref="1039688935"/> + <reference key="NSNextKeyView" ref="212414565"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="240404499"> <int key="NSCellFlags">67108864</int> @@ -1229,34 +1322,12 @@ </object> <bool key="NSAllowsLogicalLayoutDirection">NO</bool> </object> - <object class="NSButton" id="563113326"> - <reference key="NSNextResponder" ref="1039688935"/> - <int key="NSvFlags">265</int> - <string key="NSFrame">{{674, 344}, {43, 28}}</string> - <reference key="NSSuperview" ref="1039688935"/> - <string key="NSReuseIdentifierKey">_NS:9</string> - <bool key="NSEnabled">YES</bool> - <object class="NSButtonCell" key="NSCell" id="344258736"> - <int key="NSCellFlags">67108864</int> - <int key="NSCellFlags2">134348800</int> - <string key="NSContents">S…</string> - <reference key="NSSupport" ref="26"/> - <string key="NSCellIdentifier">_NS:9</string> - <reference key="NSControlView" ref="563113326"/> - <int key="NSButtonFlags">-2038284288</int> - <int key="NSButtonFlags2">129</int> - <string key="NSAlternateContents"/> - <string key="NSKeyEquivalent"/> - <int key="NSPeriodicDelay">200</int> - <int key="NSPeriodicInterval">25</int> - </object> - <bool key="NSAllowsLogicalLayoutDirection">NO</bool> - </object> <object class="NSButton" id="1058029781"> <reference key="NSNextResponder" ref="1039688935"/> <int key="NSvFlags">265</int> - <string key="NSFrame">{{582, 344}, {94, 28}}</string> + <string key="NSFrame">{{580, 344}, {94, 28}}</string> <reference key="NSSuperview" ref="1039688935"/> + <reference key="NSNextKeyView" ref="745374830"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="808873518"> <int key="NSCellFlags">67108864</int> @@ -1278,6 +1349,7 @@ <int key="NSvFlags">10</int> <string key="NSFrame">{{20, 312}, {690, 5}}</string> <reference key="NSSuperview" ref="1039688935"/> + <reference key="NSNextKeyView" ref="93580453"/> <string key="NSOffsets">{0, 0}</string> <object class="NSTextFieldCell" key="NSTitleCell"> <int key="NSCellFlags">67108864</int> @@ -1298,8 +1370,9 @@ <object class="NSTextField" id="412690578"> <reference key="NSNextResponder" ref="1039688935"/> <int key="NSvFlags">266</int> - <string key="NSFrame">{{127, 349}, {452, 19}}</string> + <string key="NSFrame">{{127, 349}, {450, 19}}</string> <reference key="NSSuperview" ref="1039688935"/> + <reference key="NSNextKeyView" ref="1058029781"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="291144691"> <int key="NSCellFlags">-2073034687</int> @@ -1319,6 +1392,7 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{17, 351}, {105, 14}}</string> <reference key="NSSuperview" ref="1039688935"/> + <reference key="NSNextKeyView" ref="412690578"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="869459931"> <int key="NSCellFlags">68157504</int> @@ -1337,6 +1411,7 @@ <int key="NSvFlags">-2147483380</int> <string key="NSFrame">{{226, 288}, {273, 18}}</string> <reference key="NSSuperview" ref="1039688935"/> + <reference key="NSNextKeyView" ref="505274803"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="328323922"> <int key="NSCellFlags">-2080374784</int> @@ -1357,21 +1432,23 @@ </object> <object class="NSTabView" id="683006936"> <reference key="NSNextResponder" ref="1039688935"/> - <int key="NSvFlags">17</int> + <int key="NSvFlags">273</int> <string key="NSFrame">{{438, 16}, {276, 268}}</string> <reference key="NSSuperview" ref="1039688935"/> + <reference key="NSNextKeyView" ref="855848511"/> <array class="NSMutableArray" key="NSTabViewItems"> <object class="NSTabViewItem" id="286086449"> <string key="NSIdentifier">sql</string> <object class="NSView" key="NSView" id="311280472"> - <reference key="NSNextResponder" ref="683006936"/> - <int key="NSvFlags">256</int> + <nil key="NSNextResponder"/> + <int key="NSvFlags">274</int> <array class="NSMutableArray" key="NSSubviews"> <object class="NSButton" id="896448830"> <reference key="NSNextResponder" ref="311280472"/> <int key="NSvFlags">268</int> <string key="NSFrame">{{11, 195}, {233, 18}}</string> <reference key="NSSuperview" ref="311280472"/> + <reference key="NSNextKeyView" ref="855467986"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="1070796296"> <int key="NSCellFlags">-2080374784</int> @@ -1395,6 +1472,7 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{12, 219}, {233, 14}}</string> <reference key="NSSuperview" ref="311280472"/> + <reference key="NSNextKeyView" ref="896448830"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="882864517"> <int key="NSCellFlags">68157504</int> @@ -1413,6 +1491,7 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{12, 95}, {233, 14}}</string> <reference key="NSSuperview" ref="311280472"/> + <reference key="NSNextKeyView" ref="771021044"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="460496284"> <int key="NSCellFlags">68157504</int> @@ -1431,6 +1510,7 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{12, 115}, {232, 18}}</string> <reference key="NSSuperview" ref="311280472"/> + <reference key="NSNextKeyView" ref="904279924"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="902213604"> <int key="NSCellFlags">67108864</int> @@ -1454,6 +1534,7 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{12, 135}, {232, 18}}</string> <reference key="NSSuperview" ref="311280472"/> + <reference key="NSNextKeyView" ref="163591590"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="619630097"> <int key="NSCellFlags">-2080374784</int> @@ -1477,6 +1558,7 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{12, 71}, {232, 18}}</string> <reference key="NSSuperview" ref="311280472"/> + <reference key="NSNextKeyView" ref="243826641"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="302595793"> <int key="NSCellFlags">67108864</int> @@ -1500,6 +1582,7 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{12, 51}, {232, 18}}</string> <reference key="NSSuperview" ref="311280472"/> + <reference key="NSNextKeyView" ref="864598499"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="595529721"> <int key="NSCellFlags">-2080374784</int> @@ -1523,6 +1606,7 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{12, 31}, {233, 14}}</string> <reference key="NSSuperview" ref="311280472"/> + <reference key="NSNextKeyView" ref="946500215"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="618129698"> <int key="NSCellFlags">68157504</int> @@ -1541,6 +1625,7 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{15, 4}, {60, 19}}</string> <reference key="NSSuperview" ref="311280472"/> + <reference key="NSNextKeyView" ref="137273930"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="754103523"> <int key="NSCellFlags">-1804599231</int> @@ -1661,6 +1746,7 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{29, 175}, {215, 18}}</string> <reference key="NSSuperview" ref="311280472"/> + <reference key="NSNextKeyView" ref="68865676"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="368147897"> <int key="NSCellFlags">67108864</int> @@ -1684,6 +1770,7 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{29, 156}, {215, 18}}</string> <reference key="NSSuperview" ref="311280472"/> + <reference key="NSNextKeyView" ref="472940336"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="703689900"> <int key="NSCellFlags">-2080374784</int> @@ -1704,7 +1791,7 @@ </object> </array> <string key="NSFrame">{{10, 7}, {256, 248}}</string> - <reference key="NSSuperview" ref="683006936"/> + <reference key="NSNextKeyView" ref="868197026"/> </object> <string key="NSLabel">SQL</string> <reference key="NSColor" ref="683790803"/> @@ -2555,14 +2642,15 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 <object class="NSTabViewItem" id="317037302"> <string key="NSIdentifier">xml</string> <object class="NSView" key="NSView" id="855848511"> - <nil key="NSNextResponder"/> - <int key="NSvFlags">256</int> + <reference key="NSNextResponder" ref="683006936"/> + <int key="NSvFlags">274</int> <array class="NSMutableArray" key="NSSubviews"> <object class="NSTextField" id="65089502"> <reference key="NSNextResponder" ref="855848511"/> <int key="NSvFlags">268</int> <string key="NSFrame">{{11, 131}, {72, 14}}</string> <reference key="NSSuperview" ref="855848511"/> + <reference key="NSNextKeyView" ref="700877238"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="649072289"> <int key="NSCellFlags">68157504</int> @@ -2600,6 +2688,7 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 <int key="NSvFlags">268</int> <string key="NSFrame">{{11, 171}, {179, 18}}</string> <reference key="NSSuperview" ref="855848511"/> + <reference key="NSNextKeyView" ref="542859898"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="628367768"> <int key="NSCellFlags">-2080374784</int> @@ -2623,6 +2712,7 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 <int key="NSvFlags">268</int> <string key="NSFrame">{{12, 195}, {180, 14}}</string> <reference key="NSSuperview" ref="855848511"/> + <reference key="NSNextKeyView" ref="68485429"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="442957493"> <int key="NSCellFlags">68157504</int> @@ -2641,6 +2731,7 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 <int key="NSvFlags">268</int> <string key="NSFrame">{{11, 151}, {179, 18}}</string> <reference key="NSSuperview" ref="855848511"/> + <reference key="NSNextKeyView" ref="65089502"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="588899969"> <int key="NSCellFlags">-2080374784</int> @@ -2664,6 +2755,7 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 <int key="NSvFlags">268</int> <string key="NSFrame">{{59, 212}, {119, 22}}</string> <reference key="NSSuperview" ref="855848511"/> + <reference key="NSNextKeyView" ref="283307909"/> <bool key="NSEnabled">YES</bool> <object class="NSPopUpButtonCell" key="NSCell" id="732046199"> <int key="NSCellFlags">-2076180416</int> @@ -2719,6 +2811,7 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 <int key="NSvFlags">268</int> <string key="NSFrame">{{11, 217}, {46, 14}}</string> <reference key="NSSuperview" ref="855848511"/> + <reference key="NSNextKeyView" ref="132499812"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="713176599"> <int key="NSCellFlags">68157504</int> @@ -2734,6 +2827,8 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 </object> </array> <string key="NSFrame">{{10, 7}, {256, 248}}</string> + <reference key="NSSuperview" ref="683006936"/> + <reference key="NSNextKeyView" ref="875960206"/> </object> <string key="NSLabel">XML</string> <reference key="NSColor" ref="683790803"/> @@ -2786,13 +2881,13 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 <reference key="NSTabView" ref="683006936"/> </object> </array> - <reference key="NSSelectedTabViewItem" ref="286086449"/> + <reference key="NSSelectedTabViewItem" ref="317037302"/> <reference key="NSFont" ref="695505032"/> <int key="NSTvFlags">4</int> <bool key="NSAllowTruncatedLabels">YES</bool> <bool key="NSDrawsBackground">YES</bool> <array class="NSMutableArray" key="NSSubviews"> - <reference ref="311280472"/> + <reference ref="855848511"/> </array> </object> <object class="NSScrollView" id="505274803"> @@ -2801,13 +2896,14 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 <array class="NSMutableArray" key="NSSubviews"> <object class="NSClipView" id="475696168"> <reference key="NSNextResponder" ref="505274803"/> - <int key="NSvFlags">2304</int> + <int key="NSvFlags">2322</int> <array class="NSMutableArray" key="NSSubviews"> <object class="NSTableView" id="324452213"> <reference key="NSNextResponder" ref="475696168"/> <int key="NSvFlags">4352</int> <string key="NSFrameSize">{412, 221}</string> <reference key="NSSuperview" ref="475696168"/> + <reference key="NSNextKeyView" ref="695806109"/> <bool key="NSEnabled">YES</bool> <bool key="NSAllowsLogicalLayoutDirection">NO</bool> <bool key="NSControlAllowsExpansionToolTips">YES</bool> @@ -2816,6 +2912,7 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 <int key="NSvFlags">256</int> <string key="NSFrameSize">{412, 17}</string> <reference key="NSSuperview" ref="452013144"/> + <reference key="NSNextKeyView" ref="450730105"/> <reference key="NSTableView" ref="324452213"/> </object> <object class="_NSCornerView" key="NSCornerView" id="450730105"> @@ -2823,6 +2920,7 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 <int key="NSvFlags">-2147483392</int> <string key="NSFrame">{{144, 0}, {16, 17}}</string> <reference key="NSSuperview" ref="505274803"/> + <reference key="NSNextKeyView" ref="475696168"/> </object> <array class="NSMutableArray" key="NSTableColumns"> <object class="NSTableColumn" id="730805233"> @@ -2994,6 +3092,7 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 <int key="NSvFlags">-2147483392</int> <string key="NSFrame">{{148, 1}, {11, 228}}</string> <reference key="NSSuperview" ref="505274803"/> + <reference key="NSNextKeyView" ref="414783283"/> <bool key="NSAllowsLogicalLayoutDirection">NO</bool> <int key="NSsFlags">256</int> <reference key="NSTarget" ref="505274803"/> @@ -3005,6 +3104,7 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 <int key="NSvFlags">-2147483392</int> <string key="NSFrame">{{-100, -100}, {191, 15}}</string> <reference key="NSSuperview" ref="505274803"/> + <reference key="NSNextKeyView" ref="452013144"/> <bool key="NSAllowsLogicalLayoutDirection">NO</bool> <int key="NSsFlags">1</int> <reference key="NSTarget" ref="505274803"/> @@ -3013,7 +3113,7 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 </object> <object class="NSClipView" id="452013144"> <reference key="NSNextResponder" ref="505274803"/> - <int key="NSvFlags">2304</int> + <int key="NSvFlags">2338</int> <array class="NSMutableArray" key="NSSubviews"> <reference ref="181185916"/> </array> @@ -3028,12 +3128,13 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 </array> <string key="NSFrame">{{21, 42}, {414, 239}}</string> <reference key="NSSuperview" ref="1039688935"/> - <reference key="NSNextKeyView" ref="475696168"/> + <reference key="NSNextKeyView" ref="681376734"/> <int key="NSsFlags">133650</int> <reference key="NSVScroller" ref="695806109"/> <reference key="NSHScroller" ref="681376734"/> <reference key="NSContentView" ref="475696168"/> <reference key="NSHeaderClipView" ref="452013144"/> + <reference key="NSCornerView" ref="450730105"/> <bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes> <double key="NSMinMagnification">0.25</double> <double key="NSMaxMagnification">4</double> @@ -3041,6 +3142,7 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 </object> </array> <string key="NSFrameSize">{730, 378}</string> + <reference key="NSNextKeyView" ref="85590559"/> <string key="NSClassName">NSView</string> </object> <object class="NSUserDefaultsController" id="965845845"> @@ -3622,9 +3724,17 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 <object class="IBActionConnection" key="connection"> <string key="label">exportCurrentSettings:</string> <reference key="source" ref="1001"/> - <reference key="destination" ref="563113326"/> + <reference key="destination" ref="1043233379"/> </object> - <string key="id">SsW-ax-uuL</string> + <string key="id">qlz-iS-nue</string> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">importCurrentSettings:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="821214266"/> + </object> + <string key="id">abL-95-pHf</string> </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> @@ -4017,9 +4127,9 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 <reference ref="93580453"/> <reference ref="185191090"/> <reference ref="429080228"/> - <reference ref="1058029781"/> <reference ref="414783283"/> - <reference ref="563113326"/> + <reference ref="745374830"/> + <reference ref="1058029781"/> </array> <reference key="parent" ref="0"/> <string key="objectName">Exporter View</string> @@ -5226,17 +5336,45 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 <reference key="parent" ref="193458164"/> </object> <object class="IBObjectRecord"> - <string key="id">77c-r9-26W</string> - <reference key="object" ref="563113326"/> + <string key="id">fTa-Pi-oat</string> + <reference key="object" ref="745374830"/> <array class="NSMutableArray" key="children"> - <reference ref="344258736"/> + <reference ref="949231914"/> </array> <reference key="parent" ref="1039688935"/> </object> <object class="IBObjectRecord"> - <string key="id">DcJ-W4-asV</string> - <reference key="object" ref="344258736"/> - <reference key="parent" ref="563113326"/> + <string key="id">CFF-pW-Ooq</string> + <reference key="object" ref="949231914"/> + <array class="NSMutableArray" key="children"> + <reference ref="136150039"/> + </array> + <reference key="parent" ref="745374830"/> + </object> + <object class="IBObjectRecord"> + <string key="id">FZy-tc-1Lv</string> + <reference key="object" ref="136150039"/> + <array class="NSMutableArray" key="children"> + <reference ref="630979950"/> + <reference ref="1043233379"/> + <reference ref="821214266"/> + </array> + <reference key="parent" ref="949231914"/> + </object> + <object class="IBObjectRecord"> + <string key="id">7YA-Zh-COE</string> + <reference key="object" ref="630979950"/> + <reference key="parent" ref="136150039"/> + </object> + <object class="IBObjectRecord"> + <string key="id">n0o-5Z-jWq</string> + <reference key="object" ref="1043233379"/> + <reference key="parent" ref="136150039"/> + </object> + <object class="IBObjectRecord"> + <string key="id">ENy-fo-Iwf</string> + <reference key="object" ref="821214266"/> + <reference key="parent" ref="136150039"/> </object> </array> </object> @@ -5247,6 +5385,7 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 <string key="1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="1.IBWindowTemplateEditedContentRect">{{538, 113}, {517, 498}}</string> <boolean value="NO" key="1.NSWindowTemplate.visibleAtLaunch"/> + <reference key="1086.IBNSViewMetadataGestureRecognizers" ref="0"/> <string key="1086.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <object class="NSColor" key="1086.IBViewIntegration.shadowColor"> <int key="NSColorSpace">2</int> @@ -5585,16 +5724,28 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 <string key="579.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="580.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="581.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> - <object class="NSMutableDictionary" key="77c-r9-26W.IBAttributePlaceholdersKey"> + <string key="7YA-Zh-COE.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="CFF-pW-Ooq.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <object class="NSMutableDictionary" key="ENy-fo-Iwf.IBAttributePlaceholdersKey"> + <string key="NS.key.0">ToolTip</string> + <object class="IBToolTipAttribute" key="NS.object.0"> + <string key="name">ToolTip</string> + <reference key="object" ref="821214266"/> + <string key="toolTip">Replace the current export settings with settings loaded from disk</string> + </object> + </object> + <string key="ENy-fo-Iwf.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="FZy-tc-1Lv.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="fTa-Pi-oat.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <object class="NSMutableDictionary" key="n0o-5Z-jWq.IBAttributePlaceholdersKey"> <string key="NS.key.0">ToolTip</string> <object class="IBToolTipAttribute" key="NS.object.0"> <string key="name">ToolTip</string> - <reference key="object" ref="563113326"/> + <reference key="object" ref="1043233379"/> <string key="toolTip">Save the current export settings to disk</string> </object> </object> - <string key="77c-r9-26W.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> - <string key="DcJ-W4-asV.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="n0o-5Z-jWq.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> </dictionary> <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/> <nil key="activeLocalization"/> diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m index 7757c0ba..9986fa98 100644 --- a/Source/SPBundleEditorController.m +++ b/Source/SPBundleEditorController.m @@ -721,7 +721,7 @@ [panel setNameFieldStringValue:[[self _currentSelectedObject] objectForKey:kBundleNameKey]]; [panel beginSheetModalForWindow:[self window] completionHandler:^(NSInteger returnCode) { - if (returnCode != NSOKButton) return; + if (returnCode != NSFileHandlingPanelOKButton) return; // Panel is still on screen. Hide it first. (This is Apple's recommended way) [panel orderOut:nil]; diff --git a/Source/SPConstants.h b/Source/SPConstants.h index 4246906f..b236cda9 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -641,6 +641,16 @@ extern NSString *SPURLSchemeQueryResultStatusPathHeader; extern NSString *SPURLSchemeQueryResultMetaPathHeader; extern NSString *SPCommonCryptoExceptionName; +extern NSString *SPErrorDomain; // generic SP error domain for NSError + +typedef NS_ENUM(NSInteger,SPErrorCode) { // error codes in SPErrorDomain + /** When plist deserialization fails with nil return and no NSError or the returned object has the wrong type */ + SPErrorWrongTypeOrNil = 110001, + /** Parsed data is syntactically correct, but semantically wrong (e.g. a SPF file with the wrong content format */ + SPErrorWrongContentType = 110002, + /** Some data has a version that we don't know how to handle (can be used with e.g. SPF files, which have explicit version numbers) */ + SPErrorWrongContentVersion = 110003, +}; #define SPAppDelegate ((SPAppController *)[NSApp delegate]) diff --git a/Source/SPConstants.m b/Source/SPConstants.m index e5a407f4..4098f062 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -443,6 +443,7 @@ NSString *SPURLSchemeQueryResultStatusPathHeader = @"/tmp/SP_QUERY_RESULT_STAT NSString *SPURLSchemeQueryResultMetaPathHeader = @"/tmp/SP_QUERY_META_"; NSString *SPCommonCryptoExceptionName = @"SPCommonCryptoException"; +NSString *SPErrorDomain = @"SPErrorDomain"; void inline _SPClear(id *addr) { [*addr release], *addr = nil; diff --git a/Source/SPExportController.h b/Source/SPExportController.h index d36c8f81..f94596ca 100644 --- a/Source/SPExportController.h +++ b/Source/SPExportController.h @@ -254,6 +254,14 @@ - (void)openExportErrorsSheetWithString:(NSString *)errors; - (void)displayExportFinishedGrowlNotification; +/** + * Tries to set the export input to a given value or falls back to a default if not valid + * @param input The source to use + * @return YES if the source was accepted, NO otherwise + * @pre _switchTab needs to have been run before this method to decide valid inputs + */ +- (BOOL)setExportInput:(SPExportSource)input; + // IB action methods - (IBAction)export:(id)sender; - (IBAction)closeSheet:(id)sender; diff --git a/Source/SPExportController.m b/Source/SPExportController.m index 95fbc5b6..9113decc 100644 --- a/Source/SPExportController.m +++ b/Source/SPExportController.m @@ -198,9 +198,6 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; [exporters removeAllObjects]; [exportFiles removeAllObjects]; - // Select the 'selected tables' source option - [exportInputPopUpButton selectItemAtIndex:source]; - // If tables were supplied, select them if (exportTables) { @@ -231,6 +228,7 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; // Ensure interface validation [self _switchTab]; [self _updateExportAdvancedOptionsLabel]; + [self setExportInput:source]; [NSApp beginSheet:[self window] modalForWindow:[tableDocumentInstance parentWindow] @@ -306,9 +304,6 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; } [self exportTables:selectedTables asFormat:selectedExportType usingSource:selectedExportSource]; - - // Ensure UI validation - [self switchInput:exportInputPopUpButton]; } /** @@ -337,27 +332,50 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; [[sender window] orderOut:self]; } +- (BOOL)setExportInput:(SPExportSource)input +{ + SPExportSource actualInput = input; + // Dot will always be a TableExport + if(exportType == SPDotExport) { + actualInput = SPTableExport; + } + //check if the type actually is valid + else if(![[exportInputPopUpButton itemAtIndex:input] isEnabled]) { + //...no, pick a valid one instead + for (NSMenuItem *item in [exportInputPopUpButton itemArray]) { + if([item isEnabled]) { + actualInput = [exportInputPopUpButton indexOfItem:item]; + goto set_input; + } + } + // nothing found (should not happen) + SPLog(@"did not find any valid export input!?"); + return NO; + } +set_input: + exportSource = actualInput; + + [exportInputPopUpButton selectItemAtIndex:exportSource]; + + BOOL isSelectedTables = (exportSource == SPTableExport); + + [exportFilePerTableCheck setHidden:(!isSelectedTables) || (exportType == SPSQLExport)]; + [exportTableList setEnabled:isSelectedTables]; + [exportSelectAllTablesButton setEnabled:isSelectedTables]; + [exportDeselectAllTablesButton setEnabled:isSelectedTables]; + [exportRefreshTablesButton setEnabled:isSelectedTables]; + + [self updateAvailableExportFilenameTokens]; // will also update the filename itself + + return (actualInput == input); +} + /** * Enables/disables and shows/hides various interface controls depending on the selected item. */ - (IBAction)switchInput:(id)sender { - if ([sender isKindOfClass:[NSPopUpButton class]]) { - - // Determine what data to use (filtered result, custom query result or selected table(s)) for the export operation - exportSource = (exportType == SPDotExport) ? SPTableExport : [exportInputPopUpButton indexOfSelectedItem]; - - BOOL isSelectedTables = ([sender indexOfSelectedItem] == SPTableExport); - - [exportFilePerTableCheck setHidden:(!isSelectedTables) || (exportType == SPSQLExport)]; - [exportTableList setEnabled:isSelectedTables]; - [exportSelectAllTablesButton setEnabled:isSelectedTables]; - [exportDeselectAllTablesButton setEnabled:isSelectedTables]; - [exportRefreshTablesButton setEnabled:isSelectedTables]; - - [self updateAvailableExportFilenameTokens]; - [self updateDisplayedExportFilename]; - } + [self setExportInput:(SPExportSource)[exportInputPopUpButton indexOfSelectedItem]]; } /** @@ -428,7 +446,7 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; [panel setDirectoryURL:[NSURL URLWithString:[exportPathField stringValue]]]; [panel beginSheetModalForWindow:[self window] completionHandler:^(NSInteger returnCode) { - if (returnCode == NSOKButton) { + if (returnCode == NSFileHandlingPanelOKButton) { NSString *path = [[panel directoryURL] path]; if(!path) { @throw [NSException exceptionWithName:NSInternalInconsistencyException @@ -673,9 +691,6 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; - (IBAction)exportCustomQueryResultAsFormat:(id)sender { [self exportTables:nil asFormat:[sender tag] usingSource:SPQueryExport]; - - // Ensure UI validation - [self switchInput:exportInputPopUpButton]; } #pragma mark - @@ -770,11 +785,11 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; BOOL isSQL = (exportType == SPSQLExport); BOOL isCSV = (exportType == SPCSVExport); BOOL isXML = (exportType == SPXMLExport); - BOOL isHTML = (exportType == SPHTMLExport); - BOOL isPDF = (exportType == SPPDFExport); + //BOOL isHTML = (exportType == SPHTMLExport); + //BOOL isPDF = (exportType == SPPDFExport); BOOL isDot = (exportType == SPDotExport); - BOOL enable = (isCSV || isXML || isHTML || isPDF || isDot); + BOOL enable = (isCSV || isXML /* || isHTML || isPDF */ || isDot); [exportFilePerTableCheck setHidden:(isSQL || isDot)]; [exportTableList setEnabled:(!isDot)]; diff --git a/Source/SPExportControllerDelegate.m b/Source/SPExportControllerDelegate.m index 748fec1d..cf3101cf 100644 --- a/Source/SPExportControllerDelegate.m +++ b/Source/SPExportControllerDelegate.m @@ -32,8 +32,8 @@ #import "SPExportFilenameUtilities.h" #import "SPExportFileNameTokenObject.h" -#define IS_TOKEN(x) [x isKindOfClass:[SPExportFileNameTokenObject class]] -#define IS_STRING(x) [x isKindOfClass:[NSString class]] +static inline BOOL IS_TOKEN(id x); +static inline BOOL IS_STRING(id x); // Defined to suppress warnings @interface SPExportController (SPExportControllerPrivateAPI) @@ -345,5 +345,15 @@ @end -#undef IS_TOKEN -#undef IS_STRING +#pragma mark - + +BOOL IS_TOKEN(id x) +{ + return [x isKindOfClass:[SPExportFileNameTokenObject class]]; +} + +BOOL IS_STRING(id x) +{ + return [x isKindOfClass:[NSString class]]; +} + diff --git a/Source/SPExportFilenameUtilities.h b/Source/SPExportFilenameUtilities.h index 978dfc2c..b0ba9763 100644 --- a/Source/SPExportFilenameUtilities.h +++ b/Source/SPExportFilenameUtilities.h @@ -41,6 +41,7 @@ - (void)updateDisplayedExportFilename; - (void)updateAvailableExportFilenameTokens; +- (NSArray *)currentAllowedExportFilenameTokens; - (NSString *)generateDefaultExportFilename; - (NSString *)currentDefaultExportFileExtension; - (NSString *)expandCustomFilenameFormatUsingTableName:(NSString *)table; diff --git a/Source/SPExportFilenameUtilities.m b/Source/SPExportFilenameUtilities.m index ac09dd3b..69b8f786 100644 --- a/Source/SPExportFilenameUtilities.m +++ b/Source/SPExportFilenameUtilities.m @@ -153,6 +153,18 @@ [self updateDisplayedExportFilename]; } +- (NSArray *)currentAllowedExportFilenameTokens +{ + NSArray *mixed = [exportCustomFilenameTokenPool objectValue]; + NSMutableArray *tokens = [NSMutableArray arrayWithCapacity:[mixed count]]; // ...or less + + for (id obj in mixed) { + if([obj isKindOfClass:[SPExportFileNameTokenObject class]]) [tokens addObject:obj]; + } + + return tokens; +} + /** * Generates the default export filename based on the selected export options. * diff --git a/Source/SPExportSettingsPersistence.h b/Source/SPExportSettingsPersistence.h index 90f29cfe..41609125 100644 --- a/Source/SPExportSettingsPersistence.h +++ b/Source/SPExportSettingsPersistence.h @@ -34,11 +34,31 @@ @interface SPExportController (SPExportSettingsPersistence) - (IBAction)exportCurrentSettings:(id)sender; +- (IBAction)importCurrentSettings:(id)sender; + +/** + * @return The current settings as a dictionary which can be serialized + */ - (NSDictionary *)currentSettingsAsDictionary; +/** Overwrite current export settings with those defined in dict + * @param dict The new settings to apply (passing nil is an error.) + * @param err Errors while applying (will mostly be about invalid format, type) + * Can pass NULL, if not interested in details. + * Will NOT be changed unless the method also returns NO + * @return success + */ +- (BOOL)applySettingsFromDictionary:(NSDictionary *)dict error:(NSError **)err; + /** * @return A serialized form of the "custom filename" field */ - (NSArray *)currentCustomFilenameAsArray; +/** + * @param tokenList A serialized form of the "custom filename" field + * @see currentCustomFilenameAsArray + */ +- (void)setCustomFilenameFromArray:(NSArray *)tokenList; + @end diff --git a/Source/SPExportSettingsPersistence.m b/Source/SPExportSettingsPersistence.m index 68963856..f1fe98a2 100644 --- a/Source/SPExportSettingsPersistence.m +++ b/Source/SPExportSettingsPersistence.m @@ -30,33 +30,69 @@ #import "SPExportSettingsPersistence.h" #import "SPExportFileNameTokenObject.h" +#import "SPExportFilenameUtilities.h" +#import "SPExportController+SharedPrivateAPI.h" /** * converts a ([obj state] == NSOnState) to @YES / @NO * (because doing @([obj state] == NSOnState) will result in an integer 0/1) */ static inline NSNumber *IsOn(id obj); +/** + * Sets the state of obj to NSOnState or NSOffState based on the value of ref + */ +static inline void SetOnOff(NSNumber *ref,id obj); + +static const NSString *SPFExportSettingsContentType = @"export settings"; + +@interface SPExportController (Private) + +- (void)_updateExportAdvancedOptionsLabel; +- (void)_switchTab; + +@end @interface SPExportController (SPExportSettingsPersistence_Private) +// those methods will convert the name of a C enum constant to a NSString + (NSString *)describeExportSource:(SPExportSource)es; + (NSString *)describeExportType:(SPExportType)et; + (NSString *)describeCompressionFormat:(SPFileCompressionFormat)cf; + (NSString *)describeXMLExportFormat:(SPXMLExportFormat)xf; + (NSString *)describeSQLExportInsertDivider:(SPSQLExportInsertDivider)eid; +// these will store the C enum constant named by NSString in dst and return YES, +// if a valid mapping exists. Otherwise will just return NO and not modify dst. ++ (BOOL)copyExportSourceForDescription:(NSString *)esd to:(SPExportSource *)dst; ++ (BOOL)copyCompressionFormatForDescription:(NSString *)esd to:(SPFileCompressionFormat *)dst; ++ (BOOL)copyExportTypeForDescription:(NSString *)esd to:(SPExportType *)dst; ++ (BOOL)copyXMLExportFormatForDescription:(NSString *)xfd to:(SPXMLExportFormat *)dst; ++ (BOOL)copySQLExportInsertDividerForDescription:(NSString *)xfd to:(SPSQLExportInsertDivider *)dst; + - (NSDictionary *)exporterSettings; - (NSDictionary *)csvSettings; - (NSDictionary *)dotSettings; - (NSDictionary *)xmlSettings; - (NSDictionary *)sqlSettings; +- (void)applyExporterSettings:(NSDictionary *)settings; +- (void)applyCsvSettings:(NSDictionary *)settings; +- (void)applyDotSettings:(NSDictionary *)settings; +- (void)applyXmlSettings:(NSDictionary *)settings; +- (void)applySqlSettings:(NSDictionary *)settings; + - (id)exporterSpecificSettingsForSchemaObject:(NSString *)name ofType:(SPTableType)type; - (id)dotSpecificSettingsForSchemaObject:(NSString *)name ofType:(SPTableType)type; - (id)xmlSpecificSettingsForSchemaObject:(NSString *)name ofType:(SPTableType)type; - (id)csvSpecificSettingsForSchemaObject:(NSString *)name ofType:(SPTableType)type; - (id)sqlSpecificSettingsForSchemaObject:(NSString *)name ofType:(SPTableType)type; +- (void)applyExporterSpecificSettings:(id)settings forSchemaObject:(NSString *)name ofType:(SPTableType)type; +- (void)applyDotSpecificSettings:(id)settings forSchemaObject:(NSString *)name ofType:(SPTableType)type; +- (void)applyXmlSpecificSettings:(id)settings forSchemaObject:(NSString *)name ofType:(SPTableType)type; +- (void)applyCsvSpecificSettings:(id)settings forSchemaObject:(NSString *)name ofType:(SPTableType)type; +- (void)applySqlSpecificSettings:(id)settings forSchemaObject:(NSString *)name ofType:(SPTableType)type; + @end #pragma mark - @@ -64,6 +100,7 @@ static inline NSNumber *IsOn(id obj); @implementation SPExportController (SPExportSettingsPersistence) #define NAMEOF(x) case x: return @#x +#define VALUEOF(x,y,dst) if([y isEqualToString:@#x]) { *dst = x; return YES; } + (NSString *)describeExportSource:(SPExportSource)es { @@ -75,6 +112,14 @@ static inline NSNumber *IsOn(id obj); return nil; } ++ (BOOL)copyExportSourceForDescription:(NSString *)esd to:(SPExportSource *)dst +{ + VALUEOF(SPFilteredExport, esd,dst); + VALUEOF(SPQueryExport, esd,dst); + VALUEOF(SPTableExport, esd,dst); + return NO; +} + + (NSString *)describeExportType:(SPExportType)et { switch (et) { @@ -89,6 +134,18 @@ static inline NSNumber *IsOn(id obj); return nil; } ++ (BOOL)copyExportTypeForDescription:(NSString *)etd to:(SPExportType *)dst +{ + VALUEOF(SPSQLExport, etd, dst); + VALUEOF(SPCSVExport, etd, dst); + VALUEOF(SPXMLExport, etd, dst); + VALUEOF(SPDotExport, etd, dst); + //VALUEOF(SPPDFExport, etd, dst); + //VALUEOF(SPHTMLExport, etd, dst); + //VALUEOF(SPExcelExport, etd, dst); + return NO; +} + + (NSString *)describeCompressionFormat:(SPFileCompressionFormat)cf { switch (cf) { @@ -99,6 +156,14 @@ static inline NSNumber *IsOn(id obj); return nil; } ++ (BOOL)copyCompressionFormatForDescription:(NSString *)cfd to:(SPFileCompressionFormat *)dst +{ + VALUEOF(SPNoCompression, cfd, dst); + VALUEOF(SPGzipCompression, cfd, dst); + VALUEOF(SPBzip2Compression, cfd, dst); + return NO; +} + + (NSString *)describeXMLExportFormat:(SPXMLExportFormat)xf { switch (xf) { @@ -108,6 +173,13 @@ static inline NSNumber *IsOn(id obj); return nil; } ++ (BOOL)copyXMLExportFormatForDescription:(NSString *)xfd to:(SPXMLExportFormat *)dst +{ + VALUEOF(SPXMLExportMySQLFormat, xfd, dst); + VALUEOF(SPXMLExportPlainFormat, xfd, dst); + return NO; +} + + (NSString *)describeSQLExportInsertDivider:(SPSQLExportInsertDivider)eid { switch (eid) { @@ -117,7 +189,70 @@ static inline NSNumber *IsOn(id obj); return nil; } ++ (BOOL)copySQLExportInsertDividerForDescription:(NSString *)eidd to:(SPSQLExportInsertDivider *)dst +{ + VALUEOF(SPSQLInsertEveryNDataBytes, eidd, dst); + VALUEOF(SPSQLInsertEveryNRows, eidd, dst); + return NO; +} + #undef NAMEOF +#undef VALUEOF + +- (IBAction)importCurrentSettings:(id)sender +{ + //show open file dialog + NSOpenPanel *panel = [NSOpenPanel openPanel]; + + [panel setAllowedFileTypes:@[SPFileExtensionDefault]]; + [panel setAllowsOtherFileTypes:YES]; + + [panel beginSheetModalForWindow:[self window] completionHandler:^(NSInteger result) { + if(result != NSFileHandlingPanelOKButton) return; + + [panel orderOut:nil]; // Panel is still on screen. Hide it first. (This is Apple's recommended way) + + NSError *err = nil; + NSData *plist = [NSData dataWithContentsOfURL:[panel URL] + options:0 + error:&err]; + + NSDictionary *settings = nil; + if(!err) { + settings = [NSPropertyListSerialization propertyListWithData:plist + options:NSPropertyListImmutable + format:NULL + error:&err]; + } + + if(!err) { + [self applySettingsFromDictionary:settings error:&err]; + if(!err) return; + } + + // give an explanation for some errors + if([[err domain] isEqualToString:SPErrorDomain]) { + if([err code] == SPErrorWrongTypeOrNil) { + NSDictionary *info = @{ + NSLocalizedDescriptionKey: NSLocalizedString(@"Invalid file supplied!", @"export : import settings : file error title"), + NSLocalizedRecoverySuggestionErrorKey: NSLocalizedString(@"The selected file is either not a valid SPF file or severely corrupted.", @"export : import settings : file error description"), + }; + err = [NSError errorWithDomain:[err domain] code:[err code] userInfo:info]; + } + else if([err code] == SPErrorWrongContentType) { + NSDictionary *info = @{ + NSLocalizedDescriptionKey: NSLocalizedString(@"Wrong SPF content type!", @"export : import settings : spf content type error title"), + NSLocalizedRecoverySuggestionErrorKey: [NSString stringWithFormat:NSLocalizedString(@"The selected file contains data of type “%1$@”, but type “%2$@” is needed. Please choose a different file.", @"export : import settings : spf content type error description"),[[err userInfo] objectForKey:@"isType"],[[err userInfo] objectForKey:@"expectedType"]], + }; + err = [NSError errorWithDomain:[err domain] code:[err code] userInfo:info]; + } + } + + NSAlert *alert = [NSAlert alertWithError:err]; + [alert setAlertStyle:NSCriticalAlertStyle]; + [alert runModal]; + }]; +} - (IBAction)exportCurrentSettings:(id)sender { @@ -134,6 +269,9 @@ static inline NSNumber *IsOn(id obj); [panel beginSheetModalForWindow:[self window] completionHandler:^(NSInteger returnCode) { if(returnCode != NSFileHandlingPanelOKButton) return; + // Panel is still on screen. Hide it first. (This is Apple's recommended way) + [panel orderOut:nil]; + NSError *err = nil; NSData *plist = [NSPropertyListSerialization dataWithPropertyList:[self currentSettingsAsDictionary] format:NSPropertyListXMLFormat_v1_0 @@ -172,11 +310,42 @@ static inline NSNumber *IsOn(id obj); return tokenListOut; } +- (void)setCustomFilenameFromArray:(NSArray *)tokenList +{ + NSMutableArray *tokenListOut = [NSMutableArray arrayWithCapacity:[tokenList count]]; + NSArray *allowedTokens = [self currentAllowedExportFilenameTokens]; + + for (id obj in tokenList) { + if([obj isKindOfClass:[NSString class]]) { + [tokenListOut addObject:obj]; + } + else if([obj isKindOfClass:[NSDictionary class]]) { + //there must be at least a non-empty tokenId that is also in the token pool + NSString *tokenId = [obj objectForKey:@"tokenId"]; + if([tokenId length]) { + SPExportFileNameTokenObject *token = [SPExportFileNameTokenObject tokenWithId:tokenId]; + if([allowedTokens containsObject:token]) { + [tokenListOut addObject:token]; + continue; + } + } + SPLog(@"Ignoring an invalid or unknown token with tokenId=%@",tokenId); + } + else { + SPLog(@"unknown object in import token list: %@",obj); + } + } + + [exportCustomFilenameTokenField setObjectValue:tokenListOut]; + + [self updateDisplayedExportFilename]; +} + - (NSDictionary *)currentSettingsAsDictionary { NSMutableDictionary *root = [NSMutableDictionary dictionary]; - [root setObject:@"export settings" forKey:SPFFormatKey]; + [root setObject:SPFExportSettingsContentType forKey:SPFFormatKey]; [root setObject:@1 forKey:SPFVersionKey]; [root setObject:[exportPathField stringValue] forKey:@"exportPath"]; @@ -209,6 +378,98 @@ static inline NSNumber *IsOn(id obj); return root; } +- (BOOL)applySettingsFromDictionary:(NSDictionary *)dict error:(NSError **)err +{ + //check for dict/nil + if(![dict isKindOfClass:[NSDictionary class]]) { + if(err) { + *err = [NSError errorWithDomain:SPErrorDomain + code:SPErrorWrongTypeOrNil + userInfo:nil]; // we don't know where data came from, so we can't provide meaningful help to the user + } + return NO; + } + + //check for export settings + NSString *ctype = [dict objectForKey:SPFFormatKey]; + if (![SPFExportSettingsContentType isEqualToString:ctype]) { + if(err) { + NSDictionary *errInfo = @{ + @"isType": ctype, + @"expectedType": SPFExportSettingsContentType + }; + *err = [NSError errorWithDomain:SPErrorDomain + code:SPErrorWrongContentType + userInfo:errInfo]; + } + return NO; + } + + //check for version + NSInteger version = [[dict objectForKey:SPFVersionKey] integerValue]; + if(version != 1) { + if(err) { + NSDictionary *errInfo = @{ + @"isVersion": @(version), + NSLocalizedDescriptionKey: NSLocalizedString(@"Unsupported version for export settings!", @"export : import settings : file version error title"), + NSLocalizedRecoverySuggestionErrorKey: [NSString stringWithFormat:NSLocalizedString(@"The selected export settings were stored with version\u00A0%1$ld, but only settings with the following versions can be imported: %2$@.\n\nEither save the settings in a backwards compatible way or update your version of Sequel Pro.", @"export : import settings : file version error description ($1 = is version, $2 = list of supported versions)"),version,@"1"], + }; + *err = [NSError errorWithDomain:SPErrorDomain + code:SPErrorWrongContentVersion + userInfo:errInfo]; + } + return NO; + } + + //ok, we can try to import that... + + [exporters removeAllObjects]; + [exportFiles removeAllObjects]; + + id o; + if((o = [dict objectForKey:@"exportPath"])) [exportPathField setStringValue:o]; + + SPExportType et; + if((o = [dict objectForKey:@"exportType"]) && [[self class] copyExportTypeForDescription:o to:&et]) { + [exportTypeTabBar selectTabViewItemAtIndex:et]; + } + + //exportType should be changed first, as exportSource depends on it + SPExportSource es; + if((o = [dict objectForKey:@"exportSource"]) && [[self class] copyExportSourceForDescription:o to:&es]) { + [self setExportInput:es]; //try to set it. might fail e.g. if the settings were saved with "query result" but right now no custom query result exists + } + + // set exporter specific settings + [self applyExporterSettings:[dict objectForKey:@"settings"]]; + + // load schema object settings + if(exportSource == SPTableExport) { + NSDictionary *perObjectSettings = [dict objectForKey:@"schemaObjects"]; + + for (NSString *table in [perObjectSettings allKeys]) { + id settings = [perObjectSettings objectForKey:table]; + [self applyExporterSpecificSettings:settings forSchemaObject:table ofType:SPTableTypeTable]; + } + + [exportTableList reloadData]; + } + + if((o = [dict objectForKey:@"lowMemoryStreaming"])) [exportProcessLowMemoryButton setState:([o boolValue] ? NSOnState : NSOffState)]; + + SPFileCompressionFormat cf; + if((o = [dict objectForKey:@"compressionFormat"]) && [[self class] copyCompressionFormatForDescription:o to:&cf]) [exportOutputCompressionFormatPopupButton selectItemAtIndex:cf]; + + // might have changed + [self _updateExportAdvancedOptionsLabel]; + + // token pool is only valid once the schema object selection is done + [self updateAvailableExportFilenameTokens]; + if((o = [dict objectForKey:@"customFilename"])) [self setCustomFilenameFromArray:o]; + + return YES; +} + - (NSDictionary *)exporterSettings { switch (exportType) { @@ -230,6 +491,27 @@ static inline NSNumber *IsOn(id obj); } } +- (void)applyExporterSettings:(NSDictionary *)settings +{ + switch (exportType) { + case SPCSVExport: + return [self applyCsvSettings:settings]; + case SPSQLExport: + return [self applySqlSettings:settings]; + case SPXMLExport: + return [self applyXmlSettings:settings]; + case SPDotExport: + return [self applyDotSettings:settings]; + case SPExcelExport: + case SPHTMLExport: + case SPPDFExport: + default: + @throw [NSException exceptionWithName:NSInternalInconsistencyException + reason:@"exportType not implemented!" + userInfo:@{@"exportType": @(exportType)}]; + } +} + - (NSDictionary *)csvSettings { return @{ @@ -243,11 +525,31 @@ static inline NSNumber *IsOn(id obj); }; } +- (void)applyCsvSettings:(NSDictionary *)settings +{ + id o; + if((o = [settings objectForKey:@"exportToMultipleFiles"])) SetOnOff(o,exportFilePerTableCheck); + [self toggleNewFilePerTable:nil]; + + if((o = [settings objectForKey:@"CSVIncludeFieldNames"])) SetOnOff(o, exportCSVIncludeFieldNamesCheck); + if((o = [settings objectForKey:@"CSVFieldsTerminated"])) [exportCSVFieldsTerminatedField setStringValue:o]; + if((o = [settings objectForKey:@"CSVFieldsWrapped"])) [exportCSVFieldsWrappedField setStringValue:o]; + if((o = [settings objectForKey:@"CSVLinesTerminated"])) [exportCSVLinesTerminatedField setStringValue:o]; + if((o = [settings objectForKey:@"CSVFieldsEscaped"])) [exportCSVFieldsEscapedField setStringValue:o]; + if((o = [settings objectForKey:@"CSVNULLValuesAsText"])) [exportCSVNULLValuesAsTextField setStringValue:o]; +} + - (NSDictionary *)dotSettings { return @{@"DotForceLowerTableNames": IsOn(exportDotForceLowerTableNamesCheck)}; } +- (void)applyDotSettings:(NSDictionary *)settings +{ + id o; + if((o = [settings objectForKey:@"DotForceLowerTableNames"])) SetOnOff(o, exportDotForceLowerTableNamesCheck); +} + - (NSDictionary *)xmlSettings { return @{ @@ -259,6 +561,21 @@ static inline NSNumber *IsOn(id obj); }; } +- (void)applyXmlSettings:(NSDictionary *)settings +{ + id o; + SPXMLExportFormat xmlf; + if((o = [settings objectForKey:@"exportToMultipleFiles"])) SetOnOff(o, exportFilePerTableCheck); + [self toggleNewFilePerTable:nil]; + + if((o = [settings objectForKey:@"XMLFormat"]) && [[self class] copyXMLExportFormatForDescription:o to:&xmlf]) [exportXMLFormatPopUpButton selectItemAtIndex:xmlf]; + if((o = [settings objectForKey:@"XMLOutputIncludeStructure"])) SetOnOff(o, exportXMLIncludeStructure); + if((o = [settings objectForKey:@"XMLOutputIncludeContent"])) SetOnOff(o, exportXMLIncludeContent); + if((o = [settings objectForKey:@"XMLNULLString"])) [exportXMLNULLValuesAsTextField setStringValue:o]; + + [self toggleXMLOutputFormat:exportXMLFormatPopUpButton]; +} + - (NSDictionary *)sqlSettings { BOOL includeStructure = ([exportSQLIncludeStructureCheck state] == NSOnState); @@ -267,6 +584,7 @@ static inline NSNumber *IsOn(id obj); @"SQLIncludeStructure": IsOn(exportSQLIncludeStructureCheck), @"SQLIncludeContent": IsOn(exportSQLIncludeContentCheck), @"SQLIncludeErrors": IsOn(exportSQLIncludeErrorsCheck), + @"SQLIncludeDROP": IsOn(exportSQLIncludeDropSyntaxCheck), @"SQLUseUTF8BOM": IsOn(exportUseUTF8BOMButton), @"SQLBLOBFieldsAsHex": IsOn(exportSQLBLOBFieldsAsHexCheck), @"SQLInsertNValue": @([exportSQLInsertNValueTextField integerValue]), @@ -283,6 +601,32 @@ static inline NSNumber *IsOn(id obj); return dict; } +- (void)applySqlSettings:(NSDictionary *)settings +{ + id o; + SPSQLExportInsertDivider div; + + if((o = [settings objectForKey:@"SQLIncludeContent"])) SetOnOff(o, exportSQLIncludeContentCheck); + [self toggleSQLIncludeContent:exportSQLIncludeContentCheck]; + + if((o = [settings objectForKey:@"SQLIncludeDROP"])) SetOnOff(o, exportSQLIncludeDropSyntaxCheck); + [self toggleSQLIncludeDropSyntax:exportSQLIncludeDropSyntaxCheck]; + + if((o = [settings objectForKey:@"SQLIncludeStructure"])) SetOnOff(o, exportSQLIncludeStructureCheck); + [self toggleSQLIncludeStructure:exportSQLIncludeStructureCheck]; + + if((o = [settings objectForKey:@"SQLIncludeErrors"])) SetOnOff(o, exportSQLIncludeErrorsCheck); + if((o = [settings objectForKey:@"SQLUseUTF8BOM"])) SetOnOff(o, exportUseUTF8BOMButton); + if((o = [settings objectForKey:@"SQLBLOBFieldsAsHex"])) SetOnOff(o, exportSQLBLOBFieldsAsHexCheck); + if((o = [settings objectForKey:@"SQLInsertNValue"])) [exportSQLInsertNValueTextField setIntegerValue:[o integerValue]]; + if((o = [settings objectForKey:@"SQLInsertDivider"]) && [[self class] copySQLExportInsertDividerForDescription:o to:&div]) [exportSQLInsertDividerPopUpButton selectItemAtIndex:div]; + + if([exportSQLIncludeStructureCheck state] == NSOnState) { + if((o = [settings objectForKey:@"SQLIncludeAutoIncrementValue"])) SetOnOff(o, exportSQLIncludeAutoIncrementValueButton); + if((o = [settings objectForKey:@"SQLIncludeDropSyntax"])) SetOnOff(o, exportSQLIncludeDropSyntaxCheck); + } +} + - (id)exporterSpecificSettingsForSchemaObject:(NSString *)name ofType:(SPTableType)type { switch (exportType) { @@ -304,12 +648,38 @@ static inline NSNumber *IsOn(id obj); } } +- (void)applyExporterSpecificSettings:(id)settings forSchemaObject:(NSString *)name ofType:(SPTableType)type +{ + switch (exportType) { + case SPCSVExport: + return [self applyCsvSpecificSettings:settings forSchemaObject:name ofType:type]; + case SPSQLExport: + return [self applySqlSpecificSettings:settings forSchemaObject:name ofType:type]; + case SPXMLExport: + return [self applyXmlSpecificSettings:settings forSchemaObject:name ofType:type]; + case SPDotExport: + return [self applyDotSpecificSettings:settings forSchemaObject:name ofType:type]; + case SPExcelExport: + case SPHTMLExport: + case SPPDFExport: + default: + @throw [NSException exceptionWithName:NSInternalInconsistencyException + reason:@"exportType not implemented!" + userInfo:@{@"exportType": @(exportType)}]; + } +} + - (id)dotSpecificSettingsForSchemaObject:(NSString *)name ofType:(SPTableType)type { // Dot is a graph of the whole database - nothing to pick from return nil; } +- (void)applyDotSpecificSettings:(id)settings forSchemaObject:(NSString *)name ofType:(SPTableType)type +{ + //should never be called +} + - (id)xmlSpecificSettingsForSchemaObject:(NSString *)name ofType:(SPTableType)type { // XML per table setting is only yes/no @@ -324,6 +694,20 @@ static inline NSNumber *IsOn(id obj); return nil; } +- (void)applyXmlSpecificSettings:(id)settings forSchemaObject:(NSString *)name ofType:(SPTableType)type +{ + // XML per table setting is only yes/no + if(type == SPTableTypeTable) { + // we have to look through the table views' rows to find the appropriate table... + for (NSMutableArray *table in tables) { + if([[table objectAtIndex:0] isEqualTo:name]) { + [table replaceObjectAtIndex:2 withObject:@([settings boolValue])]; + return; + } + } + } +} + - (id)csvSpecificSettingsForSchemaObject:(NSString *)name ofType:(SPTableType)type { // CSV per table setting is only yes/no @@ -338,6 +722,20 @@ static inline NSNumber *IsOn(id obj); return nil; } +- (void)applyCsvSpecificSettings:(id)settings forSchemaObject:(NSString *)name ofType:(SPTableType)type +{ + // CSV per table setting is only yes/no + if(type == SPTableTypeTable) { + // we have to look through the table views' rows to find the appropriate table... + for (NSMutableArray *table in tables) { + if([[table objectAtIndex:0] isEqualTo:name]) { + [table replaceObjectAtIndex:2 withObject:@([settings boolValue])]; + return; + } + } + } +} + - (id)sqlSpecificSettingsForSchemaObject:(NSString *)name ofType:(SPTableType)type { BOOL structure = ([exportSQLIncludeStructureCheck state] == NSOnState); @@ -370,6 +768,28 @@ static inline NSNumber *IsOn(id obj); return nil; } +- (void)applySqlSpecificSettings:(id)settings forSchemaObject:(NSString *)name ofType:(SPTableType)type +{ + BOOL structure = ([exportSQLIncludeStructureCheck state] == NSOnState); + BOOL content = ([exportSQLIncludeContentCheck state] == NSOnState); + BOOL drop = ([exportSQLIncludeDropSyntaxCheck state] == NSOnState); + + // SQL allows per table setting of structure/content/drop table + if(type == SPTableTypeTable) { + // we have to look through the table views' rows to find the appropriate table... + for (NSMutableArray *table in tables) { + if([[table objectAtIndex:0] isEqualTo:name]) { + NSArray *flags = settings; + + [table replaceObjectAtIndex:1 withObject:@((structure && [flags containsObject:@"structure"]))]; + [table replaceObjectAtIndex:2 withObject:@((content && [flags containsObject:@"content"]))]; + [table replaceObjectAtIndex:3 withObject:@((drop && [flags containsObject:@"drop"]))]; + return; + } + } + } +} + @end #pragma mark - @@ -378,3 +798,8 @@ NSNumber *IsOn(id obj) { return (([obj state] == NSOnState)? @YES : @NO); } + +void SetOnOff(NSNumber *ref,id obj) +{ + [obj setState:([ref boolValue] ? NSOnState : NSOffState)]; +} |