From 7567724b1e66bc394bf36c7d7b153dd048018f03 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 3 Feb 2010 12:46:23 +0000 Subject: =?UTF-8?q?=E2=80=A2=20improved=20error=20handling=20in=20Structur?= =?UTF-8?q?e=20View=20for=20adding/renaming/removing=20a=20field=20if=20th?= =?UTF-8?q?e=20actual=20underlying=20table=20doesn't=20exit=20anymore;=20n?= =?UTF-8?q?ow=20it=20informs=20the=20user,=20clean=20the=20view,=20and=20r?= =?UTF-8?q?eloads=20the=20Table=20List=20=E2=80=A2=20improved=20error=20ha?= =?UTF-8?q?ndling=20in=20Content=20View=20for=20refreshing=20data=20for=20?= =?UTF-8?q?the=20current=20table=20if=20the=20table=20doesn't=20exist=20an?= =?UTF-8?q?ymore=20-=20this=20fix=20and=20the=20fix=20in=20[TableContent?= =?UTF-8?q?=20setCompareTypes:]=20to=20check=20for=20valid=20table=20data?= =?UTF-8?q?=20removes=20some=20NSPlaceholderString=20and=20NSScanner=20war?= =?UTF-8?q?nings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/TableSource.m | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'Source/TableSource.m') diff --git a/Source/TableSource.m b/Source/TableSource.m index 819bdea7..79a7f4ae 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -820,7 +820,29 @@ fetches the result as an array with a dictionary for each row in it } else { alertSheetOpened = YES; - + if([mySQLConnection getLastErrorID] == 1146) { // If the current table doesn't exist anymore + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), + NSLocalizedString(@"OK", @"OK button"), + nil, nil, tableWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), nil, nil, + [NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to alter table '%@'.\n\nMySQL said: %@", @"error while trying to alter table message"), + selectedTable, [mySQLConnection getLastErrorMessage]]); + + isEditingRow = NO; + isEditingNewRow = NO; + currentlyEditingRow = -1; + [tableFields removeAllObjects]; + [indexes removeAllObjects]; + [tableSourceView reloadData]; + [indexView reloadData]; + [addFieldButton setEnabled:NO]; + [copyFieldButton setEnabled:NO]; + [removeFieldButton setEnabled:NO]; + [addIndexButton setEnabled:NO]; + [removeIndexButton setEnabled:NO]; + [editTableButton setEnabled:NO]; + [tablesListInstance updateTables:self]; + return NO; + } // Problem: alert sheet doesn't respond to first click if (isEditingNewRow) { SPBeginAlertSheet(NSLocalizedString(@"Error adding field", @"error adding field message"), @@ -947,7 +969,7 @@ fetches the result as an array with a dictionary for each row in it currentlyEditingRow = -1; } [tableSourceView reloadData]; - } + } else if ([contextInfo isEqualToString:@"removeField"] || [contextInfo isEqualToString:@"removeFieldAndForeignKey"]) { if (returnCode == NSAlertDefaultReturn) { [self _removeFieldAndForeignKey:[contextInfo hasSuffix:@"AndForeignKey"]]; @@ -966,6 +988,8 @@ fetches the result as an array with a dictionary for each row in it else if ([contextInfo isEqualToString:@"cannotremovefield"]) { ; } + else + alertSheetOpened = NO; } #pragma mark - -- cgit v1.2.3