aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableRelations.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-11-04 01:15:53 +0000
committerrowanbeentje <rowan@beent.je>2009-11-04 01:15:53 +0000
commit48d02b7080cadc507b1e7897c54ce2a8cf149acf (patch)
treef45eba9b97c71e1579580d790e9c9aa00088b26a /Source/SPTableRelations.m
parent0d5acfadf8d43ab3889f50456f5dc7ff42bf1a12 (diff)
downloadsequelpro-48d02b7080cadc507b1e7897c54ce2a8cf149acf.tar.gz
sequelpro-48d02b7080cadc507b1e7897c54ce2a8cf149acf.tar.bz2
sequelpro-48d02b7080cadc507b1e7897c54ce2a8cf149acf.zip
- Add task support to all the main interface views
- Improve task support on previously supported views - Use a threaded task load for all initial table loads - Support threaded task loads for table content loads, reloads, sorts, and filters - Improve upon previous threaded task loads by minimising view updates and supporting updates of the existing data arrays where valid
Diffstat (limited to 'Source/SPTableRelations.m')
-rw-r--r--Source/SPTableRelations.m69
1 files changed, 63 insertions, 6 deletions
diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m
index 92eebfaf..bdc1c418 100644
--- a/Source/SPTableRelations.m
+++ b/Source/SPTableRelations.m
@@ -63,8 +63,18 @@
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(tableSelectionChanged:)
- name:NSTableViewSelectionDidChangeNotification
- object:tableList];
+ name:SPTableChangedNotification
+ object:tableDocumentInstance];
+
+ // Add observers for document task activity
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(startDocumentTaskForTab:)
+ name:SPDocumentTaskStartNotification
+ object:tableDocumentInstance];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(endDocumentTaskForTab:)
+ name:SPDocumentTaskEndNotification
+ object:tableDocumentInstance];
}
#pragma mark -
@@ -210,9 +220,11 @@
*/
- (void)tableSelectionChanged:(NSNotification *)notification
{
+ BOOL enableInteraction = ![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:MAIN_TOOLBAR_TABLE_RELATIONS] || ![tableDocumentInstance isWorking];
+
// To begin enable all interface elements
- [addRelationButton setEnabled:YES];
- [refreshRelationsButton setEnabled:YES];
+ [addRelationButton setEnabled:enableInteraction];
+ [refreshRelationsButton setEnabled:enableInteraction];
[relationsTableView setEnabled:YES];
// Get the current table's storage engine
@@ -223,8 +235,8 @@
// Update the text label
[labelTextField setStringValue:[NSString stringWithFormat:@"Relations for table: %@", [tablesListInstance tableName]]];
- [addRelationButton setEnabled:YES];
- [refreshRelationsButton setEnabled:YES];
+ [addRelationButton setEnabled:enableInteraction];
+ [refreshRelationsButton setEnabled:enableInteraction];
[relationsTableView setEnabled:YES];
}
else {
@@ -268,9 +280,54 @@
*/
- (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
+ if ([tableDocumentInstance isWorking]) return NO;
+
return NO;
}
+/**
+ * Disable row selection while the document is working.
+ */
+- (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(NSInteger)rowIndex
+{
+ return ![tableDocumentInstance isWorking];
+}
+
+#pragma mark -
+#pragma mark Task interaction
+
+/**
+ * Disable all content interactive elements during an ongoing task.
+ */
+- (void) startDocumentTaskForTab:(NSNotification *)aNotification
+{
+
+ // Only proceed if this view is selected.
+ if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:MAIN_TOOLBAR_TABLE_RELATIONS])
+ return;
+
+ [addRelationButton setEnabled:NO];
+ [refreshRelationsButton setEnabled:NO];
+ [removeRelationButton setEnabled:NO];
+}
+
+/**
+ * Enable all content interactive elements after an ongoing task.
+ */
+- (void) endDocumentTaskForTab:(NSNotification *)aNotification
+{
+
+ // Only proceed if this view is selected.
+ if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:MAIN_TOOLBAR_TABLE_RELATIONS])
+ return;
+
+ if ([relationsTableView isEnabled]) {
+ [addRelationButton setEnabled:YES];
+ [refreshRelationsButton setEnabled:YES];
+ }
+ [removeRelationButton setEnabled:([relationsTableView numberOfSelectedRows] > 0)];
+}
+
#pragma mark -
#pragma mark Other