diff options
author | stuconnolly <stuart02@gmail.com> | 2010-07-07 22:02:13 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2010-07-07 22:02:13 +0000 |
commit | 2a1f907c897a4aa6970ed56cfc97e50307e4ea1a (patch) | |
tree | 38c6d9163aa71c030619a9e092e81a66e767f499 /Source | |
parent | 2327652bf0e17a04d8f888835979580638beda84 (diff) | |
download | sequelpro-2a1f907c897a4aa6970ed56cfc97e50307e4ea1a.tar.gz sequelpro-2a1f907c897a4aa6970ed56cfc97e50307e4ea1a.tar.bz2 sequelpro-2a1f907c897a4aa6970ed56cfc97e50307e4ea1a.zip |
As the initial MySQL connection is now threaded, start the current tab's progress indicator to indicate that it's connecting in the event that the user switches to a different tab. Also preserve the tab's label as 'Connecting...' when switching tabs.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPConnectionController.h | 3 | ||||
-rw-r--r-- | Source/SPConnectionController.m | 22 | ||||
-rw-r--r-- | Source/SPDatabaseDocument.m | 21 |
3 files changed, 40 insertions, 6 deletions
diff --git a/Source/SPConnectionController.h b/Source/SPConnectionController.h index 2f274a27..4c8a0a9d 100644 --- a/Source/SPConnectionController.h +++ b/Source/SPConnectionController.h @@ -66,6 +66,7 @@ MCPConnection *mySQLConnection; BOOL automaticFavoriteSelection; BOOL cancellingConnection; + BOOL isConnecting; NSInteger previousType; NSInteger type; @@ -140,6 +141,8 @@ @property (readwrite, retain) NSString *connectionKeychainItemAccount; @property (readwrite, retain) NSString *connectionSSHKeychainItemName; @property (readwrite, retain) NSString *connectionSSHKeychainItemAccount; + +@property (readonly, assign) BOOL isConnecting; @property (readonly, assign) NSString *favoritesPBoardType; - (id)initWithDocument:(SPDatabaseDocument *)theTableDocument; diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index 8007ca86..fb293c4b 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -61,6 +61,8 @@ @synthesize connectionSSHKeychainItemName; @synthesize connectionSSHKeychainItemAccount; +@synthesize isConnecting; + #pragma mark - /** @@ -80,6 +82,7 @@ mySQLConnection = nil; sshTunnel = nil; cancellingConnection = NO; + isConnecting = NO; mySQLConnectionCancelled = NO; favoritesPBoardType = @"FavoritesPBoardType"; @@ -182,7 +185,9 @@ if (![self checkHost]) return; // Basic details have validated - start the connection process animating + isConnecting = YES; cancellingConnection = NO; + [addToFavoritesButton setHidden:YES]; [addToFavoritesButton display]; [helpButton setHidden:YES]; @@ -193,6 +198,9 @@ [progressIndicator display]; [progressIndicatorText setHidden:NO]; [progressIndicatorText display]; + + // Start the current tab's progress indicator + [tableDocument setIsProcessing:YES]; // If the password(s) are marked as having been originally sourced from a keychain, check whether they // have been changed or not; if not, leave the mark in place and remove the password from the field @@ -245,7 +253,7 @@ */ - (IBAction)cancelMySQLConnection:(id)sender { - [progressIndicatorText setStringValue:NSLocalizedString(@"Cancelling...", @"cancelling connection message")]; + [progressIndicatorText setStringValue:NSLocalizedString(@"Cancelling...", @"cancelling task status message")]; [progressIndicatorText display]; mySQLConnectionCancelled = YES; @@ -1083,6 +1091,9 @@ // Must be performed on the main thread if (![NSThread isMainThread]) return [[self onMainThread] _restoreConnectionInterface]; + // Stop the current tab's progress indicator + [tableDocument setIsProcessing:NO]; + // Reset the UI [addToFavoritesButton setHidden:NO]; [addToFavoritesButton display]; @@ -1112,6 +1123,8 @@ */ - (void)_mySQLConnectionEstablished { + isConnecting = NO; + // If the user hit cancel during the connection attempt, kill the connection once // established and reset the UI. if (mySQLConnectionCancelled) { @@ -1131,6 +1144,9 @@ [progressIndicatorText setStringValue:NSLocalizedString(@"Connected", @"connection established message")]; [progressIndicatorText display]; + // Stop the current tab's progress indicator + [tableDocument setIsProcessing:NO]; + // Successful connection! [connectButton setEnabled:NO]; [connectButton display]; @@ -1231,6 +1247,8 @@ } // Tidy up + isConnecting = NO; + if (sshTunnel) [sshTunnel release], sshTunnel = nil; [mySQLConnection release], mySQLConnection = nil; @@ -1246,6 +1264,8 @@ [[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 getLastErrorMessage]] detail:nil]; // Tidy up + isConnecting = NO; + if (sshTunnel) [sshTunnel release], sshTunnel = nil; [mySQLConnection release], mySQLConnection = nil; diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 8492001f..d6c17b5e 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -2616,6 +2616,10 @@ if ([[[self fileURL] path] length] && ![self isUntitled]) pathName = [NSString stringWithFormat:@"%@ — ", [[[self fileURL] path] lastPathComponent]]; + if ([connectionController isConnecting]) { + return NSLocalizedString(@"Connecting…", @"window title string indicating that sp is connecting"); + } + if ([self getConnection] == nil) return [NSString stringWithFormat:@"%@%@", pathName, @"Sequel Pro"]; @@ -3793,10 +3797,16 @@ if ([[[self fileURL] path] length] && ![self isUntitled]) { pathName = [NSString stringWithFormat:@"%@ — ", [[[self fileURL] path] lastPathComponent]]; } - if (!_isConnected) { + + if ([connectionController isConnecting]) { + windowTitle = NSLocalizedString(@"Connecting…", @"window title string indicating that sp is connecting"); + tabTitle = windowTitle; + } + else if (!_isConnected) { windowTitle = [NSString stringWithFormat:@"%@%@", pathName, @"Sequel Pro"]; tabTitle = windowTitle; - } else { + } + else { windowTitle = [NSMutableString string]; tabTitle = [NSMutableString string]; @@ -3835,7 +3845,7 @@ [tabTitle appendString:[self table]]; } } - + // Set the titles [parentTabViewItem setLabel:tabTitle]; if ([parentWindowController selectedTableDocument] == self) { @@ -4381,11 +4391,12 @@ */ - (void)connectionControllerInitiatingConnection:(id)controller { - // Update the window title to indicate that we are try to establish a connection + // Update the window title to indicate that we are trying to establish a connection [parentTabViewItem setLabel:NSLocalizedString(@"Connecting…", @"window title string indicating that sp is connecting")]; + if ([parentWindowController selectedTableDocument] == self) { [parentWindow setTitle:NSLocalizedString(@"Connecting…", @"window title string indicating that sp is connecting")]; - } + } } /** |