aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPHistoryController.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-11-08 22:58:56 +0000
committerrowanbeentje <rowan@beent.je>2009-11-08 22:58:56 +0000
commit8f3065bb99ff46ddfcffdd05eb55e09871cad0c9 (patch)
tree0e580a5c151e6933c95c0b8417ae44f8c8f8acb4 /Source/SPHistoryController.m
parent55bf19f025ab67562b151a40e2440c5c76b00ee5 (diff)
downloadsequelpro-8f3065bb99ff46ddfcffdd05eb55e09871cad0c9.tar.gz
sequelpro-8f3065bb99ff46ddfcffdd05eb55e09871cad0c9.tar.bz2
sequelpro-8f3065bb99ff46ddfcffdd05eb55e09871cad0c9.zip
- Support nested task levels to allow tasks to overlap
- Thread history loading, thus using the nested task elvels and fixing history interaction in recent builds - Thread initial database loads - Improve progress indicator slightly
Diffstat (limited to 'Source/SPHistoryController.m')
-rw-r--r--Source/SPHistoryController.m31
1 files changed, 28 insertions, 3 deletions
diff --git a/Source/SPHistoryController.m b/Source/SPHistoryController.m
index 7f522b7d..6c2683d0 100644
--- a/Source/SPHistoryController.m
+++ b/Source/SPHistoryController.m
@@ -51,6 +51,7 @@
- (void) awakeFromNib
{
tableContentInstance = [theDocument valueForKey:@"tableContentInstance"];
+ tablesListInstance = [theDocument valueForKey:@"tablesListInstance"];
}
- (void) dealloc
@@ -252,6 +253,7 @@
/**
* Load a history entry and attempt to return the interface to that state.
+ * Performs the load in a task which is threaded as necessary.
*/
- (void) loadEntryAtPosition:(unsigned int)position
{
@@ -262,6 +264,22 @@
return;
}
+ // Ensure a save of the current state - scroll position, selection - if we're at the last entry
+ if (historyPosition == [history count] - 1) [self updateHistoryEntries];
+
+ // Start the task and perform the load
+ [theDocument startTaskWithDescription:NSLocalizedString(@"Loading history entry...", @"Loading history entry task desc")];
+ if ([NSThread isMainThread]) {
+ [NSThread detachNewThreadSelector:@selector(loadEntryTaskWithPosition:) toTarget:self withObject:[NSNumber numberWithUnsignedInt:position]];
+ } else {
+ [self loadEntryTaskWithPosition:[NSNumber numberWithUnsignedInt:position]];
+ }
+}
+- (void) loadEntryTaskWithPosition:(NSNumber *)positionNumber
+{
+ NSAutoreleasePool *loadPool = [[NSAutoreleasePool alloc] init];
+ unsigned int position = [positionNumber unsignedIntValue];
+
modifyingHistoryState = YES;
// Update the position and extract the history entry
@@ -289,6 +307,10 @@
// Check and set the database
if (![[theDocument database] isEqualToString:[historyEntry objectForKey:@"database"]]) {
NSPopUpButton *chooseDatabaseButton = [theDocument valueForKey:@"chooseDatabaseButton"];
+ [tablesListInstance setTableListSelectability:YES];
+ [[tablesListInstance valueForKey:@"tablesListView"] deselectAll:self];
+ [theDocument setDatabaseListIsSelectable:YES];
+ [tablesListInstance setTableListSelectability:YES];
[chooseDatabaseButton selectItemWithTitle:[historyEntry objectForKey:@"database"]];
[theDocument chooseDatabase:self];
if (![[theDocument database] isEqualToString:[historyEntry objectForKey:@"database"]]) {
@@ -298,7 +320,6 @@
// Check and set the table
if ([historyEntry objectForKey:@"table"] && ![[theDocument table] isEqualToString:[historyEntry objectForKey:@"table"]]) {
- TablesList *tablesListInstance = [theDocument valueForKey:@"tablesListInstance"];
NSArray *tables = [tablesListInstance tables];
if ([tables indexOfObject:[historyEntry objectForKey:@"table"]] == NSNotFound) {
return [self abortEntryLoad];
@@ -308,10 +329,10 @@
return [self abortEntryLoad];
}
} else if (![historyEntry objectForKey:@"table"] && [theDocument table]) {
- TablesList *tablesListInstance = [theDocument valueForKey:@"tablesListInstance"];
+ [tablesListInstance setTableListSelectability:YES];
[[tablesListInstance valueForKey:@"tablesListView"] deselectAll:self];
} else {
- [[theDocument valueForKey:@"tablesListInstance"] setContentRequiresReload:YES];
+ [tablesListInstance setContentRequiresReload:YES];
}
// Check and set the view
@@ -340,6 +361,10 @@
modifyingHistoryState = NO;
[self updateToolbarItem];
+
+ // End the task
+ [theDocument endTask];
+ [loadPool drain];
}
/**