diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPNavigatorController.m | 40 | ||||
-rw-r--r-- | Source/TablesList.m | 3 |
2 files changed, 40 insertions, 3 deletions
diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m index 21389757..a9ce93c8 100644 --- a/Source/SPNavigatorController.m +++ b/Source/SPNavigatorController.m @@ -28,8 +28,10 @@ #import "SPConstants.h" #import "ImageAndTextCell.h" #import "TableDocument.h" +#import "TablesList.h" #import "SPArrayAdditions.h" #import "SPLogger.h" +#import "SPTooltip.h" static SPNavigatorController *sharedNavigatorController = nil; @@ -630,7 +632,9 @@ static SPNavigatorController *sharedNavigatorController = nil; return NO; return YES; } - +/* + * Double-click on item selects the chosen path in active connection window + */ - (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item { if([outlineView levelForItem:item] == 0) return NO; @@ -638,13 +642,45 @@ static SPNavigatorController *sharedNavigatorController = nil; id parentObject = [outlineView parentForItem:item] ? [outlineView parentForItem:item] : schemaData; id parentKeys = [parentObject allKeysForObject:item]; if(parentKeys && [parentKeys count] == 1) { + + NSPoint pos = [NSEvent mouseLocation]; + pos.y -= 20; + + // Do not allow to double-click at PROCs and FUNCs since it doesn't make sense + if([item isKindOfClass:[NSDictionary class]] && [item objectForKey:@" struct_type "] && [[item objectForKey:@" struct_type "] intValue] > 1) { + [SPTooltip showWithObject:NSLocalizedString(@"You only can select tables or views.", @"you only can select tables or views tooltip") + atLocation:pos + ofType:@"text"]; + return NO; + } + NSArray *pathArray = [[[parentKeys objectAtIndex:0] description] componentsSeparatedByString:SPUniqueSchemaDelimiter]; if([pathArray count] > 1) { + TableDocument *doc = [[NSDocumentController sharedDocumentController] currentDocument]; + if([doc isWorking]) { + [SPTooltip showWithObject:NSLocalizedString(@"Active connection window is busy. Please wait and try again.", @"active connection window is busy. please wait and try again. tooltip") + atLocation:pos + ofType:@"text"]; + return NO; + } if([[doc connectionID] isEqualToString:[pathArray objectAtIndex:0]]) { + + // select db if(![[doc database] isEqualToString:[pathArray objectAtIndex:1]]) { - // todo + if([[doc valueForKeyPath:@"mySQLConnection"] isConnected]) { + [[doc valueForKeyPath:@"chooseDatabaseButton"] selectItemWithTitle:[pathArray objectAtIndex:1]]; + [doc chooseDatabase:self]; + } } + // select table/view if given + if([pathArray count] > 2) + [[doc valueForKeyPath:@"tablesListInstance"] performSelector:@selector(selectTableOrViewWithName:) withObject:[pathArray objectAtIndex:2] afterDelay:0.1]; + + } else { + [SPTooltip showWithObject:NSLocalizedString(@"The connection of the active connection window is not identical.", @"the connection of the active connection window is not identical tooltip") + atLocation:pos + ofType:@"text"]; } } } diff --git a/Source/TablesList.m b/Source/TablesList.m index 6de845f3..03454e80 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -1234,6 +1234,7 @@ [self updateSelectionWithTaskString:[NSString stringWithFormat:NSLocalizedString(@"Loading %@...", @"Loading table task string"), theName]]; } } + [tablesListView scrollRowToVisible:[tablesListView selectedRow]]; return YES; } @@ -1422,7 +1423,7 @@ tableName = [filteredTables objectAtIndex:[tablesListView selectedRow]]; [self updateSelectionWithTaskString:[NSString stringWithFormat:NSLocalizedString(@"Loading %@...", @"Loading table task string"), tableName]]; - if([[SPNavigatorController sharedNavigatorController] syncMode]) { + if([[SPNavigatorController sharedNavigatorController] syncMode] && [tablesListView numberOfSelectedRows] == 1) { NSMutableString *schemaPath = [NSMutableString string]; [schemaPath setString:[tableDocumentInstance connectionID]]; if([tableDocumentInstance database] && [[tableDocumentInstance database] length]) { |