diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-03-21 22:17:50 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-03-21 22:17:50 +0000 |
commit | b5cabd449156acaf18815759ee4cc5383e8fa4f6 (patch) | |
tree | 7e1c0c01cb8c86fb7dba26abf4c0b7a582d0a20f | |
parent | 919f4705fc4d4e59133e4279a1e87dc432e12f2d (diff) | |
download | sequelpro-b5cabd449156acaf18815759ee4cc5383e8fa4f6.tar.gz sequelpro-b5cabd449156acaf18815759ee4cc5383e8fa4f6.tar.bz2 sequelpro-b5cabd449156acaf18815759ee4cc5383e8fa4f6.zip |
• Navigator
- added 'sync' mode - the navigator follows the active window db/table selection if navigator has not multiple selected items
- added drag support of selected items
-- as comma separated and backtick quoted string for external apps
-- as array of schema paths for SP
• CMTextView
- added drop support for selected items coming from the Navigator
- insert them as comma list relative to current selected db/table
-rw-r--r-- | Interfaces/English.lproj/Navigator.xib | 94 | ||||
-rw-r--r-- | Source/CMTextView.m | 38 | ||||
-rw-r--r-- | Source/SPNavigatorController.h | 4 | ||||
-rw-r--r-- | Source/SPNavigatorController.m | 137 | ||||
-rw-r--r-- | Source/TableDocument.m | 30 | ||||
-rw-r--r-- | Source/TablesList.m | 15 |
6 files changed, 307 insertions, 11 deletions
diff --git a/Interfaces/English.lproj/Navigator.xib b/Interfaces/English.lproj/Navigator.xib index d4dd1904..974f8160 100644 --- a/Interfaces/English.lproj/Navigator.xib +++ b/Interfaces/English.lproj/Navigator.xib @@ -21,7 +21,7 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="97"/> + <integer value="43"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -57,7 +57,7 @@ <string key="NSWindowClass">NSPanel</string> <nil key="NSViewClass"/> <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> - <string key="NSWindowContentMinSize">{150, 200}</string> + <string key="NSWindowContentMinSize">{200, 200}</string> <object class="NSView" key="NSWindowView" id="881437593"> <reference key="NSNextResponder"/> <int key="NSvFlags">256</int> @@ -66,7 +66,7 @@ <object class="NSSearchField" id="701533802"> <reference key="NSNextResponder" ref="881437593"/> <int key="NSvFlags">270</int> - <string key="NSFrame">{{20, 336}, {241, 19}}</string> + <string key="NSFrame">{{20, 336}, {174, 19}}</string> <reference key="NSSuperview" ref="881437593"/> <int key="NSViewLayerContentsRedrawPolicy">2</int> <bool key="NSEnabled">YES</bool> @@ -240,6 +240,7 @@ </object> <int key="NSResizingMask">3</int> <bool key="NSIsResizeable">YES</bool> + <bool key="NSIsEditable">YES</bool> <reference key="NSTableView" ref="390132860"/> </object> <object class="NSTableColumn" id="583473822"> @@ -266,6 +267,7 @@ </object> <int key="NSResizingMask">3</int> <bool key="NSIsResizeable">YES</bool> + <bool key="NSIsEditable">YES</bool> <reference key="NSTableView" ref="390132860"/> </object> </object> @@ -290,7 +292,7 @@ </object> </object> <double key="NSRowHeight">14</double> - <int key="NSTvFlags">1379926016</int> + <int key="NSTvFlags">1514143744</int> <reference key="NSDelegate"/> <reference key="NSDataSource"/> <string key="NSAutosaveName">SPNavigatorSchema1</string> @@ -435,6 +437,7 @@ </object> <int key="NSResizingMask">3</int> <bool key="NSIsResizeable">YES</bool> + <bool key="NSIsEditable">YES</bool> <reference key="NSTableView" ref="771350217"/> </object> <object class="NSTableColumn" id="998799870"> @@ -461,6 +464,7 @@ </object> <int key="NSResizingMask">3</int> <bool key="NSIsResizeable">YES</bool> + <bool key="NSIsEditable">YES</bool> <reference key="NSTableView" ref="771350217"/> </object> </object> @@ -477,7 +481,7 @@ </object> <reference key="NSGridColor" ref="1022465183"/> <double key="NSRowHeight">14</double> - <int key="NSTvFlags">1379926016</int> + <int key="NSTvFlags">1514143744</int> <reference key="NSDelegate"/> <reference key="NSDataSource"/> <string key="NSAutosaveName">SPNavigatorSchema2</string> @@ -623,7 +627,7 @@ <bool key="EncodedWithXMLCoder">YES</bool> <object class="BWCustomView" id="657129721"> <reference key="NSNextResponder" ref="771483555"/> - <int key="NSvFlags">256</int> + <int key="NSvFlags">272</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSScrollView" id="830292448"> @@ -1061,13 +1065,37 @@ <int key="NSPeriodicInterval">75</int> </object> </object> + <object class="NSButton" id="357076828"> + <reference key="NSNextResponder" ref="881437593"/> + <int key="NSvFlags">265</int> + <string key="NSFrame">{{309, 337}, {42, 17}}</string> + <reference key="NSSuperview" ref="881437593"/> + <bool key="NSEnabled">YES</bool> + <object class="NSButtonCell" key="NSCell" id="541102869"> + <int key="NSCellFlags">67239424</int> + <int key="NSCellFlags2">134348800</int> + <string key="NSContents">sync</string> + <object class="NSFont" key="NSSupport"> + <string key="NSName">LucidaGrande-Bold</string> + <double key="NSSize">12</double> + <int key="NSfFlags">16</int> + </object> + <reference key="NSControlView" ref="357076828"/> + <int key="NSButtonFlags">-1228128001</int> + <int key="NSButtonFlags2">402653357</int> + <string key="NSAlternateContents"/> + <string key="NSKeyEquivalent">s</string> + <int key="NSPeriodicDelay">400</int> + <int key="NSPeriodicInterval">75</int> + </object> + </object> </object> <string key="NSFrameSize">{395, 359}</string> <reference key="NSSuperview"/> <int key="NSViewLayerContentsRedrawPolicy">2</int> </object> <string key="NSScreenRect">{{0, 0}, {1280, 778}}</string> - <string key="NSMinSize">{150, 222}</string> + <string key="NSMinSize">{200, 222}</string> <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> <string key="NSFrameAutosaveName"/> </object> @@ -1219,6 +1247,22 @@ </object> <int key="connectionID">107</int> </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">syncButton</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="357076828"/> + </object> + <int key="connectionID">110</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">syncButtonAction:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="357076828"/> + </object> + <int key="connectionID">111</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -1265,6 +1309,7 @@ <reference ref="701533802"/> <reference ref="112878735"/> <reference ref="576014685"/> + <reference ref="357076828"/> </object> <reference key="parent" ref="856804369"/> </object> @@ -1619,6 +1664,20 @@ <reference key="object" ref="1070719064"/> <reference key="parent" ref="479609640"/> </object> + <object class="IBObjectRecord"> + <int key="objectID">108</int> + <reference key="object" ref="357076828"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="541102869"/> + </object> + <reference key="parent" ref="881437593"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">109</int> + <reference key="object" ref="541102869"/> + <reference key="parent" ref="357076828"/> + </object> </object> </object> <object class="NSMutableDictionary" key="flattenedProperties"> @@ -1628,6 +1687,9 @@ <string>-1.IBPluginDependency</string> <string>-2.IBPluginDependency</string> <string>-3.IBPluginDependency</string> + <string>108.IBAttributePlaceholdersKey</string> + <string>108.IBPluginDependency</string> + <string>109.IBPluginDependency</string> <string>13.IBPluginDependency</string> <string>14.IBPluginDependency</string> <string>15.IBPluginDependency</string> @@ -1695,6 +1757,16 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <object class="NSMutableDictionary"> + <string key="NS.key.0">ToolTip</string> + <object class="IBToolTipAttribute" key="NS.object.0"> + <string key="name">ToolTip</string> + <reference key="object" ref="357076828"/> + <string key="toolTip">Synchronize connection window selection with Navigator (⌥⌘S)</string> + </object> + </object> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.brandonwalkin.BWToolkit</string> <string>com.brandonwalkin.BWToolkit</string> <string>com.brandonwalkin.BWToolkit</string> @@ -1716,7 +1788,7 @@ <string>{{72, 342}, {395, 359}}</string> <boolean value="NO"/> <boolean value="YES"/> - <string>{150, 200}</string> + <string>{200, 200}</string> <string>ImageAndTextCell</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -1781,7 +1853,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">107</int> + <int key="maxID">111</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.1+"> @@ -1804,6 +1876,7 @@ <string>filterTree:</string> <string>outlineViewAction:</string> <string>reloadAllStructures:</string> + <string>syncButtonAction:</string> <string>updateEntries:</string> </object> <object class="NSMutableArray" key="dict.values"> @@ -1812,6 +1885,7 @@ <string>id</string> <string>id</string> <string>id</string> + <string>id</string> </object> </object> <object class="NSMutableDictionary" key="outlets"> @@ -1824,6 +1898,7 @@ <string>outlineSchema2</string> <string>quickAccessTable</string> <string>searchField</string> + <string>syncButton</string> </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -1833,6 +1908,7 @@ <string>id</string> <string>id</string> <string>id</string> + <string>id</string> </object> </object> <object class="IBClassDescriptionSource" key="sourceIdentifier"> diff --git a/Source/CMTextView.m b/Source/CMTextView.m index 6d6befc8..2a5c43c7 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -3056,6 +3056,44 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) } return YES; } + + // Insert selected items coming from the Navigator + if ( [[pboard types] containsObject:@"SPDragFromNavigatorPboardType"] ) { + NSPoint draggingLocation = [sender draggingLocation]; + draggingLocation = [self convertPoint:draggingLocation fromView:nil]; + NSUInteger characterIndex = [self characterIndexOfPoint:draggingLocation]; + [self setSelectedRange:NSMakeRange(characterIndex,0)]; + + NSKeyedUnarchiver *unarchiver = [[[NSKeyedUnarchiver alloc] initForReadingWithData:[pboard dataForType:@"SPDragFromNavigatorPboardType"]] autorelease]; + NSArray *draggedItems = [[NSArray alloc] initWithArray:(NSArray *)[unarchiver decodeObjectForKey:@"itemdata"]]; + [unarchiver finishDecoding]; + + NSMutableString *dragString = [NSMutableString string]; + NSMutableString *aPath = [NSMutableString string]; + + NSString *currentDb = nil; + NSString *currentTable = nil; + + if ([[[[self window] delegate] valueForKeyPath:@"tablesListInstance"] valueForKey:@"selectedDatabase"] != nil) + currentDb = [[[[self window] delegate] valueForKeyPath:@"tablesListInstance"] valueForKeyPath:@"selectedDatabase"]; + if ([[[[self window] delegate] valueForKeyPath:@"tablesListInstance"] valueForKey:@"tableName"] != nil) + currentTable = [[[[self window] delegate] valueForKeyPath:@"tablesListInstance"] valueForKeyPath:@"tableName"]; + + if(!currentDb) currentDb = @""; + if(!currentTable) currentTable = @""; + + for(NSString* item in draggedItems) { + if([dragString length]) [dragString appendString:@", "]; + [aPath setString:item]; + // Insert path relative to the current selected db and table if any + [aPath replaceOccurrencesOfRegex:[NSString stringWithFormat:@"^%@%@", currentDb, SPUniqueSchemaDelimiter] withString:@""]; + [aPath replaceOccurrencesOfRegex:[NSString stringWithFormat:@"^%@%@", currentTable, SPUniqueSchemaDelimiter] withString:@""]; + [dragString appendString:[[aPath componentsSeparatedByString:SPUniqueSchemaDelimiter] componentsJoinedByPeriodAndBacktickQuoted]]; + } + [self breakUndoCoalescing]; + [self insertText:dragString]; + return YES; + } return [super performDragOperation:sender]; } diff --git a/Source/SPNavigatorController.h b/Source/SPNavigatorController.h index c0789c4f..6895a9f2 100644 --- a/Source/SPNavigatorController.h +++ b/Source/SPNavigatorController.h @@ -34,6 +34,7 @@ IBOutlet id infoTable; IBOutlet id quickAccessTable; IBOutlet id searchField; + IBOutlet id syncButton; NSUserDefaults *prefs; @@ -56,10 +57,13 @@ - (IBAction)updateEntries:(id)sender; - (IBAction)reloadAllStructures:(id)sender; - (IBAction)filterTree:(id)sender; +- (IBAction)syncButtonAction:(id)sender; - (NSString*)tableInfoLabelForIndex:(NSInteger)index; - (void)restoreSelectedItems; - (void)setIgnoreUpdate:(BOOL)flag; +- (void)selectPath:(NSString*)schemaPath; +- (BOOL)syncMode; @end diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m index 050df716..56c51438 100644 --- a/Source/SPNavigatorController.m +++ b/Source/SPNavigatorController.m @@ -27,10 +27,13 @@ #import "SPOutlineView.h" #import "SPConstants.h" #import "ImageAndTextCell.h" - +#import "TableDocument.h" +#import "SPArrayAdditions.h" static SPNavigatorController *sharedNavigatorController = nil; +#define DragFromNavigatorPboardType @"SPDragFromNavigatorPboardType" + @implementation SPNavigatorController @@ -66,6 +69,7 @@ static SPNavigatorController *sharedNavigatorController = nil; selectedKey1 = @""; selectedKey2 = @""; ignoreUpdate = NO; + [syncButton setState:NSOffState]; } return self; @@ -101,6 +105,12 @@ static SPNavigatorController *sharedNavigatorController = nil; prefs = [NSUserDefaults standardUserDefaults]; [self setWindowFrameAutosaveName:@"SPNavigator"]; + [outlineSchema1 registerForDraggedTypes:[NSArray arrayWithObjects:DragFromNavigatorPboardType, NSStringPboardType, nil]]; + [outlineSchema1 setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES]; + [outlineSchema1 setDraggingSourceOperationMask:NSDragOperationEvery forLocal:NO]; + [outlineSchema2 registerForDraggedTypes:[NSArray arrayWithObjects:DragFromNavigatorPboardType, NSStringPboardType, nil]]; + [outlineSchema2 setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES]; + [outlineSchema2 setDraggingSourceOperationMask:NSDragOperationEvery forLocal:NO]; } @@ -109,6 +119,13 @@ static SPNavigatorController *sharedNavigatorController = nil; return @"SPNavigator"; } +- (BOOL)syncMode +{ + if([[self window] isVisible]) + return ([syncButton state] == NSOffState || [outlineSchema2 numberOfSelectedRows] > 1) ? NO : YES; + return NO; +} + - (void)restoreExpandStatus { @@ -159,6 +176,45 @@ static SPNavigatorController *sharedNavigatorController = nil; } +- (void)selectPath:(NSString*)schemaPath +{ + if(schemaPath && [schemaPath length]) { + + // Do not change the selection if a field of schemaPath's table is already selected + [self saveSelectedItems]; + if([selectedKey2 length] && [selectedKey2 hasPrefix:[NSString stringWithFormat:@"%@%@", schemaPath, SPUniqueSchemaDelimiter]]) + return; + + id item = schemaData; + NSArray *pathArray = [schemaPath componentsSeparatedByString:SPUniqueSchemaDelimiter]; + NSMutableString *aKey = [NSMutableString string]; + [outlineSchema2 collapseItem:[item objectForKey:[pathArray objectAtIndex:0]] collapseChildren:YES]; + for(NSInteger i=0; i < [pathArray count]; i++) { + [aKey appendString:[pathArray objectAtIndex:i]]; + if(![item objectForKey:aKey]) break; + item = [item objectForKey:aKey]; + [outlineSchema2 expandItem:item]; + [aKey appendString:SPUniqueSchemaDelimiter]; + } + if(item != nil) { + NSInteger itemIndex = [outlineSchema2 rowForItem:item]; + if (itemIndex >= 0) { + [outlineSchema2 selectRowIndexes:[NSIndexSet indexSetWithIndex:itemIndex] byExtendingSelection:NO]; + [outlineSchema2 scrollRowToVisible:[outlineSchema2 selectedRow]]; + id item = [outlineSchema2 itemAtRow:[outlineSchema2 selectedRow]]; + // Try to scroll the view that all children of schemaPath are visible if possible + NSInteger cnt = [item count]+1; + NSRange r = [outlineSchema2 rowsInRect:[outlineSchema2 visibleRect]]; + NSInteger offset = (cnt > r.length) ? (r.length-2) : cnt; + offset += [outlineSchema2 selectedRow]; + if(offset >= [outlineSchema2 numberOfRows]) + offset = [outlineSchema2 numberOfRows] - 1; + [outlineSchema2 scrollRowToVisible:offset]; + } + } + } +} + - (void)restoreSelectedItems { @@ -282,6 +338,7 @@ static SPNavigatorController *sharedNavigatorController = nil; selectedKey2 = @""; selectionViewPort1 = NSZeroRect; selectionViewPort2 = NSZeroRect; + [syncButton setState:NSOffState]; if ([[[NSDocumentController sharedDocumentController] documents] count]) { for(id doc in [[NSDocumentController sharedDocumentController] documents]) { @@ -302,6 +359,26 @@ static SPNavigatorController *sharedNavigatorController = nil; NSString *pattern = [searchField stringValue]; } +- (IBAction)syncButtonAction:(id)sender +{ + if([syncButton state] == NSOnState) { + if ([[[NSDocumentController sharedDocumentController] documents] count]) { + TableDocument *doc = [[NSDocumentController sharedDocumentController] currentDocument]; + NSMutableString *key = [NSMutableString string]; + [key setString:[doc connectionID]]; + if([doc database] && [(NSString*)[doc database] length]){ + [key appendString:SPUniqueSchemaDelimiter]; + [key appendString:[doc database]]; + } + if([doc table] && [(NSString*)[doc table] length]){ + [key appendString:SPUniqueSchemaDelimiter]; + [key appendString:[doc table]]; + } + [self selectPath:key]; + } + } +} + #pragma mark - #pragma mark outline delegates @@ -507,6 +584,28 @@ static SPNavigatorController *sharedNavigatorController = nil; return YES; } +- (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item +{ + if([outlineView levelForItem:item] == 0) return NO; + + id parentObject = [outlineView parentForItem:item] ? [outlineView parentForItem:item] : schemaData; + id parentKeys = [parentObject allKeysForObject:item]; + if(parentKeys && [parentKeys count] == 1) { + NSArray *pathArray = [[[parentKeys objectAtIndex:0] description] componentsSeparatedByString:SPUniqueSchemaDelimiter]; + if([pathArray count] > 1) { + TableDocument *doc = [[NSDocumentController sharedDocumentController] currentDocument]; + if([[doc connectionID] isEqualToString:[pathArray objectAtIndex:0]]) { + if(![[doc database] isEqualToString:[pathArray objectAtIndex:1]]) { + // todo + } + } + } + } + + + return NO; +} + - (void)outlineViewSelectionDidChange:(NSNotification *)aNotification { id ov = [aNotification object]; @@ -524,7 +623,7 @@ static SPNavigatorController *sharedNavigatorController = nil; [infoTable setRowHeight:18.0]; NSInteger i = 0; for(id item in selectedItem) { - if([item isKindOfClass:[NSString class]] && [item length]) { + if([item isKindOfClass:[NSString class]] && [(NSString*)item length]) { [infoArray addObject:[NSString stringWithFormat:@"%@: %@", [self tableInfoLabelForIndex:i], [item stringByReplacingOccurrencesOfString:@"," withString:@", "]]]; } i++; @@ -534,6 +633,40 @@ static SPNavigatorController *sharedNavigatorController = nil; [infoTable reloadData]; } +- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard +{ + // Provide data for our custom type, and simple NSStrings. + [pboard declareTypes:[NSArray arrayWithObjects:DragFromNavigatorPboardType, NSStringPboardType, nil] owner:self]; + + // Collect the actual schema paths without leading connection ID + NSMutableArray *draggedItems = [NSMutableArray array]; + for(id item in items) { + id parentObject = [outlineView parentForItem:item] ? [outlineView parentForItem:item] : schemaData; + id parentKeys = [parentObject allKeysForObject:item]; + if(parentKeys && [parentKeys count] == 1) + [draggedItems addObject:[[[parentKeys objectAtIndex:0] description] stringByReplacingOccurrencesOfRegex:[NSString stringWithFormat:@"^.*?%@", SPUniqueSchemaDelimiter] withString:@""]]; + } + + // Drag the array with schema paths + NSMutableData *arraydata = [[[NSMutableData alloc] init] autorelease]; + NSKeyedArchiver *archiver = [[[NSKeyedArchiver alloc] initForWritingWithMutableData:arraydata] autorelease]; + [archiver encodeObject:draggedItems forKey:@"itemdata"]; + [archiver finishEncoding]; + [pboard setData:arraydata forType:DragFromNavigatorPboardType]; + + // For external destinations provide a comma separated string + NSMutableString *dragString = [NSMutableString string]; + for(id item in draggedItems) { + if([dragString length]) [dragString appendString:@", "]; + [dragString appendString:[[item componentsSeparatedByString:SPUniqueSchemaDelimiter] componentsJoinedByPeriodAndBacktickQuotedAndIgnoreFirst]]; + } + + if(![dragString length]) return NO; + + [pboard setString:dragString forType:NSStringPboardType]; + return YES; +} + #pragma mark - #pragma mark table delegates diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 36291911..763a444b 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -743,6 +743,7 @@ break; } } + } /** @@ -857,6 +858,17 @@ // Do not update the navigator since nothing is changed [[SPNavigatorController sharedNavigatorController] setIgnoreUpdate:YES]; + // If Navigator runs in syncMode let it follow the selection + if([[SPNavigatorController sharedNavigatorController] syncMode]) { + NSMutableString *schemaPath = [NSMutableString string]; + [schemaPath setString:[self connectionID]]; + if([chooseDatabaseButton titleOfSelectedItem] && [[chooseDatabaseButton titleOfSelectedItem] length]) { + [schemaPath appendString:SPUniqueSchemaDelimiter]; + [schemaPath appendString:[chooseDatabaseButton titleOfSelectedItem]]; + } + [[SPNavigatorController sharedNavigatorController] selectPath:schemaPath]; + } + // Start a task [self startTaskWithDescription:[NSString stringWithFormat:NSLocalizedString(@"Loading database '%@'...", @"Loading database task string"), [chooseDatabaseButton titleOfSelectedItem]]]; if ([NSThread isMainThread]) { @@ -3692,6 +3704,24 @@ return YES; } +- (void)windowDidBecomeKey:(NSNotification *)notification +{ + // Synchronize Navigator with current active document if Navigator runs in syncMode + if([[SPNavigatorController sharedNavigatorController] syncMode] && [self connectionID] && ![[self connectionID] isEqualToString:@"_"]) { + NSMutableString *schemaPath = [NSMutableString string]; + [schemaPath setString:[self connectionID]]; + if([self database] && [[self database] length]) { + [schemaPath appendString:SPUniqueSchemaDelimiter]; + [schemaPath appendString:[self database]]; + if([self table] && [[self table] length]) { + [schemaPath appendString:SPUniqueSchemaDelimiter]; + [schemaPath appendString:[self table]]; + } + } + [[SPNavigatorController sharedNavigatorController] selectPath:schemaPath]; + } +} + /** * Invoked when the document window is resized */ diff --git a/Source/TablesList.m b/Source/TablesList.m index 74f4a390..6de845f3 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -39,6 +39,7 @@ #import "NSNotificationAdditions.h" #import "SPConstants.h" #import "SPAlertSheets.h" +#import "SPNavigatorController.h" @interface TablesList (PrivateAPI) @@ -1420,6 +1421,20 @@ if ([tablesListView numberOfSelectedRows] == 1 && [(NSString *)[filteredTables objectAtIndex:[tablesListView selectedRow]] length]) tableName = [filteredTables objectAtIndex:[tablesListView selectedRow]]; [self updateSelectionWithTaskString:[NSString stringWithFormat:NSLocalizedString(@"Loading %@...", @"Loading table task string"), tableName]]; + + if([[SPNavigatorController sharedNavigatorController] syncMode]) { + NSMutableString *schemaPath = [NSMutableString string]; + [schemaPath setString:[tableDocumentInstance connectionID]]; + if([tableDocumentInstance database] && [[tableDocumentInstance database] length]) { + [schemaPath appendString:SPUniqueSchemaDelimiter]; + [schemaPath appendString:[tableDocumentInstance database]]; + if(tableName && [tableName length]) { + [schemaPath appendString:SPUniqueSchemaDelimiter]; + [schemaPath appendString:tableName]; + } + } + [[SPNavigatorController sharedNavigatorController] selectPath:schemaPath]; + } } /** |