aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-02-03 10:34:33 +0000
committerBibiko <bibiko@eva.mpg.de>2010-02-03 10:34:33 +0000
commitc9e9a6a1c8d8c9d0e40a45a2ce2d5d95cf1dafba (patch)
tree271313021ba56cbb86357da56d6158cf43509129 /Source
parent4fe58d39c65438f13398a3617f06e2077840a176 (diff)
downloadsequelpro-c9e9a6a1c8d8c9d0e40a45a2ce2d5d95cf1dafba.tar.gz
sequelpro-c9e9a6a1c8d8c9d0e40a45a2ce2d5d95cf1dafba.tar.bz2
sequelpro-c9e9a6a1c8d8c9d0e40a45a2ce2d5d95cf1dafba.zip
• field mapping sheet is now document-modal instead of blocking SP entirely
• if an error occurred while retrieving column or index data in Structure pane reset Structure pane to a stable status, display the error message, and reload Tables List table due to the fact the it's very likely that SP tries to retrieve data from a table which doesn't exist anymore • fixed spelling of "occurred" Note: NOT YET DONE: if in Structure view the actual underlying table was deleted or renamed by an other mysql event and the user tries to add/change a field do suppress this attempt safely
Diffstat (limited to 'Source')
-rw-r--r--Source/SPTableData.m4
-rw-r--r--Source/TableDump.h3
-rw-r--r--Source/TableDump.m33
-rw-r--r--Source/TableSource.m42
4 files changed, 71 insertions, 11 deletions
diff --git a/Source/SPTableData.m b/Source/SPTableData.m
index 1c00758a..9dffd962 100644
--- a/Source/SPTableData.m
+++ b/Source/SPTableData.m
@@ -668,7 +668,7 @@
if ([mySQLConnection isConnected]) {
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"),
+ [NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving information.\nMySQL said: %@", @"message of panel when retrieving information failed"),
[mySQLConnection getLastErrorMessage]]);
}
return nil;
@@ -686,7 +686,7 @@
if ([mySQLConnection isConnected]) {
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"),
+ [NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving information.\nMySQL said: %@", @"message of panel when retrieving information failed"),
[mySQLConnection getLastErrorMessage]]);
}
return nil;
diff --git a/Source/TableDump.h b/Source/TableDump.h
index 3b89bdc5..7e1dc5cc 100644
--- a/Source/TableDump.h
+++ b/Source/TableDump.h
@@ -105,12 +105,15 @@
NSInteger fieldMappingCurrentRow;
NSUserDefaults *prefs;
BOOL progressCancelled;
+
+ NSInteger fieldMapperSheetStatus;
}
// IBAction methods
- (IBAction)reloadTables:(id)sender;
- (IBAction)selectTables:(id)sender;
- (IBAction)closeSheet:(id)sender;
+- (IBAction)closeFieldMapperSheet:(id)sender;
- (IBAction)stepRow:(id)sender;
- (IBAction)cancelProgressBar:(id)sender;
diff --git a/Source/TableDump.m b/Source/TableDump.m
index 15a8c344..b6f71c2c 100644
--- a/Source/TableDump.m
+++ b/Source/TableDump.m
@@ -103,6 +103,15 @@
[exportMultipleXMLTableView reloadData];
}
+- (IBAction)closeFieldMapperSheet:(id)sender
+{
+
+ [NSApp endSheet:fieldMappingSheet returnCode:[sender tag]];
+ // [[self window] orderOut:self];
+ //
+ // [NSApp endSheet:fieldMappingSheet];
+}
+
/**
* Common method for ending modal sessions
*/
@@ -1190,23 +1199,29 @@
// Trigger a table selection and setup
[self changeTable:self];
+ fieldMapperSheetStatus = 1;
+
// Show fieldMapping sheet
[NSApp beginSheet:fieldMappingSheet
modalForWindow:tableWindow
modalDelegate:self
- didEndSelector:nil
+ didEndSelector:@selector(fieldMapperDidEndSheet:returnCode:contextInfo:)
contextInfo:nil];
- NSInteger code = [NSApp runModalForWindow:fieldMappingSheet];
- [NSApp endSheet:fieldMappingSheet];
- [fieldMappingSheet orderOut:nil];
+ // Wait for fieldMappingSheet
+ while (fieldMapperSheetStatus == 1)
+ usleep(100000);
- // Return success or failure based on confirmation or cancellation
- if (code) {
- return TRUE;
- } else {
+ if(fieldMapperSheetStatus == 2)
+ return YES;
+ else
return FALSE;
- }
+
+}
+- (void)fieldMapperDidEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
+{
+ [sheet orderOut:self];
+ fieldMapperSheetStatus = (returnCode) ? 2 : 3;
}
/*
diff --git a/Source/TableSource.m b/Source/TableSource.m
index 1aa6185e..819bdea7 100644
--- a/Source/TableSource.m
+++ b/Source/TableSource.m
@@ -99,6 +99,27 @@ loads aTable, put it in an array, update the tableViewColumns and reload the tab
//perform queries and load results in array (each row as a dictionary)
tableSourceResult = [[mySQLConnection queryString:[NSString stringWithFormat:@"SHOW COLUMNS FROM %@", [selectedTable backtickQuotedString]]] retain];
+ if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ NSString *errorMessage = [NSString stringWithString:[mySQLConnection getLastErrorMessage]];
+ [tableFields removeAllObjects];
+ [indexes removeAllObjects];
+ [tableSourceView reloadData];
+ [tablesListInstance updateTables:self];
+ [indexView reloadData];
+ [addFieldButton setEnabled:NO];
+ [copyFieldButton setEnabled:NO];
+ [removeFieldButton setEnabled:NO];
+ [addIndexButton setEnabled:NO];
+ [removeIndexButton setEnabled:NO];
+ [editTableButton setEnabled:NO];
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance];
+ SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"),
+ nil, nil, [NSApp mainWindow], self, nil, nil, nil,
+ [NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving information.\nMySQL said: %@", @"message of panel when retrieving information failed"),
+ errorMessage]);
+ return;
+ }
+
[tableSourceResult setReturnDataAsStrings:YES];
// listFieldsFromTable is broken in the current version of the framework (no back-ticks for table name)!
@@ -108,6 +129,27 @@ loads aTable, put it in an array, update the tableViewColumns and reload the tab
[tableSourceResult release];
indexResult = [[mySQLConnection queryString:[NSString stringWithFormat:@"SHOW INDEX FROM %@", [selectedTable backtickQuotedString]]] retain];
+ if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ NSString *errorMessage = [NSString stringWithString:[mySQLConnection getLastErrorMessage]];
+ [tableFields removeAllObjects];
+ [indexes removeAllObjects];
+ [tableSourceView reloadData];
+ [tablesListInstance updateTables:self];
+ [indexView reloadData];
+ [addFieldButton setEnabled:NO];
+ [copyFieldButton setEnabled:NO];
+ [removeFieldButton setEnabled:NO];
+ [addIndexButton setEnabled:NO];
+ [removeIndexButton setEnabled:NO];
+ [editTableButton setEnabled:NO];
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance];
+ SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"),
+ nil, nil, [NSApp mainWindow], self, nil, nil, nil,
+ [NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving information.\nMySQL said: %@", @"message of panel when retrieving information failed"),
+ errorMessage]);
+
+ return;
+ }
[indexResult setReturnDataAsStrings:YES];
// [indexes setArray:[[self fetchResultAsArray:indexResult] retain]];
[indexes setArray:[self fetchResultAsArray:indexResult]];