From cd003769b9cdd036266e01683c09ede3430ff385 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Thu, 29 Jan 2009 00:43:35 +0000 Subject: Add 'Refresh Databases' menu item to the main database selection drop down. Fixes issue #143 --- Source/TableDocument.m | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 7c41a049..78f29d24 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -434,23 +434,27 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa return; [chooseDatabaseButton removeAllItems]; + [chooseDatabaseButton addItemWithTitle:NSLocalizedString(@"Choose Database...", @"menu item for choose db")]; [[chooseDatabaseButton menu] addItem:[NSMenuItem separatorItem]]; [[chooseDatabaseButton menu] addItemWithTitle:NSLocalizedString(@"Add Database...", @"menu item to add db") action:@selector(addDatabase:) keyEquivalent:@""]; + [[chooseDatabaseButton menu] addItemWithTitle:NSLocalizedString(@"Refresh Databases", @"menu item to refresh databases") action:@selector(setDatabases:) keyEquivalent:@""]; [[chooseDatabaseButton menu] addItem:[NSMenuItem separatorItem]]; - MCPResult *queryResult = [mySQLConnection listDBs]; - if ([queryResult numOfRows]) [queryResult dataSeek:0]; + + if ([queryResult numOfRows]) { + [queryResult dataSeek:0]; + } + int i; - for ( i = 0 ; i < [queryResult numOfRows] ; i++ ) { + + for (i = 0 ; i < [queryResult numOfRows] ; i++) + { [chooseDatabaseButton addItemWithTitle:[[queryResult fetchRowAsArray] objectAtIndex:0]]; } - if ( ![self database] ) { - [chooseDatabaseButton selectItemAtIndex:0]; - } else { - [chooseDatabaseButton selectItemWithTitle:[self database]]; - } + + (![self database]) ? [chooseDatabaseButton selectItemAtIndex:0] : [chooseDatabaseButton selectItemWithTitle:[self database]]; } /** -- cgit v1.2.3