diff options
author | stuconnolly <stuart02@gmail.com> | 2009-07-02 01:08:20 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2009-07-02 01:08:20 +0000 |
commit | 633b7969c21612273fb1b27a1ddefdcc628576e4 (patch) | |
tree | 6a0a5b298505a85230f938c9c239868f0fe48b00 /Source | |
parent | 33032bcebcf4254755db1b6d9b7cb51e806f2fc3 (diff) | |
download | sequelpro-633b7969c21612273fb1b27a1ddefdcc628576e4.tar.gz sequelpro-633b7969c21612273fb1b27a1ddefdcc628576e4.tar.bz2 sequelpro-633b7969c21612273fb1b27a1ddefdcc628576e4.zip |
Add contextual menus to the table content and table relations views. Completes the implementation of issue #139 as all views now have contextual menus.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPTableRelations.m | 15 | ||||
-rw-r--r-- | Source/TableContent.m | 21 |
2 files changed, 36 insertions, 0 deletions
diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m index d3212a0e..a65de7ea 100644 --- a/Source/SPTableRelations.m +++ b/Source/SPTableRelations.m @@ -302,6 +302,21 @@ } } +/** + * Menu validation + */ +- (BOOL)validateMenuItem:(NSMenuItem *)menuItem +{ + // Remove row + if ([menuItem action] == @selector(removeRelation:)) { + [menuItem setTitle:([relationsTableView numberOfSelectedRows] > 1) ? @"Delete Relations" : @"Delete Relation"]; + + return ([relationsTableView numberOfSelectedRows] > 0); + } + + return [super validateMenuItem:menuItem]; +} + /* * Dealloc. */ diff --git a/Source/TableContent.m b/Source/TableContent.m index 16f86ff1..9a96a28a 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -2550,6 +2550,27 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn [tableContentView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; } } + +/** + * Menu validation + */ +- (BOOL)validateMenuItem:(NSMenuItem *)menuItem +{ + // Remove row + if ([menuItem action] == @selector(removeRow:)) { + [menuItem setTitle:([tableContentView numberOfSelectedRows] > 1) ? @"Delete Rows" : @"Delete Row"]; + + return ([tableContentView numberOfSelectedRows] > 0); + } + + // Duplicate row + if ([menuItem action] == @selector(copyRow:)) { + return ([tableContentView numberOfSelectedRows] == 1); + } + + return [super validateMenuItem:menuItem]; +} + // Last but not least - (void)dealloc { |