From ed2d754e46bd6a104f1b093b979720727e95dcb5 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 23 Jun 2009 19:33:06 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed=20several=20problems=20for=20alerting?= =?UTF-8?q?=20an=20error=20sheet=20inside=20of=20a=20didEndSelector:=20of?= =?UTF-8?q?=20an=20other=20sheet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/TableContent.m | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'Source/TableContent.m') diff --git a/Source/TableContent.m b/Source/TableContent.m index 06ff12bd..91ecdd53 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -1838,9 +1838,12 @@ if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { [self reloadTable:self]; } else { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, - [NSString stringWithFormat:NSLocalizedString(@"Couldn't remove rows.\nMySQL said: %@", @"message of panel when field cannot be removed"), - [mySQLConnection getLastErrorMessage]]); + [self performSelector:@selector(showErrorSheetWith:) + withObject:[NSArray arrayWithObjects:NSLocalizedString(@"Error", @"error"), + [NSString stringWithFormat:NSLocalizedString(@"Couldn't remove rows.\nMySQL said: %@", @"message of panel when field cannot be removed"), + [mySQLConnection getLastErrorMessage]], + nil] + afterDelay:0.3]; } } } else if ( [contextInfo isEqualToString:@"removerow"] ) { @@ -1869,9 +1872,13 @@ } if ( errors ) { - NSBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"%d rows have not been removed. Reload the table to be sure that the rows exist and use a primary key for your table.", @"message of panel when not all selected fields have been deleted"), errors]); + [self performSelector:@selector(showErrorSheetWith:) + withObject:[NSArray arrayWithObjects:NSLocalizedString(@"Warning", @"warning"), + [NSString stringWithFormat:NSLocalizedString(@"%d row%@ ha%@ not been removed. Reload the table to be sure that the rows exist and use a primary key for your table.", @"message of panel when not all selected fields have been deleted"), errors, (errors>1)?@"s":@"", (errors>1)?@"ve":@"s"], + nil] + afterDelay:0.3]; } - + //do deleting (after enumerating) if ( [prefs boolForKey:@"ReloadAfterRemovingRow"] ) { [self reloadTableValues:self]; @@ -1918,6 +1925,19 @@ } } +/* + * Show Error sheet (can be called from inside of a endSheet selector) + * via [self performSelector:@selector(showErrorSheetWithTitle:) withObject: afterDelay:] + */ +-(void)showErrorSheetWith:(id)error +{ + // error := first object is the title , second the message, only one button OK + NSBeginAlertSheet([error objectAtIndex:0], NSLocalizedString(@"OK", @"OK button"), + nil, nil, tableWindow, self, nil, nil, nil, + [error objectAtIndex:1]); +} + + /* * Returns the number of rows in the selected table * Queries the number from MySQL if enabled in prefs and result is limited, otherwise just return the fullResult count. -- cgit v1.2.3