diff options
-rw-r--r-- | Interfaces/English.lproj/ExportDialog.xib | 32 | ||||
-rw-r--r-- | Resources/Plists/PreferenceDefaults.plist | 4 | ||||
-rw-r--r-- | Source/SPConstants.h | 9 | ||||
-rw-r--r-- | Source/SPConstants.m | 6 | ||||
-rw-r--r-- | Source/SPExportController.m | 83 | ||||
-rw-r--r-- | Source/SPExportSettingsPersistence.m | 3 |
6 files changed, 33 insertions, 104 deletions
diff --git a/Interfaces/English.lproj/ExportDialog.xib b/Interfaces/English.lproj/ExportDialog.xib index 5275ec30..25d5b075 100644 --- a/Interfaces/English.lproj/ExportDialog.xib +++ b/Interfaces/English.lproj/ExportDialog.xib @@ -3808,38 +3808,6 @@ y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ1MvVTtXR1lXW2Ndc1+DYZNjo2WzZ8dp2 </object> <string key="id">1238</string> </object> - <object class="IBConnectionRecord"> - <object class="IBBindingConnection" key="connection"> - <string key="label">value: values.SPExportMemoryModeLastValue</string> - <reference key="source" ref="829070828"/> - <reference key="destination" ref="965845845"/> - <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="829070828"/> - <reference key="NSDestination" ref="965845845"/> - <string key="NSLabel">value: values.SPExportMemoryModeLastValue</string> - <string key="NSBinding">value</string> - <string key="NSKeyPath">values.SPExportMemoryModeLastValue</string> - <int key="NSNibBindingConnectorVersion">2</int> - </object> - </object> - <string key="id">1389</string> - </object> - <object class="IBConnectionRecord"> - <object class="IBBindingConnection" key="connection"> - <string key="label">selectedIndex: values.SPExportCompressionLastValue</string> - <reference key="source" ref="257072199"/> - <reference key="destination" ref="965845845"/> - <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="257072199"/> - <reference key="NSDestination" ref="965845845"/> - <string key="NSLabel">selectedIndex: values.SPExportCompressionLastValue</string> - <string key="NSBinding">selectedIndex</string> - <string key="NSKeyPath">values.SPExportCompressionLastValue</string> - <int key="NSNibBindingConnectorVersion">2</int> - </object> - </object> - <string key="id">1387</string> - </object> </array> <object class="IBMutableOrderedSet" key="objectRecords"> <array key="orderedObjects"> diff --git a/Resources/Plists/PreferenceDefaults.plist b/Resources/Plists/PreferenceDefaults.plist index 687b4b09..1d55e65a 100644 --- a/Resources/Plists/PreferenceDefaults.plist +++ b/Resources/Plists/PreferenceDefaults.plist @@ -149,8 +149,6 @@ <real>3</real> <key>NewFieldsAllowNulls</key> <true/> - <key>NoBOMforSQLdumpFile</key> - <true/> <key>NullValue</key> <string>NULL</string> <key>PrintBackground</key> @@ -189,8 +187,6 @@ <true/> <key>SPFirstRun</key> <true/> - <key>SQLExportUseCompression</key> - <false/> <key>SSHMultiplexingEnabled</key> <false/> <key>TableInformationPanelCollapsed</key> diff --git a/Source/SPConstants.h b/Source/SPConstants.h index ec190ba4..db51b462 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -67,7 +67,8 @@ typedef NS_ENUM(NSUInteger, SPExportType) { SPDotExport = 3, SPPDFExport = 4, SPHTMLExport = 5, - SPExcelExport = 6 + SPExcelExport = 6, + SPAnyExportType = NSUIntegerMax, // this is a transient type to indicate "no specific choice" }; // Export source constants @@ -402,11 +403,7 @@ extern NSString *SPCSVImportFieldEscapeCharacter; extern NSString *SPCSVImportFirstLineIsHeader; extern NSString *SPCSVFieldImportMappingAlignment; extern NSString *SPImportClipboardTempFileNamePrefix; -extern NSString *SPSQLExportUseCompression; -extern NSString *SPNoBOMforSQLdumpFile; -extern NSString *SPExportLastDirectory; -extern NSString *SPExportFilenameFormat; // legacy -extern NSString *SPExportFilenameFormatIntl; // new, user language independent version +extern NSString *SPLastExportSettings; // Export filename tokens extern NSString *SPFileNameDatabaseTokenName; diff --git a/Source/SPConstants.m b/Source/SPConstants.m index 1c62d37e..16f59f7a 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -202,11 +202,7 @@ NSString *SPCSVImportFirstLineIsHeader = @"CSVImportFirstLineIsHeader" NSString *SPCSVImportLineTerminator = @"CSVImportLineTerminator"; NSString *SPCSVFieldImportMappingAlignment = @"CSVFieldImportMappingAlignment"; NSString *SPImportClipboardTempFileNamePrefix = @"/tmp/_SP_ClipBoard_Import_File_"; -NSString *SPSQLExportUseCompression = @"SQLExportUseCompression"; -NSString *SPNoBOMforSQLdumpFile = @"NoBOMforSQLdumpFile"; -NSString *SPExportLastDirectory = @"SPExportLastDirectory"; -NSString *SPExportFilenameFormat = @"SPExportFilenameFormat"; -NSString *SPExportFilenameFormatIntl = @"CustomExportFilenameFormat"; +NSString *SPLastExportSettings = @"LastExportSettings"; // Export filename tokens NSString *SPFileNameDatabaseTokenName = @"database"; diff --git a/Source/SPExportController.m b/Source/SPExportController.m index 9113decc..2439dd86 100644 --- a/Source/SPExportController.m +++ b/Source/SPExportController.m @@ -42,6 +42,7 @@ #import "SPThreadAdditions.h" #import "SPCustomQuery.h" #import "SPExportController+SharedPrivateAPI.h" +#import "SPExportSettingsPersistence.h" #import <SPMySQL/SPMySQL.h> @@ -63,7 +64,6 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; - (void)_displayExportTypeOptions:(BOOL)display; - (void)_updateExportFormatInformation; - (void)_updateExportAdvancedOptionsLabel; -- (void)_setPreviousExportFilenameAndPath; - (void)_toggleExportButton:(id)uiStateDict; - (void)_toggleExportButtonOnBackgroundThread; @@ -120,8 +120,6 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; heightOffset1 = 0; heightOffset2 = 0; - windowMinWidth = [[self window] minSize].width; - windowMinHeigth = [[self window] minSize].height; prefs = [NSUserDefaults standardUserDefaults]; @@ -150,13 +148,17 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; if (mainNibLoaded) return; mainNibLoaded = YES; + + windowMinWidth = [[self window] minSize].width; + windowMinHeigth = [[self window] minSize].height; // Select the 'selected tables' option [exportInputPopUpButton selectItemAtIndex:SPTableExport]; // Select the SQL tab [[exportTypeTabBar tabViewItemAtIndex:0] setView:exporterView]; - + [exportTypeTabBar selectTabViewItemAtIndex:0]; + // By default a new SQL INSERT statement should be created every 250KiB of data [exportSQLInsertNValueTextField setIntegerValue:250]; @@ -186,14 +188,28 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; * @param source The source of the export. See SPExportSource constants. */ - (void)exportTables:(NSArray *)exportTables asFormat:(SPExportType)format usingSource:(SPExportSource)source -{ - // Select the correct tab - [exportTypeTabBar selectTabViewItemAtIndex:format]; +{ + // set some defaults + [exportCSVNULLValuesAsTextField setStringValue:[prefs stringForKey:SPNullValue]]; + [exportXMLNULLValuesAsTextField setStringValue:[prefs stringForKey:SPNullValue]]; + if(![[exportPathField stringValue] length]) { + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDesktopDirectory, NSAllDomainsMask, YES); + // If found the set the default path to the user's desktop, otherwise use their home directory + [exportPathField setStringValue:([paths count] > 0) ? [paths objectAtIndex:0] : NSHomeDirectory()]; + } - [self _setPreviousExportFilenameAndPath]; + // initially popuplate the tables list + [self refreshTableList:nil]; + + // overwrite defaults with user settings from last export + [self applySettingsFromDictionary:[prefs objectForKey:SPLastExportSettings] error:NULL]; + + // overwrite those with settings for the current export + + // Select the correct tab + if(format != SPAnyExportType) [exportTypeTabBar selectTabViewItemAtIndex:format]; [self updateDisplayedExportFilename]; - [self refreshTableList:nil]; [exporters removeAllObjects]; [exportFiles removeAllObjects]; @@ -281,7 +297,7 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; */ - (IBAction)export:(id)sender { - SPExportType selectedExportType = SPSQLExport; + SPExportType selectedExportType = SPAnyExportType; SPExportSource selectedExportSource = SPTableExport; NSArray *selectedTables = [tablesListInstance selectedTableItems]; @@ -454,7 +470,6 @@ set_input: userInfo:nil]; } [exportPathField setStringValue:path]; - [prefs setObject:path forKey:SPExportLastDirectory]; } }]; } @@ -703,24 +718,8 @@ set_input: { // Perform the export if (returnCode == NSOKButton) { - - // Check whether to save the export filename. Save it if it's not blank and contains at least one - // token - this suggests it's not a one-off filename - if ([[exportCustomFilenameTokenField stringValue] length] < 1) { - [prefs removeObjectForKey:SPExportFilenameFormatIntl]; - } - else { - BOOL saveFilename = NO; - - NSArray *representedObjects = [exportCustomFilenameTokenField objectValue]; - - for (id aToken in representedObjects) - { - if ([aToken isKindOfClass:[SPExportFileNameTokenObject class]]) saveFilename = YES; - } - - if (saveFilename) [prefs setObject:[NSKeyedArchiver archivedDataWithRootObject:representedObjects] forKey:SPExportFilenameFormatIntl]; - } + + [prefs setObject:[self currentSettingsAsDictionary] forKey:SPLastExportSettings]; // If we are about to perform a table export, cache the current number of tables within the list, // refresh the list and then compare the numbers to accommodate situations where new tables are @@ -843,9 +842,6 @@ set_input: [exportDotForceLowerTableNamesCheck setState:(serverLowerCaseTableNameValue == 0)?NSOffState:NSOnState]; } - - [exportCSVNULLValuesAsTextField setStringValue:[prefs stringForKey:SPNullValue]]; - [exportXMLNULLValuesAsTextField setStringValue:[prefs stringForKey:SPNullValue]]; [self _displayExportTypeOptions:(isSQL || isCSV || isXML || isDot)]; [self updateAvailableExportFilenameTokens]; @@ -973,29 +969,6 @@ set_input: } /** - * Sets the previous export filename and path if available. - */ -- (void)_setPreviousExportFilenameAndPath -{ - id o; - // Restore the export filename if it exists, and update the display - if ((o = [prefs objectForKey:SPExportFilenameFormatIntl])) { - [exportCustomFilenameTokenField setObjectValue:[NSKeyedUnarchiver unarchiveObjectWithData:o]]; - } - - // If a directory has previously been selected, reselect it - if ((o = [prefs objectForKey:SPExportLastDirectory])) { - [exportPathField setStringValue:o]; - } - else { - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDesktopDirectory, NSAllDomainsMask, YES); - - // If found the set the default path to the user's desktop, otherwise use their home directory - [exportPathField setStringValue:([paths count] > 0) ? [paths objectAtIndex:0] : NSHomeDirectory()]; - } -} - -/** * Enables or disables the export button based on the state of various interface controls. * * @param uiStateDict A dictionary containing the state of various UI controls. diff --git a/Source/SPExportSettingsPersistence.m b/Source/SPExportSettingsPersistence.m index 38a4ed84..29a981af 100644 --- a/Source/SPExportSettingsPersistence.m +++ b/Source/SPExportSettingsPersistence.m @@ -46,7 +46,6 @@ static inline void SetOnOff(NSNumber *ref,id obj); @interface SPExportController (Private) - (void)_updateExportAdvancedOptionsLabel; -- (void)_switchTab; @end @@ -463,7 +462,7 @@ static inline void SetOnOff(NSNumber *ref,id obj); // token pool is only valid once the schema object selection is done [self updateAvailableExportFilenameTokens]; - if((o = [dict objectForKey:@"customFilename"])) [self setCustomFilenameFromArray:o]; + if((o = [dict objectForKey:@"customFilename"]) && [o isKindOfClass:[NSArray class]]) [self setCustomFilenameFromArray:o]; return YES; } |