aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStuart Connolly <stuart02@gmail.com>2017-03-28 23:15:10 +0100
committerStuart Connolly <stuart02@gmail.com>2017-03-28 23:15:10 +0100
commit5f1b37e21c113101b2d72124f6dbd22b77a4fddc (patch)
tree500018962114439a4fbdc26d68df84a89a2b66d7 /Source
parentdbcea5c9ed64331f02a1f4e5525dfbfff0d61894 (diff)
downloadsequelpro-5f1b37e21c113101b2d72124f6dbd22b77a4fddc.tar.gz
sequelpro-5f1b37e21c113101b2d72124f6dbd22b77a4fddc.tar.bz2
sequelpro-5f1b37e21c113101b2d72124f6dbd22b77a4fddc.zip
Move table relations delegate methods into their own catrgory to be consistent with other controllers.
Diffstat (limited to 'Source')
-rw-r--r--Source/SPTableRelations.h6
-rw-r--r--Source/SPTableRelations.m56
-rw-r--r--Source/SPTableRelationsDelegate.h35
-rw-r--r--Source/SPTableRelationsDelegate.m87
4 files changed, 127 insertions, 57 deletions
diff --git a/Source/SPTableRelations.h b/Source/SPTableRelations.h
index 1ab7f1b7..6fa2bd57 100644
--- a/Source/SPTableRelations.h
+++ b/Source/SPTableRelations.h
@@ -34,7 +34,7 @@
@class SPTablesList;
@class SPTableData;
-@interface SPTableRelations : NSObject
+@interface SPTableRelations : NSObject <NSTableViewDelegate, NSTableViewDataSource>
{
IBOutlet SPDatabaseDocument *tableDocumentInstance;
IBOutlet SPTablesList *tablesListInstance;
@@ -85,8 +85,8 @@
- (void)tableSelectionChanged:(NSNotification *)notification;
// Task interaction
-- (void)startDocumentTaskForTab:(NSNotification *)aNotification;
-- (void)endDocumentTaskForTab:(NSNotification *)aNotification;
+- (void)startDocumentTaskForTab:(NSNotification *)notification;
+- (void)endDocumentTaskForTab:(NSNotification *)notification;
// Other
- (NSArray *)relationDataForPrinting;
diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m
index 64a7b98b..20059fbb 100644
--- a/Source/SPTableRelations.m
+++ b/Source/SPTableRelations.m
@@ -373,27 +373,6 @@ static NSString *SPRelationOnDeleteKey = @"on_delete";
}
#pragma mark -
-#pragma mark TextField delegate methods
-
-- (void)controlTextDidChange:(NSNotification *)notification
-{
- // Make sure the user does not enter a taken name, using the quickly-generated incomplete list
- if ([notification object] == constraintName) {
- NSString *userValue = [[constraintName stringValue] lowercaseString];
-
- // Make field red and disable add button
- if ([takenConstraintNames containsObject:userValue]) {
- [constraintName setTextColor:[NSColor redColor]];
- [confirmAddRelationButton setEnabled:NO];
- }
- else {
- [constraintName setTextColor:[NSColor controlTextColor]];
- [confirmAddRelationButton setEnabled:YES];
- }
- }
-}
-
-#pragma mark -
#pragma mark Tableview datasource methods
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
@@ -413,44 +392,13 @@ static NSString *SPRelationOnDeleteKey = @"on_delete";
}
#pragma mark -
-#pragma mark Tableview delegate methods
-
-/**
- * Called whenever the relations table view selection changes.
- */
-- (void)tableViewSelectionDidChange:(NSNotification *)notification
-{
- [removeRelationButton setEnabled:([relationsTableView numberOfSelectedRows] > 0)];
-}
-
-/*
- * Double-click action on table cells - for the time being, return
- * NO to disable editing.
- */
-- (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
-{
- if ([tableDocumentInstance isWorking]) return NO;
-
- return NO;
-}
-
-/**
- * Disable row selection while the document is working.
- */
-- (BOOL)tableView:(NSTableView *)tableView 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
+- (void)startDocumentTaskForTab:(NSNotification *)notification
{
-
// Only proceed if this view is selected.
if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableRelations]) return;
@@ -462,7 +410,7 @@ static NSString *SPRelationOnDeleteKey = @"on_delete";
/**
* Enable all content interactive elements after an ongoing task.
*/
-- (void)endDocumentTaskForTab:(NSNotification *)aNotification
+- (void)endDocumentTaskForTab:(NSNotification *)notification
{
// Only proceed if this view is selected.
if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableRelations]) return;
diff --git a/Source/SPTableRelationsDelegate.h b/Source/SPTableRelationsDelegate.h
new file mode 100644
index 00000000..79b1e914
--- /dev/null
+++ b/Source/SPTableRelationsDelegate.h
@@ -0,0 +1,35 @@
+//
+// SPTableRelationsDelegate.h
+// sequel-pro
+//
+// Created by Stuart Connolly (stuconnolly.com) on March 28, 2017.
+// Copyright (c) 2017 Stuart Connolly. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+// More info at <https://github.com/sequelpro/sequelpro>
+
+#import "SPTableRelations.h"
+
+@interface SPTableRelations (SPTableRelationsDelegate)
+
+@end
diff --git a/Source/SPTableRelationsDelegate.m b/Source/SPTableRelationsDelegate.m
new file mode 100644
index 00000000..bf083318
--- /dev/null
+++ b/Source/SPTableRelationsDelegate.m
@@ -0,0 +1,87 @@
+//
+// SPTableRelationsDelegate.m
+// sequel-pro
+//
+// Created by Stuart Connolly (stuconnolly.com) on March 28, 2017.
+// Copyright (c) 2017 Stuart Connolly. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+// More info at <https://github.com/sequelpro/sequelpro>
+
+#import "SPTableRelationsDelegate.h"
+#import "SPDatabaseDocument.h"
+
+@implementation SPTableRelations (SPTableRelationsDelegate)
+
+#pragma mark -
+#pragma mark TextField delegate methods
+
+- (void)controlTextDidChange:(NSNotification *)notification
+{
+ // Make sure the user does not enter a taken name, using the quickly-generated incomplete list
+ if ([notification object] == constraintName) {
+ NSString *userValue = [[constraintName stringValue] lowercaseString];
+
+ // Make field red and disable add button
+ if ([takenConstraintNames containsObject:userValue]) {
+ [constraintName setTextColor:[NSColor redColor]];
+ [confirmAddRelationButton setEnabled:NO];
+ }
+ else {
+ [constraintName setTextColor:[NSColor controlTextColor]];
+ [confirmAddRelationButton setEnabled:YES];
+ }
+ }
+}
+
+#pragma mark -
+#pragma mark Tableview delegate methods
+
+/**
+ * Called whenever the relations table view selection changes.
+ */
+- (void)tableViewSelectionDidChange:(NSNotification *)notification
+{
+ [removeRelationButton setEnabled:([relationsTableView numberOfSelectedRows] > 0)];
+}
+
+/*
+ * Double-click action on table cells - for the time being, return
+ * NO to disable editing.
+ */
+- (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
+{
+ if ([tableDocumentInstance isWorking]) return NO;
+
+ return NO;
+}
+
+/**
+ * Disable row selection while the document is working.
+ */
+- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)rowIndex
+{
+ return ![tableDocumentInstance isWorking];
+}
+
+@end