aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2009-06-24 22:56:41 +0000
committerstuconnolly <stuart02@gmail.com>2009-06-24 22:56:41 +0000
commite56731e44cf507c17f3e8f231f452fda0dad3bb5 (patch)
tree8b34a384f00f3e97e00f8d6faf5924d760d4f1f3 /Source
parentcae0a084e52ea3e2e4c1ac92908f41920d9cbbdc (diff)
downloadsequelpro-e56731e44cf507c17f3e8f231f452fda0dad3bb5.tar.gz
sequelpro-e56731e44cf507c17f3e8f231f452fda0dad3bb5.tar.bz2
sequelpro-e56731e44cf507c17f3e8f231f452fda0dad3bb5.zip
Change the remove relation confirmation dialog to a sheet as opposed to a modal dialog.
Diffstat (limited to 'Source')
-rw-r--r--Source/SPTableRelations.m82
1 files changed, 48 insertions, 34 deletions
diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m
index b10d5f46..d3212a0e 100644
--- a/Source/SPTableRelations.m
+++ b/Source/SPTableRelations.m
@@ -182,41 +182,15 @@
{
if ([relationsTableView numberOfSelectedRows] > 0) {
- int response = NSRunAlertPanel(NSLocalizedString(@"Delete relation", @"delete relation message"),
- NSLocalizedString(@"Are you sure you want to delete the selected relations? This action cannot be undone", @"delete selected relation informative message"),
- NSLocalizedString(@"Delete", @"delete button"),
- NSLocalizedString(@"Cancel", @"cancel button"), nil );
+ NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Delete relation", @"delete relation message")
+ defaultButton:NSLocalizedString(@"Delete", @"delete button")
+ alternateButton:NSLocalizedString(@"Cancel", @"cancel button")
+ otherButton:nil
+ informativeTextWithFormat:NSLocalizedString(@"Are you sure you want to delete the selected relations? This action cannot be undone.", @"delete selected relation informative message")];
- if (response == NSAlertDefaultReturn) {
-
- NSString *thisTable = [tablesListInstance tableName];
- NSIndexSet *selectedSet = [relationsTableView selectedRowIndexes];
-
- unsigned int row = [selectedSet lastIndex];
-
- while (row != NSNotFound)
- {
- NSString *relationName = [[relationData objectAtIndex:row] objectForKey:@"name"];
- NSString *query = [NSString stringWithFormat:@"ALTER TABLE %@ DROP FOREIGN KEY %@", [thisTable backtickQuotedString], [relationName backtickQuotedString]];
-
- [connection queryString:query];
-
- if (![[connection getLastErrorMessage] isEqualToString:@""] ) {
-
- NSBeginAlertSheet(NSLocalizedString(@"Unable to remove relation", @"error removing relation message"),
- NSLocalizedString(@"OK", @"OK button"),
- nil, nil, [NSApp mainWindow], nil, nil, nil, nil,
- [NSString stringWithFormat:NSLocalizedString(@"The selected relation couldn't be removed.\n\nMySQL said: %@", @"error removing relation informative message"), [connection getLastErrorMessage]]);
-
- // Abort loop
- break;
- }
-
- row = [selectedSet indexLessThanIndex:row];
- }
-
- [self _refreshRelationDataForcingCacheRefresh:YES];
- }
+ [alert setAlertStyle:NSCriticalAlertStyle];
+
+ [alert beginSheetModalForWindow:tableWindow modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:@"removeRelation"];
}
}
@@ -288,6 +262,46 @@
#pragma mark -
#pragma mark Other
+/**
+ * NSAlert didEnd method.
+ */
+- (void)alertDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(NSString *)contextInfo
+{
+ if ([contextInfo isEqualToString:@"removeRelation"]) {
+
+ if (returnCode == NSAlertDefaultReturn) {
+
+ NSString *thisTable = [tablesListInstance tableName];
+ NSIndexSet *selectedSet = [relationsTableView selectedRowIndexes];
+
+ unsigned int row = [selectedSet lastIndex];
+
+ while (row != NSNotFound)
+ {
+ NSString *relationName = [[relationData objectAtIndex:row] objectForKey:@"name"];
+ NSString *query = [NSString stringWithFormat:@"ALTER TABLE %@ DROP FOREIGN KEY %@", [thisTable backtickQuotedString], [relationName backtickQuotedString]];
+
+ [connection queryString:query];
+
+ if (![[connection getLastErrorMessage] isEqualToString:@""] ) {
+
+ NSBeginAlertSheet(NSLocalizedString(@"Unable to remove relation", @"error removing relation message"),
+ NSLocalizedString(@"OK", @"OK button"),
+ nil, nil, [NSApp mainWindow], nil, nil, nil, nil,
+ [NSString stringWithFormat:NSLocalizedString(@"The selected relation couldn't be removed.\n\nMySQL said: %@", @"error removing relation informative message"), [connection getLastErrorMessage]]);
+
+ // Abort loop
+ break;
+ }
+
+ row = [selectedSet indexLessThanIndex:row];
+ }
+
+ [self _refreshRelationDataForcingCacheRefresh:YES];
+ }
+ }
+}
+
/*
* Dealloc.
*/