diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CustomQuery.m | 11 | ||||
-rw-r--r-- | Source/SPAlertSheets.h | 36 | ||||
-rw-r--r-- | Source/SPAlertSheets.m | 55 | ||||
-rw-r--r-- | Source/SPConnectionController.m | 9 | ||||
-rw-r--r-- | Source/SPExtendedTableInfo.m | 9 | ||||
-rw-r--r-- | Source/SPKeychain.m | 2 | ||||
-rw-r--r-- | Source/SPProcessListController.m | 5 | ||||
-rw-r--r-- | Source/SPTableData.m | 9 | ||||
-rw-r--r-- | Source/SPTableRelations.m | 5 | ||||
-rw-r--r-- | Source/SPUserManager.m | 10 | ||||
-rw-r--r-- | Source/TableContent.m | 15 | ||||
-rw-r--r-- | Source/TableDocument.m | 16 | ||||
-rw-r--r-- | Source/TableDump.m | 27 | ||||
-rw-r--r-- | Source/TableSource.m | 15 | ||||
-rw-r--r-- | Source/TablesList.m | 31 |
15 files changed, 176 insertions, 79 deletions
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index e35a7b26..790db8f5 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -42,6 +42,7 @@ #import "SPConstants.h" #import "SPEncodingPopupAccessory.h" #import "SPDataStorage.h" +#import "SPAlertSheets.h" @implementation CustomQuery @@ -162,7 +163,7 @@ // This should never evaluate to true as we are now performing menu validation, meaning the 'Save Query to Favorites' menu item will // only be enabled if the query text view has at least one character present. if ([[textView string] isEqualToString:@""]) { - NSBeginAlertSheet(NSLocalizedString(@"Empty query", @"empty query message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Empty query", @"empty query message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Cannot save an empty query.", @"empty query informative message")); return; } @@ -179,7 +180,7 @@ // This should never evaluate to true as we are now performing menu validation, meaning the 'Save Query to Favorites' menu item will // only be enabled if the query text view has at least one character present. if ([[textView string] isEqualToString:@""]) { - NSBeginAlertSheet(NSLocalizedString(@"Empty query", @"empty query message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Empty query", @"empty query message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Cannot save an empty query.", @"empty query informative message")); return; } @@ -1545,7 +1546,7 @@ // Check for errors while UPDATE if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), NSLocalizedString(@"Cancel", @"cancel button"), nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), NSLocalizedString(@"Cancel", @"cancel button"), nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Couldn't write field.\nMySQL said: %@", @"message of panel when error while updating field to db"), [mySQLConnection getLastErrorMessage]]); return; @@ -1555,7 +1556,7 @@ // This shouldn't happen – for safety reasons if ( ![mySQLConnection affectedRows] ) { if ( [prefs boolForKey:SPShowNoAffectedRowsError] ) { - NSBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"The row was not written to the MySQL database. You probably haven't changed anything.\nReload the table to be sure that the row exists and use a primary key for your table.\n(This error can be turned off in the preferences.)", @"message of panel when no rows have been affected after writing to the db")); } else { NSBeep(); @@ -1569,7 +1570,7 @@ [self performQueries:[NSArray arrayWithObject:lastExecutedQuery] withCallback:NULL]; } else { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Updating field content failed. Couldn't identify field origin unambiguously (%ld match%@). It's very likely that while editing this field the table `%@` was changed by an other user.", @"message of panel when error while updating field to db after enabling it"), (long)numberOfPossibleUpdateRows, (numberOfPossibleUpdateRows>1)?@"es":@"", tableForColumn]); diff --git a/Source/SPAlertSheets.h b/Source/SPAlertSheets.h new file mode 100644 index 00000000..2610ee41 --- /dev/null +++ b/Source/SPAlertSheets.h @@ -0,0 +1,36 @@ +// +// $Id$ +// +// SPAlertSheets.h +// sequel-pro +// +// Created by Rowan Beentje on January 20, 2010 +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at <http://code.google.com/p/sequel-pro/> + +void SPBeginAlertSheet( + NSString *title, + NSString *defaultButton, + NSString *alternateButton, + NSString *otherButton, + NSWindow *docWindow, + id modalDelegate, + SEL didEndSelector, + SEL didDismissSelector, + void *contextInfo, + NSString *msg +);
\ No newline at end of file diff --git a/Source/SPAlertSheets.m b/Source/SPAlertSheets.m new file mode 100644 index 00000000..581dfc37 --- /dev/null +++ b/Source/SPAlertSheets.m @@ -0,0 +1,55 @@ +// +// $Id$ +// +// SPAlertSheets.m +// sequel-pro +// +// Created by Rowan Beentje on January 20, 2010 +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at <http://code.google.com/p/sequel-pro/> + +/** + * Provide a very simple alias of NSBeginAlertSheet with one difference: + * printf-type format strings are no longer supported within the "msg" + * message text argument, preventing access of random stack areas for + * error text which contains inadvertant printf formatting. + */ +void SPBeginAlertSheet( + NSString *title, + NSString *defaultButton, + NSString *alternateButton, + NSString *otherButton, + NSWindow *docWindow, + id modalDelegate, + SEL didEndSelector, + SEL didDismissSelector, + void *contextInfo, + NSString *msg +) { + NSBeginAlertSheet( + title, + defaultButton, + alternateButton, + otherButton, + docWindow, + modalDelegate, + didEndSelector, + didDismissSelector, + contextInfo, + [msg stringByReplacingOccurrencesOfString:@"%" withString:@"%%"] + ); +} diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index 5c87bf7d..8acade5c 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -29,6 +29,7 @@ #import "ImageAndTextCell.h" #import "RegexKitLite.h" #import "SPConstants.h" +#import "SPAlertSheets.h" @implementation SPConnectionController @@ -150,13 +151,13 @@ { // Ensure that host is not empty if this is a TCP/IP or SSH connection if (([self type] == SPTCPIPConnection || [self type] == SPSSHTunnelConnection) && ![[self host] length]) { - NSBeginAlertSheet(NSLocalizedString(@"Insufficient connection details", @"insufficient details message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, documentWindow, self, nil, nil, nil, NSLocalizedString(@"Insufficient details provided to establish a connection. Please enter at least the hostname.", @"insufficient details informative message")); + SPBeginAlertSheet(NSLocalizedString(@"Insufficient connection details", @"insufficient details message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, documentWindow, self, nil, nil, nil, NSLocalizedString(@"Insufficient details provided to establish a connection. Please enter at least the hostname.", @"insufficient details informative message")); return; } // If SSH is enabled, ensure that the SSH host is not nil if ([self type] == SPSSHTunnelConnection && ![[self sshHost] length]) { - NSBeginAlertSheet(NSLocalizedString(@"Insufficient connection details", @"insufficient details message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, documentWindow, self, nil, nil, nil, NSLocalizedString(@"Insufficient details provided to establish a connection. Please enter the hostname for the SSH Tunnel, or disable the SSH Tunnel.", @"insufficient SSH tunnel details informative message")); + SPBeginAlertSheet(NSLocalizedString(@"Insufficient connection details", @"insufficient details message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, documentWindow, self, nil, nil, nil, NSLocalizedString(@"Insufficient details provided to establish a connection. Please enter the hostname for the SSH Tunnel, or disable the SSH Tunnel.", @"insufficient SSH tunnel details informative message")); return; } @@ -413,7 +414,7 @@ } // Display the connection error message - NSBeginAlertSheet(theTitle, NSLocalizedString(@"OK", @"OK button"), (errorDetail) ? NSLocalizedString(@"Show Detail", @"Show detail button") : nil, (isSSHTunnelBindError) ? NSLocalizedString(@"Use Standard Connection", @"use standard connection button") : nil, documentWindow, self, nil, @selector(errorSheetDidEnd:returnCode:contextInfo:), @"connect", theErrorMessage); + SPBeginAlertSheet(theTitle, NSLocalizedString(@"OK", @"OK button"), (errorDetail) ? NSLocalizedString(@"Show Detail", @"Show detail button") : nil, (isSSHTunnelBindError) ? NSLocalizedString(@"Use Standard Connection", @"use standard connection button") : nil, documentWindow, self, nil, @selector(errorSheetDidEnd:returnCode:contextInfo:), @"connect", theErrorMessage); } /** @@ -598,7 +599,7 @@ - (BOOL) checkHost { if ([self type] != SPSocketConnection && [[self host] isEqualToString:@"localhost"]) { - NSBeginAlertSheet(NSLocalizedString(@"You have entered 'localhost' for a non-socket connection", @"title of error when using 'localhost' for a network connection"), + SPBeginAlertSheet(NSLocalizedString(@"You have entered 'localhost' for a non-socket connection", @"title of error when using 'localhost' for a network connection"), NSLocalizedString(@"Use 127.0.0.1", @"Use 127.0.0.1 button"), // Main button NSLocalizedString(@"Connect via socket", @"Connect via socket button"), // Alternate button nil, // Other button diff --git a/Source/SPExtendedTableInfo.m b/Source/SPExtendedTableInfo.m index 8b414219..88c91981 100644 --- a/Source/SPExtendedTableInfo.m +++ b/Source/SPExtendedTableInfo.m @@ -30,6 +30,7 @@ #import "SPStringAdditions.h" #import "SPConstants.h" #import "TableDocument.h" +#import "SPAlertSheets.h" @interface SPExtendedTableInfo (PrivateAPI) @@ -106,7 +107,7 @@ else { [sender selectItemWithTitle:currentType]; - NSBeginAlertSheet(NSLocalizedString(@"Error changing table type", @"error changing table type message"), + SPBeginAlertSheet(NSLocalizedString(@"Error changing table type", @"error changing table type message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to change the table type to '%@'.\n\nMySQL said: %@", @"error changing table type informative message"), newType, [connection getLastErrorMessage]]); } @@ -135,7 +136,7 @@ else { [sender selectItemWithTitle:currentEncoding]; - NSBeginAlertSheet(NSLocalizedString(@"Error changing table encoding", @"error changing table encoding message"), + SPBeginAlertSheet(NSLocalizedString(@"Error changing table encoding", @"error changing table encoding message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to change the table encoding to '%@'.\n\nMySQL said: %@", @"error changing table encoding informative message"), newEncoding, [connection getLastErrorMessage]]); } @@ -164,7 +165,7 @@ else { [sender selectItemWithTitle:currentCollation]; - NSBeginAlertSheet(NSLocalizedString(@"Error changing table collation", @"error changing table collation message"), + SPBeginAlertSheet(NSLocalizedString(@"Error changing table collation", @"error changing table collation message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to change the table collation to '%@'.\n\nMySQL said: %@", @"error changing table collation informative message"), newCollation, [connection getLastErrorMessage]]); } @@ -352,7 +353,7 @@ [self reloadTable:self]; } else { - NSBeginAlertSheet(NSLocalizedString(@"Error changing table comment", @"error changing table comment message"), + SPBeginAlertSheet(NSLocalizedString(@"Error changing table comment", @"error changing table comment message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to change the table's comment to '%@'.\n\nMySQL said: %@", @"error changing table comment informative message"), newComment, [connection getLastErrorMessage]]); } diff --git a/Source/SPKeychain.m b/Source/SPKeychain.m index eecca884..622c3a86 100644 --- a/Source/SPKeychain.m +++ b/Source/SPKeychain.m @@ -104,7 +104,7 @@ NSBeginAlertSheet(NSLocalizedString(@"Error adding password to Keychain", @"error adding password to keychain message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, nil, - [NSString stringWithFormat:NSLocalizedString(@"An error occured while trying to add the password to your Keychain. Repairing your Keychain might resolve this, but if it doesn't please report it to the Sequel Pro team, supplying the error code %i.", @"error adding password to keychain informative message"), status]); + NSLocalizedString(@"An error occured while trying to add the password to your Keychain. Repairing your Keychain might resolve this, but if it doesn't please report it to the Sequel Pro team, supplying the error code %i.", @"error adding password to keychain informative message"), status); } } } diff --git a/Source/SPProcessListController.m b/Source/SPProcessListController.m index 98137fb4..51f644d6 100644 --- a/Source/SPProcessListController.m +++ b/Source/SPProcessListController.m @@ -29,6 +29,7 @@ #import "SPArrayAdditions.h" #import "TableDocument.h" #import "SPConstants.h" +#import "SPAlertSheets.h" @interface SPProcessListController (PrivateAPI) @@ -447,7 +448,7 @@ // Check for errors if (![[connection getLastErrorMessage] isEqualToString:@""]) { - NSBeginAlertSheet(NSLocalizedString(@"Unable to kill query", @"error killing query message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [self window], self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Unable to kill query", @"error killing query message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [self window], self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occured while attempting to kill the query associated with connection %lu.\n\nMySQL said: %@", @"error killing query informative message"), (unsigned long)processId, [connection getLastErrorMessage]]); } @@ -465,7 +466,7 @@ // Check for errors if (![[connection getLastErrorMessage] isEqualToString:@""]) { - NSBeginAlertSheet(NSLocalizedString(@"Unable to kill connection", @"error killing connection message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [self window], self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Unable to kill connection", @"error killing connection message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [self window], self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occured while attempting to kill connection %lu.\n\nMySQL said: %@", @"error killing query informative message"), (unsigned long)processId, [connection getLastErrorMessage]]); } diff --git a/Source/SPTableData.m b/Source/SPTableData.m index 0c8d2517..a0a4d860 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -32,6 +32,7 @@ #import "SPStringAdditions.h" #import "SPArrayAdditions.h" #import "SPConstants.h" +#import "SPAlertSheets.h" @implementation SPTableData @@ -325,7 +326,7 @@ // Check for any errors, but only display them if a connection still exists if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { if ([mySQLConnection isConnected]) { - NSBeginAlertSheet(NSLocalizedString(@"Error retrieving table information", @"error retrieving table information message"), NSLocalizedString(@"OK", @"OK button"), + SPBeginAlertSheet(NSLocalizedString(@"Error retrieving table information", @"error retrieving table information message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving the information for table '%@'. Please try again.\n\nMySQL said: %@", @"error retrieving table information informative message"), tableName, [mySQLConnection getLastErrorMessage]]); @@ -633,7 +634,7 @@ // Check for any errors, but only display them if a connection still exists if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { if ([mySQLConnection isConnected]) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occured while retrieving view information.\nMySQL said: %@", @"message of panel when retrieving view information failed"), [mySQLConnection getLastErrorMessage]]); @@ -651,7 +652,7 @@ // Check for any errors, but only display them if a connection still exists if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { if ([mySQLConnection isConnected]) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occured while retrieving view information.\nMySQL said: %@", @"message of panel when retrieving view information failed"), [mySQLConnection getLastErrorMessage]]); @@ -754,7 +755,7 @@ // Check for any errors, only displaying them if the connection hasn't been terminated if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { if ([mySQLConnection isConnected]) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occured while retrieving status data.\nMySQL said: %@", @"message of panel when retrieving view information failed"), [mySQLConnection getLastErrorMessage]]); diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m index 504797e2..ee72fd3a 100644 --- a/Source/SPTableRelations.m +++ b/Source/SPTableRelations.m @@ -29,6 +29,7 @@ #import "SPTableData.h" #import "SPStringAdditions.h" #import "SPConstants.h" +#import "SPAlertSheets.h" @interface SPTableRelations (PrivateAPI) @@ -135,7 +136,7 @@ // 0 indicates success if (retCode) { - NSBeginAlertSheet(NSLocalizedString(@"Error creating relation", @"error creating relation message"), + SPBeginAlertSheet(NSLocalizedString(@"Error creating relation", @"error creating relation message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], nil, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"The specified relation was unable to be created.\n\nMySQL said: %@", @"error creating relation informative message"), [connection getLastErrorMessage]]); @@ -366,7 +367,7 @@ if (![[connection getLastErrorMessage] isEqualToString:@""] ) { - NSBeginAlertSheet(NSLocalizedString(@"Unable to remove relation", @"error removing relation message"), + SPBeginAlertSheet(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]]); diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m index 8e60a334..c9be9a87 100644 --- a/Source/SPUserManager.m +++ b/Source/SPUserManager.m @@ -671,7 +671,7 @@ [[[user parent] valueForKey:@"password"] tickQuotedString]]; // Create user in database - [self.mySqlConnection queryString:[NSString stringWithFormat:createStatement]]; + [self.mySqlConnection queryString:createStatement]; if ([self checkAndDisplayMySqlError]) { [self grantPrivilegesToUser:user]; @@ -702,9 +702,9 @@ // in a try/catch check to avoid exceptions for unhandled privs @try { if ([[user valueForKey:key] boolValue] == TRUE) { - [grantPrivileges addObject:[NSString stringWithFormat:@"%@", [privilege replaceUnderscoreWithSpace]]]; + [grantPrivileges addObject:[privilege replaceUnderscoreWithSpace]]; } else { - [revokePrivileges addObject:[NSString stringWithFormat:@"%@", [privilege replaceUnderscoreWithSpace]]]; + [revokePrivileges addObject:[privilege replaceUnderscoreWithSpace]]; } } @catch (NSException * e) { @@ -718,7 +718,7 @@ [[[user parent] valueForKey:@"user"] tickQuotedString], [[user valueForKey:@"host"] tickQuotedString]]; DLog(@"%@", grantStatement); - [self.mySqlConnection queryString:[NSString stringWithFormat:grantStatement]]; + [self.mySqlConnection queryString:grantStatement]; [self checkAndDisplayMySqlError]; } @@ -730,7 +730,7 @@ [[[user parent] valueForKey:@"user"] tickQuotedString], [[user valueForKey:@"host"] tickQuotedString]]; DLog(@"%@", revokeStatement); - [self.mySqlConnection queryString:[NSString stringWithFormat:revokeStatement]]; + [self.mySqlConnection queryString:revokeStatement]; [self checkAndDisplayMySqlError]; } } diff --git a/Source/TableContent.m b/Source/TableContent.m index 03054f5b..4c8d9775 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -50,6 +50,7 @@ #import "SPConstants.h" #import "SPDataStorage.h" #import "TableDocument.h" +#import "SPAlertSheets.h" @implementation TableContent @@ -1275,7 +1276,7 @@ if ( [tableContentView numberOfSelectedRows] < 1 ) return; if ( [tableContentView numberOfSelectedRows] > 1 ) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"You can only copy single rows.", @"message of panel when trying to copy multiple rows")); + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"You can only copy single rows.", @"message of panel when trying to copy multiple rows")); return; } @@ -1807,7 +1808,7 @@ // If no rows have been changed, show error if appropriate. if ( ![mySQLConnection affectedRows] && ![mySQLConnection getLastErrorMessage] && ![[mySQLConnection getLastErrorMessage] length]) { if ( [prefs boolForKey:SPShowNoAffectedRowsError] ) { - NSBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"The row was not written to the MySQL database. You probably haven't changed anything.\nReload the table to be sure that the row exists and use a primary key for your table.\n(This error can be turned off in the preferences.)", @"message of panel when no rows have been affected after writing to the db")); } else { NSBeep(); @@ -1856,7 +1857,7 @@ // Report errors which have occurred } else { - NSBeginAlertSheet(NSLocalizedString(@"Couldn't write row", @"Couldn't write row error"), NSLocalizedString(@"Edit row", @"Edit row button"), NSLocalizedString(@"Discard changes", @"discard changes button"), nil, tableWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), nil, @"addrow", + SPBeginAlertSheet(NSLocalizedString(@"Couldn't write row", @"Couldn't write row error"), NSLocalizedString(@"Edit row", @"Edit row button"), NSLocalizedString(@"Discard changes", @"discard changes button"), nil, tableWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), nil, @"addrow", [NSString stringWithFormat:NSLocalizedString(@"MySQL said:\n\n%@", @"message of panel when error while adding row to db"), [mySQLConnection getLastErrorMessage]]); return NO; } @@ -1936,7 +1937,7 @@ // When the option to not show blob or text options is set, we have a problem - we don't have // the right values to use in the WHERE statement. Throw an error if this is the case. if ( [prefs boolForKey:SPLoadBlobsAsNeeded] && [self tableContainsBlobOrTextColumns] ) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"You can't hide blob and text fields when working with tables without index.", @"message of panel when trying to edit tables without index and with hidden blob/text fields")); [keys removeAllObjects]; [tableContentView deselectAll:self]; @@ -2291,7 +2292,7 @@ -(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"), + SPBeginAlertSheet([error objectAtIndex:0], NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [error objectAtIndex:1]); } @@ -2752,7 +2753,7 @@ [self loadTableValues]; if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Couldn't sort table. MySQL said: %@", @"message of panel when sorting of table failed"), [mySQLConnection getLastErrorMessage]]); [sortPool drain]; return; @@ -2854,7 +2855,7 @@ MCPResult *tempResult = [mySQLConnection queryString:query]; if (![tempResult numOfRows]) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Couldn't load the row. Reload the table to be sure that the row exists and use a primary key for your table.", @"message of panel when loading of row failed")); return NO; } diff --git a/Source/TableDocument.m b/Source/TableDocument.m index f61ead71..8d9bdca7 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -47,13 +47,13 @@ #import "SPHistoryController.h" #import "SPPreferenceController.h" #import "SPPrintAccessory.h" -//#import "QLPreviewPanel.h" #import "SPUserManager.h" #import "SPEncodingPopupAccessory.h" #import "SPConstants.h" #import "YRKSpinningProgressIndicator.h" #import "SPProcessListController.h" #import "SPServerVariablesController.h" +#import "SPAlertSheets.h" // Printing #import "MGTemplateEngine.h" @@ -997,7 +997,7 @@ // show error on connection failed if ( ![mySQLConnection selectDB:[chooseDatabaseButton titleOfSelectedItem]] ) { if ( [mySQLConnection isConnected] ) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Unable to connect to database %@.\nBe sure that you have the necessary privileges.", @"message of panel when connection to db failed after selecting from popupbutton"), [chooseDatabaseButton titleOfSelectedItem]]); + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Unable to connect to database %@.\nBe sure that you have the necessary privileges.", @"message of panel when connection to db failed after selecting from popupbutton"), [chooseDatabaseButton titleOfSelectedItem]]); [self setDatabases:self]; } [self endTask]; @@ -1167,7 +1167,7 @@ -(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"), + SPBeginAlertSheet([error objectAtIndex:0], NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [error objectAtIndex:1]); } @@ -2203,10 +2203,10 @@ if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { //flushed privileges without errors - NSBeginAlertSheet(NSLocalizedString(@"Flushed Privileges", @"title of panel when successfully flushed privs"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Successfully flushed privileges.", @"message of panel when successfully flushed privs")); + SPBeginAlertSheet(NSLocalizedString(@"Flushed Privileges", @"title of panel when successfully flushed privs"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Successfully flushed privileges.", @"message of panel when successfully flushed privs")); } else { //error while flushing privileges - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Couldn't flush privileges.\nMySQL said: %@", @"message of panel when flushing privs failed"), + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Couldn't flush privileges.\nMySQL said: %@", @"message of panel when flushing privs failed"), [mySQLConnection getLastErrorMessage]]); } } @@ -3647,7 +3647,7 @@ // This check is not necessary anymore as the add database button is now only enabled if the name field // has a length greater than zero. We'll leave it in just in case. if ([[databaseNameField stringValue] isEqualToString:@""]) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Database must have a name.", @"message of panel when no db name is given")); + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Database must have a name.", @"message of panel when no db name is given")); return; } @@ -3663,14 +3663,14 @@ if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { // An error occurred - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Couldn't create database.\nMySQL said: %@", @"message of panel when creation of db failed"), [mySQLConnection getLastErrorMessage]]); + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Couldn't create database.\nMySQL said: %@", @"message of panel when creation of db failed"), [mySQLConnection getLastErrorMessage]]); return; } // Error while selecting the new database (is this even possible?) if (![mySQLConnection selectDB:[databaseNameField stringValue]] ) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Unable to connect to database %@.\nBe sure that you have the necessary privileges.", @"message of panel when connection to db failed after selecting from popupbutton"), [databaseNameField stringValue]]); + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Unable to connect to database %@.\nBe sure that you have the necessary privileges.", @"message of panel when connection to db failed after selecting from popupbutton"), [databaseNameField stringValue]]); [self setDatabases:self]; diff --git a/Source/TableDump.m b/Source/TableDump.m index 1d1987be..e555786b 100644 --- a/Source/TableDump.m +++ b/Source/TableDump.m @@ -37,6 +37,7 @@ #import "SPArrayAdditions.h" #import "RegexKitLite.h" #import "SPConstants.h" +#import "SPAlertSheets.h" @implementation TableDump @@ -282,7 +283,7 @@ if ( [[NSFileManager defaultManager] fileExistsAtPath:exportFile] ) { if ( ![[NSFileManager defaultManager] isWritableFileAtPath:exportFile] || !(fileHandle = [NSFileHandle fileHandleForWritingAtPath:exportFile]) ) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Couldn't replace the file. Be sure that you have the necessary privileges.", @"message of panel when file cannot be replaced")); [pool release]; return; @@ -294,7 +295,7 @@ // Otherwise attempt to create a file } else { if ( ![[NSFileManager defaultManager] createFileAtPath:exportFile contents:[NSData data] attributes:nil] ) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Couldn't write to file. Be sure that you have the necessary privileges.", @"message of panel when file cannot be written")); [pool release]; return; @@ -304,7 +305,7 @@ fileHandle = [NSFileHandle fileHandleForWritingAtPath:exportFile]; if ( !fileHandle ) { [[NSFileManager defaultManager] removeFileAtPath:exportFile handler:nil]; - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Couldn't write to file. Be sure that you have the necessary privileges.", @"message of panel when file cannot be written")); [pool release]; return; @@ -434,7 +435,7 @@ // Display error message on problems if ( !progressCancelled && !success ) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Couldn't write to file. Be sure that you have the necessary privileges.", @"message of panel when file cannot be written")); } @@ -568,7 +569,7 @@ // Open a filehandle for the SQL file sqlFileHandle = [NSFileHandle fileHandleForReadingAtPath:filename]; if (!sqlFileHandle) { - NSBeginAlertSheet(NSLocalizedString(@"Import Error title", @"Import Error"), + SPBeginAlertSheet(NSLocalizedString(@"Import Error title", @"Import Error"), NSLocalizedString(@"OK button label", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"SQL file open error", @"The SQL file you selected could not be found or read.")); @@ -608,7 +609,7 @@ // Report file read errors, and bail @catch (NSException *exception) { [self closeAndStopProgressSheet]; - NSBeginAlertSheet(NSLocalizedString(@"SQL read error title", @"File read error"), + SPBeginAlertSheet(NSLocalizedString(@"SQL read error title", @"File read error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"SQL read error", @"An error occurred when reading the file.\n\nOnly %ld queries were executed.\n\n(%@)"), (long)queriesPerformed, [exception reason]]); @@ -656,7 +657,7 @@ encoding:[MCPConnection encodingForMySQLEncoding:[[tableDocumentInstance connectionEncoding] UTF8String]]]; if (!sqlString) { [self closeAndStopProgressSheet]; - NSBeginAlertSheet(NSLocalizedString(@"SQL read error title", @"File read error"), + SPBeginAlertSheet(NSLocalizedString(@"SQL read error title", @"File read error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"SQL encoding read error", @"An error occurred when reading the file, as it could not be read in either UTF-8 or %@.\n\nOnly %ld queries were executed."), [[tableDocumentInstance connectionEncoding] UTF8String], (long)queriesPerformed]); @@ -808,7 +809,7 @@ // Open a filehandle for the CSV file csvFileHandle = [NSFileHandle fileHandleForReadingAtPath:filename]; if (!csvFileHandle) { - NSBeginAlertSheet(NSLocalizedString(@"Import Error title", @"Import Error"), + SPBeginAlertSheet(NSLocalizedString(@"Import Error title", @"Import Error"), NSLocalizedString(@"OK button label", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"CSV file open error", @"The CSV file you selected could not be found or read.")); @@ -866,7 +867,7 @@ // Report file read errors, and bail @catch (NSException *exception) { [self closeAndStopProgressSheet]; - NSBeginAlertSheet(NSLocalizedString(@"CSV read error title", @"File read error"), + SPBeginAlertSheet(NSLocalizedString(@"CSV read error title", @"File read error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"CSV read error", @"An error occurred when reading the file.\n\nOnly %ld rows were imported.\n\n(%@)"), (long)rowsImported, [exception reason]]); @@ -906,7 +907,7 @@ csvString = [[NSString alloc] initWithData:[csvDataBuffer subdataWithRange:NSMakeRange(dataBufferLastQueryEndPosition, dataBufferPosition - dataBufferLastQueryEndPosition)] encoding:csvEncoding]; if (!csvString) { [self closeAndStopProgressSheet]; - NSBeginAlertSheet(NSLocalizedString(@"CSV read error title", @"File read error"), + SPBeginAlertSheet(NSLocalizedString(@"CSV read error title", @"File read error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"CSV encoding read error", @"An error occurred when reading the file, as it could not be read using %@.\n\nOnly %ld rows were imported."), [[tableDocumentInstance connectionEncoding] UTF8String], (long)rowsImported]); @@ -1126,7 +1127,7 @@ // Ensure data was provided, or alert than an import error occurred and return false. if (![importData count]) { [self closeAndStopProgressSheet]; - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, @@ -1139,7 +1140,7 @@ // Sanity check the first row of the CSV to prevent hang loops caused by wrong line ending entry if ([[importData objectAtIndex:0] count] > 512) { [self closeAndStopProgressSheet]; - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, @@ -1157,7 +1158,7 @@ // If there's no tables to select, error if (![[fieldMappingPopup itemArray] count]) { [self closeAndStopProgressSheet]; - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, diff --git a/Source/TableSource.m b/Source/TableSource.m index 7f943850..1fd0cd44 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -31,6 +31,7 @@ #import "SPStringAdditions.h" #import "SPArrayAdditions.h" #import "SPConstants.h" +#import "SPAlertSheets.h" @interface TableSource (PrivateAPI) @@ -777,14 +778,14 @@ fetches the result as an array with a dictionary for each row in it // Problem: alert sheet doesn't respond to first click if (isEditingNewRow) { - NSBeginAlertSheet(NSLocalizedString(@"Error adding field", @"error adding field message"), + SPBeginAlertSheet(NSLocalizedString(@"Error adding field", @"error adding field message"), NSLocalizedString(@"Edit row", @"Edit row button"), NSLocalizedString(@"Discard changes", @"discard changes button"), nil, tableWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), nil, @"addrow", [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to add the field '%@'.\n\nMySQL said: %@", @"error adding field informative message"), [theRow objectForKey:@"Field"], [mySQLConnection getLastErrorMessage]]); } else { - NSBeginAlertSheet(NSLocalizedString(@"Error changing field", @"error changing field message"), + SPBeginAlertSheet(NSLocalizedString(@"Error changing field", @"error changing field message"), NSLocalizedString(@"Edit row", @"Edit row button"), NSLocalizedString(@"Discard changes", @"discard changes button"), nil, tableWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), nil, @"addrow", [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to change the field '%@'.\n\nMySQL said: %@", @"error changing field informative message"), @@ -802,7 +803,7 @@ fetches the result as an array with a dictionary for each row in it -(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"), + SPBeginAlertSheet([error objectAtIndex:0], NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [error objectAtIndex:1]); } @@ -1228,7 +1229,7 @@ would result in a position change. // Run the query; report any errors, or reload the table on success [mySQLConnection queryString:queryString]; if ( ![[mySQLConnection getLastErrorMessage] isEqualTo:@""] ) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Couldn't move field. MySQL said: %@", @"message of panel when field cannot be added in drag&drop operation"), [mySQLConnection getLastErrorMessage]]); } else { [tableDataInstance resetAllData]; @@ -1496,7 +1497,7 @@ would result in a position change. [self loadTable:selectedTable]; } else { - NSBeginAlertSheet(NSLocalizedString(@"Unable to add index", @"add index error message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Unable to add index", @"add index error message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occured while trying to add the index.\n\nMySQL said: %@", @"add index error informative message"), [mySQLConnection getLastErrorMessage]]); } } @@ -1529,7 +1530,7 @@ would result in a position change. if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { - NSBeginAlertSheet(NSLocalizedString(@"Unable to remove relation", @"error removing relation message"), + SPBeginAlertSheet(NSLocalizedString(@"Unable to remove relation", @"error removing relation message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], nil, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to remove the relation '%@'.\n\nMySQL said: %@", @"error removing relation informative message"), relationName, [mySQLConnection getLastErrorMessage]]); @@ -1588,7 +1589,7 @@ would result in a position change. if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { - NSBeginAlertSheet(NSLocalizedString(@"Unable to remove relation", @"error removing relation message"), + SPBeginAlertSheet(NSLocalizedString(@"Unable to remove relation", @"error removing relation message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], nil, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to remove the relation '%@'.\n\nMySQL said: %@", @"error removing relation informative message"), constraintName, [mySQLConnection getLastErrorMessage]]); diff --git a/Source/TablesList.m b/Source/TablesList.m index baca3e8a..645e2305 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -37,6 +37,7 @@ #import "NSMutableArray-MultipleSort.h" #import "NSNotificationAdditions.h" #import "SPConstants.h" +#import "SPAlertSheets.h" @interface TablesList (PrivateAPI) @@ -1221,7 +1222,7 @@ else if ([anObject isEqualToString:@""]) { // Table has no name alertSheetOpened = YES; - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), nil, @"addRow", NSLocalizedString(@"Empty names are not allowed.", @"message of panel when no name is given for an item")); } else { @@ -1253,7 +1254,7 @@ // Check for errors, only displaying if the connection hasn't been terminated if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { if ([mySQLConnection isConnected]) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occured while retrieving create syntax for '%@'.\n\nMySQL said: %@", @"message of panel when create syntax cannot be retrieved"), selectedTableName, [mySQLConnection getLastErrorMessage]]); @@ -1318,7 +1319,7 @@ else { // Error while renaming alertSheetOpened = YES; - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), nil, @"addRow", [NSString stringWithFormat:NSLocalizedString(@"Couldn't rename '%@'.\nMySQL said: %@", @"message of panel when an item cannot be renamed"), anObject, [mySQLConnection getLastErrorMessage]]); @@ -1888,10 +1889,6 @@ // Couldn't truncate table if (![[mySQLConnection getLastErrorMessage] isEqualTo:@""]) { - // NSBeginAlertSheet(NSLocalizedString(@"Error truncating table", @"error truncating table message"), - // NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), nil, nil, - // [NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to truncate the table '%@'.\n\nMySQL said: %@", @"error truncating table informative message"), [filteredTables objectAtIndex:currentIndex], [mySQLConnection getLastErrorMessage]]); - NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error truncating table", @"error truncating table message") defaultButton:NSLocalizedString(@"OK", @"OK button") alternateButton:nil @@ -1973,7 +1970,7 @@ // Error while creating new table alertSheetOpened = YES; - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), nil, @"addRow", [NSString stringWithFormat:NSLocalizedString(@"Couldn't add table %@.\nMySQL said: %@", @"message of panel when table cannot be created with the given name"), tableName, [mySQLConnection getLastErrorMessage]]); @@ -1993,7 +1990,7 @@ NSString *tableType; if ([[copyTableNameField stringValue] isEqualToString:@""]) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Table must have a name.", @"message of panel when no name is given for table")); + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Table must have a name.", @"message of panel when no name is given for table")); return; } @@ -2029,7 +2026,7 @@ if ( ![queryResult numOfRows] ) { //error while getting table structure - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Couldn't get create syntax.\nMySQL said: %@", @"message of panel when table information cannot be retrieved"), [mySQLConnection getLastErrorMessage]]); } else { @@ -2073,7 +2070,7 @@ // Check for errors, only displaying if the connection hasn't been terminated if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { if ([mySQLConnection isConnected]) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occured while retrieving the create syntax for '%@'.\nMySQL said: %@", @"message of panel when create syntax cannot be retrieved"), selectedTableName, [mySQLConnection getLastErrorMessage]]); } return; @@ -2086,7 +2083,7 @@ [mySQLConnection queryString:[tableSyntax stringByReplacingOccurrencesOfRegex:[NSString stringWithFormat:@"(?<=%@ )(`[^`]+?`)", [tableType uppercaseString]] withString:[[copyTableNameField stringValue] backtickQuotedString]]]; if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Couldn't duplicate '%@'.\nMySQL said: %@", @"message of panel when an item cannot be renamed"), [copyTableNameField stringValue], [mySQLConnection getLastErrorMessage]]); } @@ -2095,7 +2092,7 @@ if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { //error while creating new table - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Couldn't create '%@'.\nMySQL said: %@", @"message of panel when table cannot be created"), [copyTableNameField stringValue], [mySQLConnection getLastErrorMessage]]); } else { @@ -2108,7 +2105,7 @@ ]]; if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { - NSBeginAlertSheet( + SPBeginAlertSheet( NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"OK", @"OK button"), nil, @@ -2170,7 +2167,7 @@ [mySQLConnection queryString:[NSString stringWithFormat:@"RENAME TABLE %@ TO %@", [[self tableName] backtickQuotedString], [[tableRenameField stringValue] backtickQuotedString]]]; if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occured while renaming table '%@'.\n\nMySQL said: %@", @"rename table error informative message"), [self tableName], [mySQLConnection getLastErrorMessage]]); } @@ -2200,7 +2197,7 @@ // Check for errors, only displaying if the connection hasn't been terminated if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { if ([mySQLConnection isConnected]) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occured while retrieving create syntax for '%@'.\n\nMySQL said: %@", @"message of panel when create syntax cannot be retrieved"), [self tableName], [mySQLConnection getLastErrorMessage]]); } @@ -2235,7 +2232,7 @@ } } if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Couldn't rename '%@'.\nMySQL said: %@", @"message of panel when an item cannot be renamed"), [self tableName], [mySQLConnection getLastErrorMessage]]); } else { if (isTableListFiltered) { |