From c9e9a6a1c8d8c9d0e40a45a2ce2d5d95cf1dafba Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 3 Feb 2010 10:34:33 +0000 Subject: =?UTF-8?q?=E2=80=A2=20field=20mapping=20sheet=20is=20now=20docume?= =?UTF-8?q?nt-modal=20instead=20of=20blocking=20SP=20entirely=20=E2=80=A2?= =?UTF-8?q?=20if=20an=20error=20occurred=20while=20retrieving=20column=20o?= =?UTF-8?q?r=20index=20data=20in=20Structure=20pane=20reset=20Structure=20?= =?UTF-8?q?pane=20to=20a=20stable=20status,=20display=20the=20error=20mess?= =?UTF-8?q?age,=20and=20reload=20Tables=20List=20table=20due=20to=20the=20?= =?UTF-8?q?fact=20the=20it's=20very=20likely=20that=20SP=20tries=20to=20re?= =?UTF-8?q?trieve=20data=20from=20a=20table=20which=20doesn't=20exist=20an?= =?UTF-8?q?ymore=20=E2=80=A2=20fixed=20spelling=20of=20"occurred"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- Interfaces/English.lproj/DBView.xib | 222 ++++++++++++++++++++++++++++++++---- Source/SPTableData.m | 4 +- Source/TableDump.h | 3 + Source/TableDump.m | 33 ++++-- Source/TableSource.m | 42 +++++++ 5 files changed, 269 insertions(+), 35 deletions(-) diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index a4e8d47f..657d8b75 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -23,8 +23,9 @@ YES - + + YES @@ -7975,7 +7976,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {3.40282e+38, 3.40282e+38} {213, 107} - + 256 YES @@ -7984,6 +7985,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 264 {{20, 233}, {140, 14}} + YES 67239424 @@ -8010,6 +8012,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 2322 {352, 14} + @@ -8059,6 +8062,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {{1, 1}, {352, 178}} + @@ -8070,6 +8074,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 256 {{353, 1}, {11, 178}} + 256 _doScroller: @@ -8080,6 +8085,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 -2147483392 {{-100, -100}, {87, 18}} + 257 _doScroller: @@ -8089,6 +8095,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {{20, 45}, {365, 180}} + 18 @@ -8100,6 +8107,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 257 {{314, 13}, {76, 28}} + YES 67239424 @@ -8118,6 +8126,8 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {405, 267} + + {{0, 0}, {1440, 878}} {213, 129} @@ -8541,7 +8551,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {3.40282e+38, 3.40282e+38} {350, 250} - + 256 YES @@ -8926,6 +8936,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {465, 294} + {{0, 0}, {1920, 1178}} {350, 272} @@ -12390,22 +12401,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 4524 - - - closeSheet: - - - - 4594 - - - - closeSheet: - - - - 4596 - recordCountLabel @@ -15199,6 +15194,22 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 6752 + + + closeFieldMapperSheet: + + + + 6758 + + + + closeFieldMapperSheet: + + + + 6759 + @@ -23548,9 +23559,9 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{603, 243}, {465, 294}} + {{315, 449}, {465, 294}} com.apple.InterfaceBuilder.CocoaPlugin - {{603, 243}, {465, 294}} + {{315, 449}, {465, 294}} {{387, 725}, {432, 282}} @@ -23661,10 +23672,10 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{239, 357}, {944, 550}} + {{116, 357}, {944, 550}} com.apple.InterfaceBuilder.CocoaPlugin - {{239, 357}, {944, 550}} + {{116, 357}, {944, 550}} {{62, 352}, {845, 504}} @@ -24850,7 +24861,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 - 6752 + 6759 @@ -26434,6 +26445,169 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 + + YES + + TableDump + NSObject + + YES + + YES + cancelProgressBar: + changeFormat: + changeTable: + closeFieldMapperSheet: + closeSheet: + panelSelectionDidChange: + reloadTables: + selectTables: + stepRow: + switchInput: + switchTab: + + + YES + id + id + id + id + id + id + id + id + id + id + id + + + + YES + + YES + addCreateTableSwitch + addDropTableSwitch + addErrorsSwitch + addTableContentSwitch + csvFullStreamingSwitch + customQueryInstance + errorsSheet + errorsView + exportCSVView + exportDumpTableView + exportDumpView + exportFieldNamesSwitch + exportFieldsEnclosedField + exportFieldsEscapedField + exportFieldsTerminatedField + exportLinesTerminatedField + exportMultipleCSVTableView + exportMultipleCSVView + exportMultipleFieldNamesSwitch + exportMultipleFieldsEnclosedField + exportMultipleFieldsEscapedField + exportMultipleFieldsTerminatedField + exportMultipleLinesTerminatedField + exportMultipleXMLTableView + exportMultipleXMLView + exportTabBar + exportTableList + exportToolbar + exportWindow + fieldMappingPopup + fieldMappingSheet + fieldMappingTableView + importCSVBox + importCSVView + importFieldNamesSwitch + importFieldsEnclosedField + importFieldsEscapedField + importFieldsTerminatedField + importFormatPopup + importLinesTerminatedField + multiCSVFullStreamingSwitch + multiXMLFullStreamingSwitch + recordCountLabel + rowDownButton + rowUpButton + singleProgressBar + singleProgressSheet + singleProgressText + singleProgressTitle + sqlFullStreamingSwitch + tableContentInstance + tableDataInstance + tableDocumentInstance + tableSourceInstance + tableWindow + tablesListInstance + + + YES + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + NSPopUpButton + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + + + + IBDocumentRelativeSource + ../../Source/TableDump.h + + + YES 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]]; -- cgit v1.2.3