aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-06-13 17:43:14 +0000
committerrowanbeentje <rowan@beent.je>2009-06-13 17:43:14 +0000
commit8f880b82a86b2bfe6bbf70ff934096b8a720bb20 (patch)
tree62a12dfd86cff689bd8fbb949f087dda22315a6c
parenta37764926965179f38e2434b4232cd0c0524a2fa (diff)
downloadsequelpro-8f880b82a86b2bfe6bbf70ff934096b8a720bb20.tar.gz
sequelpro-8f880b82a86b2bfe6bbf70ff934096b8a720bb20.tar.bz2
sequelpro-8f880b82a86b2bfe6bbf70ff934096b8a720bb20.zip
- Default the index type picker to INDEX if a primary key already exists on the table (addresses #290)
- Set the default focus correctly on the add index sheet
-rw-r--r--Source/TableSource.m16
1 files changed, 15 insertions, 1 deletions
diff --git a/Source/TableSource.m b/Source/TableSource.m
index 20a7ae11..cf7a7232 100644
--- a/Source/TableSource.m
+++ b/Source/TableSource.m
@@ -450,16 +450,30 @@ opens the indexSheet
*/
- (IBAction)openIndexSheet:(id)sender
{
- int code = 0;
+ int i, code = 0;
// Check whether a save of the current field row is required.
if ( ![self saveRowOnDeselect] ) return;
+ // Set sheet defaults - key type PRIMARY, key name PRIMARY and disabled, and blank indexed columns
[indexTypeField selectItemAtIndex:0];
[indexNameField setEnabled:NO];
[indexNameField setStringValue:@"PRIMARY"];
[indexedColumnsField setStringValue:@""];
+ [indexSheet makeFirstResponder:indexedColumnsField];
+
+ // Check to see whether a primary key already exists for the table, and if so select an INDEX instead
+ for (i = 0; i < [indexes count]; i++) {
+ if ([[[tableFields objectAtIndex:i] objectForKey:@"Key"] isEqualToString:@"PRI"]) {
+ [indexTypeField selectItemAtIndex:1];
+ [indexNameField setEnabled:YES];
+ [indexNameField setStringValue:@""];
+ [indexSheet makeFirstResponder:indexNameField];
+ break;
+ }
+ }
+ // Begin the sheet
[NSApp beginSheet:indexSheet
modalForWindow:tableWindow modalDelegate:self
didEndSelector:nil contextInfo:nil];