diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/TableContent.m | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/Source/TableContent.m b/Source/TableContent.m index e28cf44e..0e6d21b3 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -774,37 +774,49 @@ [tableContentView editColumn:0 row:[tableContentView selectedRow] withEvent:nil select:YES]; } -- (IBAction)removeRow:(id)sender -/* - asks user if he really wants to delete the selected rows +/** + * Asks the user if they really want to delete the selected rows */ +- (IBAction)removeRow:(id)sender { // Check whether a save of the current row is required. - if ( ![self saveRowOnDeselect] ) return; + if (![self saveRowOnDeselect]) + return; - if ( ![tableContentView numberOfSelectedRows] ) + if (![tableContentView numberOfSelectedRows]) return; - /* - if ( ([tableContentView numberOfSelectedRows] == [self numberOfRowsInTableView:tableContentView]) && - areShowingAllRows && - (![prefs boolForKey:@"LimitResults"] || ([tableContentView numberOfSelectedRows] < [prefs integerForKey:@"LimitResultsValue"])) ) { - */ - if ( ([tableContentView numberOfSelectedRows] == [tableContentView numberOfRows]) && + + NSAlert *alert = [NSAlert alertWithMessageText:@"" + defaultButton:NSLocalizedString(@"Delete", @"delete button") + alternateButton:NSLocalizedString(@"Cancel", @"cancel button") + otherButton:nil + informativeTextWithFormat:@""]; + + [alert setAlertStyle:NSCriticalAlertStyle]; + + NSString *contextInfo = @"removerow"; + + if (([tableContentView numberOfSelectedRows] == [tableContentView numberOfRows]) && (([prefs boolForKey:@"LimitResults"] && [tableContentView numberOfSelectedRows] == [self fetchNumberOfRows]) || - (![prefs boolForKey:@"LimitResults"] && [tableContentView numberOfSelectedRows] == [self getNumberOfRows])) ) { - NSBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"Delete", @"delete button"), NSLocalizedString(@"Cancel", @"cancel button"), nil, tableWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), - nil, @"removeallrows", NSLocalizedString(@"Do you really want to delete all rows?", @"message of panel asking for confirmation for deleting all rows")); - } else if ( [tableContentView numberOfSelectedRows] == 1 ) { - NSBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"Delete", @"delete button"), NSLocalizedString(@"Cancel", @"cancel button"), nil, tableWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), - nil, @"removerow", NSLocalizedString(@"Do you really want to delete the selected row?", @"message of panel asking for confirmation for deleting the selected row")); - } else { - NSBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"Delete", @"delete button"), NSLocalizedString(@"Cancel", @"cancel button"), nil, tableWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), - nil, @"removerow", - [NSString stringWithFormat:NSLocalizedString(@"Do you really want to delete the selected %d rows?", @"message of panel asking for confirmation for deleting the selected rows"), [tableContentView numberOfSelectedRows]]); + (![prefs boolForKey:@"LimitResults"] && [tableContentView numberOfSelectedRows] == [self getNumberOfRows]))) { + + contextInfo = @"removeallrows"; + + [alert setMessageText:NSLocalizedString(@"Delete all rows?", @"delete all rows message")]; + [alert setInformativeText:NSLocalizedString(@"Are you sure you want to delete all the rows from this table. This action cannot be undone.", @"delete all rows informative message")]; + } + else if ([tableContentView numberOfSelectedRows] == 1) { + [alert setMessageText:NSLocalizedString(@"Delete selected row?", @"delete selected row message")]; + [alert setInformativeText:NSLocalizedString(@"Are you sure you want to delete the selected row from this table. This action cannot be undone.", @"delete selected row informative message")]; + } + else { + [alert setMessageText:NSLocalizedString(@"Delete rows?", @"delete rows message")]; + [alert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"Are you sure you want to delete the selected %d rows from this table. This action cannot be undone.", @"delete rows informative message"), [tableContentView numberOfSelectedRows]]]; } + + [alert beginSheetModalForWindow:tableWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:contextInfo]; } - //editSheet methods - (IBAction)closeEditSheet:(id)sender { @@ -1587,9 +1599,9 @@ CMMCPResult *queryResult; int i, errors; - [sheet orderOut:self]; - if ( [contextInfo isEqualToString:@"addrow"] ) { + [sheet orderOut:self]; + if ( returnCode == NSAlertDefaultReturn ) { //problem: reenter edit mode doesn't function [tableContentView editColumn:0 row:[tableContentView selectedRow] withEvent:nil select:YES]; |