aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2009-05-11 23:01:11 +0000
committerstuconnolly <stuart02@gmail.com>2009-05-11 23:01:11 +0000
commit718f6e66a5a43483fedf3c0d33731e6d15363357 (patch)
tree2db6533874e53729d67eecb9ffc57c394906709d /Source
parent94fc42a398c088c822390fe3fba6ddffb66e426d (diff)
downloadsequelpro-718f6e66a5a43483fedf3c0d33731e6d15363357.tar.gz
sequelpro-718f6e66a5a43483fedf3c0d33731e6d15363357.tar.bz2
sequelpro-718f6e66a5a43483fedf3c0d33731e6d15363357.zip
Improve warning dialogs when removing table rows. Part of issue #192.
Diffstat (limited to 'Source')
-rw-r--r--Source/TableContent.m60
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];