aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPConnectionController.m39
-rw-r--r--Source/SPConnectionControllerDelegate.m36
2 files changed, 55 insertions, 20 deletions
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index 93b7dc36..212df1da 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -72,6 +72,7 @@ static NSString *SPExportFavoritesFilename = @"SequelProFavorites.plist";
- (NSString *)_stripInvalidCharactersFromString:(NSString *)subject;
- (void)_updateFavoritePasswordsFromField:(NSControl *)control;
+- (void)_resetConnectionDetailsInputInterface;
static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, void *key);
@@ -743,7 +744,9 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
account:[keychain accountForSSHUser:[self sshUser] sshHost:[self sshHost]]];
}
- SPTreeNode *node = [favoritesController addFavoriteNodeWithData:newFavorite asChildOfNode:nil];
+ SPTreeNode *selectedNode = [self selectedFavoriteNode];
+
+ SPTreeNode *node = [favoritesController addFavoriteNodeWithData:newFavorite asChildOfNode:[selectedNode isGroup] ? selectedNode : nil];
[self _reloadFavoritesViewData];
[self _selectNode:node];
@@ -1328,6 +1331,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
[favoritesController removeFavoriteNode:node];
+ [self _resetConnectionDetailsInputInterface];
[self _reloadFavoritesViewData];
// Clear the selection
@@ -1476,6 +1480,39 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
}
}
+/**
+ * Resets the connection details input interface to an empty state.
+ */
+- (void)_resetConnectionDetailsInputInterface
+{
+ if (currentFavorite) [currentFavorite release], currentFavorite = nil;
+
+ [self setName:@""];
+ [self setHost:@""];
+ [self setSocket:@""];
+ [self setUser:@""];
+ [self setPort:@""];
+ [self setDatabase:@""];
+ [self setPassword:@""];
+
+ // SSL details
+ [self setUseSSL:NSOffState];
+ [self setSslKeyFileLocationEnabled:NSOffState];
+ [self setSslKeyFileLocation:@""];
+ [self setSslCertificateFileLocationEnabled:NSOffState];
+ [self setSslCertificateFileLocation:@""];
+ [self setSslCACertFileLocationEnabled:NSOffState];
+ [self setSslCACertFileLocation:@""];
+
+ // SSH details
+ [self setSshHost:@""];
+ [self setSshUser:@""];
+ [self setSshPassword:@""];
+ [self setSshKeyLocationEnabled:NSOffState];
+ [self setSshKeyLocation:@""];
+ [self setSshPort:@""];
+}
+
#pragma mark -
- (void)dealloc
diff --git a/Source/SPConnectionControllerDelegate.m b/Source/SPConnectionControllerDelegate.m
index 796edc12..bc065171 100644
--- a/Source/SPConnectionControllerDelegate.m
+++ b/Source/SPConnectionControllerDelegate.m
@@ -33,8 +33,6 @@
#import "SPGroupNode.h"
#import "SPTreeNode.h"
-#define CELL(cell) (SPTableTextFieldCell *)cell
-
static NSString *SPDatabaseImage = @"database-small";
@interface SPConnectionController ()
@@ -47,6 +45,7 @@ static NSString *SPDatabaseImage = @"database-small";
- (NSString *)_stripInvalidCharactersFromString:(NSString *)subject;
+- (void)_resetConnectionDetailsInputInterface;
- (void)_setNodeIsExpanded:(BOOL)expanded fromNotification:(NSNotification *)notification;
@end
@@ -79,7 +78,7 @@ static NSString *SPDatabaseImage = @"database-small";
}
- (void)outlineViewSelectionDidChange:(NSNotification *)notification
-{
+{
NSInteger selected = [favoritesOutlineView numberOfSelectedRows];
if (selected == 1) {
@@ -92,14 +91,15 @@ static NSString *SPDatabaseImage = @"database-small";
[addToFavoritesButton setEnabled:NO];
favoriteNameFieldWasTouched = YES;
-
- [connectionResizeContainer setHidden:NO];
- [connectionInstructionsTextField setStringValue:NSLocalizedString(@"Enter connection details below, or choose a favorite", @"enter connection details label")];
}
- else {
- [connectionResizeContainer setHidden:YES];
- [connectionInstructionsTextField setStringValue:NSLocalizedString(@"Please choose a favorite", @"please choose a favorite connection view label")];
+ else {
+ [addToFavoritesButton setEnabled:YES];
+
+ [self _resetConnectionDetailsInputInterface];
}
+
+ [connectionResizeContainer setHidden:NO];
+ [connectionInstructionsTextField setStringValue:NSLocalizedString(@"Enter connection details below, or choose a favorite", @"enter connection details label")];
}
else if (selected > 1) {
[connectionResizeContainer setHidden:YES];
@@ -111,16 +111,8 @@ static NSString *SPDatabaseImage = @"database-small";
{
SPTreeNode *node = (SPTreeNode *)item;
- [CELL(cell) setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
-
- [CELL(cell) setTextColor:([favoritesOutlineView isEnabled]) ? [NSColor blackColor] : [NSColor grayColor]];
-
- if (![[node parentNode] parentNode]) {
- [CELL(cell) setImage:nil];
- }
- else {
- [CELL(cell) setImage:(![node isGroup]) ? [NSImage imageNamed:SPDatabaseImage] : folderImage];
- }
+ [(SPTableTextFieldCell *)cell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
+ [(SPTableTextFieldCell *)cell setImage:(![[node parentNode] parentNode]) ? nil : (![node isGroup]) ? [NSImage imageNamed:SPDatabaseImage] : folderImage];
}
- (CGFloat)outlineView:(NSOutlineView *)outlineView heightOfRowByItem:(id)item
@@ -624,6 +616,12 @@ static NSString *SPDatabaseImage = @"database-small";
#pragma mark -
#pragma mark Private API
+/**
+ * Sets the expanded state of the node from the supplied outline view notification.
+ *
+ * @param expanded The state of the node
+ * @param notification The notification genrated from the state change
+ */
- (void)_setNodeIsExpanded:(BOOL)expanded fromNotification:(NSNotification *)notification
{
SPGroupNode *node = [[[notification userInfo] valueForKey:@"NSObject"] representedObject];