aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-08-15 15:01:44 +0000
committerBibiko <bibiko@eva.mpg.de>2010-08-15 15:01:44 +0000
commit5dc4311e9a135ba86b57972240db8ee25b5e77bd (patch)
tree2263fa2a2c2c18eabde8e4720ff9cfda54a703ca
parent6ba9531a7f5bd5430e3c1e38956a766912701a8f (diff)
downloadsequelpro-5dc4311e9a135ba86b57972240db8ee25b5e77bd.tar.gz
sequelpro-5dc4311e9a135ba86b57972240db8ee25b5e77bd.tar.bz2
sequelpro-5dc4311e9a135ba86b57972240db8ee25b5e77bd.zip
Improve export menu item validation by disabling export as XML and CSV when only multiple procs and/or functions are selected
-rw-r--r--Source/SPDatabaseDocument.m22
1 files changed, 16 insertions, 6 deletions
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index 42d42931..21d5034a 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -3522,15 +3522,25 @@
NSInteger tag = [menuItem tag];
NSInteger type = [tablesListInstance tableType];
+ NSInteger numberOfSelectedItems = [[[tablesListInstance valueForKeyPath:@"tablesListView"] selectedRowIndexes] count];
- BOOL enable = (([self database] != nil) && ([[[tablesListInstance valueForKeyPath:@"tablesListView"] selectedRowIndexes] count]));
+ BOOL enable = (([self database] != nil) && numberOfSelectedItems);
- if (type == SPTableTypeTable) {
- return enable;
- }
- else if ((type == SPTableTypeProc) || (type == SPTableTypeFunc)) {
+ // Enable all export formats if at least one table/view is selected
+ if (numberOfSelectedItems == 1) {
+ if (type == SPTableTypeTable || type == SPTableTypeView) {
+ return enable;
+ }
+ else if ((type == SPTableTypeProc) || (type == SPTableTypeFunc)) {
+ return (enable && (tag == SPSQLExport));
+ }
+ } else {
+ for(NSNumber *type in [tablesListInstance selectedTableTypes])
+ if([type intValue] == SPTableTypeTable || [type intValue] == SPTableTypeView)
+ return enable;
+
return (enable && (tag == SPSQLExport));
- }
+ }
}
if ([menuItem action] == @selector(import:) ||