aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/MainMenu.xib11
-rw-r--r--Source/CMCopyTable.h1
-rw-r--r--Source/CMCopyTable.m43
3 files changed, 37 insertions, 18 deletions
diff --git a/Interfaces/English.lproj/MainMenu.xib b/Interfaces/English.lproj/MainMenu.xib
index a51aa337..1cc2960d 100644
--- a/Interfaces/English.lproj/MainMenu.xib
+++ b/Interfaces/English.lproj/MainMenu.xib
@@ -12,7 +12,7 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="1059"/>
+ <integer value="498"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -691,6 +691,7 @@
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="625762401"/>
<reference key="NSMixedImage" ref="315854375"/>
+ <int key="NSTag">2001</int>
</object>
<object class="NSMenuItem" id="609933882">
<reference key="NSMenu" ref="71086556"/>
@@ -700,7 +701,7 @@
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="625762401"/>
<reference key="NSMixedImage" ref="315854375"/>
- <int key="NSTag">2001</int>
+ <int key="NSTag">2002</int>
</object>
<object class="NSMenuItem" id="121139500">
<reference key="NSMenu" ref="71086556"/>
@@ -710,7 +711,7 @@
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="625762401"/>
<reference key="NSMixedImage" ref="315854375"/>
- <int key="NSTag">2002</int>
+ <int key="NSTag">2003</int>
</object>
<object class="NSMenuItem" id="892596559">
<reference key="NSMenu" ref="71086556"/>
@@ -5183,7 +5184,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{428, 215}, {235, 333}}</string>
+ <string>{{428, 491}, {235, 333}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{180, 535}, {182, 253}}</string>
@@ -6139,7 +6140,6 @@
<string>checksumTable:</string>
<string>chooseDatabase:</string>
<string>chooseEncoding:</string>
- <string>closeErrorConnectionSheet:</string>
<string>closePanelSheet:</string>
<string>closePasswordSheet:</string>
<string>closeSheet:</string>
@@ -6224,7 +6224,6 @@
<string>id</string>
<string>id</string>
<string>id</string>
- <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
diff --git a/Source/CMCopyTable.h b/Source/CMCopyTable.h
index 03fc53cb..6baa2527 100644
--- a/Source/CMCopyTable.h
+++ b/Source/CMCopyTable.h
@@ -114,5 +114,6 @@
@end
+extern NSInteger MENU_EDIT_COPY;
extern NSInteger MENU_EDIT_COPY_WITH_COLUMN;
extern NSInteger MENU_EDIT_COPY_AS_SQL;
diff --git a/Source/CMCopyTable.m b/Source/CMCopyTable.m
index dc9cc770..9c12b358 100644
--- a/Source/CMCopyTable.m
+++ b/Source/CMCopyTable.m
@@ -28,13 +28,16 @@
#import "SPArrayAdditions.h"
#import "SPStringAdditions.h"
#import "TableContent.h"
+#import "SPTableTriggers.h"
+#import "SPTableRelations.h"
#import "CustomQuery.h"
#import "SPNotLoaded.h"
#import "SPConstants.h"
#import "SPDataStorage.h"
-NSInteger MENU_EDIT_COPY_WITH_COLUMN = 2001;
-NSInteger MENU_EDIT_COPY_AS_SQL = 2002;
+NSInteger MENU_EDIT_COPY = 2001;
+NSInteger MENU_EDIT_COPY_WITH_COLUMN = 2002;
+NSInteger MENU_EDIT_COPY_AS_SQL = 2003;
@implementation CMCopyTable
@@ -75,19 +78,35 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2002;
return NSDragOperationCopy;
}
-//only have the copy menu item enabled when row(s) are selected
+/**
+ * Only have the copy menu item enabled when row(s) are selected in
+ * supported tables.
+ */
- (BOOL)validateMenuItem:(NSMenuItem*)anItem
-{
- if ( [[anItem title] isEqualToString:@"Copy"]
- || [anItem tag] == MENU_EDIT_COPY_WITH_COLUMN )
- {
- return ([self selectedRow] > -1);
+{
+ NSInteger menuItemTag = [anItem tag];
+
+ // Don't validate anything other than the copy commands
+ if (menuItemTag != MENU_EDIT_COPY && menuItemTag != MENU_EDIT_COPY_WITH_COLUMN && menuItemTag != MENU_EDIT_COPY_AS_SQL) {
+ return YES;
}
- if ( [anItem tag] == MENU_EDIT_COPY_AS_SQL )
- {
- return (columnDefinitions != nil && [self selectedRow] > -1);
+
+ // Don't enable menus for relations or triggers - no action to take yet
+ if ([[self delegate] isKindOfClass:[SPTableRelations class]] || [[self delegate] isKindOfClass:[SPTableTriggers class]]) {
+ return NO;
+ }
+
+ // Enable the Copy [with column names] commands if a row is selected
+ if (menuItemTag == MENU_EDIT_COPY || menuItemTag == MENU_EDIT_COPY_WITH_COLUMN) {
+ return ([self numberOfSelectedRows] > 0);
}
- return YES;
+
+ // Enable the Copy as SQL commands if rows are selected and column definitions are available
+ if (menuItemTag == MENU_EDIT_COPY_AS_SQL) {
+ return (columnDefinitions != nil && [self numberOfSelectedRows] > 0);
+ }
+
+ return NO;
}
//get selected rows a string of newline separated lines of tab separated fields