From 17ee678d8b552693f45a9d38cdf0684aed6dabf6 Mon Sep 17 00:00:00 2001 From: avenjamin Date: Mon, 22 Dec 2008 11:56:33 +0000 Subject: Clean up of validate menu items method. --- Source/TableDocument.m | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/Source/TableDocument.m b/Source/TableDocument.m index d1412032..9b5ce8e0 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -1168,34 +1168,23 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa */ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { - if ([menuItem action] == @selector(import:)) { - return ([self database] != nil); - } - - if ([menuItem action] == @selector(importCSV:)) { - return ([self database] != nil && [self table] != nil); - } - - if ([menuItem action] == @selector(export:)) { + if ([menuItem action] == @selector(import:) || + [menuItem action] == @selector(export:) || + [menuItem action] == @selector(exportMultipleTables:) || + [menuItem action] == @selector(removeDatabase:)) + { return ([self database] != nil); } - if ([menuItem action] == @selector(exportTable:)) { + if ([menuItem action] == @selector(exportTable:)) + { return ([self database] != nil && [self table] != nil); } - if ([menuItem action] == @selector(exportMultipleTables:)) { - return ([self database] != nil); - } - if ([menuItem action] == @selector(chooseEncoding:)) { return [self supportsEncoding]; } - if ([menuItem action] == @selector(removeDatabase:)) { - return ([self database] != nil); - } - // table menu items if ([menuItem action] == @selector(showCreateTableSyntax:) || [menuItem action] == @selector(copyCreateTableSyntax:) || @@ -1208,6 +1197,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa { return ([self table] != nil && [[self table] isNotEqualTo:@""]); } + return [super validateMenuItem:menuItem]; } -- cgit v1.2.3