diff options
author | rowanbeentje <rowan@beent.je> | 2009-08-07 23:57:16 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2009-08-07 23:57:16 +0000 |
commit | 2297b13252ee7149606ecd4544898614f0ac9298 (patch) | |
tree | e9d704588859ba7b18a783f5ae214052d68fa8bf | |
parent | 67a72bc3a598528f9d45010716df3554dd882241 (diff) | |
download | sequelpro-2297b13252ee7149606ecd4544898614f0ac9298.tar.gz sequelpro-2297b13252ee7149606ecd4544898614f0ac9298.tar.bz2 sequelpro-2297b13252ee7149606ecd4544898614f0ac9298.zip |
Merge in recent fixes from trunk for 0.9.6 release:
- r1145 (Custom Query completion fixes)
- r1148 (CSV file import reload bugfix)
- Parts of r1150 (history navigation no longer generates invalid states)
- r1172 (Add to favorites and favorites saving fixes)
-rw-r--r-- | Interfaces/English.lproj/ConnectionView.xib | 70 | ||||
-rw-r--r-- | Source/CMTextView.m | 30 | ||||
-rw-r--r-- | Source/SPConnectionController.m | 37 | ||||
-rw-r--r-- | Source/SPHistoryController.h | 4 | ||||
-rw-r--r-- | Source/SPHistoryController.m | 14 | ||||
-rw-r--r-- | Source/TableContent.m | 3 | ||||
-rw-r--r-- | Source/TableDocument.m | 17 |
7 files changed, 96 insertions, 79 deletions
diff --git a/Interfaces/English.lproj/ConnectionView.xib b/Interfaces/English.lproj/ConnectionView.xib index 2587aec9..ecd681d5 100644 --- a/Interfaces/English.lproj/ConnectionView.xib +++ b/Interfaces/English.lproj/ConnectionView.xib @@ -8,7 +8,7 @@ <string key="IBDocument.HIToolboxVersion">353.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="5343"/> + <integer value="5344"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -980,6 +980,7 @@ <int key="NSCellFlags2">272630784</int> <string key="NSContents"/> <reference key="NSSupport" ref="807120225"/> + <string key="NSPlaceholderString">optional if public key is available</string> <reference key="NSControlView" ref="21480939"/> <bool key="NSDrawsBackground">YES</bool> <reference key="NSBackgroundColor" ref="211632616"/> @@ -1121,7 +1122,7 @@ <reference key="NSSuperview" ref="735564334"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="220047154"> - <int key="NSCellFlags">604110336</int> + <int key="NSCellFlags">67239424</int> <int key="NSCellFlags2">134217728</int> <string key="NSContents">Add to Favorites</string> <reference key="NSSupport" ref="807120225"/> @@ -1838,26 +1839,6 @@ <int key="connectionID">5327</int> </object> <object class="IBConnectionRecord"> - <object class="IBBindingConnection" key="connection"> - <string key="label">value: sshPassword</string> - <reference key="source" ref="21480939"/> - <reference key="destination" ref="545410097"/> - <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="21480939"/> - <reference key="NSDestination" ref="545410097"/> - <string key="NSLabel">value: sshPassword</string> - <string key="NSBinding">value</string> - <string key="NSKeyPath">sshPassword</string> - <object class="NSDictionary" key="NSOptions"> - <string key="NS.key.0">NSContinuouslyUpdatesValue</string> - <reference key="NS.object.0" ref="5"/> - </object> - <int key="NSNibBindingConnectorVersion">2</int> - </object> - </object> - <int key="connectionID">5331</int> - </object> - <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> <string key="label">dataSource</string> <reference key="source" ref="1012579052"/> @@ -2475,6 +2456,35 @@ </object> <int key="connectionID">5448</int> </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">value: sshPassword</string> + <reference key="source" ref="21480939"/> + <reference key="destination" ref="545410097"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="21480939"/> + <reference key="NSDestination" ref="545410097"/> + <string key="NSLabel">value: sshPassword</string> + <string key="NSBinding">value</string> + <string key="NSKeyPath">sshPassword</string> + <object class="NSDictionary" key="NSOptions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSMutableArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>NSContinuouslyUpdatesValue</string> + <string>NSNullPlaceholder</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="5"/> + <string>optional if public key is available</string> + </object> + </object> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">5449</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -4016,7 +4026,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">5448</int> + <int key="maxID">5449</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -4052,6 +4062,13 @@ </object> <object class="IBPartialClassDescription"> <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="968459546"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">Source/SPConnectionController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> <object class="NSMutableDictionary" key="actions"> <string key="NS.key.0">toggleCollapse:</string> <string key="NS.object.0">id</string> @@ -4161,7 +4178,7 @@ <string>NSButton</string> <string>NSView</string> <string>NSSplitView</string> - <string>NSView</string> + <string>BWAnchoredButtonBar</string> <string>NSView</string> <string>NSTextView</string> <string>NSWindow</string> @@ -4179,10 +4196,7 @@ <string>NSTextField</string> </object> </object> - <object class="IBClassDescriptionSource" key="sourceIdentifier" id="968459546"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">Source/SPConnectionController.h</string> - </object> + <reference key="sourceIdentifier" ref="968459546"/> </object> <object class="IBPartialClassDescription"> <string key="className">SPFlippedView</string> diff --git a/Source/CMTextView.m b/Source/CMTextView.m index 2ce6022d..45c7f0df 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -121,6 +121,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) * the set of unique words, SQL keywords, user-defined funcs/procs, tables etc. * NSDic key "display" := the displayed and to be inserted word * NSDic key "image" := an image to be shown left from "display" (optional) + * + * [NSDictionary dictionaryWithObjectsAndKeys:@"foo", @"display", @"`foo`", @"insert", @"func-small", @"image", nil] */ - (NSArray *)suggestionsForSQLCompletionWith:(NSString *)currentWord dictMode:(BOOL)isDictMode { @@ -183,25 +185,18 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) } } - // Add predefined keywords if(!isDictMode) { - // [possibleCompletions addObjectsFromArray:[self keywords]]; - NSString *s; - enumerate([self keywords], s) + + // Add predefined keywords + for (id s in [self keywords]) [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:s, @"display", @"dummy-small", @"image", nil]]; - } - - // Add predefined functions - if(!isDictMode) { - // [possibleCompletions addObjectsFromArray:[self functions]]; - NSString *s; - enumerate([self functions], s) + // Add predefined functions + for (id s in [self functions]) [possibleCompletions addObject:[NSDictionary dictionaryWithObjectsAndKeys:s, @"display", @"func-small", @"image", nil]]; } - - // Build array of dictionaries as e.g.: - // [NSDictionary dictionaryWithObjectsAndKeys:@"foo", @"display", @"`foo`", @"insert", @"func-small", @"image", nil] + + // Make suggestions unique for(id suggestion in possibleCompletions) if(![compl containsObject:suggestion]) [compl addObject:suggestion]; @@ -912,12 +907,6 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) if(![[[self textStorage] attribute:kBTQuote atIndex:charRange.location effectiveRange:nil] isEqualToString:kBTQuoteValue] ) { // Only parse for words if text size is less than 6MB - // if([[self string] length]<6000000) - // { - // NSCharacterSet *separators = [NSCharacterSet characterSetWithCharactersInString:@" \t\r\n,()\"'`-!;=+|?:~@"]; - // NSArray *textViewWords = [[self string] componentsSeparatedByCharactersInSet:separators]; - // [possibleCompletions addObjectsFromArray:textViewWords]; - // } if([[self string] length]<6000000) { NSCharacterSet *separators = [NSCharacterSet characterSetWithCharactersInString:@" \t\r\n,()[]{}\"'`-!;=+|?:~@"]; @@ -927,6 +916,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) } [possibleCompletions addObjectsFromArray:[self keywords]]; + [possibleCompletions addObjectsFromArray:[self functions]]; } // Check for possible completions diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index e5a0a473..b27f24f2 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -657,8 +657,8 @@ { NSString *thePassword, *theSSHPassword; NSNumber *favoriteid = [NSNumber numberWithInt:[[NSString stringWithFormat:@"%f", [[NSDate date] timeIntervalSince1970]] hash]]; - NSString *favoriteName = [[self name] length]?[self name]:[NSString stringWithFormat:@"%@@%@", [self user], [self host]]; - if (![[self name] length] && ![[self database] isEqualToString:@""]) + NSString *favoriteName = [[self name] length]?[self name]:[NSString stringWithFormat:@"%@@%@", ([self user] && [[self user] length])?[self user]:@"anonymous", [self host]]; + if (![[self name] length] && [self database] && ![[self database] isEqualToString:@""]) favoriteName = [NSString stringWithFormat:@"%@ %@", [self database], favoriteName]; // Ensure that host is not empty if this is a TCP/IP or SSH connection @@ -676,21 +676,20 @@ // Ensure that a socket connection is not inadvertently used if (![self checkHost]) return; - // Construct the favorite details - NSDictionary *newFavorite = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithInt:[self type]], @"type", - favoriteName, @"name", - [self host], @"host", - [self socket], @"socket", - [self user], @"user", - [self port], @"port", - [self database], @"database", - [self sshHost], @"sshHost", - [self sshUser], @"sshUser", - [self sshPort], @"sshPort", - favoriteid, @"id", - nil]; - + // Construct the favorite details - cannot use only dictionaryWithObjectsAndKeys for possible nil values. + NSMutableDictionary *newFavorite = [NSMutableDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithInt:[self type]], @"type", + favoriteName, @"name", + [self host], @"host", + favoriteid, @"id", + nil]; + if ([self socket]) [newFavorite setObject:[self socket] forKey:@"socket"]; + if ([self user]) [newFavorite setObject:[self user] forKey:@"user"]; + if ([self port]) [newFavorite setObject:[self port] forKey:@"port"]; + if ([self database]) [newFavorite setObject:[self database] forKey:@"database"]; + if ([self sshHost]) [newFavorite setObject:[self sshHost] forKey:@"sshHost"]; + if ([self sshUser]) [newFavorite setObject:[self sshUser] forKey:@"sshUser"]; + if ([self sshPort]) [newFavorite setObject:[self sshPort] forKey:@"sshPort"]; // Add the new favorite to the user defaults array NSMutableArray *currentFavorites; @@ -708,7 +707,7 @@ if (mySQLConnection && connectionKeychainItemName) { thePassword = [keychain getPasswordForName:connectionKeychainItemName account:connectionKeychainItemAccount]; } - if (![thePassword isEqualToString:@""]) { + if (thePassword && ![thePassword isEqualToString:@""]) { [keychain addPassword:thePassword forName:[keychain nameForFavoriteName:favoriteName id:[NSString stringWithFormat:@"%i", [favoriteid intValue]]] account:[keychain accountForUser:[self user] host:[self host] database:[self database]]]; @@ -719,7 +718,7 @@ if (mySQLConnection && connectionSSHKeychainItemName) { theSSHPassword = [keychain getPasswordForName:connectionSSHKeychainItemName account:connectionSSHKeychainItemAccount]; } - if (![theSSHPassword isEqualToString:@""]) { + if (theSSHPassword && ![theSSHPassword isEqualToString:@""]) { [keychain addPassword:theSSHPassword forName:[keychain nameForSSHForFavoriteName:favoriteName id:[NSString stringWithFormat:@"%i", [favoriteid intValue]]] account:[keychain accountForSSHUser:[self sshUser] sshHost:[self sshHost]]]; diff --git a/Source/SPHistoryController.h b/Source/SPHistoryController.h index 3e3c5452..4924d036 100644 --- a/Source/SPHistoryController.h +++ b/Source/SPHistoryController.h @@ -42,9 +42,11 @@ enum sphistory_view_types TableContent *tableContentInstance; NSMutableArray *history; unsigned int historyPosition; - BOOL restoringHistoryState; + BOOL modifyingHistoryState; } +@property (readwrite, assign) BOOL modifyingHistoryState; + // Interface interaction - (void) updateToolbarItem; - (IBAction) historyControlClicked:(NSSegmentedControl *)theControl; diff --git a/Source/SPHistoryController.m b/Source/SPHistoryController.m index acd25ea0..69ec9e57 100644 --- a/Source/SPHistoryController.m +++ b/Source/SPHistoryController.m @@ -30,6 +30,8 @@ @implementation SPHistoryController +@synthesize modifyingHistoryState; + #pragma mark Setup and teardown /** @@ -40,7 +42,7 @@ if (self = [super init]) { history = [[NSMutableArray alloc] init]; historyPosition = NSNotFound; - restoringHistoryState = NO; + modifyingHistoryState = NO; } return self; } @@ -134,7 +136,7 @@ { // Don't modify anything if we're in the process of restoring an old history state - if (restoringHistoryState) return; + if (modifyingHistoryState) return; // Work out the current document details NSString *theDatabase = [theDocument database]; @@ -217,7 +219,7 @@ return; } - restoringHistoryState = YES; + modifyingHistoryState = YES; // Update the position and extract the history entry historyPosition = position; @@ -236,7 +238,7 @@ && [[historyEntry objectForKey:@"view"] intValue] == [self currentlySelectedView] == SP_VIEW_CONTENT) { [tableContentInstance loadTable:[historyEntry objectForKey:@"table"]]; - restoringHistoryState = NO; + modifyingHistoryState = NO; [self updateToolbarItem]; return; } @@ -293,7 +295,7 @@ } } - restoringHistoryState = NO; + modifyingHistoryState = NO; [self updateToolbarItem]; } @@ -304,7 +306,7 @@ - (void) abortEntryLoad { NSBeep(); - restoringHistoryState = NO; + modifyingHistoryState = NO; } @end diff --git a/Source/TableContent.m b/Source/TableContent.m index 1e470112..6492b09d 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -436,6 +436,9 @@ */ - (IBAction)reloadTableValues:(id)sender { + // If no table is selected return + if (!selectedTable) return; + NSString *queryString; MCPResult *queryResult; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index eb2b6129..526ddae0 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -403,8 +403,12 @@ return; } - // Save existing scroll position and details - [spHistoryControllerInstance updateHistoryEntries]; + // Save existing scroll position and details, and ensure no duplicate entries are created as table list changes + BOOL historyStateChanging = [spHistoryControllerInstance modifyingHistoryState]; + if (!historyStateChanging) { + [spHistoryControllerInstance updateHistoryEntries]; + [spHistoryControllerInstance setModifyingHistoryState:YES]; + } // show error on connection failed if ( ![mySQLConnection selectDB:[chooseDatabaseButton titleOfSelectedItem]] ) { @@ -423,7 +427,10 @@ [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@", mySQLVersion, [self name], [self database]]]; // Add a history entry - [spHistoryControllerInstance updateHistoryEntries]; + if (!historyStateChanging) { + [spHistoryControllerInstance setModifyingHistoryState:NO]; + [spHistoryControllerInstance updateHistoryEntries]; + } } /** @@ -1371,9 +1378,9 @@ return [connectionController name]; } if ([connectionController type] == SP_CONNECTION_SOCKET) { - return [NSString stringWithFormat:@"%@@localhost", [connectionController user]?[connectionController user]:@""]; + return [NSString stringWithFormat:@"%@@localhost", ([connectionController user] && [[connectionController user] length])?[connectionController user]:@"anonymous"]; } - return [NSString stringWithFormat:@"%@@%@", [connectionController user]?[connectionController user]:@"", [connectionController host]?[connectionController host]:@""]; + return [NSString stringWithFormat:@"%@@%@", ([connectionController user] && [[connectionController user] length])?[connectionController user]:@"anonymous", [connectionController host]?[connectionController host]:@""]; } /** |