aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPNavigatorController.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-03-24 12:31:16 +0000
committerBibiko <bibiko@eva.mpg.de>2010-03-24 12:31:16 +0000
commit47f354070f1fa8dfeb46c4065075ee53de4c1626 (patch)
treef3fd6c947d3966baa4cf59d08b8ca02f0a756256 /Source/SPNavigatorController.m
parent1ddc896d2f88bea86e4b0457d63f7a53b846851d (diff)
downloadsequelpro-47f354070f1fa8dfeb46c4065075ee53de4c1626.tar.gz
sequelpro-47f354070f1fa8dfeb46c4065075ee53de4c1626.tar.bz2
sequelpro-47f354070f1fa8dfeb46c4065075ee53de4c1626.zip
• Navigator
- ENTER and RETURN selects schema path in active connection window - outsourced some stuff to SPNavigatorOutlineView • added rotating sync arrows to project for future usage
Diffstat (limited to 'Source/SPNavigatorController.m')
-rw-r--r--Source/SPNavigatorController.m122
1 files changed, 74 insertions, 48 deletions
diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m
index 757797ee..46780402 100644
--- a/Source/SPNavigatorController.m
+++ b/Source/SPNavigatorController.m
@@ -33,6 +33,7 @@
#import "SPLogger.h"
#import "SPTooltip.h"
+
static SPNavigatorController *sharedNavigatorController = nil;
#define DragFromNavigatorPboardType @"SPDragFromNavigatorPboardType"
@@ -66,6 +67,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
if((self = [super initWithWindowNibName:@"Navigator"])) {
schemaData = [[NSMutableDictionary alloc] init];
+ schemaDataUnFiltered = [[NSMutableDictionary alloc] init];
expandStatus1 = [[NSMutableDictionary alloc] init];
expandStatus2 = [[NSMutableDictionary alloc] init];
infoArray = [[NSMutableArray alloc] init];
@@ -73,6 +75,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
selectedKey2 = @"";
ignoreUpdate = NO;
[syncButton setState:NSOffState];
+
}
return self;
@@ -82,6 +85,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
- (void)dealloc
{
if(schemaData) [schemaData release];
+ if(schemaDataUnFiltered) [schemaDataUnFiltered release];
if(infoArray) [infoArray release];
if(expandStatus1) [expandStatus1 release];
if(expandStatus2) [expandStatus2 release];
@@ -122,6 +126,8 @@ static SPNavigatorController *sharedNavigatorController = nil;
return @"SPNavigator";
}
+#pragma mark -
+
- (BOOL)syncMode
{
if([[self window] isVisible])
@@ -161,14 +167,14 @@ static SPNavigatorController *sharedNavigatorController = nil;
selectionViewPort2 = [outlineSchema2 visibleRect];
if(schemaData) {
id selection = nil;
- selection = [outlineSchema1 itemAtRow:[outlineSchema1 selectedRow]];
+ selection = [outlineSchema1 selectedItem];
if(selection) {
id parentObject = [outlineSchema1 parentForItem:selection] ? [outlineSchema1 parentForItem:selection] : schemaData;
id parentKeys = [parentObject allKeysForObject:selection];
if(parentKeys && [parentKeys count] == 1)
selectedKey1 = [[parentKeys objectAtIndex:0] description];
}
- selection = [outlineSchema2 itemAtRow:[outlineSchema2 selectedRow]];
+ selection = [outlineSchema2 selectedItem];
if(selection) {
id parentObject = [outlineSchema2 parentForItem:selection] ? [outlineSchema2 parentForItem:selection] : schemaData;
id parentKeys = [parentObject allKeysForObject:selection];
@@ -206,7 +212,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
[outlineSchema2 selectRowIndexes:[NSIndexSet indexSetWithIndex:itemIndex] byExtendingSelection:NO];
if([outlineSchema2 numberOfSelectedRows] != 1) return;
[outlineSchema2 scrollRowToVisible:[outlineSchema2 selectedRow]];
- id item = [outlineSchema2 itemAtRow:[outlineSchema2 selectedRow]];
+ id item = [outlineSchema2 selectedItem];
// 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]];
@@ -301,6 +307,43 @@ static SPNavigatorController *sharedNavigatorController = nil;
}
}
+- (void)selectInActiveDocumentItem:(id)item fromView:(id)outlineView
+{
+ if([outlineView levelForItem:item] == 0) return;
+
+ 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;
+
+ 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;
+ }
+ if([[doc connectionID] isEqualToString:[pathArray objectAtIndex:0]]) {
+
+ // Select the database and table
+ [doc selectDatabase:[pathArray objectAtIndex:1] item:([pathArray count] > 2)?[pathArray objectAtIndex:2]:nil];
+
+ } 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"];
+
+ }
+ }
+ }
+}
+
#pragma mark -
#pragma mark IBActions
@@ -574,7 +617,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
if([parentObject allKeysForObject:item] && [[parentObject allKeysForObject:item] count]) {
NSString *key = [[parentObject allKeysForObject:item] objectAtIndex:0];
if([key rangeOfString:@"&SSH&"].length)
- return [NSString stringWithFormat:@"ssh: %@", [[key componentsSeparatedByString:@"&SSH&"] lastObject]];
+ return [NSString stringWithFormat:@"ssh: %@", [[[key componentsSeparatedByString:@"&SSH&"] lastObject] stringByReplacingOccurrencesOfString:@"&DEL&" withString:@" - "]];
else if([key rangeOfString:@"&DEL&"].length)
return [[key componentsSeparatedByString:@"&DEL&"] lastObject];
else
@@ -637,48 +680,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
*/
- (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) {
-
- 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 the database and table
- [doc selectDatabase:[pathArray objectAtIndex:1] item:([pathArray count] > 2)?[pathArray objectAtIndex:2]:nil];
-
- } 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"];
- }
- return YES;
- }
- }
-
-
+ [self selectInActiveDocumentItem:item fromView:outlineView];
return NO;
}
@@ -687,9 +689,9 @@ static SPNavigatorController *sharedNavigatorController = nil;
id ov = [aNotification object];
id selectedItem;
if(ov == outlineSchema1) {
- selectedItem = [outlineSchema1 itemAtRow:[outlineSchema1 selectedRow]];
+ selectedItem = [outlineSchema1 selectedItem];
} else if (ov == outlineSchema2) {
- selectedItem = [outlineSchema2 itemAtRow:[outlineSchema2 selectedRow]];
+ selectedItem = [outlineSchema2 selectedItem];
}
if(selectedItem) {
@@ -731,6 +733,19 @@ static SPNavigatorController *sharedNavigatorController = nil;
[infoTable reloadData];
}
+- (void)outlineView:(NSOutlineView *)outlineView didClickTableColumn:(NSTableColumn *)tableColumn
+{
+ if(outlineView == outlineSchema1) {
+ [infoQuickAccessSplitView setPosition:0 ofDividerAtIndex:0];
+ [schemaStatusSplitView setPosition:1000 ofDividerAtIndex:0];
+ [schema12SplitView setPosition:1000 ofDividerAtIndex:0];
+ } else if(outlineView == outlineSchema2) {
+ [infoQuickAccessSplitView setPosition:0 ofDividerAtIndex:0];
+ [schemaStatusSplitView setPosition:1000 ofDividerAtIndex:0];
+ [schema12SplitView setPosition:0 ofDividerAtIndex:0];
+ }
+}
+
- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
{
// Provide data for our custom type, and simple NSStrings.
@@ -816,6 +831,17 @@ static SPNavigatorController *sharedNavigatorController = nil;
return nil;
}
+- (void)tableView:(NSTableView*)tableView didClickTableColumn:(NSTableColumn *)tableColumn
+{
+
+ if(tableView == infoTable || tableView == quickAccessTable) {
+ [infoQuickAccessSplitView setPosition:1000 ofDividerAtIndex:0];
+ [schemaStatusSplitView setPosition:200 ofDividerAtIndex:0];
+ [outlineSchema1 scrollRowToVisible:[outlineSchema1 selectedRow]];
+ [outlineSchema2 scrollRowToVisible:[outlineSchema2 selectedRow]];
+ }
+}
+
#pragma mark -
#pragma mark others