aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m1
-rw-r--r--Resources/English.lproj/DatabaseProcessList.stringsbin8972 -> 9308 bytes
-rw-r--r--Resources/English.lproj/FieldEditorSheet.stringsbin3650 -> 11096 bytes
-rw-r--r--Resources/English.lproj/Localizable.stringsbin177134 -> 177426 bytes
-rw-r--r--Source/SPCopyTable.m7
-rw-r--r--Source/SPTableContent.m90
-rw-r--r--Source/SPTableStructure.h1
-rw-r--r--Source/SPTableStructure.m47
-rw-r--r--Source/SPTableView.m8
9 files changed, 73 insertions, 81 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
index 362c3dc6..c9ab0b12 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
@@ -416,7 +416,6 @@ static BOOL sTruncateLongFieldInLogs = YES;
// Apply SSL if appropriate
if (useSSL) {
- NSLog(@"sdfsdfsfds SET");
mysql_ssl_set(mConnection,
sslKeyFilePath ? [sslKeyFilePath UTF8String] : NULL,
sslCertificatePath ? [sslCertificatePath UTF8String] : NULL,
diff --git a/Resources/English.lproj/DatabaseProcessList.strings b/Resources/English.lproj/DatabaseProcessList.strings
index 71db3ee9..9df6ea58 100644
--- a/Resources/English.lproj/DatabaseProcessList.strings
+++ b/Resources/English.lproj/DatabaseProcessList.strings
Binary files differ
diff --git a/Resources/English.lproj/FieldEditorSheet.strings b/Resources/English.lproj/FieldEditorSheet.strings
index 0c7ad875..7c9b31d1 100644
--- a/Resources/English.lproj/FieldEditorSheet.strings
+++ b/Resources/English.lproj/FieldEditorSheet.strings
Binary files differ
diff --git a/Resources/English.lproj/Localizable.strings b/Resources/English.lproj/Localizable.strings
index 29fdc2a8..659cd4ba 100644
--- a/Resources/English.lproj/Localizable.strings
+++ b/Resources/English.lproj/Localizable.strings
Binary files differ
diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m
index 962557f1..faf1b231 100644
--- a/Source/SPCopyTable.m
+++ b/Source/SPCopyTable.m
@@ -739,6 +739,13 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003;
return;
}
+ // Check if ESCAPE is hit and use it to cancel row editing if supported
+ else if ([theEvent keyCode] == 53 && [[self delegate] respondsToSelector:@selector(cancelRowEditing)])
+ {
+ if ([[self delegate] cancelRowEditing]) return;
+ }
+
+
[super keyDown:theEvent];
}
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index 79afe0a8..99e34af1 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -1623,14 +1623,10 @@
if ( [contextInfo isEqualToString:@"removeallrows"] ) {
if ( returnCode == NSAlertDefaultReturn ) {
- //check if the user is currently editing a row
- if (isEditingRow) {
- //cancel the edit
- isEditingRow = NO;
- // in case the delete fails, make sure we at least stay in a somewhat consistent state
- [tableValues replaceRowAtIndex:currentlyEditingRow withRowContents:oldRow];
- currentlyEditingRow = -1;
- }
+
+ // Check if the user is currently editing a row, and revert to ensure a somewhat
+ // consistent state if deletion fails.
+ if (isEditingRow) [self cancelRowEditing];
[mySQLConnection queryString:[NSString stringWithFormat:@"DELETE FROM %@", [selectedTable backtickQuotedString]]];
if ( ![mySQLConnection queryErrored] ) {
@@ -1668,31 +1664,17 @@
if ([selectedRows count]!=1) {
NSLog(@"Expected only one selected row, but found %d",[selectedRows count]);
}
- // this code is pretty much taken from the escape key handler
+
+ // Always cancel the edit; if the user is currently editing a new row, we can just discard it;
+ // if editing an old row, restore it to the original to ensure consistent state if deletion fails.
+ // If editing a new row, deselect the row and return - as no table reload is required.
if ( isEditingNewRow ) {
- // since the user is currently editing a new row, we don't actually have to delete any rows from the database
- // we just have to remove the row from the view (and the store)
- isEditingRow = NO;
- isEditingNewRow = NO;
- tableRowsCount--;
- [tableValues removeRowAtIndex:currentlyEditingRow];
- currentlyEditingRow = -1;
- [self updateCountText];
- [tableContentView reloadData];
-
- //deselect the row
+ [self cancelRowEditing]; // Resets isEditingNewRow!
[tableContentView selectRowIndexes:[NSIndexSet indexSet] byExtendingSelection:NO];
-
- // we also don't have to reload the table, since no query went to the database
return;
} else {
- //cancel the edit
- isEditingRow = NO;
- // in case the delete fails, make sure we at least stay in a somewhat consistent state
- [tableValues replaceRowAtIndex:currentlyEditingRow withRowContents:oldRow];
- currentlyEditingRow = -1;
+ [self cancelRowEditing];
}
-
}
[tableContentView selectRowIndexes:[NSIndexSet indexSet] byExtendingSelection:NO];
@@ -2430,16 +2412,7 @@
// Discard changes selected
} else {
- if ( !isEditingNewRow ) {
- [tableValues replaceRowAtIndex:currentlyEditingRow withRowContents:oldRow];
- isEditingRow = NO;
- } else {
- tableRowsCount--;
- [tableValues removeRowAtIndex:currentlyEditingRow];
- isEditingRow = NO;
- isEditingNewRow = NO;
- }
- currentlyEditingRow = -1;
+ [self cancelRowEditing];
}
[tableContentView reloadData];
}
@@ -2477,6 +2450,29 @@
}
/**
+ * Cancel active row editing, replacing the previous row if there was one
+ * and resetting state.
+ * Returns whether row editing was cancelled.
+ */
+- (BOOL)cancelRowEditing
+{
+ if (!isEditingRow) return NO;
+ if (isEditingNewRow) {
+ tableRowsCount--;
+ [tableValues removeRowAtIndex:currentlyEditingRow];
+ [self updateCountText];
+ isEditingNewRow = NO;
+ } else {
+ [tableValues replaceRowAtIndex:currentlyEditingRow withRowContents:oldRow];
+ }
+ isEditingRow = NO;
+ currentlyEditingRow = -1;
+ [tableContentView reloadData];
+ [tableContentView makeFirstResponder];
+ return YES;
+}
+
+/**
* Returns the WHERE argument to identify a row.
* If "row" is -2, it uses the oldRow.
* Uses the primary key if available, otherwise uses all fields as argument and sets LIMIT to 1
@@ -3295,7 +3291,6 @@
}
-
// Catch editing events in the row and if the row isn't currently being edited,
// start an edit. This allows edits including enum changes to save correctly.
if ( !isEditingRow ) {
@@ -3835,22 +3830,7 @@
// Abort editing
[control abortEditing];
- if ( isEditingRow && !isEditingNewRow ) {
- isEditingRow = NO;
- [tableValues replaceRowAtIndex:row withRowContents:oldRow];
- } else if ( isEditingNewRow ) {
- isEditingRow = NO;
- isEditingNewRow = NO;
- tableRowsCount--;
- [tableValues removeRowAtIndex:row];
- [self updateCountText];
- [tableContentView reloadData];
- }
- currentlyEditingRow = -1;
-
- // Preserve the focus
- [tableContentView makeFirstResponder];
-
+ [self cancelRowEditing];
return TRUE;
}
diff --git a/Source/SPTableStructure.h b/Source/SPTableStructure.h
index 8a1fa32a..d5229153 100644
--- a/Source/SPTableStructure.h
+++ b/Source/SPTableStructure.h
@@ -85,6 +85,7 @@
- (IBAction)removeField:(id)sender;
- (IBAction)resetAutoIncrement:(id)sender;
- (IBAction)showOptimizedFieldType:(id)sender;
+- (BOOL)cancelRowEditing;
// Index sheet methods
- (IBAction)closeSheet:(id)sender;
diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m
index c6e4d7f7..4d9a496f 100644
--- a/Source/SPTableStructure.m
+++ b/Source/SPTableStructure.m
@@ -609,6 +609,27 @@
}
}
+/**
+ * Cancel active row editing, replacing the previous row if there was one
+ * and resetting state.
+ * Returns whether row editing was cancelled.
+ */
+- (BOOL)cancelRowEditing
+{
+ if (!isEditingRow) return NO;
+ if (isEditingNewRow) {
+ isEditingNewRow = NO;
+ [tableFields removeObjectAtIndex:currentlyEditingRow];
+ } else {
+ [tableFields replaceObjectAtIndex:currentlyEditingRow withObject:[NSMutableDictionary dictionaryWithDictionary:oldRow]];
+ }
+ isEditingRow = NO;
+ [tableSourceView reloadData];
+ currentlyEditingRow = -1;
+ [tableSourceView makeFirstResponder];
+ return YES;
+}
+
#pragma mark -
#pragma mark Index sheet methods
@@ -1065,18 +1086,7 @@ closes the keySheet
// Discard changes and cancel editing
else {
- if (!isEditingNewRow) {
- [tableFields replaceObjectAtIndex:currentlyEditingRow
- withObject:[NSMutableDictionary dictionaryWithDictionary:oldRow]];
- isEditingRow = NO;
- }
- else {
- [tableFields removeObjectAtIndex:currentlyEditingRow];
- isEditingRow = NO;
- isEditingNewRow = NO;
- }
-
- currentlyEditingRow = -1;
+ [self cancelRowEditing];
}
[tableSourceView reloadData];
@@ -1706,18 +1716,7 @@ would result in a position change.
else if ( [[control window] methodForSelector:command] == [[control window] methodForSelector:@selector(cancelOperation:)] )
{
[control abortEditing];
- if ( isEditingRow && !isEditingNewRow ) {
- isEditingRow = NO;
- [tableFields replaceObjectAtIndex:row withObject:[NSMutableDictionary dictionaryWithDictionary:oldRow]];
- } else if ( isEditingNewRow ) {
- isEditingRow = NO;
- isEditingNewRow = NO;
- [tableFields removeObjectAtIndex:row];
- [tableSourceView reloadData];
- }
- currentlyEditingRow = -1;
- [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
- [tableSourceView makeFirstResponder];
+ [self cancelRowEditing];
return YES;
} else {
return NO;
diff --git a/Source/SPTableView.m b/Source/SPTableView.m
index c3f76baf..aa0b5067 100644
--- a/Source/SPTableView.m
+++ b/Source/SPTableView.m
@@ -89,7 +89,7 @@
{
// Check if ENTER or RETURN is hit and edit the column.
- if([self numberOfSelectedRows] == 1 && ([theEvent keyCode] == 36 || [theEvent keyCode] == 76))
+ if ([self numberOfSelectedRows] == 1 && ([theEvent keyCode] == 36 || [theEvent keyCode] == 76))
{
if([[[[self delegate] class] description] isEqualToString:@"SPFieldMapperController"]) {
@@ -126,6 +126,12 @@
}
}
+
+ // Check if ESCAPE is hit and use it to cancel row editing if supported
+ else if ([theEvent keyCode] == 53 && [[self delegate] respondsToSelector:@selector(cancelRowEditing)])
+ {
+ if ([[self delegate] cancelRowEditing]) return;
+ }
[super keyDown:theEvent];