From cd588325f3843d7c2e246ad58a8a47d78236e35c Mon Sep 17 00:00:00 2001 From: Bibiko Date: Thu, 12 Aug 2010 10:33:07 +0000 Subject: =?UTF-8?q?=E2=80=A2=C2=A0some=20minor=20work=20on=20Navigator=20-?= =?UTF-8?q?=20refresh=20on=20first=20init=20-=20sped=20up=20sorting=20a=20?= =?UTF-8?q?bit=20-=20code=20improvements=20-=20removed=20Quick=20Access=20?= =?UTF-8?q?since=20it=20can=20be=20outsourced=20(in=20the=20future)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/Navigator.xib | 838 ++++++++++----------------------- Source/SPNavigatorController.h | 5 +- Source/SPNavigatorController.m | 44 +- 3 files changed, 291 insertions(+), 596 deletions(-) diff --git a/Interfaces/English.lproj/Navigator.xib b/Interfaces/English.lproj/Navigator.xib index b48f2a92..223d8871 100644 --- a/Interfaces/English.lproj/Navigator.xib +++ b/Interfaces/English.lproj/Navigator.xib @@ -21,12 +21,12 @@ YES - + YES - com.apple.InterfaceBuilder.CocoaPlugin com.brandonwalkin.BWToolkit + com.apple.InterfaceBuilder.CocoaPlugin YES @@ -56,7 +56,7 @@ Navigator NSPanel - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} {200, 200} @@ -178,7 +178,7 @@ 256 - {394, 19} + {383, 14} 2 YES @@ -186,14 +186,14 @@ 256 - {394, 17} + {383, 17} 2 - -2147483392 + 256 {{384, 0}, {12, 17}} 2 @@ -233,7 +233,7 @@ controlBackgroundColor 3 - MC42NjY2NjY2NjY3AA + MC42NjY2NjY2ODY1AA @@ -245,7 +245,7 @@ type - 200 + 189 40 1000 @@ -292,7 +292,7 @@ 14 - 1245708288 + 1243611136 SPNavigatorSchema1 @@ -305,7 +305,7 @@ 12 - {{1, 17}, {394, 19}} + {{1, 17}, {383, 0}} 2 @@ -315,25 +315,25 @@ - -2147483392 - {{384, 17}, {11, 13}} + 256 + {{384, 17}, {11, -11}} 2 + YES 256 _doScroller: - 0.92857140302658081 -2147483392 - {{1, 19}, {383, 11}} + {{1, 6}, {383, 11}} 2 257 _doScroller: - 0.97208124399185181 + 0.99739581346511841 @@ -342,7 +342,7 @@ YES - {{1, 0}, {394, 17}} + {{1, 0}, {383, 17}} 2 @@ -352,11 +352,11 @@ - {396, 37} + {396, 18} 2 - 562 + 626 @@ -365,7 +365,7 @@ QSAAAEEgAABBYAAAQWAAAA - {395, 37} + {395, 18} 2 NSView @@ -388,7 +388,7 @@ 256 - {394, 177} + {394, 196} 2 YES @@ -494,7 +494,7 @@ 12 - {{1, 17}, {394, 177}} + {{1, 17}, {394, 196}} 2 @@ -541,7 +541,7 @@ - {396, 195} + {396, 214} 2 @@ -554,7 +554,7 @@ QSAAAEEgAABBYAAAQWAAAA - {{0, 38}, {395, 195}} + {{0, 19}, {395, 214}} 2 NSView @@ -627,359 +627,167 @@ 274 YES - + + + 268 + {{398, 23}, {96, 32}} + + YES + + 67239424 + 134217728 + Button + + LucidaGrande + 13 + 1044 + + + -2038284033 + 268435585 + + f + 200 + 25 + + + 274 YES - - - 272 + + + 2304 YES - - + + 274 - + {394, 82} + + YES + + + 256 + {394, 17} + + + + + + -2147483392 + {{224, 0}, {16, 17}} + + + YES - - - 2304 - - YES - - - 274 - {394, 32} - - YES - - - 256 - {394, 17} - - - - - - -2147483392 - {{224, 0}, {16, 17}} - - - - YES - - 391 - 40 - 1000 - - 75628096 - 2048 - Information - - - 3 - MC4zMzMzMzI5ODU2AA - - - - - 67239488 - 268568576 - Text Cell - - - - - - 3 - YES - - - - 3 - 2 - - 6 - System - _sourceListBackgroundColor - - 1 - MC44MzkyMTU2OTU5IDAuODY2NjY2Njc0NiAwLjg5ODAzOTIyMTgAA - - - - 18 - 1379926016 - - - 4 - 15 - 0 - YES - 1 - 1 + + 391 + 40 + 1000 + + 75628096 + 2048 + Information + + + 3 + MC4zMzMzMzI5ODU2AA + - {{1, 17}, {394, 32}} - - - - - 4 - - - - -2147483392 - {{224, 17}, {11, 102}} - - 256 - - _doScroller: - 0.65625 - - - - -2147483392 - {{1, 38}, {393, 11}} - - 257 - - _doScroller: - 0.99746191501617432 - - - - 2304 - - YES - + + 67239488 + 268568576 + Text Cell + + + + - {{1, 0}, {394, 17}} - - - - - 4 + 3 + YES + - - {396, 50} - - - 562 - - - - - - QSAAAEEgAABBoAAAQaAAAA - - - {395, 50} - - NSView - - - - 272 - - YES - - - 274 - - YES - - - 2304 - - YES - - - 256 - {394, 31} - - YES - - - 256 - {394, 17} - - - - - - -2147483392 - {{379, 0}, {16, 17}} - - - - YES - - 391 - 40 - 1000 - - 75628096 - 2048 - Quick Access - - - 3 - MC4zMzMzMzI5ODU2AA - - - - - 67239488 - 133120 - Text Cell - - - - - - 3 - YES - - - - 3 - 2 - - 6 - System - _sourceListBackgroundColor - - 1 - MC44MzkyMTU2OTU5IDAuODY2NjY2Njc0NiAwLjg5ODAzOTIyMTgAA - - - - 14 - 1379926016 - - - 4 - 15 - 0 - YES - 1 - 1 - - - {{1, 17}, {394, 31}} - - - - - 4 - - - - -2147483392 - {{-100, -100}, {11, 17}} - - 256 - - _doScroller: - 0.53125 + 3 + 2 + + 6 + System + _sourceListBackgroundColor + + 1 + MC44MzkyMTU2OTU5IDAuODY2NjY2Njc0NiAwLjg5ODAzOTIyMTgAA - - - -2147483392 - {{1, 34}, {379, 11}} - - 257 - - _doScroller: - 0.96798032522201538 - - - - 2304 - - YES - - - {{1, 0}, {394, 17}} - - - - - 4 - - - {396, 49} - - - 546 - - - - - - QSAAAEEgAABBgAAAQYAAAA + + 18 + 1379926016 + + + 4 + 15 + 0 + YES + 1 + 1 - {{0, 51}, {395, 49}} - - NSView - - - {395, 100} - - 2 - SPNavigatorStatusQuickAcces - - NO - - YES - - YES - - - - - YES - - + {{1, 17}, {394, 82}} + + + + + 4 - - - - - - - YES - - YES - - + + + -2147483392 + {{224, 17}, {11, 102}} + + 256 + + _doScroller: + 0.65625 - - YES - - + + + -2147483392 + {{1, 38}, {393, 11}} + + 257 + + _doScroller: + 0.99746191501617432 - - - YES - - YES - - - - - YES - - + + + 2304 + + YES + + + {{1, 0}, {394, 17}} + + + + + 4 + - 0 - NO + {396, 100} + + + 562 + + + + + + QSAAAEEgAABBoAAAQaAAAA {{0, 234}, {395, 100}} @@ -1005,7 +813,7 @@ YES - + @@ -1054,11 +862,7 @@ -2080244224 134217728 - - LucidaGrande - 13 - 1044 - + -2041822977 268435618 @@ -1103,7 +907,7 @@ {{0, 0}, {1280, 778}} {200, 222} - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} @@ -1190,54 +994,6 @@ 99 - - - infoTable - - - - 100 - - - - quickAccessTable - - - - 101 - - - - delegate - - - - 102 - - - - dataSource - - - - 103 - - - - dataSource - - - - 104 - - - - delegate - - - - 105 - searchField @@ -1312,43 +1068,51 @@ - nextKeyView - - + schemaStatusSplitView + + - 129 + 133 - nextKeyView - - + schema12SplitView + + - 130 + 134 - infoQuickAccessSplitView - - + delegate + + - 132 + 142 - schemaStatusSplitView - - + dataSource + + - 133 + 143 - schema12SplitView + infoTable - + - 134 + 145 + + + + selectText: + + + + 149 @@ -1471,7 +1235,8 @@ YES - + + Custom View Status @@ -1621,149 +1386,84 @@ - 68 - - - YES - - - - - Split View (Status / Quick Access) - - - 69 - - - YES - - - - - - 70 - - - YES - - - - - - 71 - - - YES - - - - - - - Bordered Scroll View (Table View Quick Access) - - - 72 - - - - - 73 - - - - - 74 - + 108 + YES - + - + - 75 - - + 109 + + - 76 - + 135 + YES - + + + + - + + Bordered Scroll View (Table View Status Info) - 79 - - + 136 + + - 89 - + 137 + YES - - - - + - - Bordered Scroll View (Table View Status Info) - - - 90 - - - - - 91 - - + - 92 - - - YES - - - + 138 + + - 93 - - + 139 + + - 94 - + 140 + YES - + - + - 97 - - + 141 + + - 108 - + 146 + YES - + - + + Apple F Dummy Button - 109 - - + 147 + + @@ -1778,7 +1478,17 @@ 108.IBPluginDependency 109.IBPluginDependency 13.IBPluginDependency + 135.IBPluginDependency + 136.IBPluginDependency + 137.IBPluginDependency + 138.IBPluginDependency + 139.IBPluginDependency 14.IBPluginDependency + 140.IBPluginDependency + 141.CustomClassName + 141.IBPluginDependency + 146.IBPluginDependency + 147.IBPluginDependency 15.IBPluginDependency 19.IBPluginDependency 20.IBPluginDependency @@ -1817,27 +1527,8 @@ 66.IBAttributePlaceholdersKey 66.IBPluginDependency 67.IBPluginDependency - 68.IBPluginDependency - 69.IBPluginDependency - 70.IBPluginDependency - 71.IBPluginDependency - 72.IBPluginDependency - 73.IBPluginDependency - 74.IBPluginDependency - 75.IBPluginDependency - 76.IBPluginDependency - 79.CustomClassName - 79.IBPluginDependency 8.IBPluginDependency - 89.IBPluginDependency 9.IBPluginDependency - 90.IBPluginDependency - 91.IBPluginDependency - 92.IBPluginDependency - 93.IBPluginDependency - 94.IBPluginDependency - 97.CustomClassName - 97.IBPluginDependency YES @@ -1855,7 +1546,17 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.brandonwalkin.BWToolkit + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.brandonwalkin.BWToolkit + com.apple.InterfaceBuilder.CocoaPlugin + SPTableTextFieldCell + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.brandonwalkin.BWToolkit com.brandonwalkin.BWToolkit com.brandonwalkin.BWToolkit @@ -1870,9 +1571,9 @@ com.apple.InterfaceBuilder.CocoaPlugin ImageAndTextCell com.apple.InterfaceBuilder.CocoaPlugin - {{104, 323}, {395, 359}} + {{131, 379}, {395, 359}} com.apple.InterfaceBuilder.CocoaPlugin - {{104, 323}, {395, 359}} + {{131, 379}, {395, 359}} {200, 200} @@ -1901,26 +1602,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.brandonwalkin.BWToolkit - com.brandonwalkin.BWToolkit - com.brandonwalkin.BWToolkit - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - ImageAndTextCell - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - SPTableTextFieldCell com.apple.InterfaceBuilder.CocoaPlugin @@ -1940,7 +1622,7 @@ - 134 + 149 diff --git a/Source/SPNavigatorController.h b/Source/SPNavigatorController.h index d84598f8..4d6ee994 100644 --- a/Source/SPNavigatorController.h +++ b/Source/SPNavigatorController.h @@ -31,11 +31,9 @@ IBOutlet id outlineSchema2; IBOutlet id navigatorWindow; IBOutlet id infoTable; - IBOutlet id quickAccessTable; IBOutlet id searchField; IBOutlet id syncButton; - IBOutlet id infoQuickAccessSplitView; IBOutlet id schemaStatusSplitView; IBOutlet id schema12SplitView; @@ -66,7 +64,10 @@ NSImage *functionIcon; NSImage *fieldIcon; + BOOL wasNotShown; + Class NSDictionaryClass; + } + (SPNavigatorController *)sharedNavigatorController; diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m index 08e7b847..24fafee2 100644 --- a/Source/SPNavigatorController.m +++ b/Source/SPNavigatorController.m @@ -32,6 +32,7 @@ #import "SPArrayAdditions.h" #import "SPLogger.h" #import "SPTooltip.h" +#import static SPNavigatorController *sharedNavigatorController = nil; @@ -39,6 +40,12 @@ static SPNavigatorController *sharedNavigatorController = nil; @implementation SPNavigatorController +static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* context) +{ + return (NSComparisonResult)objc_msgSend(s1, @selector(localizedCompare:), s2); +} + + /* * Returns the shared query console. */ @@ -76,6 +83,7 @@ static SPNavigatorController *sharedNavigatorController = nil; ignoreUpdate = NO; isFiltered = NO; isFiltering = NO; + wasNotShown = YES; [syncButton setState:NSOffState]; NSDictionaryClass = [NSDictionary class]; @@ -475,7 +483,8 @@ static SPNavigatorController *sharedNavigatorController = nil; [updatingConnections removeObject:connectionName]; - if([[self window] isVisible]) { + if([[self window] isVisible] || wasNotShown) { + wasNotShown = NO; [outlineSchema1 reloadData]; [outlineSchema2 reloadData]; @@ -700,7 +709,7 @@ static SPNavigatorController *sharedNavigatorController = nil; } } } - [schemaDataFiltered setDictionary:[structure retain]]; + [schemaDataFiltered setDictionary:structure]; [NSThread detachNewThreadSelector:@selector(reloadAfterFiltering) toTarget:self withObject:nil]; } @@ -719,11 +728,17 @@ static SPNavigatorController *sharedNavigatorController = nil; } +- (void)_expandItemOutlineSchema2AfterReloading +{ + [outlineSchema2 expandItem:[outlineSchema2 itemAtRow:0] expandChildren:YES]; +} + - (void)reloadAfterFiltering { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + isFiltering = YES; [outlineSchema2 reloadData]; - [outlineSchema2 expandItem:[outlineSchema2 itemAtRow:0] expandChildren:YES]; + [self performSelectorOnMainThread:@selector(_expandItemOutlineSchema2AfterReloading) withObject:nil waitUntilDone:YES]; isFiltering = NO; [pool release]; } @@ -815,14 +830,11 @@ static SPNavigatorController *sharedNavigatorController = nil; } if ([item isKindOfClass:NSDictionaryClass]) { - NSSortDescriptor *desc = [[NSSortDescriptor alloc] initWithKey:nil ascending:YES selector:@selector(localizedCompare:)]; - NSArray *sortedItems = [[item allKeys] sortedArrayUsingDescriptors:[NSArray arrayWithObject:desc]]; - [desc release]; - return [item objectForKey:[sortedItems objectAtIndex:index]]; + return [item objectForKey:NSArrayObjectAtIndex([(NSArray*)objc_msgSend(item, @selector(allKeys)) sortedArrayUsingFunction:compareStrings context:nil],index)]; } else if ([item isKindOfClass:[NSArray class]]) { - return [item objectAtIndex:index]; + return NSArrayObjectAtIndex(item,index); } return nil; @@ -913,14 +925,15 @@ static SPNavigatorController *sharedNavigatorController = nil; return [[NSArrayObjectAtIndex([parentObject allKeysForObject:item], 0) componentsSeparatedByString:SPUniqueSchemaDelimiter] lastObject]; } else { - if([[parentObject allKeysForObject:item] count]) { + id allKeysForItem = [parentObject allKeysForObject:item]; + if([allKeysForItem count]) { if([outlineView levelForItem:item] == 1) { // It's a db name which wasn't queried yet [[tableColumn dataCell] setImage:databaseIcon]; - return [[[[parentObject allKeysForObject:item] objectAtIndex:0] componentsSeparatedByString:SPUniqueSchemaDelimiter] lastObject]; + return [[NSArrayObjectAtIndex(allKeysForItem,0) componentsSeparatedByString:SPUniqueSchemaDelimiter] lastObject]; } else { // It's a field and use the key " struct_type " to increase the distance between node and first child - if(![NSArrayObjectAtIndex([parentObject allKeysForObject:item], 0) hasPrefix:@" "]) { + if(![NSArrayObjectAtIndex(allKeysForItem,0) hasPrefix:@" "]) { [[tableColumn dataCell] setImage:fieldIcon]; return [[NSArrayObjectAtIndex([parentObject allKeysForObject:item], 0) componentsSeparatedByString:SPUniqueSchemaDelimiter] lastObject]; } else { @@ -1068,11 +1081,9 @@ static SPNavigatorController *sharedNavigatorController = nil; - (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]; } @@ -1167,9 +1178,10 @@ static SPNavigatorController *sharedNavigatorController = nil; - (void)tableView:(NSTableView*)tableView didClickTableColumn:(NSTableColumn *)tableColumn { - if(tableView == infoTable || tableView == quickAccessTable) { - [infoQuickAccessSplitView setPosition:1000 ofDividerAtIndex:0]; - [schemaStatusSplitView setPosition:200 ofDividerAtIndex:0]; + if(tableView == infoTable) { + CGFloat winHeight = [[self window] frame].size.height; + // winHeight = (winHeight < 500) ? winHeight/2 : 500; + [schemaStatusSplitView setPosition:winHeight-200 ofDividerAtIndex:0]; [outlineSchema1 scrollRowToVisible:[outlineSchema1 selectedRow]]; [outlineSchema2 scrollRowToVisible:[outlineSchema2 selectedRow]]; } -- cgit v1.2.3