aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/DBView.xib30
-rw-r--r--Source/TableDocument.h1
-rw-r--r--Source/TableDocument.m33
3 files changed, 58 insertions, 6 deletions
diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib
index bf8c0bcd..c1ca69af 100644
--- a/Interfaces/English.lproj/DBView.xib
+++ b/Interfaces/English.lproj/DBView.xib
@@ -8,6 +8,7 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="1911"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -3692,7 +3693,7 @@
<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
<string key="NSWindowContentMinSize">{256, 191}</string>
<object class="NSView" key="NSWindowView" id="586457094">
- <nil key="NSNextResponder"/>
+ <reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -4270,7 +4271,7 @@
<reference key="NSSuperview" ref="248896606"/>
</object>
</object>
- <string key="NSFrame">{{-3, 44}, {525, 222}}</string>
+ <string key="NSFrame">{{-3, 42}, {525, 222}}</string>
<reference key="NSSuperview" ref="586457094"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
@@ -4292,6 +4293,7 @@
</object>
</object>
<string key="NSFrameSize">{519, 335}</string>
+ <reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
<string key="NSMinSize">{256, 213}</string>
@@ -8274,6 +8276,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
<string key="NSFrame">{{1, 1}, {198, 107}}</string>
<reference key="NSSuperview" ref="27548452"/>
+ <reference key="NSNextKeyView" ref="29661959"/>
<reference key="NSDocView" ref="29661959"/>
<reference key="NSBGColor" ref="1024678221"/>
<int key="NScvFlags">4</int>
@@ -8301,6 +8304,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
<string key="NSFrame">{{20, 20}, {211, 109}}</string>
<reference key="NSSuperview" ref="774289419"/>
+ <reference key="NSNextKeyView" ref="383807970"/>
<int key="NSsFlags">18</int>
<reference key="NSVScroller" ref="438736883"/>
<reference key="NSHScroller" ref="721548430"/>
@@ -12485,6 +12489,22 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
<int key="connectionID">5373</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">dataSource</string>
+ <reference key="source" ref="158332213"/>
+ <reference key="destination" ref="427689665"/>
+ </object>
+ <int key="connectionID">5374</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="158332213"/>
+ <reference key="destination" ref="427689665"/>
+ </object>
+ <int key="connectionID">5376</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -19706,8 +19726,8 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{429, 388}, {519, 335}}</string>
- <string>{{429, 388}, {519, 335}}</string>
+ <string>{{476, 484}, {519, 335}}</string>
+ <string>{{476, 484}, {519, 335}}</string>
<reference ref="9"/>
<string>{{136, 447}, {519, 335}}</string>
<reference ref="8"/>
@@ -20710,7 +20730,7 @@ Y2hhbmdlIHRoZSBvcmRlcg</string>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">5373</int>
+ <int key="maxID">5376</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
diff --git a/Source/TableDocument.h b/Source/TableDocument.h
index 299e5430..b9426e31 100644
--- a/Source/TableDocument.h
+++ b/Source/TableDocument.h
@@ -85,6 +85,7 @@
NSString *selectedDatabase;
NSString *mySQLVersion;
NSUserDefaults *prefs;
+ NSString *favoriteNamebBeingChanged;
NSMenu *selectEncodingMenu;
BOOL _supportsEncoding;
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index 269af5e1..1f6f16bb 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -1814,7 +1814,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocum
}
-// TableView datasource methods
+#pragma mark TableView datasource methods
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{
@@ -1837,6 +1837,37 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocum
return theValue;
}
+/**
+ * Although the connection sheet tableview uses bindings to display the favourites we implement this method in
+ * order to update the keychain associated with favourites that are renamed. Its not the best approach, but it works.
+ */
+- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
+{
+ NSDictionary *favorite = [favorites objectAtIndex:rowIndex];
+
+ [keyChainInstance deletePasswordForName:[NSString stringWithFormat:@"Sequel Pro : %@", favoriteNamebBeingChanged]
+ account:[NSString stringWithFormat:@"%@@%@/%@", [favorite objectForKey:@"user"], [favorite objectForKey:@"host"], [favorite objectForKey:@"database"]]];
+
+ if ( ![[passwordField stringValue] isEqualToString:@""] )
+ [keyChainInstance addPassword:[passwordField stringValue]
+ forName:[NSString stringWithFormat:@"Sequel Pro : %@", object]
+ account:[NSString stringWithFormat:@"%@@%@/%@", [favorite objectForKey:@"user"], [favorite objectForKey:@"host"], [favorite objectForKey:@"database"]]];
+
+ favoriteNamebBeingChanged = nil;
+}
+
+/**
+ * We implement this method so we can get the name of the favourtie before its renamed. We need the name so we
+ * look it up in the keychain and update its name, which is done in the above method. This is obviously not the
+ * best approach to doing this as it means we need an ivar just to track the favourite that is about to be renamed.
+ */
+- (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
+{
+ favoriteNamebBeingChanged = [[favorites objectAtIndex:rowIndex] objectForKey:@"name"];
+
+ return YES;
+}
+
- (IBAction)terminate:(id)sender
{
[[NSApp orderedDocuments] makeObjectsPerformSelector:@selector(cancelConnectSheet:) withObject:nil];