From d4ee9e678f07167536dc54f6dfd276864a41e5cf Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Tue, 19 Oct 2010 14:44:33 +0000 Subject: Add a 'Refresh Tables' menu item to the 'Database' menu. It currently has the shortcut Ctrl+Cmd+R, but this can always be remapped in system preferences. Implemented issue #845. --- Source/SPDatabaseDocument.m | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'Source/SPDatabaseDocument.m') diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index bd5ee773..4e598866 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -1070,6 +1070,14 @@ [alert beginSheetModalForWindow:parentWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"removeDatabase"]; } +/** + * Refreshes the tables list by calling SPTablesList's updateTables. + */ +- (IBAction)refreshTables:(id)sender +{ + [tablesListInstance updateTables:self]; +} + /** * Displays the database server variables sheet. */ @@ -3589,19 +3597,22 @@ 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; - + } + 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:) || + if ([menuItem action] == @selector(import:) || [menuItem action] == @selector(removeDatabase:) || - [menuItem action] == @selector(copyDatabase:) || - [menuItem action] == @selector(renameDatabase:)) + [menuItem action] == @selector(copyDatabase:) || + [menuItem action] == @selector(renameDatabase:) || + [menuItem action] == @selector(refreshTables:)) { return ([self database] != nil); } @@ -3628,12 +3639,11 @@ } if ([menuItem action] == @selector(printDocument:)) { - return (([self database] != nil && [[tablesListInstance valueForKeyPath:@"tablesListView"] numberOfSelectedRows] == 1) - // if Custom Query Tab is active the textView will handle printDocument by itself + return (([self database] != nil && [[tablesListInstance valueForKeyPath:@"tablesListView"] numberOfSelectedRows] == 1) || + // If Custom Query Tab is active the textView will handle printDocument by itself // if it is first responder; otherwise allow to print the Query Result table even - //if no db/table is selected - || [tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 2 - ); + // if no db/table is selected + [tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 2); } if ([menuItem action] == @selector(chooseEncoding:)) { -- cgit v1.2.3