aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableContent.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-08-24 14:26:00 +0000
committerBibiko <bibiko@eva.mpg.de>2010-08-24 14:26:00 +0000
commitd90aac6dfab328485bad6ec450388d90684a0ee6 (patch)
treed09c5bbe1cb309018a3298e805eb79aec3e1c053 /Source/SPTableContent.m
parent015321ca8747bbd2ee6f8a153e779835f75f9efe (diff)
downloadsequelpro-d90aac6dfab328485bad6ec450388d90684a0ee6.tar.gz
sequelpro-d90aac6dfab328485bad6ec450388d90684a0ee6.tar.bz2
sequelpro-d90aac6dfab328485bad6ec450388d90684a0ee6.zip
• outsourced control:textView:doCommandBySelector: stuff to SPCopyTable since we need that for Content and Custom Query table; only class specific stuff like ESC trapping will handled in the actual class
• enabled in cell editing for Custom Query tables - also added spreadsheet button to Custom Query status bar • fixed ESC trapping: F5 can be used for completion • simplified [SPCopyTable keyDown:] for trapping ENTER/RETURN key • some code cosmetics
Diffstat (limited to 'Source/SPTableContent.m')
-rw-r--r--Source/SPTableContent.m157
1 files changed, 9 insertions, 148 deletions
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index 4017f42a..2a48d471 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -2681,6 +2681,7 @@
return [[tempRow objectAtIndex:0] integerValue];
}
+
/*
* Close an open sheet.
*/
@@ -3764,155 +3765,16 @@
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command
{
- NSString *fieldType;
- NSUInteger row, column, i;
-
- row = [tableContentView editedRow];
- column = [tableContentView editedColumn];
-
- // Trap tab key
- // -- for handling of blob fields look at [self control:textShouldBeginEditing:]
- if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(insertTab:)] )
- {
- [[control window] makeFirstResponder:control];
-
- if([tablesListInstance tableType] == SPTableTypeView) {
- // Look for the next editable field
- if ( column != ( [tableContentView numberOfColumns] - 1 ) ) {
- i = 1;
- while ([self fieldEditStatusForRow:row andColumn:[NSArrayObjectAtIndex([tableContentView tableColumns], column+i) identifier]] != 1) {
- i++;
-
- // If there are no columns after the latest blob or text column, save the current line.
- if ( (column+i) >= [tableContentView numberOfColumns] ) {
- return TRUE;
- }
- }
-
- [tableContentView editColumn:column+i row:row withEvent:nil select:YES];
-
- }
- } else {
-
- // Save the current line if it's the last field in the table
- if ( column == ( [tableContentView numberOfColumns] - 1 ) ) {
- [self addRowToDB];
- return YES;
- } else {
- // Select the next field for editing
- [tableContentView editColumn:column+1 row:row withEvent:nil select:YES];
- return YES;
- }
-
- }
+ // Check firstly if SPCopyTable can handle command
+ if([tableContentView control:control textView:textView doCommandBySelector:(SEL)command])
return YES;
- }
-
- // Trap shift-tab key
- if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(insertBacktab:)] )
- {
- [[control window] makeFirstResponder:control];
-
- if([tablesListInstance tableType] == SPTableTypeView) {
- // Look for the next editable field backwards
- if ( column > 0 ) {
- i = 1;
- while ([self fieldEditStatusForRow:row andColumn:[NSArrayObjectAtIndex([tableContentView tableColumns], column-i) identifier]] != 1) {
- i++;
-
- // If there are no columns before the latestone, return.
- if ( column == i ) {
- return TRUE;
- }
- }
-
- [tableContentView editColumn:column-i row:row withEvent:nil select:YES];
-
- }
- } else {
-
- // Save the current line if it's the last field in the table
- if ( column < 1 ) {
- [self addRowToDB];
- return YES;
- } else {
- // Select the previous field for editing
- [tableContentView editColumn:column-1 row:row withEvent:nil select:YES];
- return YES;
- }
-
- }
- return YES;
- }
-
- // Trap enter key
- else if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(insertNewline:)] )
- {
- // If enum field is edited RETURN selects the new value instead of saving the entire row
- NSString *fieldType = [[tableDataInstance columnWithName:[[NSArrayObjectAtIndex([tableContentView tableColumns], column) headerCell] stringValue]] objectForKey:@"typegrouping"];
- if([fieldType isEqualToString:@"enum"])
- return YES;
-
- [[control window] makeFirstResponder:control];
- if([tablesListInstance tableType] != SPTableTypeView)
- [self addRowToDB];
- return TRUE;
-
- }
-
- // Trap down arrow key
- else if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(moveDown:)] )
- {
-
- // If enum field is edited ARROW key navigates through the popup list
- NSString *fieldType = [[tableDataInstance columnWithName:[[NSArrayObjectAtIndex([tableContentView tableColumns], column) headerCell] stringValue]] objectForKey:@"typegrouping"];
- if([fieldType isEqualToString:@"enum"])
- return NO;
-
- NSUInteger newRow = row+1;
- if (newRow>=tableRowsCount) return TRUE; //check if we're already at the end of the list
-
- [[control window] makeFirstResponder:control];
- if([tablesListInstance tableType] != SPTableTypeView)
- [self addRowToDB];
-
- if (newRow>=tableRowsCount) return TRUE; //check again. addRowToDB could reload the table and change the number of rows
- if (column>=[tableValues columnCount]) return TRUE; //the column count could change too
-
- [tableContentView selectRowIndexes:[NSIndexSet indexSetWithIndex:newRow] byExtendingSelection:NO];
- [tableContentView editColumn:column row:newRow withEvent:nil select:YES];
- return TRUE;
- }
-
- // Trap up arrow key
- else if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(moveUp:)] )
- {
-
- // If enum field is edited ARROW key navigates through the popup list
- NSString *fieldType = [[tableDataInstance columnWithName:[[NSArrayObjectAtIndex([tableContentView tableColumns], column) headerCell] stringValue]] objectForKey:@"typegrouping"];
- if([fieldType isEqualToString:@"enum"])
- return NO;
-
- if (row==0) return TRUE; //already at the beginning of the list
- NSUInteger newRow = row-1;
-
- [[control window] makeFirstResponder:control];
- if([tablesListInstance tableType] != SPTableTypeView)
- [self addRowToDB];
-
- if (newRow>=tableRowsCount) return TRUE; // addRowToDB could reload the table and change the number of rows
- if (column>=[tableValues columnCount]) return TRUE; //the column count could change too
-
- [tableContentView selectRowIndexes:[NSIndexSet indexSetWithIndex:newRow] byExtendingSelection:NO];
- [tableContentView editColumn:column row:newRow withEvent:nil select:YES];
- return TRUE;
- }
// Trap the escape key
- else if ( [[control window] methodForSelector:command] == [[control window] methodForSelector:@selector(_cancelKey:)] ||
- [textView methodForSelector:command] == [textView methodForSelector:@selector(complete:)] )
+ if ( [[control window] methodForSelector:command] == [[control window] methodForSelector:@selector(cancelOperation:)] )
{
+ NSUInteger row = [tableContentView editedRow];
+
// Abort editing
[control abortEditing];
if ( isEditingRow && !isEditingNewRow ) {
@@ -3933,10 +3795,9 @@
return TRUE;
}
- else
- {
- return FALSE;
- }
+
+ return FALSE;
+
}
/**