diff options
author | stuconnolly <stuart02@gmail.com> | 2010-05-24 18:07:43 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2010-05-24 18:07:43 +0000 |
commit | bbe0f861dd4e3ab99aa3d555d3fc5db5ee5ae39d (patch) | |
tree | 1cf7d41f091854e8e2288946684267ce0f8ceaf4 /Source/SPExportController.h | |
parent | d48005bd9b34f2fb1afd31f7487b7bbf8b9b978f (diff) | |
download | sequelpro-bbe0f861dd4e3ab99aa3d555d3fc5db5ee5ae39d.tar.gz sequelpro-bbe0f861dd4e3ab99aa3d555d3fc5db5ee5ae39d.tar.bz2 sequelpro-bbe0f861dd4e3ab99aa3d555d3fc5db5ee5ae39d.zip |
Merge export redesign branch back into trunk.
Includes a completely redesign approach to all export data types based on the use of NSOperation subclasses. CSV, SQL, XML and dot export types are currently functional, while the source files for PDF and HTML export types exist they are to be implemented, but are currently hidden from the interface.
Also includes the following:
- Completely redesigned export interface.
- The ability to customize CSV NULL values.
- The ability to specify whether the UTF-8 BOM should be used in SQL dumps.
- The ability to specify whether BLOB fields are output as hex or plain text during SQL dumps. Defaults to hex.
- Exporting currently selected tables via the tables list context menu.
Outstanding issues:
- Not all progress indicators for all export types are functional (or functioning correctly).
- A few issues related to the introduction of only exporting the content and create and drop syntax of specific tables during SQL dumps.
Needs some serious testing and benchmarking to ensure it replicates the current export functionality.
Diffstat (limited to 'Source/SPExportController.h')
-rw-r--r-- | Source/SPExportController.h | 260 |
1 files changed, 187 insertions, 73 deletions
diff --git a/Source/SPExportController.h b/Source/SPExportController.h index 773b678d..0865fef3 100644 --- a/Source/SPExportController.h +++ b/Source/SPExportController.h @@ -5,6 +5,7 @@ // sequel-pro // // Created by Ben Perry (benperry.com.au) on 21/02/09. +// Modified by Stuart Connolly (stuconnolly.com) // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -23,118 +24,231 @@ // More info at <http://code.google.com/p/sequel-pro/> #import <Cocoa/Cocoa.h> -#import <MCPKit/MCPKit.h> -#import "SPExporterDataAccess.h" +#import "SPConstants.h" -#import "SPLogger.h" +@class MCPConnection, BWAnchoredButtonBar; -// Export type constants -enum { - SP_SQL_EXPORT = 1, - SP_CSV_EXPORT = 2, - SP_XML_EXPORT = 3, - SP_PDF_EXPORT = 4, - SP_HTML_EXPORT = 5, - SP_EXCEL_EXPORT = 6 -}; -typedef NSUInteger SPExportType; - -// Export source constants -enum { - SP_FILTERED_EXPORT = 1, - SP_CUSTOM_QUERY_EXPORT = 2, - SP_TABLE_EXPORT = 3 -}; -typedef NSUInteger SPExportSource; - -@interface SPExportController : NSObject <SPExporterDataAccess> +/** + * @class SPExportController SPExportController.m + * + * @author Stuart Connolly http://stuconnolly.com/ + * + * Export controller. + */ +@interface SPExportController : NSWindowController { - // Table document + // Controllers IBOutlet id tableDocumentInstance; - - // Tables list + IBOutlet id tableContentInstance; + IBOutlet id customQueryInstance; IBOutlet id tablesListInstance; - - // Table data IBOutlet id tableDataInstance; // Export window - IBOutlet id exportWindow; - IBOutlet id exportToolbar; - IBOutlet id exportPathField; - IBOutlet id exportTableList; - IBOutlet id exportTabBar; - IBOutlet id exportInputMatrix; - IBOutlet id exportFilePerTableCheck; - IBOutlet id exportFilePerTableNote; - IBOutlet id exportProcessLowMemory; + IBOutlet NSButton *exportButton; + IBOutlet NSToolbar *exportToolbar; + IBOutlet NSTextField *exportPathField; + IBOutlet NSTableView *exportTableList; + IBOutlet NSTabView *exportTabBar; + IBOutlet NSMatrix *exportInputMatrix; + IBOutlet NSButton *exportFilePerTableCheck; + IBOutlet NSTextField *exportFilePerTableNote; + IBOutlet NSButton *exportSelectAllTablesButton; + IBOutlet NSButton *exportDeselectAllTablesButton; + IBOutlet NSButton *exportRefreshTablesButton; + IBOutlet NSScrollView *exportTablelistScrollView; + + // Errors sheet + IBOutlet NSWindow *errorsWindow; + IBOutlet NSTextView *errorsTextView; + + // Advanced options view + IBOutlet NSButton *exportAdvancedOptionsViewButton; + IBOutlet NSView *exportAdvancedOptionsView; + IBOutlet NSButton *exportAdvancedOptionsViewLabelButton; + IBOutlet NSButton *exportUseUTF8BOMButton; + IBOutlet NSButton *exportCompressOutputFile; + IBOutlet NSButton *exportProcessLowMemoryButton; + IBOutlet NSTextField *exportCSVNULLValuesAsTextField; + + IBOutlet BWAnchoredButtonBar *exportTableListButtonBar; // Export progress sheet - IBOutlet id exportProgressWindow; - IBOutlet id exportProgressTitle; - IBOutlet id exportProgressText; - IBOutlet id exportProgressIndicator; + IBOutlet NSWindow *exportProgressWindow; + IBOutlet NSTextField *exportProgressTitle; + IBOutlet NSTextField *exportProgressText; + IBOutlet NSProgressIndicator *exportProgressIndicator; + + // Custom filename view + IBOutlet NSView *exportCustomFilenameView; + IBOutlet NSButton *exportCustomFilenameButton; + IBOutlet NSTokenField *exportCustomFilenameTokenField; + IBOutlet NSTokenField *exportCustomFilenameTokensField; + IBOutlet NSTextField *exportCustomFilenameExampleTextField; // SQL - IBOutlet id exportSQLIncludeStructureCheck; - IBOutlet id exportSQLIncludeDropSyntaxCheck; - IBOutlet id exportSQLIncludeErrorsCheck; + IBOutlet NSButton *exportSQLIncludeStructureCheck; + IBOutlet NSButton *exportSQLIncludeDropSyntaxCheck; + IBOutlet NSButton *exportSQLIncludeContentCheck; + IBOutlet NSButton *exportSQLIncludeErrorsCheck; + IBOutlet NSButton *exportSQLBLOBFieldsAsHexCheck; // Excel - IBOutlet id exportExcelSheetOrFilePerTableMatrix; + IBOutlet NSMatrix *exportExcelSheetOrFilePerTableMatrix; // CSV - IBOutlet id exportCSVIncludeFieldNamesCheck; - IBOutlet id exportCSVFieldsTerminatedField; - IBOutlet id exportCSVFieldsWrappedField; - IBOutlet id exportCSVFieldsEscapedField; - IBOutlet id exportCSVLinesTerminatedField; + IBOutlet NSButton *exportCSVIncludeFieldNamesCheck; + IBOutlet NSComboBox *exportCSVFieldsTerminatedField; + IBOutlet NSComboBox *exportCSVFieldsWrappedField; + IBOutlet NSComboBox *exportCSVFieldsEscapedField; + IBOutlet NSComboBox *exportCSVLinesTerminatedField; // HTML - IBOutlet id exportHTMLIncludeStructureCheck; - IBOutlet id exportHTMLIncludeHeadAndBodyTagsCheck; - - // XML - IBOutlet id exportXMLIncludeStructureCheck; + IBOutlet NSButton *exportHTMLIncludeStructureCheck; // PDF - IBOutlet id exportPDFIncludeStructureCheck; - - // Token name view - IBOutlet id tokenNameView; - IBOutlet id tokenNameField; - IBOutlet id tokenNameTokensField; - IBOutlet id exampleNameLabel; + IBOutlet NSButton *exportPDFIncludeStructureCheck; - // Cancellation flag + /** + * Cancellation flag + */ BOOL exportCancelled; - // Current database's tables + /** + * Multi-file export flag + */ + BOOL exportToMultipleFiles; + + /** + * Create custom filename flag + */ + BOOL createCustomFilename; + + /** + * Number of tables being exported + */ + NSUInteger exportTableCount; + + /** + * Index of the current table being exported + */ + NSUInteger currentTableExportIndex; + + /** + * Export type label + */ + NSString *exportTypeLabel; + + /** + * Export filename + */ + NSString *exportFilename; + + /** + * Current database's tables + */ NSMutableArray *tables; - // Database connection + /** + * Database connection + */ MCPConnection *connection; - // Concurrent operation queue + /** + * Concurrent operation queue + */ NSOperationQueue *operationQueue; - // Table/export operation mapping - NSMutableDictionary *tableExportMapping; + /** + * Exporters + */ + NSMutableArray *exporters; + + /** + * Global export file handle + */ + NSFileHandle *exportFileHandle; + + /** + * Export type + */ + SPExportType exportType; + + /** + * Export source + */ + SPExportSource exportSource; + + /** + * Available filename tokens + */ + NSString *availableFilenameTokens; + + /** + * Display advanced view flag + */ + BOOL showAdvancedView; + + /** + * User defaults + */ + NSUserDefaults *prefs; + + /** + * Current toolbar item + */ + NSToolbarItem *currentToolbarItem; + + /** + * Previous connection encoding + */ + NSString *sqlPreviousConnectionEncoding; + + /** + * Previous connection encoding was via Latin1 + */ + BOOL sqlPreviousConnectionEncodingViaLatin1; - // Top-level nib objects that require releasing on dealloc - NSMutableArray *nibObjectsToRelease; + NSInteger heightOffset; + NSUInteger windowMinWidth; + NSUInteger windowMinHeigth; } -@property (readwrite, assign) BOOL exportCancelled; -@property (readwrite, assign) MCPConnection *connection; +/** + * @property exportCancelled Export cancellation flag + */ +@property(readwrite, assign) BOOL exportCancelled; + +/** + * @property exportToMultipleFiles Export to multiple files flag + */ +@property(readwrite, assign) BOOL exportToMultipleFiles; + +/** + * @property connection Database connection + */ +@property(readwrite, assign) MCPConnection *connection; -// IB action methods - (void)export; +- (void)exportTables:(NSArray *)table asFormat:(SPExportType)format; +- (void)openExportErrorsSheetWithString:(NSString *)errors; +- (void)displayExportFinishedGrowlNotification; +- (NSString *)expandCustomFilenameFormatFromString:(NSString *)format usingTableName:(NSString *)table; + +// IB action methods - (IBAction)closeSheet:(id)sender; - (IBAction)switchTab:(id)sender; - (IBAction)switchInput:(id)sender; - (IBAction)cancelExport:(id)sender; - (IBAction)changeExportOutputPath:(id)sender; +- (IBAction)refreshTableList:(id)sender; +- (IBAction)selectDeselectAllTables:(id)sender; +- (IBAction)toggleCustomFilenameFormat:(id)sender; +- (IBAction)toggleAdvancedExportOptionsView:(id)sender; + +- (IBAction)toggleSQLIncludeStructure:(id)sender; +- (IBAction)toggleSQLIncludeContent:(id)sender; +- (IBAction)toggleSQLIncludeDropSyntax:(id)sender; @end |