From 633b7969c21612273fb1b27a1ddefdcc628576e4 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Thu, 2 Jul 2009 01:08:20 +0000 Subject: Add contextual menus to the table content and table relations views. Completes the implementation of issue #139 as all views now have contextual menus. --- Interfaces/English.lproj/DBView.xib | 145 +++++++++++++++++++++++++++++++++--- Source/SPTableRelations.m | 15 ++++ Source/TableContent.m | 21 ++++++ 3 files changed, 172 insertions(+), 9 deletions(-) diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index a550f7c8..085bea00 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -8,8 +8,9 @@ 353.00 YES + - + YES @@ -619,7 +620,7 @@ source - + 256 YES @@ -1933,7 +1934,6 @@ {{10, 7}, {700, 544}} - Structure @@ -3979,7 +3979,7 @@ relations - + 256 YES @@ -4355,20 +4355,21 @@ {{10, 7}, {700, 544}} + Relations - + 134217731 YES YES YES - + @@ -12685,6 +12686,42 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 + + + + YES + + + Delete Row + + 2147483647 + + + + + + Duplicate Row + + 2147483647 + + + + + + + + + YES + + + Delete Relation + + 2147483647 + + + + + @@ -16557,6 +16594,46 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 6224 + + + menu + + + + 6229 + + + + removeRow: + + + + 6230 + + + + copyRow: + + + + 6231 + + + + menu + + + + 6236 + + + + removeRelation: + + + + 6237 + @@ -23379,6 +23456,42 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 + + 6225 + + + YES + + + + + Table Content Menu + + + 6226 + + + + + 6227 + + + + + 6232 + + + YES + + + + Table Relations Menu + + + 6233 + + + @@ -24792,6 +24905,13 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 6219.IBEditorWindowLastContentRect 6219.IBPluginDependency 6220.IBPluginDependency + 6225.IBEditorWindowLastContentRect + 6225.IBPluginDependency + 6226.IBPluginDependency + 6227.IBPluginDependency + 6232.IBEditorWindowLastContentRect + 6232.IBPluginDependency + 6233.IBPluginDependency 654.IBPluginDependency 654.ImportedFromIB2 655.IBPluginDependency @@ -25945,8 +26065,8 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{235, 270}, {944, 550}} - {{235, 270}, {944, 550}} + {{631, 363}, {944, 550}} + {{631, 363}, {944, 550}} {{62, 352}, {845, 504}} @@ -26745,6 +26865,13 @@ aGUgYWN0aXZlIHNlbGVjdGlvbiAo4oyl4oyYUik {{873, 547}, {141, 23}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + {{896, 390}, {152, 43}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{539, 190}, {158, 23}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -26965,7 +27092,7 @@ Y2hhbmdlIHRoZSBvcmRlcg - 6224 + 6237 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 { -- cgit v1.2.3