aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-03-20 16:58:14 +0000
committerBibiko <bibiko@eva.mpg.de>2010-03-20 16:58:14 +0000
commit57d35fbecd2517fe8b1914d1f2335be06e2a8b17 (patch)
tree56f622121b65d87b671ebe0d898078f14b503d16 /Source
parentb1d22ab0eaf73b6c1cd73faabee4e592e6731814 (diff)
downloadsequelpro-57d35fbecd2517fe8b1914d1f2335be06e2a8b17.tar.gz
sequelpro-57d35fbecd2517fe8b1914d1f2335be06e2a8b17.tar.bz2
sequelpro-57d35fbecd2517fe8b1914d1f2335be06e2a8b17.zip
• Navigator progress
- made expand status persistent for current SP session - added draft to display additional information about selected fields - tried the minimize the jittering while resizing outline views (test) Note: to test it simply unhide menu item in MainMenu.xib
Diffstat (limited to 'Source')
-rw-r--r--Source/SPNavigatorController.h9
-rw-r--r--Source/SPNavigatorController.m198
2 files changed, 190 insertions, 17 deletions
diff --git a/Source/SPNavigatorController.h b/Source/SPNavigatorController.h
index 50f84cac..43b7a1a8 100644
--- a/Source/SPNavigatorController.h
+++ b/Source/SPNavigatorController.h
@@ -31,10 +31,16 @@
IBOutlet id outlineSchema1;
IBOutlet id outlineSchema2;
IBOutlet id navigatorWindow;
+ IBOutlet id infoTable;
+ IBOutlet id quickAccessTable;
+ IBOutlet id searchField;
NSUserDefaults *prefs;
NSMutableDictionary *schemaData;
+ NSMutableArray *infoArray;
+ NSMutableDictionary *expandStatus1;
+ NSMutableDictionary *expandStatus2;
}
@@ -42,5 +48,8 @@
- (IBAction)outlineViewAction:(id)sender;
- (IBAction)updateEntries:(id)sender;
+- (IBAction)reloadAllStructures:(id)sender;
+- (IBAction)filterTree:(id)sender;
+- (NSString*)tableInfoLabelForIndex:(NSInteger)index;
@end
diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m
index 1520957b..eb3afb48 100644
--- a/Source/SPNavigatorController.m
+++ b/Source/SPNavigatorController.m
@@ -24,7 +24,9 @@
#import "SPNavigatorController.h"
#import "RegexKitLite.h"
+#import "SPOutlineView.h"
#import "SPConstants.h"
+#import "ImageAndTextCell.h"
static SPNavigatorController *sharedNavigatorController = nil;
@@ -57,7 +59,10 @@ static SPNavigatorController *sharedNavigatorController = nil;
{
if((self = [super initWithWindowNibName:@"Navigator"])) {
- schemaData = [[NSMutableDictionary alloc] init];
+ schemaData = [[NSMutableDictionary alloc] init];
+ expandStatus1 = [[NSMutableDictionary alloc] init];
+ expandStatus2 = [[NSMutableDictionary alloc] init];
+ infoArray = [[NSMutableArray alloc] init];
}
@@ -68,6 +73,9 @@ static SPNavigatorController *sharedNavigatorController = nil;
- (void)dealloc
{
if(schemaData) [schemaData release];
+ if(infoArray) [infoArray release];
+ if(expandStatus1) [expandStatus1 release];
+ if(expandStatus2) [expandStatus2 release];
}
/*
* The following base protocol methods are implemented to ensure the singleton status of this class.
@@ -99,6 +107,27 @@ static SPNavigatorController *sharedNavigatorController = nil;
return @"SPNavigator";
}
+- (void)restoreExpandStatus
+{
+ NSInteger i;
+ for( i = 0; i < [outlineSchema1 numberOfRows]; i++ ) {
+ id item = [outlineSchema1 itemAtRow:i];
+ id parentObject = [outlineSchema1 parentForItem:item] ? [outlineSchema1 parentForItem:item] : schemaData;
+ id parentKeys = [parentObject allKeysForObject:item];
+ if(parentKeys && [parentKeys count] == 1)
+ if( [expandStatus1 objectForKey:[parentKeys objectAtIndex:0]] )
+ [outlineSchema1 expandItem:item];
+ }
+ for( i = 0; i < [outlineSchema2 numberOfRows]; i++ ) {
+ id item = [outlineSchema2 itemAtRow:i];
+ id parentObject = [outlineSchema1 parentForItem:item] ? [outlineSchema2 parentForItem:item] : schemaData;
+ id parentKeys = [parentObject allKeysForObject:item];
+ if(parentKeys && [parentKeys count] == 1)
+ if( [expandStatus2 objectForKey:[parentKeys objectAtIndex:0]] )
+ [outlineSchema2 expandItem:item];
+ }
+}
+
#pragma mark -
#pragma mark IBActions
@@ -109,7 +138,8 @@ static SPNavigatorController *sharedNavigatorController = nil;
if(schemaData) {
selectedItem1 = [outlineSchema1 itemAtRow:[outlineSchema1 selectedRow]];
selectedItem2 = [outlineSchema2 itemAtRow:[outlineSchema2 selectedRow]];
- [schemaData release]; schemaData = nil;
+ [schemaData release];
+ schemaData = nil;
}
schemaData = [[NSMutableDictionary alloc] init];
if ([[[NSDocumentController sharedDocumentController] documents] count]) {
@@ -139,6 +169,8 @@ static SPNavigatorController *sharedNavigatorController = nil;
[outlineSchema1 reloadData];
[outlineSchema2 reloadData];
+ // [self performSelector:@selector(restoreExpandStatus) withObject:nil afterDelay:0.2];
+ [self restoreExpandStatus];
if(selectedItem1) {
NSInteger itemIndex = [outlineSchema1 rowForItem:selectedItem1];
if (itemIndex < 0) {
@@ -158,14 +190,71 @@ static SPNavigatorController *sharedNavigatorController = nil;
}
}
+- (IBAction)reloadAllStructures:(id)sender
+{
+ if(schemaData) {
+ [schemaData release];
+ schemaData = nil;
+ }
+
+ schemaData = [[NSMutableDictionary alloc] init];
+ [infoArray removeAllObjects];
+
+ [outlineSchema1 reloadData];
+ [outlineSchema2 reloadData];
+
+ if ([[[NSDocumentController sharedDocumentController] documents] count]) {
+ for(id doc in [[NSDocumentController sharedDocumentController] documents]) {
+ if(![[doc valueForKeyPath:@"mySQLConnection"] isConnected]) continue;
+ [NSThread detachNewThreadSelector:@selector(queryDbStructure) toTarget:[doc valueForKeyPath:@"mySQLConnection"] withObject:nil];
+ }
+ }
+
+}
+
- (IBAction)outlineViewAction:(id)sender
{
}
+- (IBAction)filterTree:(id)sender
+{
+ NSString *pattern = [searchField stringValue];
+}
+
#pragma mark -
#pragma mark outline delegates
+- (void)outlineViewItemDidExpand:(NSNotification *)notification
+{
+ SPOutlineView *ov = [notification object];
+ id item = [[notification userInfo] objectForKey:@"NSObject"];
+
+ id parentObject = [ov parentForItem:item] ? [ov parentForItem:item] : schemaData;
+
+ if(ov == outlineSchema1)
+ {
+ [expandStatus1 setObject:@"" forKey:[[parentObject allKeysForObject:item] objectAtIndex:0]];
+ }
+ else if(ov == outlineSchema2)
+ {
+ [expandStatus2 setObject:@"" forKey:[[parentObject allKeysForObject:item] objectAtIndex:0]];
+ }
+}
+
+- (void)outlineViewItemDidCollapse:(NSNotification *)notification
+{
+ SPOutlineView *ov = [notification object];
+ id item = [[notification userInfo] objectForKey:@"NSObject"];
+
+ id parentObject = [ov parentForItem:item] ? [ov parentForItem:item] : schemaData;
+
+ if(ov == outlineSchema1)
+ [expandStatus1 removeObjectForKey:[[parentObject allKeysForObject:item] objectAtIndex:0]];
+ else if(ov == outlineSchema2)
+ [expandStatus2 removeObjectForKey:[[parentObject allKeysForObject:item] objectAtIndex:0]];
+}
+
- (id)outlineView:(id)outlineView child:(NSInteger)index ofItem:(id)item
{
if (item == nil) item = schemaData;
@@ -305,28 +394,103 @@ static SPNavigatorController *sharedNavigatorController = nil;
return YES;
}
-- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(NSCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
+- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item
{
+ id parentObject = [outlineView parentForItem:item] ? [outlineView parentForItem:item] : schemaData;
+ if([[[parentObject allKeysForObject:item] objectAtIndex:0] hasPrefix:@" "])
+ return NO;
+ return YES;
+}
+- (void)outlineViewSelectionDidChange:(NSNotification *)aNotification
+{
+ id ov = [aNotification object];
+ id selectedItem;
+ if(ov == outlineSchema1) {
+ selectedItem = [outlineSchema1 itemAtRow:[outlineSchema1 selectedRow]];
+ } else if (ov == outlineSchema2) {
+ selectedItem = [outlineSchema2 itemAtRow:[outlineSchema2 selectedRow]];
+ }
+ if(selectedItem) {
+ [infoArray removeAllObjects];
+ [infoArray addObject:@""];
+ if([selectedItem isKindOfClass:[NSArray class]]) {
+ [infoTable setRowHeight:18.0];
+ NSInteger i = 0;
+ for(id item in selectedItem) {
+ if([item isKindOfClass:[NSString class]] && [item length]) {
+ [infoArray addObject:[NSString stringWithFormat:@"%@: %@", [self tableInfoLabelForIndex:i], [item stringByReplacingOccurrencesOfString:@"," withString:@", "]]];
+ }
+ i++;
+ }
+ }
+ }
+ [infoTable reloadData];
}
-// - (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
-// {
-// return [tableColumn dataCell];
-//
-// // If we return a cell for the 'nil' tableColumn, it will be used as a "full width" cell and span all the columns
-// if ([item isKindOfClass:[NSDictionary class]] && (tableColumn == nil)) {
-// // We want to use the cell for the name column, but we could construct a new cell if we wanted to, or return a different cell for each row.
-// return [[outlineView tableColumnWithIdentifier:@"field"] dataCell];
-// }
-// return [tableColumn dataCell];
-// }
-- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item
+#pragma mark -
+#pragma mark table delegates
+
+- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
{
- id parentObject = [outlineView parentForItem:item] ? [outlineView parentForItem:item] : schemaData;
- if([[[parentObject allKeysForObject:item] objectAtIndex:0] hasPrefix:@" "])
+ if(aTableView == infoTable)
+ return [infoArray count];
+
+ return 0;
+
+}
+
+- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row
+{
+ return (row == 0) ? 5.0 : [tableView rowHeight];
+}
+
+- (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(NSInteger)rowIndex
+{
+ if(aTableView == infoTable)
return NO;
+
return YES;
}
+
+- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
+{
+ if(aTableView == infoTable) {
+ if(rowIndex == 0) {
+ [(ImageAndTextCell*)aCell setImage:[NSImage imageNamed:@"dummy-small"]];
+ [(ImageAndTextCell*)aCell setDrawsBackground:NO];
+ } else {
+ [(ImageAndTextCell*)aCell setImage:[NSImage imageNamed:@"table-property"]];
+ [(ImageAndTextCell*)aCell setIndentationLevel:1];
+ [(ImageAndTextCell*)aCell setDrawsBackground:NO];
+ }
+ }
+}
+
+- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
+{
+ if(aTableView == infoTable) {
+ return [infoArray objectAtIndex:rowIndex];
+ }
+
+ return nil;
+}
+
+- (NSString*)tableInfoLabelForIndex:(NSInteger)index
+{
+ switch(index) {
+ case 0:
+ return NSLocalizedString(@"Type", @"type label");
+ case 1:
+ return NSLocalizedString(@"Encoding", @"encoding label");
+ case 2:
+ return NSLocalizedString(@"Key", @"key label");
+ case 3:
+ return NSLocalizedString(@"Extra", @"extra label");
+ case 4:
+ return NSLocalizedString(@"Privileges", @"Privileges label");
+ }
+ return @"";
+}
@end