From 6333eb96026649557a66d23efbf3746fd285307e Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 16 Jun 2009 15:22:49 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed:=20if=20the=20user=20tries=20to=20del?= =?UTF-8?q?ete=20the=20last=20defined=20field=20in=20a=20given=20table=20s?= =?UTF-8?q?how=20an=20alert=20saying=20that=20this=20isn't=20allowed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/TableSource.m | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Source/TableSource.m b/Source/TableSource.m index 8ed241b8..6509fa24 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -348,6 +348,21 @@ reloads the table (performing a new mysql-query) if (![self saveRowOnDeselect]) return; + // Check if the user tries to delete the last defined field in table + if ([tableSourceView numberOfRows] < 2) { + NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error while deleting field", @"Error while deleting field") + defaultButton:NSLocalizedString(@"OK", @"OK button") + alternateButton:nil + otherButton:nil + informativeTextWithFormat:NSLocalizedString(@"You cannot delete the last field in a table. Use “Remove table” (DROP TABLE) instead.", + @"You cannot delete the last field in that table. Use “Remove table” (DROP TABLE) instead")]; + + [alert setAlertStyle:NSCriticalAlertStyle]; + + [alert beginSheetModalForWindow:tableWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"cannotremovefield"]; + + } + NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Delete field?", @"delete field message") defaultButton:NSLocalizedString(@"Delete", @"delete button") alternateButton:NSLocalizedString(@"Cancel", @"cancel button") @@ -796,7 +811,10 @@ fetches the result as an array with a dictionary for each row in it [NSString stringWithFormat:NSLocalizedString(@"Couldn't remove index.\nMySQL said: %@", @"message of panel when index cannot be removed"), [mySQLConnection getLastErrorMessage]]); } } + } else if ( [contextInfo isEqualToString:@"cannotremovefield"]) { + ; } + } /** -- cgit v1.2.3