aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDatabaseDocument.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-08-13 16:48:59 +0000
committerstuconnolly <stuart02@gmail.com>2010-08-13 16:48:59 +0000
commitf1e829f98f50d9e75e7ba111361a625f7aab802d (patch)
tree930c14091b0cba5d4c44ec1e4fc70c34f55c56fe /Source/SPDatabaseDocument.m
parentefdcfb17f87863fef42f209f72eb4c4ccd888d35 (diff)
downloadsequelpro-f1e829f98f50d9e75e7ba111361a625f7aab802d.tar.gz
sequelpro-f1e829f98f50d9e75e7ba111361a625f7aab802d.tar.bz2
sequelpro-f1e829f98f50d9e75e7ba111361a625f7aab802d.zip
Tidy up database renaming and copying by removing the use of alert dialogs within loops to prevent locking up the main thread. These operations ideally should also be threaded.
Diffstat (limited to 'Source/SPDatabaseDocument.m')
-rw-r--r--Source/SPDatabaseDocument.m45
1 files changed, 32 insertions, 13 deletions
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index 3a0e029d..27e773b9 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -4673,41 +4673,60 @@
@implementation SPDatabaseDocument (PrivateAPI)
-- (void)_copyDatabase {
+- (void)_copyDatabase
+{
if ([[databaseCopyNameField stringValue] isEqualToString:@""]) {
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, parentWindow, self, nil, nil, NSLocalizedString(@"Database must have a name.", @"message of panel when no db name is given"));
return;
}
+
SPDatabaseCopy *dbActionCopy = [[SPDatabaseCopy alloc] init];
- [dbActionCopy setConnection: [self getConnection]];
- [dbActionCopy setMessageWindow: parentWindow];
+
+ [dbActionCopy setConnection:[self getConnection]];
+ [dbActionCopy setMessageWindow:parentWindow];
BOOL copyWithContent = [copyDatabaseDataButton state] == NSOnState;
- if ([dbActionCopy copyDatabaseFrom: [self database]
- to: [databaseCopyNameField stringValue]
- withContent: copyWithContent]) {
+ if ([dbActionCopy copyDatabaseFrom:[self database] to:[databaseCopyNameField stringValue] withContent:copyWithContent]) {
[self selectDatabase:[databaseCopyNameField stringValue] item:nil];
}
+ else {
+ SPBeginAlertSheet(NSLocalizedString(@"Unable to copy database", @"unable to copy database message"),
+ NSLocalizedString(@"OK", @"OK button"), nil, nil, parentWindow, self, nil, nil,
+ [NSString stringWithFormat:NSLocalizedString(@"An error occured while trying to copy the database '%@' to '%@'.", @"unable to copy database message informative message"), [self database], [databaseCopyNameField stringValue]]);
+ }
+
[dbActionCopy release];
- [self setDatabases: self];
+
+ // Update DB list
+ [self setDatabases:self];
}
-- (void)_renameDatabase {
+- (void)_renameDatabase
+{
if ([[databaseRenameNameField stringValue] isEqualToString:@""]) {
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, parentWindow, self, nil, nil, NSLocalizedString(@"Database must have a name.", @"message of panel when no db name is given"));
return;
}
+
SPDatabaseRename *dbActionRename = [[SPDatabaseRename alloc] init];
- [dbActionRename setConnection: [self getConnection]];
- [dbActionRename setMessageWindow: parentWindow];
- if ([dbActionRename renameDatabaseFrom: [self database]
- to: [databaseRenameNameField stringValue]]) {
+ [dbActionRename setConnection:[self getConnection]];
+ [dbActionRename setMessageWindow:parentWindow];
+
+ if ([dbActionRename renameDatabaseFrom:[self database] to:[databaseRenameNameField stringValue]]) {
[self selectDatabase:[databaseRenameNameField stringValue] item:nil];
}
+ else {
+ SPBeginAlertSheet(NSLocalizedString(@"Unable to rename database", @"unable to rename database message"),
+ NSLocalizedString(@"OK", @"OK button"), nil, nil, parentWindow, self, nil, nil,
+ [NSString stringWithFormat:NSLocalizedString(@"An error occured while trying to rename the database '%@' to '%@'.", @"unable to rename database message informative message"), [self database], [databaseRenameNameField stringValue]]);
+ }
+
[dbActionRename release];
- [self setDatabases: self];
+
+ // Update DB list
+ [self setDatabases:self];
}
/**