aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPExportController.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-08-12 12:56:20 +0000
committerstuconnolly <stuart02@gmail.com>2010-08-12 12:56:20 +0000
commitfc02f913371d522a025c47824fafeba8e3174da1 (patch)
tree086561fd418bf35139dda47d698d7923196a4f30 /Source/SPExportController.m
parent50f15c41936be3fb62384834bb3629e09018e67b (diff)
downloadsequelpro-fc02f913371d522a025c47824fafeba8e3174da1.tar.gz
sequelpro-fc02f913371d522a025c47824fafeba8e3174da1.tar.bz2
sequelpro-fc02f913371d522a025c47824fafeba8e3174da1.zip
Various export enhancements and fixes, including:
- A new SPExportFile class, providing an abstract interface to the handling and creation of export files. - Enables the centralisation of all file/file handle creation logic as well as better support for handling situations where files fail to be created, including files that already exist at the export location. - New SPExportFileHandleStatus constants to support the reporting of file handle creation. - Update SPExporter to use the new file class instead of directly using an instance of SPFileHandle. - Add the necessary logic to deal with files that already exist on disk, by providing the user with 3 options: cancel the export, ignore the files in question or overwrite them. We might want to enhance this to make new files sequential in name to prevent overwriting. Fixes issue #742. - New SPExportFileUtilities category, which centralises all the logic relating to writing export type headers as well as dealing with problems occurred during file/file handle creation. - Improve feedback given on the export progress sheet during export initialisation. - Tidy up and improve comments.
Diffstat (limited to 'Source/SPExportController.m')
-rw-r--r--Source/SPExportController.m40
1 files changed, 26 insertions, 14 deletions
diff --git a/Source/SPExportController.m b/Source/SPExportController.m
index b7d26fef..11198472 100644
--- a/Source/SPExportController.m
+++ b/Source/SPExportController.m
@@ -34,6 +34,7 @@
#import "SPStringAdditions.h"
#import "SPConstants.h"
#import "SPGrowlController.h"
+#import "SPExportFile.h"
@interface SPExportController (PrivateAPI)
@@ -56,7 +57,7 @@
#pragma mark Initialization
/**
- * Initializes an instance of SPExportController
+ * Initializes an instance of SPExportController.
*/
- (id)init
{
@@ -119,12 +120,6 @@
// 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()];
-
- // Register to receive notifications of a change in selection of the CSV field separator
- /*[[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(comboBoxSelectionDidChange:)
- name:NSComboBoxSelectionDidChangeNotification
- object:nil];*/
}
#pragma mark -
@@ -137,6 +132,8 @@
* either of these views are not active then the default source are the currently selected tables. If no
* tables are currently selected then all tables are checked. Note that in this instance the default export
* type is SQL where as in the case of filtered or query result export the default type is CSV.
+ *
+ * @param sender The caller (can be anything or nil as it is not currently used).
*/
- (IBAction)export:(id)sender
{
@@ -173,6 +170,10 @@
/**
* Displays the export window with the supplied tables and export type/format selected.
+ *
+ * @param exportTables The array of table names to be exported
+ * @param format The export format to be used. See SPExportType constants.
+ * @param source The source of the export. See SPExportSource constants.
*/
- (void)exportTables:(NSArray *)exportTables asFormat:(SPExportType)format usingSource:(SPExportSource)source
{
@@ -184,7 +185,8 @@
[self refreshTableList:self];
- if ([exportFiles count] > 0) [exportFiles removeAllObjects];
+ [exporters removeAllObjects];
+ [exportFiles removeAllObjects];
// Select the 'selected tables' source option
[exportInputPopUpButton selectItemAtIndex:source];
@@ -228,6 +230,8 @@
/**
* Opens the errors sheet and displays the supplied errors string.
+ *
+ * @param errors The errors string to be displayed
*/
- (void)openExportErrorsSheetWithString:(NSString *)errors
{
@@ -378,13 +382,9 @@
[operationQueue cancelAllOperations];
// Loop the cached export file paths and remove them from disk if they exist
- NSFileManager *fileManager = [NSFileManager defaultManager];
-
- for (NSString *filePath in exportFiles)
+ for (SPExportFile *file in exportFiles)
{
- if ([fileManager fileExistsAtPath:filePath]) {
- [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil];
- }
+ [file delete];
}
// Close the progress sheet
@@ -397,6 +397,10 @@
// Re-enable the cancel button for future exports
[sender setEnabled:YES];
+
+ // Finally get rid of all the exporters and files
+ [exportFiles removeAllObjects];
+ [exporters removeAllObjects];
}
/**
@@ -705,6 +709,8 @@
/**
* 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.
*/
- (void)_toggleExportButton:(id)uiStateDict
{
@@ -789,6 +795,8 @@
/**
* Enables or disables the export button based on the supplied number (boolean).
+ *
+ * @param enable A boolean indicating the state.
*/
- (void)_toggleExportButtonWithBool:(NSNumber *)enable
{
@@ -798,6 +806,8 @@
/**
* Resizes the export window's height by the supplied delta, while retaining the position of
* all interface controls to accommodate the custom filename view.
+ *
+ * @param delta The height delta for which the height should be adjusted for.
*/
- (void)_resizeWindowForCustomFilenameViewByHeightDelta:(NSInteger)delta
{
@@ -855,6 +865,8 @@
/**
* Resizes the export window's height by the supplied delta, while retaining the position of
* all interface controls to accommodate the advanced options view.
+ *
+ * @param delta The height delta for which the height should be adjusted for.
*/
- (void)_resizeWindowForAdvancedOptionsViewByHeightDelta:(NSInteger)delta
{