aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/TableRelations.h2
-rw-r--r--Source/TableRelations.m30
2 files changed, 19 insertions, 13 deletions
diff --git a/Source/TableRelations.h b/Source/TableRelations.h
index 60f00074..c593dc6d 100644
--- a/Source/TableRelations.h
+++ b/Source/TableRelations.h
@@ -36,6 +36,7 @@
IBOutlet id tableDataInstance;
IBOutlet id addButton;
IBOutlet id removeButton;
+ IBOutlet id refreshButton;
IBOutlet id labelText;
IBOutlet id relationsView;
IBOutlet id relationSheet;
@@ -46,7 +47,6 @@
IBOutlet id refColumnSelect;
IBOutlet id onUpdateSelect;
IBOutlet id onDeleteSelect;
-
CMMCPConnection *mySQLConnection;
diff --git a/Source/TableRelations.m b/Source/TableRelations.m
index d95cf471..daff2e52 100644
--- a/Source/TableRelations.m
+++ b/Source/TableRelations.m
@@ -239,15 +239,16 @@
*/
- (IBAction)refresh:(id)sender
{
-
[relData removeAllObjects];
- if( [tablesListInstance tableType] == SP_TABLETYPE_TABLE ) {
+ if([tablesListInstance tableType] == SP_TABLETYPE_TABLE) {
// update the top label
[labelText setStringValue:[NSString stringWithFormat:@"Relations for table: %@",[tablesListInstance tableName]]];
[tableDataInstance updateInformationForCurrentTable];
+
NSArray *constraints = [tableDataInstance getConstraints];
+
for( int i = 0; i < [constraints count]; i++ ) {
[relData addObject:[NSDictionary dictionaryWithObjectsAndKeys:
[tablesListInstance tableName], @"table",
@@ -260,13 +261,9 @@
nil]];
}
- } else {
- // update the top label
- [labelText setStringValue:@""];
- }
+ }
[relationsView reloadData];
-
}
/*
@@ -275,16 +272,26 @@
*/
- (void)tableChanged:(NSNotification *)notification
{
- if( [tablesListInstance tableType] == SP_TABLETYPE_TABLE ) {
+ // To begin enable all interface elements
+ [addButton setEnabled:YES];
+ [refreshButton setEnabled:YES];
+
+ // Get the current table's storage engine
+ NSString *engine = [tableDataInstance statusValueForKey:@"Engine"];
+
+ if (([tablesListInstance tableType] == SP_TABLETYPE_TABLE) && ([[engine lowercaseString] isEqualToString:@"innodb"])) {
[addButton setEnabled:YES];
+ [refreshButton setEnabled:YES];
+
+ [self refresh:self];
} else {
[addButton setEnabled:NO];
+ [refreshButton setEnabled:NO];
+
+ [labelText setStringValue:([tablesListInstance tableType] == SP_TABLETYPE_TABLE) ? @"This table does not support relations" : @""];
}
-
- [self refresh:nil];
}
-
//tableView datasource methods
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{
@@ -341,5 +348,4 @@
return FALSE;
}
-
@end