diff options
-rw-r--r-- | Interfaces/English.lproj/DBView.xib | 310 | ||||
-rw-r--r-- | Source/SPTableStructure.h | 2 | ||||
-rw-r--r-- | Source/SPTableStructure.m | 119 |
3 files changed, 380 insertions, 51 deletions
diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index 347fc01b..e5b93be2 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -23,7 +23,7 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="1304"/> + <integer value="7484"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -1487,7 +1487,7 @@ <int key="NSCellFlags2">133120</int> <reference key="NSSupport" ref="26"/> <reference key="NSControlView" ref="715508012"/> - <int key="NSButtonFlags">100679935</int> + <int key="NSButtonFlags">-1241497345</int> <int key="NSButtonFlags2">129</int> <string key="NSAlternateContents"/> <string key="NSKeyEquivalent"/> @@ -14748,6 +14748,14 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <int key="connectionID">7483</int> </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">encodingPopupCell</string> + <reference key="source" ref="103234030"/> + <reference key="destination" ref="309064650"/> + </object> + <int key="connectionID">7496</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -23306,7 +23314,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{125, 253}, {943, 549}}</string> + <string>{{-19, 172}, {943, 549}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <boolean value="YES"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -23617,7 +23625,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>{{339, 775}, {694, 4}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{339, 775}, {694, 4}}</string> + <string>{{339, 727}, {694, 6}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> @@ -23657,7 +23665,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> </object> <nil key="sourceID"/> - <int key="maxID">7495</int> + <int key="maxID">7497</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -28930,6 +28938,298 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> </object> </object> + <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.1+"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBPartialClassDescription"> + <string key="className">SPTableStructure</string> + <string key="superclassName">NSObject</string> + <object class="NSMutableDictionary" key="actions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>addField:</string> + <string>closeKeySheet:</string> + <string>closeSheet:</string> + <string>copyField:</string> + <string>reloadTable:</string> + <string>removeField:</string> + <string>resetAutoIncrement:</string> + <string>unhideIndexesView:</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + </object> + </object> + <object class="NSMutableDictionary" key="actionInfosByName"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>addField:</string> + <string>closeKeySheet:</string> + <string>closeSheet:</string> + <string>copyField:</string> + <string>reloadTable:</string> + <string>removeField:</string> + <string>resetAutoIncrement:</string> + <string>unhideIndexesView:</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBActionInfo"> + <string key="name">addField:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">closeKeySheet:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">closeSheet:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">copyField:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">reloadTable:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">removeField:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">resetAutoIncrement:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">unhideIndexesView:</string> + <string key="candidateClassName">id</string> + </object> + </object> + </object> + <object class="NSMutableDictionary" key="outlets"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>addFieldButton</string> + <string>addIndexButton</string> + <string>chooseKeyButton</string> + <string>collationPopupCell</string> + <string>copyFieldButton</string> + <string>databaseDataInstance</string> + <string>editTableButton</string> + <string>encodingPopupCell</string> + <string>extendedTableInfoInstance</string> + <string>indexesController</string> + <string>indexesShowButton</string> + <string>indexesTableView</string> + <string>keySheet</string> + <string>refreshIndexesButton</string> + <string>reloadFieldsButton</string> + <string>removeFieldButton</string> + <string>removeIndexButton</string> + <string>resetAutoIncrementLine</string> + <string>resetAutoIncrementSheet</string> + <string>resetAutoIncrementValue</string> + <string>structureGrabber</string> + <string>tableDataInstance</string> + <string>tableDocumentInstance</string> + <string>tableInfoInstance</string> + <string>tableSourceView</string> + <string>tablesIndexesSplitView</string> + <string>tablesListInstance</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>NSButton</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>NSSplitView</string> + <string>id</string> + </object> + </object> + <object class="NSMutableDictionary" key="toOneOutletInfosByName"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>addFieldButton</string> + <string>addIndexButton</string> + <string>chooseKeyButton</string> + <string>collationPopupCell</string> + <string>copyFieldButton</string> + <string>databaseDataInstance</string> + <string>editTableButton</string> + <string>encodingPopupCell</string> + <string>extendedTableInfoInstance</string> + <string>indexesController</string> + <string>indexesShowButton</string> + <string>indexesTableView</string> + <string>keySheet</string> + <string>refreshIndexesButton</string> + <string>reloadFieldsButton</string> + <string>removeFieldButton</string> + <string>removeIndexButton</string> + <string>resetAutoIncrementLine</string> + <string>resetAutoIncrementSheet</string> + <string>resetAutoIncrementValue</string> + <string>structureGrabber</string> + <string>tableDataInstance</string> + <string>tableDocumentInstance</string> + <string>tableInfoInstance</string> + <string>tableSourceView</string> + <string>tablesIndexesSplitView</string> + <string>tablesListInstance</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBToOneOutletInfo"> + <string key="name">addFieldButton</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">addIndexButton</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">chooseKeyButton</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">collationPopupCell</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">copyFieldButton</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">databaseDataInstance</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">editTableButton</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">encodingPopupCell</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">extendedTableInfoInstance</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">indexesController</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">indexesShowButton</string> + <string key="candidateClassName">NSButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">indexesTableView</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">keySheet</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">refreshIndexesButton</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">reloadFieldsButton</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">removeFieldButton</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">removeIndexButton</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">resetAutoIncrementLine</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">resetAutoIncrementSheet</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">resetAutoIncrementValue</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">structureGrabber</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">tableDataInstance</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">tableDocumentInstance</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">tableInfoInstance</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">tableSourceView</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">tablesIndexesSplitView</string> + <string key="candidateClassName">NSSplitView</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">tablesListInstance</string> + <string key="candidateClassName">id</string> + </object> + </object> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBDocumentRelativeSource</string> + <string key="minorKey">../../Source/SPTableStructure.h</string> + </object> + </object> + </object> <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBPartialClassDescription"> diff --git a/Source/SPTableStructure.h b/Source/SPTableStructure.h index 74905e5e..0be1082b 100644 --- a/Source/SPTableStructure.h +++ b/Source/SPTableStructure.h @@ -54,6 +54,8 @@ IBOutlet NSSplitView *tablesIndexesSplitView; IBOutlet NSButton *indexesShowButton; + IBOutlet id encodingPopupCell; + id databaseDataInstance; MCPConnection *mySQLConnection; diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m index ce21b705..2b4db263 100644 --- a/Source/SPTableStructure.m +++ b/Source/SPTableStructure.m @@ -159,17 +159,17 @@ NSArray *encodings = [databaseDataInstance getDatabaseCharacterSetEncodings]; if (([encodings count] > 0) && ([tableDataInstance tableEncoding])) { NSString *selectedTitle = @""; - [[[[tableSourceView tableColumns] objectAtIndex:10] dataCell] removeAllItems]; - [[[[tableSourceView tableColumns] objectAtIndex:10] dataCell] addItemWithTitle:@""]; + [encodingPopupCell removeAllItems]; + [encodingPopupCell addItemWithTitle:@""]; // Populate encoding popup button for (NSDictionary *encoding in encodings) { NSString *menuItemTitle = (![encoding objectForKey:@"DESCRIPTION"]) ? [encoding objectForKey:@"CHARACTER_SET_NAME"] : [NSString stringWithFormat:@"%@ (%@)", [encoding objectForKey:@"DESCRIPTION"], [encoding objectForKey:@"CHARACTER_SET_NAME"]]; - [[[[tableSourceView tableColumns] objectAtIndex:10] dataCell] addItemWithTitle:menuItemTitle]; + [encodingPopupCell addItemWithTitle:menuItemTitle]; } } else { - [[[[tableSourceView tableColumns] objectAtIndex:10] dataCell] addItemWithTitle:NSLocalizedString(@"Not available", @"not available label")]; + [encodingPopupCell addItemWithTitle:NSLocalizedString(@"Not available", @"not available label")]; } // Process all the fields to normalise keys and add additional information @@ -343,7 +343,7 @@ NSInteger insertIndex = ([tableSourceView numberOfSelectedRows] == 0 ? [tableSourceView numberOfRows] : [tableSourceView selectedRow] + 1); [tableFields insertObject:[NSMutableDictionary - dictionaryWithObjects:[NSArray arrayWithObjects:@"", @"INT", @"", @"0", @"0", @"0", ([prefs boolForKey:SPNewFieldsAllowNulls]) ? @"1" : @"0", @"", [prefs stringForKey:SPNullValue], @"None", @"", @"", @"", nil] + dictionaryWithObjects:[NSArray arrayWithObjects:@"", @"INT", @"", @"0", @"0", @"0", ([prefs boolForKey:SPNewFieldsAllowNulls]) ? @"1" : @"0", @"", [prefs stringForKey:SPNullValue], @"None", @"", [NSNumber numberWithInt:0], [NSNumber numberWithInt:0], nil] forKeys:[NSArray arrayWithObjects:@"name", @"type", @"length", @"unsigned", @"zerofill", @"binary", @"null", @"Key", @"default", @"Extra", @"comment", @"encoding", @"collation", nil]] atIndex:insertIndex]; @@ -745,7 +745,7 @@ closes the keySheet NSString *fieldEncoding = @""; if([[theRow objectForKey:@"encoding"] integerValue] > 0) { - NSString *enc = [[[[[tableSourceView tableColumns] objectAtIndex:10] dataCell] itemAtIndex:[[theRow objectForKey:@"encoding"] integerValue]] title]; + NSString *enc = [[encodingPopupCell itemAtIndex:[[theRow objectForKey:@"encoding"] integerValue]] title]; NSInteger start = [enc rangeOfString:@"("].location+1; NSInteger end = [enc length] - start - 1; fieldEncoding = [enc substringWithRange:NSMakeRange(start, end)]; @@ -1254,7 +1254,7 @@ returns a dictionary containing enum/set field names as key and possible values if([[tableColumn identifier] isEqualToString:@"collation"]) { if([[[tableFields objectAtIndex:rowIndex] objectForKey:@"encoding"] integerValue] > 0) { - NSString *enc = [[[[[tableSourceView tableColumns] objectAtIndex:10] dataCell] itemAtIndex:[[[tableFields objectAtIndex:rowIndex] objectForKey:@"encoding"] integerValue]] title]; + NSString *enc = [[encodingPopupCell itemAtIndex:[[[tableFields objectAtIndex:rowIndex] objectForKey:@"encoding"] integerValue]] title]; NSInteger start = [enc rangeOfString:@"("].location+1; NSInteger end = [enc length] - start - 1; collations = [databaseDataInstance getDatabaseCollationsForEncoding:[enc substringWithRange:NSMakeRange(start, end)]]; @@ -1281,8 +1281,8 @@ returns a dictionary containing enum/set field names as key and possible values - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex { - // Make sure that the drag operation is for the right table view - if (aTableView!=tableSourceView) return; + // Make sure that the drag operation is for the right table view + if (aTableView != tableSourceView) return; if (!isEditingRow) { [oldRow setDictionary:[tableFields objectAtIndex:rowIndex]]; @@ -1298,7 +1298,13 @@ returns a dictionary containing enum/set field names as key and possible values } } - [[tableFields objectAtIndex:rowIndex] setObject:(anObject) ? anObject : @"" forKey:[aTableColumn identifier]]; + if([[aTableColumn identifier] isEqualToString:@"type"]) { + if(anObject && [(NSString*)anObject length] && ![(NSString*)anObject hasPrefix:@"--"]) + [[tableFields objectAtIndex:rowIndex] setObject:[(NSString*)anObject uppercaseString] forKey:@"type"]; + } + else + [[tableFields objectAtIndex:rowIndex] setObject:(anObject) ? anObject : @"" forKey:[aTableColumn identifier]]; + } /** @@ -1394,7 +1400,7 @@ would result in a position change. NSString *fieldEncoding = @""; if([[originalRow objectForKey:@"encoding"] integerValue] > 0) { - NSString *enc = [[[[[tableSourceView tableColumns] objectAtIndex:10] dataCell] itemAtIndex:[[originalRow objectForKey:@"encoding"] integerValue]] title]; + NSString *enc = [[encodingPopupCell itemAtIndex:[[originalRow objectForKey:@"encoding"] integerValue]] title]; NSInteger start = [enc rangeOfString:@"("].location+1; NSInteger end = [enc length] - start - 1; fieldEncoding = [enc substringWithRange:NSMakeRange(start, end)]; @@ -1430,17 +1436,19 @@ would result in a position change. BOOL isTimestampType = [[[originalRow objectForKey:@"type"] lowercaseString] isEqualToString:@"timestamp"]; - // Add the default value - if ([[originalRow objectForKey:@"default"] isEqualToString:[prefs objectForKey:SPNullValue]]) { - if ([[originalRow objectForKey:@"null"] integerValue] == 1) { - [queryString appendString:(isTimestampType) ? @" NULL DEFAULT NULL" : @" DEFAULT NULL"]; + // Add the default value, skip it for auto_increment + if([originalRow objectForKey:@"Extra"] && ![[originalRow objectForKey:@"Extra"] isEqualToString:@"auto_increment"]) { + if ([[originalRow objectForKey:@"default"] isEqualToString:[prefs objectForKey:SPNullValue]]) { + if ([[originalRow objectForKey:@"null"] integerValue] == 1) { + [queryString appendString:(isTimestampType) ? @" NULL DEFAULT NULL" : @" DEFAULT NULL"]; + } + } + else if (isTimestampType && ([[[originalRow objectForKey:@"default"] uppercaseString] isEqualToString:@"CURRENT_TIMESTAMP"]) ) { + [queryString appendString:@" DEFAULT CURRENT_TIMESTAMP"]; + } + else { + [queryString appendFormat:@" DEFAULT '%@'", [mySQLConnection prepareString:[originalRow objectForKey:@"default"]]]; } - } - else if (isTimestampType && ([[[originalRow objectForKey:@"default"] uppercaseString] isEqualToString:@"CURRENT_TIMESTAMP"]) ) { - [queryString appendString:@" DEFAULT CURRENT_TIMESTAMP"]; - } - else { - [queryString appendFormat:@" DEFAULT '%@'", [mySQLConnection prepareString:[originalRow objectForKey:@"default"]]]; } // Any column comments @@ -1533,41 +1541,57 @@ would result in a position change. column = [tableSourceView editedColumn]; // Trap the tab key, selecting the next item in the line - if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(insertTab:)] ) + if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(insertTab:)] && [tableSourceView numberOfColumns] - 1 == column) { //save current line [[control window] makeFirstResponder:control]; - if ( column == 9 ) { - if ( [self addRowToDB] && [textView methodForSelector:command] == [textView methodForSelector:@selector(insertTab:)] ) { - if ( row < ([tableSourceView numberOfRows] - 1) ) { - [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:row+1] byExtendingSelection:NO]; - [tableSourceView editColumn:0 row:row+1 withEvent:nil select:YES]; - } else { - [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO]; - [tableSourceView editColumn:0 row:0 withEvent:nil select:YES]; - } + + if ( [self addRowToDB] && [textView methodForSelector:command] == [textView methodForSelector:@selector(insertTab:)] ) { + if ( row < ([tableSourceView numberOfRows] - 1) ) { + [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:row+1] byExtendingSelection:NO]; + [tableSourceView editColumn:0 row:row+1 withEvent:nil select:YES]; + } else { + [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO]; + [tableSourceView editColumn:0 row:0 withEvent:nil select:YES]; } - } else { - if ( column == 2 ) { - [tableSourceView editColumn:column+6 row:row withEvent:nil select:YES]; + } + return YES; + + } + + // Trap shift-tab key + else if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(insertBacktab:)] && column < 1) + { + if ( [self addRowToDB] && [textView methodForSelector:command] == [textView methodForSelector:@selector(insertBacktab:)] ) { + [[control window] makeFirstResponder:control]; + if ( row > 0) { + [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:row-1] byExtendingSelection:NO]; + [tableSourceView editColumn:([tableFields count]-1) row:row-1 withEvent:nil select:YES]; } else { - [tableSourceView editColumn:column+1 row:row withEvent:nil select:YES]; + [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:([tableFields count]-1)] byExtendingSelection:NO]; + [tableSourceView editColumn:([tableFields count]-1) row:([tableSourceView numberOfRows]-1) withEvent:nil select:YES]; } } - return TRUE; + return YES; + } // Trap the enter key, triggering a save - } else if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(insertNewline:)] ) { + // Suppress enter for non-text fields to allow selecting of chosen items from comboboxes or popups + if(![[[[[[tableSourceView tableColumns] objectAtIndex:column] dataCell] class] description] isEqualToString:@"NSTextFieldCell"]) + return YES; + [[control window] makeFirstResponder:control]; [self addRowToDB]; - return TRUE; + [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO]; + [tableSourceView makeFirstResponder]; + return YES; + + } // Trap escape, aborting the edit and reverting the row - } - else if ( [[control window] methodForSelector:command] == [[control window] methodForSelector:@selector(_cancelKey:)] || - [textView methodForSelector:command] == [textView methodForSelector:@selector(complete:)] ) + else if ( [[control window] methodForSelector:command] == [[control window] methodForSelector:@selector(cancelOperation:)] ) { [control abortEditing]; if ( isEditingRow && !isEditingNewRow ) { @@ -1580,9 +1604,11 @@ would result in a position change. [tableSourceView reloadData]; } currentlyEditingRow = -1; - return TRUE; + [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO]; + [tableSourceView makeFirstResponder]; + return YES; } else { - return FALSE; + return NO; } } @@ -1591,10 +1617,11 @@ would result in a position change. * Modify cell display by disabling table cells when a view is selected, meaning structure/index * is uneditable. */ -- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex { +- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex +{ - //make sure that the message is from the right table view - if (tableView!=tableSourceView) return; + //make sure that the message is from the right table view + if (tableView != tableSourceView) return; [aCell setEnabled:([tablesListInstance tableType] == SPTableTypeTable)]; } |