diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-06-28 13:15:34 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-06-28 13:15:34 +0000 |
commit | 615a5494c22b9d7f710f3b3efafda85f19e2909d (patch) | |
tree | ad899f431f2ee541de58229e027798470e88dd14 /Source | |
parent | 1490d184c4c3ef4bf76396203d58feece4e4a25d (diff) | |
download | sequelpro-615a5494c22b9d7f710f3b3efafda85f19e2909d.tar.gz sequelpro-615a5494c22b9d7f710f3b3efafda85f19e2909d.tar.bz2 sequelpro-615a5494c22b9d7f710f3b3efafda85f19e2909d.zip |
• allow restoring of a spf file if no table was selected while saving the spf file
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPDatabaseDocument.m | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 32bf62d0..60b29366 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -533,42 +533,48 @@ // Check and set the table NSArray *tables = [tablesListInstance tables]; + BOOL isSelectedTableDefined = YES; + if([tables indexOfObject:[spfSession objectForKey:@"table"]] == NSNotFound) { - [self endTask]; - [taskPool drain]; - return; + isSelectedTableDefined = NO; } // Restore toolbar setting if([spfSession objectForKey:@"isToolbarVisible"]) [mainToolbar setVisible:[[spfSession objectForKey:@"isToolbarVisible"] boolValue]]; - // Set table content details for restore - if([spfSession objectForKey:@"contentSortCol"]) - [tableContentInstance setSortColumnNameToRestore:[spfSession objectForKey:@"contentSortCol"] isAscending:[[spfSession objectForKey:@"contentSortCol"] boolValue]]; - if([spfSession objectForKey:@"contentPageNumber"]) - [tableContentInstance setPageToRestore:[[spfSession objectForKey:@"pageNumber"] integerValue]]; - if([spfSession objectForKey:@"contentViewport"]) - [tableContentInstance setViewportToRestore:NSRectFromString([spfSession objectForKey:@"contentViewport"])]; - if([spfSession objectForKey:@"contentFilter"]) - [tableContentInstance setFiltersToRestore:[spfSession objectForKey:@"contentFilter"]]; - - // Select table - [tablesListInstance selectTableAtIndex:[NSNumber numberWithInteger:[tables indexOfObject:[spfSession objectForKey:@"table"]]]]; - // Reset database view encoding if differs from default if([spfSession objectForKey:@"connectionEncoding"] && ![[self connectionEncoding] isEqualToString:[spfSession objectForKey:@"connectionEncoding"]]) [self setConnectionEncoding:[spfSession objectForKey:@"connectionEncoding"] reloadingViews:YES]; - // TODO up to now it doesn't work - if([spfSession objectForKey:@"contentSelectedIndexSet"]) { - NSMutableIndexSet *anIndexSet = [NSMutableIndexSet indexSet]; - NSArray *items = [spfSession objectForKey:@"contentSelectedIndexSet"]; - NSUInteger i; - for(i=0; i<[items count]; i++) - [anIndexSet addIndex:(NSUInteger)NSArrayObjectAtIndex(items, i)]; - [tableContentInstance setSelectedRowIndexesToRestore:anIndexSet]; + if(isSelectedTableDefined) { + // Set table content details for restore + if([spfSession objectForKey:@"contentSortCol"]) + [tableContentInstance setSortColumnNameToRestore:[spfSession objectForKey:@"contentSortCol"] isAscending:[[spfSession objectForKey:@"contentSortCol"] boolValue]]; + if([spfSession objectForKey:@"contentPageNumber"]) + [tableContentInstance setPageToRestore:[[spfSession objectForKey:@"pageNumber"] integerValue]]; + if([spfSession objectForKey:@"contentViewport"]) + [tableContentInstance setViewportToRestore:NSRectFromString([spfSession objectForKey:@"contentViewport"])]; + if([spfSession objectForKey:@"contentFilter"]) + [tableContentInstance setFiltersToRestore:[spfSession objectForKey:@"contentFilter"]]; + + // Select table + [tablesListInstance selectTableAtIndex:[NSNumber numberWithInteger:[tables indexOfObject:[spfSession objectForKey:@"table"]]]]; + + // TODO up to now it doesn't work + if([spfSession objectForKey:@"contentSelectedIndexSet"]) { + NSMutableIndexSet *anIndexSet = [NSMutableIndexSet indexSet]; + NSArray *items = [spfSession objectForKey:@"contentSelectedIndexSet"]; + NSUInteger i; + for(i=0; i<[items count]; i++) + [anIndexSet addIndex:(NSUInteger)NSArrayObjectAtIndex(items, i)]; + + [tableContentInstance setSelectedRowIndexesToRestore:anIndexSet]; + } + + [[tablesListInstance valueForKeyPath:@"tablesListView"] scrollRowToVisible:[tables indexOfObject:[spfSession objectForKey:@"selectedTable"]]]; + } // Select view @@ -585,8 +591,6 @@ else if([[spfSession objectForKey:@"view"] isEqualToString:@"SP_VIEW_TRIGGERS"]) [self viewTriggers:self]; - [[tablesListInstance valueForKeyPath:@"tablesListView"] scrollRowToVisible:[tables indexOfObject:[spfSession objectForKey:@"selectedTable"]]]; - [self updateWindowTitle:self]; // dealloc spfSession data |