aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-04-16 13:55:04 +0000
committerrowanbeentje <rowan@beent.je>2009-04-16 13:55:04 +0000
commit02cc3edfc5a0c64de768812220e78aba26aab81f (patch)
tree97627a337962cfc88fd52af6d98ef1b52aff1d7d
parent20c46135604cfd3a38c55647438264e5360c80a4 (diff)
downloadsequelpro-02cc3edfc5a0c64de768812220e78aba26aab81f.tar.gz
sequelpro-02cc3edfc5a0c64de768812220e78aba26aab81f.tar.bz2
sequelpro-02cc3edfc5a0c64de768812220e78aba26aab81f.zip
- The connection sheet Edit button now opens the favourites list in preferences and selects appropriately; this resolves the initially planned changes for Issue #232.
- Move updateDefaultFavoritePopup in SPPreferenceController to a public method and set TableDocument to update it when adding favorites
-rw-r--r--Source/MainController.h3
-rw-r--r--Source/MainController.m12
-rw-r--r--Source/SPPreferenceController.h4
-rw-r--r--Source/SPPreferenceController.m88
-rw-r--r--Source/TableDocument.m9
5 files changed, 75 insertions, 41 deletions
diff --git a/Source/MainController.h b/Source/MainController.h
index 962329e7..a153964d 100644
--- a/Source/MainController.h
+++ b/Source/MainController.h
@@ -44,6 +44,9 @@
- (IBAction)visitWebsite:(id)sender;
- (IBAction)visitHelpWebsite:(id)sender;
+// Getters
+- (SPPreferenceController *)preferenceController;
+
// Other
- (id)handleQuitScriptCommand:(NSScriptCommand *)command;
diff --git a/Source/MainController.m b/Source/MainController.m
index d59d2725..ad90531e 100644
--- a/Source/MainController.m
+++ b/Source/MainController.m
@@ -70,6 +70,18 @@
}
#pragma mark -
+#pragma mark Getters
+
+/**
+ * Provide a method to retrieve the prefs controller
+ */
+- (SPPreferenceController *)preferenceController
+{
+ return prefsController;
+}
+
+
+#pragma mark -
#pragma mark Services menu methods
/**
diff --git a/Source/SPPreferenceController.h b/Source/SPPreferenceController.h
index 73819cfd..cb12cde1 100644
--- a/Source/SPPreferenceController.h
+++ b/Source/SPPreferenceController.h
@@ -77,4 +77,8 @@
- (IBAction)displayAutoUpdatePreferences:(id)sender;
- (IBAction)displayNetworkPreferences:(id)sender;
+// Other
+- (void)updateDefaultFavoritePopup;
+- (void)selectFavorites:(NSArray *)favorite;
+
@end
diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m
index dc4b98c7..80f32e36 100644
--- a/Source/SPPreferenceController.m
+++ b/Source/SPPreferenceController.m
@@ -41,7 +41,6 @@
- (void)_setupToolbar;
- (void)_resizeWindowForContentView:(NSView *)view;
-- (void)_updateDefaultFavoritePopup;
@end
@@ -82,7 +81,7 @@
[favoritesTableView selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO];
[favoritesTableView reloadData];
- [self _updateDefaultFavoritePopup];
+ [self updateDefaultFavoritePopup];
}
#pragma mark -
@@ -236,7 +235,7 @@
[favoritesController addObject:favorite];
[favoritesTableView reloadData];
- [self _updateDefaultFavoritePopup];
+ [self updateDefaultFavoritePopup];
}
// -------------------------------------------------------------------------------
@@ -272,7 +271,7 @@
[favoritesController removeObjectAtArrangedObjectIndex:[favoritesTableView selectedRow]];
[favoritesTableView reloadData];
- [self _updateDefaultFavoritePopup];
+ [self updateDefaultFavoritePopup];
}
}
@@ -308,7 +307,7 @@
[favoritesController addObject:favorite];
[favoritesTableView reloadData];
- [self _updateDefaultFavoritePopup];
+ [self updateDefaultFavoritePopup];
}
}
@@ -501,7 +500,7 @@
if ([prefs integerForKey:@"DefaultFavorite"] == originalRow) {
[prefs setInteger:destinationRow forKey:@"DefaultFavorite"];
}
- [self _updateDefaultFavoritePopup];
+ [self updateDefaultFavoritePopup];
return YES;
}
@@ -685,6 +684,49 @@
}
+#pragma mark -
+#pragma mark Other
+
+
+// -------------------------------------------------------------------------------
+// updateDefaultFavoritePopup:
+//
+// Build the default favorite popup button
+// -------------------------------------------------------------------------------
+- (void)updateDefaultFavoritePopup;
+{
+ [defaultFavoritePopup removeAllItems];
+
+ // Use the last used favorite
+ [defaultFavoritePopup addItemWithTitle:@"Last Used"];
+ [[defaultFavoritePopup menu] addItem:[NSMenuItem separatorItem]];
+
+ // Load in current favorites
+ [defaultFavoritePopup addItemsWithTitles:[[favoritesController arrangedObjects] valueForKeyPath:@"name"]];
+
+ // Add item to switch to edit favorites pane
+ [[defaultFavoritePopup menu] addItem:[NSMenuItem separatorItem]];
+ [defaultFavoritePopup addItemWithTitle:@"Edit Favorites…"];
+ [[[defaultFavoritePopup menu] itemWithTitle:@"Edit Favorites…"] setAction:@selector(displayFavoritePreferences:)];
+ [[[defaultFavoritePopup menu] itemWithTitle:@"Edit Favorites…"] setTarget:self];
+
+ // Select the default favorite from prefs
+ if (![prefs boolForKey:@"SelectLastFavoriteUsed"]) {
+ [defaultFavoritePopup selectItemAtIndex:[prefs integerForKey:@"DefaultFavorite"] + 2];
+ } else {
+ [defaultFavoritePopup selectItemAtIndex:0];
+ }
+}
+
+// -------------------------------------------------------------------------------
+// selectFavorite:
+//
+// Selects the specified favorite(s) in the favorites list
+// -------------------------------------------------------------------------------
+- (void)selectFavorites:(NSArray *)favorites
+{
+ [favoritesController setSelectedObjects:favorites];
+}
@end
@@ -783,38 +825,4 @@
[view setFrameOrigin:NSMakePoint(0, 0)];
}
-
-
-// -------------------------------------------------------------------------------
-// _updateDefaultFavoritePopup:
-//
-// Build the default favorite popup button
-// -------------------------------------------------------------------------------
-- (void)_updateDefaultFavoritePopup;
-{
- [defaultFavoritePopup removeAllItems];
-
- // Use the last used favorite
- [defaultFavoritePopup addItemWithTitle:@"Last Used"];
- [[defaultFavoritePopup menu] addItem:[NSMenuItem separatorItem]];
-
- // Load in current favorites
- [defaultFavoritePopup addItemsWithTitles:[[favoritesController arrangedObjects] valueForKeyPath:@"name"]];
-
- // Add item to switch to edit favorites pane
- [[defaultFavoritePopup menu] addItem:[NSMenuItem separatorItem]];
- [defaultFavoritePopup addItemWithTitle:@"Edit Favorites…"];
- [[[defaultFavoritePopup menu] itemWithTitle:@"Edit Favorites…"] setAction:@selector(displayFavoritePreferences:)];
- [[[defaultFavoritePopup menu] itemWithTitle:@"Edit Favorites…"] setTarget:self];
-
- // Select the default favorite from prefs
- if (![prefs boolForKey:@"SelectLastFavoriteUsed"]) {
- [defaultFavoritePopup selectItemAtIndex:[prefs integerForKey:@"DefaultFavorite"] + 2];
- } else {
- [defaultFavoritePopup selectItemAtIndex:0];
- }
-}
-
-
-
@end
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index f58b9b29..850ee443 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -41,6 +41,8 @@
#import "SPQueryConsole.h"
#import "CMMCPConnection.h"
#import "CMMCPResult.h"
+#import "MainController.h"
+#import "SPPreferenceController.h"
//used for printing
#import "MGTemplateEngine.h"
@@ -409,7 +411,11 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum
*/
- (IBAction)editFavorites:(id)sender
{
-
+ SPPreferenceController *prefsController = [[NSApp delegate] preferenceController];
+
+ [prefsController showWindow:self];
+ [prefsController displayFavoritePreferences:self];
+ [prefsController selectFavorites:[favoritesController selectedObjects]];
}
/**
@@ -481,6 +487,7 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum
[favoritesController addObject:newFavorite];
[favoritesController setSelectedObjects:[NSArray arrayWithObject:newFavorite]];
+ [[[NSApp delegate] preferenceController] updateDefaultFavoritePopup];
}
/**