aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-07-25 09:16:20 +0000
committerstuconnolly <stuart02@gmail.com>2010-07-25 09:16:20 +0000
commitf578b247bed73fe2b8a7f0fc2efbe0b191890df9 (patch)
treea774c78f431eac291bb329d358c18cf112445de2 /Source
parentc073e11612e36a7f9b8d7033faf08d663dd40c1f (diff)
downloadsequelpro-f578b247bed73fe2b8a7f0fc2efbe0b191890df9.tar.gz
sequelpro-f578b247bed73fe2b8a7f0fc2efbe0b191890df9.tar.bz2
sequelpro-f578b247bed73fe2b8a7f0fc2efbe0b191890df9.zip
Make the export dialog a little smarter with regard to the current context. For example:
If either the table content or custom query editor views are active and there is data available, these options will be selected as the export source ('Filtered' or 'Query Result'). If 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. Also remove some old export methods. Related to issue #610.
Diffstat (limited to 'Source')
-rw-r--r--Source/SPDatabaseDocument.h3
-rw-r--r--Source/SPDatabaseDocument.m30
-rw-r--r--Source/SPExportController.h2
-rw-r--r--Source/SPExportController.m41
4 files changed, 50 insertions, 26 deletions
diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h
index 9f04fc71..40a221d0 100644
--- a/Source/SPDatabaseDocument.h
+++ b/Source/SPDatabaseDocument.h
@@ -258,6 +258,7 @@
- (IBAction)focusOnTableContentFilter:(id)sender;
- (IBAction)focusOnTableListFilter:(id)sender;
- (IBAction)export:(id)sender;
+
- (IBAction)exportSelectedTablesAs:(id)sender;
// Other methods
@@ -307,8 +308,6 @@
- (IBAction)saveConnectionSheet:(id)sender;
- (IBAction)import:(id)sender;
- (IBAction)importFromClipboard:(id)sender;
-- (IBAction)exportTable:(id)sender;
-- (IBAction)exportMultipleTables:(id)sender;
- (IBAction)viewStructure:(id)sender;
- (IBAction)viewContent:(id)sender;
- (IBAction)viewQuery:(id)sender;
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index a140db3f..43b5e844 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -2348,22 +2348,19 @@
}
/**
- * Opens the export dialog on the SQL dump tab with the selected tables checked for export. If no tables
- * are selected then all tables are checked.
+ * Exports the selected tables in the chosen file format.
*/
-- (IBAction)export:(id)sender
+- (IBAction)exportSelectedTablesAs:(id)sender
{
- NSArray *tables = [tablesListInstance selectedTableItems];
-
- [exportControllerInstance exportTables:([tables count]) ? tables : nil asFormat:SPSQLExport usingSource:SPTableExport];
+ [exportControllerInstance exportTables:[tablesListInstance selectedTableItems] asFormat:[sender tag] usingSource:SPTableExport];
}
/**
- * Exports the selected tables in the chosen file format.
+ * Opens the data export dialog.
*/
-- (IBAction)exportSelectedTablesAs:(id)sender
+- (IBAction)export:(id)sender
{
- [exportControllerInstance exportTables:[tablesListInstance selectedTableItems] asFormat:[sender tag] usingSource:SPTableExport];
+ [exportControllerInstance export:self];
}
#pragma mark -
@@ -3453,16 +3450,6 @@
[tableDumpInstance importFromClipboard];
}
-- (IBAction)exportTable:(id)sender
-{
- return [self export:sender];
-}
-
-- (IBAction)exportMultipleTables:(id)sender
-{
- return [self export:sender];
-}
-
/*
* Show the MySQL Help TOC of the current MySQL connection
* Invoked by the MainMenu > Help > MySQL Help
@@ -3508,7 +3495,6 @@
}
if ([menuItem action] == @selector(import:) ||
- [menuItem action] == @selector(exportMultipleTables:) ||
[menuItem action] == @selector(removeDatabase:) ||
[menuItem action] == @selector(copyDatabase:) ||
[menuItem action] == @selector(renameDatabase:))
@@ -3537,10 +3523,6 @@
return YES;
}
- if ([menuItem action] == @selector(exportTable:)) {
- return ([self database] != nil && [self table] != nil);
- }
-
if ([menuItem action] == @selector(printDocument:)) {
return (([self database] != nil && [[tablesListInstance valueForKeyPath:@"tablesListView"] numberOfSelectedRows] == 1)
// if Custom Query Tab is active the textView will handle printDocument by itself
diff --git a/Source/SPExportController.h b/Source/SPExportController.h
index b63f7c73..1868ec00 100644
--- a/Source/SPExportController.h
+++ b/Source/SPExportController.h
@@ -237,6 +237,8 @@
*/
@property(readwrite, assign) MCPConnection *connection;
+- (IBAction)export:(id)sender;
+
- (void)exportTables:(NSArray *)table asFormat:(SPExportType)format usingSource:(SPExportSource)source;
- (void)openExportErrorsSheetWithString:(NSString *)errors;
- (void)displayExportFinishedGrowlNotification;
diff --git a/Source/SPExportController.m b/Source/SPExportController.m
index 89f4fdce..0a36a32c 100644
--- a/Source/SPExportController.m
+++ b/Source/SPExportController.m
@@ -130,6 +130,47 @@
#pragma mark IB action methods
/**
+ * Opens the export dialog selecting the appropriate export type and source based on the current context.
+ * For example, if either the table content view or custom query editor views are active and there is
+ * data available, these options will be selected as the export source ('Filtered' or 'Query Result'). If
+ * 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.
+ */
+- (IBAction)export:(id)sender
+{
+ SPExportType exportType = SPSQLExport;
+ SPExportSource exportSource = SPTableExport;
+
+ NSArray *tables = [tablesListInstance selectedTableItems];
+
+ BOOL isCustomQuerySelected = ([tableDocumentInstance isCustomQuerySelected] && ([[customQueryInstance currentResult] count] > 1));
+ BOOL isContentSelected = ([[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableContent] && ([[tableContentInstance currentResult] count] > 1));
+
+ if (isContentSelected) {
+ tables = nil;
+ exportType = SPCSVExport;
+ exportSource = SPFilteredExport;
+ }
+ else if (isCustomQuerySelected) {
+ tables = nil;
+ exportType = SPCSVExport;
+ exportSource = SPQueryExport;
+ }
+ else {
+ tables = ([tables count]) ? tables : nil;
+ }
+
+ [self exportTables:tables asFormat:exportType usingSource:exportSource];
+
+ // Ensure UI validation
+ [self switchInput:exportInputPopUpButton];
+}
+
+#pragma mark -
+#pragma mark Export methods
+
+/**
* Displays the export window with the supplied tables and export type/format selected.
*/
- (void)exportTables:(NSArray *)exportTables asFormat:(SPExportType)format usingSource:(SPExportSource)source