diff options
author | rowanbeentje <rowan@beent.je> | 2012-10-06 11:48:15 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2012-10-06 11:48:15 +0000 |
commit | ecb5c70566d1303288e4faf170bda40672a799e1 (patch) | |
tree | 2882fa5fd6f25eed9c754e810785f5834225b95f /Source/SPConnectionHandler.m | |
parent | ada181f6fe5b010a5ab56030d16b35e92e58af10 (diff) | |
download | sequelpro-ecb5c70566d1303288e4faf170bda40672a799e1.tar.gz sequelpro-ecb5c70566d1303288e4faf170bda40672a799e1.tar.bz2 sequelpro-ecb5c70566d1303288e4faf170bda40672a799e1.zip |
Change the connection screen interface, particularly relating to favourite editing on the connection screen (Issue #1339, Issue #1440):
- No longer save changes made to connection favourites as soon as the interface is updated
- Alter the interfaace if favourites are editing, offering to save the changes either to the old connection favourite or to a new favourite
- Add a "Test connection" button to verify changes before saving
- Add a "Quick Connect" entry to the top of the connection view's favourites list so a blank form is always available
- Use a custom highlight when editing favourites to show the favourite has changed but is still linked
- Reduce the margin on the left-hand side of the connection favourites list to increase the available space
- Alter favourite name generation, making it less aggressive when generating names from partial details (eg creating names of just "@") and removing the user
- Alter key icon usage to correctly update the button appearance if an SSL or SSH key is selected
Diffstat (limited to 'Source/SPConnectionHandler.m')
-rw-r--r-- | Source/SPConnectionHandler.m | 61 |
1 files changed, 48 insertions, 13 deletions
diff --git a/Source/SPConnectionHandler.m b/Source/SPConnectionHandler.m index 5ae8d586..1a85bc50 100644 --- a/Source/SPConnectionHandler.m +++ b/Source/SPConnectionHandler.m @@ -45,8 +45,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; @interface SPConnectionController () - (void)_restoreConnectionInterface; - -- (void)_updateFavoritePasswordsFromField:(NSControl *)control; +- (void)_showConnectionTestResult:(NSString *)resultString; @end @@ -58,7 +57,17 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; - (void)initiateMySQLConnection { #ifndef SP_REFACTOR - [progressIndicatorText setStringValue:(sshTunnel) ? NSLocalizedString(@"MySQL connecting...", @"MySQL connecting very short status message") : NSLocalizedString(@"Connecting...", @"Generic connecting very short status message")]; + if (isTestingConnection) { + if (sshTunnel) { + [progressIndicatorText setStringValue:NSLocalizedString(@"Testing MySQL...", @"MySQL connection test very short status message")]; + } else { + [progressIndicatorText setStringValue:NSLocalizedString(@"Testing connection...", @"Connection test very short status message")]; + } + } else if (sshTunnel) { + [progressIndicatorText setStringValue:NSLocalizedString(@"MySQL connecting...", @"MySQL connecting very short status message")]; + } else { + [progressIndicatorText setStringValue:NSLocalizedString(@"Connecting...", @"Generic connecting very short status message")]; + } [progressIndicatorText display]; [connectButton setTitle:NSLocalizedString(@"Cancel", @"cancel button")]; @@ -200,7 +209,9 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; if ([self database] && ![[self database] isEqualToString:@""]) { if (![mySQLConnection selectDatabase:[self database]]) { - [[self onMainThread] failConnectionWithTitle:NSLocalizedString(@"Could not select database", @"message when database selection failed") errorMessage:[NSString stringWithFormat:NSLocalizedString(@"Connected to host, but unable to connect to database %@.\n\nBe sure that the database exists and that you have the necessary privileges.\n\nMySQL said: %@", @"message of panel when connection to db failed"), [self database], [mySQLConnection lastErrorMessage]] detail:nil rawErrorText:[mySQLConnection lastErrorMessage]]; + if (!isTestingConnection) { + [[self onMainThread] failConnectionWithTitle:NSLocalizedString(@"Could not select database", @"message when database selection failed") errorMessage:[NSString stringWithFormat:NSLocalizedString(@"Connected to host, but unable to connect to database %@.\n\nBe sure that the database exists and that you have the necessary privileges.\n\nMySQL said: %@", @"message of panel when connection to db failed"), [self database], [mySQLConnection lastErrorMessage]] detail:nil rawErrorText:[mySQLConnection lastErrorMessage]]; + } // Tidy up isConnecting = NO; @@ -209,6 +220,10 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; [mySQLConnection release], mySQLConnection = nil; [self _restoreConnectionInterface]; + if (isTestingConnection) { + [self _showConnectionTestResult:NSLocalizedString(@"Invalid database", @"Invalid database very short status message")]; + } + [pool release]; return; @@ -228,7 +243,11 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; */ - (void)initiateSSHTunnelConnection { - [progressIndicatorText setStringValue:NSLocalizedString(@"SSH connecting...", @"SSH connecting very short status message")]; + if (isTestingConnection) { + [progressIndicatorText setStringValue:NSLocalizedString(@"Testing SSH...", @"SSH testing very short status message")]; + } else { + [progressIndicatorText setStringValue:NSLocalizedString(@"SSH connecting...", @"SSH connecting very short status message")]; + } [progressIndicatorText display]; // Trim whitespace and newlines from the SSH host field before attempting to connect @@ -266,9 +285,9 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; { isConnecting = NO; - // If the user hit cancel during the connection attempt, kill the connection once - // established and reset the UI. - if (mySQLConnectionCancelled) { + // If the user hit cancel during the connection attempt, or a test connection is + // occurring, kill the connection once established and reset the UI. + if (mySQLConnectionCancelled || isTestingConnection) { if ([mySQLConnection isConnected]) { [mySQLConnection disconnect]; [mySQLConnection release], mySQLConnection = nil; @@ -278,7 +297,11 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; [self cancelConnection]; [self _restoreConnectionInterface]; - + + if (isTestingConnection) { + [self _showConnectionTestResult:NSLocalizedString(@"Connection succeeded", @"Connection success very short status message")]; + } + return; } @@ -296,7 +319,6 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; [connectButton display]; [progressIndicator stopAnimation:self]; [progressIndicatorText setHidden:YES]; - [addToFavoritesButton setHidden:NO]; #endif // If SSL was enabled, check it was established correctly @@ -418,9 +440,8 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; [progressIndicator display]; [progressIndicatorText setHidden:YES]; [progressIndicatorText display]; - [addToFavoritesButton setHidden:NO]; - [addToFavoritesButton display]; [connectButton setEnabled:YES]; + [testConnectButton setEnabled:YES]; [dbDocument clearStatusIcon]; #endif @@ -483,7 +504,6 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; // Change connection details [self setPort:tunnelPort]; [self setHost:SPLocalhostAddress]; - [self _updateFavoritePasswordsFromField:standardSQLHostField]; #ifndef SP_REFACTOR // Change to standard TCP/IP connection view @@ -495,4 +515,19 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; } } +/** + * Display a connection test error or success message + */ +- (void)_showConnectionTestResult:(NSString *)resultString +{ + if (![NSThread isMainThread]) { + [[self onMainThread] _showConnectionTestResult:resultString]; + } + + [helpButton setHidden:NO]; + [progressIndicator stopAnimation:self]; + [progressIndicatorText setStringValue:resultString]; + [progressIndicatorText setHidden:NO]; +} + @end |