aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPExportController.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2012-01-22 12:19:21 +0000
committerstuconnolly <stuart02@gmail.com>2012-01-22 12:19:21 +0000
commit1d7ed99d602bf9c7aa4ea40a9a2ab6458864e51f (patch)
tree6c08ad29618ea02caf302180706d010c90cd57e0 /Source/SPExportController.m
parente23ba5155a53c43a106ac9646f51321ccc7d86f4 (diff)
downloadsequelpro-1d7ed99d602bf9c7aa4ea40a9a2ab6458864e51f.tar.gz
sequelpro-1d7ed99d602bf9c7aa4ea40a9a2ab6458864e51f.tar.bz2
sequelpro-1d7ed99d602bf9c7aa4ea40a9a2ab6458864e51f.zip
Bring outlinew view branch up to date with trunk (r3375:3468).
Diffstat (limited to 'Source/SPExportController.m')
-rw-r--r--Source/SPExportController.m96
1 files changed, 69 insertions, 27 deletions
diff --git a/Source/SPExportController.m b/Source/SPExportController.m
index 0ff78c1f..21ab667b 100644
--- a/Source/SPExportController.m
+++ b/Source/SPExportController.m
@@ -55,6 +55,7 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
- (void)_displayExportTypeOptions:(BOOL)display;
- (void)_updateExportFormatInformation;
- (void)_updateExportAdvancedOptionsLabel;
+- (void)_setPreviousExportFilenameAndPath;
- (void)_toggleExportButton:(id)uiStateDict;
- (void)_toggleExportButtonOnBackgroundThread;
@@ -83,7 +84,9 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
[self setExportCancelled:NO];
[self setExportToMultipleFiles:YES];
-
+
+ mainNibLoaded = NO;
+
exportType = SPSQLExport;
exportSource = SPTableExport;
exportTableCount = 0;
@@ -119,7 +122,12 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
* Upon awakening select the first toolbar item
*/
- (void)awakeFromNib
-{
+{
+ // As this controller also loads its own nib, it may call awakeFromNib multiple times; perform setup only once.
+ if (mainNibLoaded) return;
+
+ mainNibLoaded = YES;
+
// Select the 'selected tables' option
[exportInputPopUpButton selectItemAtIndex:SPTableExport];
@@ -135,17 +143,6 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
// Set the progress indicator's max value
[exportProgressIndicator setMaxValue:(NSInteger)[exportProgressIndicator bounds].size.width];
- // If a directory has previously been selected, reselect it
- if ([prefs objectForKey:SPExportLastDirectory]) {
- [exportPathField setStringValue:[prefs objectForKey:SPExportLastDirectory]];
- } 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()];
- }
-
// Empty the tokenizing character set for the filename field
[exportCustomFilenameTokenField setTokenizingCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@""]];
@@ -170,12 +167,9 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
// Select the correct tab
[exportTypeTabBar selectTabViewItemAtIndex:format];
- // Restore the export filename if it exists, and update the display
- if ([prefs objectForKey:SPExportFilenameFormat]) {
- [exportCustomFilenameTokenField setObjectValue:[NSKeyedUnarchiver unarchiveObjectWithData:[prefs objectForKey:SPExportFilenameFormat]]];
- }
- [self updateDisplayedExportFilename];
+ [self _setPreviousExportFilenameAndPath];
+ [self updateDisplayedExportFilename];
[self refreshTableList:nil];
[exporters removeAllObjects];
@@ -582,6 +576,15 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
*/
- (IBAction)toggleSQLIncludeStructure:(id)sender
{
+ if (![sender state])
+ {
+ [exportSQLIncludeDropSyntaxCheck setState:NSOffState];
+ }
+
+ [exportSQLIncludeDropSyntaxCheck setEnabled:[sender state]];
+ [exportSQLIncludeAutoIncrementValueButton setEnabled:[sender state]];
+
+ [[exportTableList tableColumnWithIdentifier:SPTableViewDropColumnID] setHidden:(![sender state])];
[[exportTableList tableColumnWithIdentifier:SPTableViewStructureColumnID] setHidden:(![sender state])];
[self _toggleExportButtonOnBackgroundThread];
@@ -641,12 +644,17 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
// token - this suggests it's not a one-off filename
if (![exportCustomFilenameTokenField stringValue]) {
[prefs removeObjectForKey:SPExportFilenameFormat];
- } else {
+ }
+ else {
BOOL saveFilename = NO;
+
NSArray *representedObjects = [exportCustomFilenameTokenField objectValue];
- for (id aToken in representedObjects) {
+
+ for (id aToken in representedObjects)
+ {
if ([aToken isKindOfClass:[SPExportFileNameTokenObject class]]) saveFilename = YES;
}
+
if (saveFilename) [prefs setObject:[NSKeyedArchiver archivedDataWithRootObject:representedObjects] forKey:SPExportFilenameFormat];
}
@@ -696,7 +704,7 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{
if ([menuItem action] == @selector(exportCustomQueryResultAsFormat:)) {
- return ([[customQueryInstance currentResult] count] > 1);
+ return (([[customQueryInstance currentResult] count] > 1) && (![tableDocumentInstance isProcessing]));
}
return YES;
@@ -760,7 +768,7 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
// When exporting to SQL, only the selected tables option should be enabled
if (isSQL) {
- // Programmatically changing the selected item of a popup button does not fire it's action, so updated
+ // Programmatically changing the selected item of a popup button does not fire it's action, so update
// the selected export source manually.
exportSource = SPTableExport;
@@ -786,13 +794,18 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
// When switching to Dot export, ensure the server's lower_case_table_names value is checked the first time
// to set the export's link case sensitivity setting
if (isDot && serverLowerCaseTableNameValue == NSNotFound) {
+
MCPResult *caseResult = [connection queryString:@"SHOW VARIABLES LIKE 'lower_case_table_names'"];
+
[caseResult setReturnDataAsStrings:YES];
+
if ([caseResult numOfRows] == 1) {
serverLowerCaseTableNameValue = [[[caseResult fetchRowAsDictionary] objectForKey:@"Value"] integerValue];
- } else {
+ }
+ else {
serverLowerCaseTableNameValue = 0;
}
+
[exportDotForceLowerTableNamesCheck setState:(serverLowerCaseTableNameValue == 0)?NSOffState:NSOnState];
}
@@ -872,10 +885,14 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
switch (exportType) {
case SPCSVExport:
if ([exportFilePerTableCheck state]) break;
+
NSUInteger numberOfTables = 0;
- for (NSMutableArray *eachTable in tables) {
+
+ for (NSMutableArray *eachTable in tables)
+ {
if ([[eachTable objectAtIndex:2] boolValue]) numberOfTables++;
}
+
if (numberOfTables <= 1) break;
case SPXMLExport:
case SPDotExport:
@@ -902,15 +919,18 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
if ([exportProcessLowMemoryButton state]) {
[optionsSummary addObject:NSLocalizedString(@"Low memory", @"Low memory export summary")];
- } else {
+ }
+ else {
[optionsSummary addObject:NSLocalizedString(@"Standard memory", @"Standard memory export summary")];
}
if ([exportOutputCompressionFormatPopupButton indexOfSelectedItem] == SPNoCompression) {
[optionsSummary addObject:NSLocalizedString(@"no compression", @"No compression export summary - within a sentence")];
- } else if ([exportOutputCompressionFormatPopupButton indexOfSelectedItem] == SPGzipCompression) {
+ }
+ else if ([exportOutputCompressionFormatPopupButton indexOfSelectedItem] == SPGzipCompression) {
[optionsSummary addObject:NSLocalizedString(@"Gzip compression", @"Gzip compression export summary - within a sentence")];
- } else if ([exportOutputCompressionFormatPopupButton indexOfSelectedItem] == SPBzip2Compression) {
+ }
+ else if ([exportOutputCompressionFormatPopupButton indexOfSelectedItem] == SPBzip2Compression) {
[optionsSummary addObject:NSLocalizedString(@"bzip2 compression", @"bzip2 compression export summary - within a sentence")];
}
@@ -918,6 +938,28 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
}
/**
+ * Sets the previous export filename and path if available.
+ */
+- (void)_setPreviousExportFilenameAndPath
+{
+ // Restore the export filename if it exists, and update the display
+ if ([prefs objectForKey:SPExportFilenameFormat]) {
+ [exportCustomFilenameTokenField setObjectValue:[NSKeyedUnarchiver unarchiveObjectWithData:[prefs objectForKey:SPExportFilenameFormat]]];
+ }
+
+ // If a directory has previously been selected, reselect it
+ if ([prefs objectForKey:SPExportLastDirectory]) {
+ [exportPathField setStringValue:[prefs objectForKey:SPExportLastDirectory]];
+ }
+ 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.