diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-02-03 10:34:33 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-02-03 10:34:33 +0000 |
commit | c9e9a6a1c8d8c9d0e40a45a2ce2d5d95cf1dafba (patch) | |
tree | 271313021ba56cbb86357da56d6158cf43509129 | |
parent | 4fe58d39c65438f13398a3617f06e2077840a176 (diff) | |
download | sequelpro-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
-rw-r--r-- | Interfaces/English.lproj/DBView.xib | 222 | ||||
-rw-r--r-- | Source/SPTableData.m | 4 | ||||
-rw-r--r-- | Source/TableDump.h | 3 | ||||
-rw-r--r-- | Source/TableDump.m | 33 | ||||
-rw-r--r-- | 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 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="6232"/> + <integer value="4566"/> <integer value="5"/> + <integer value="6232"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -7975,7 +7976,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> <string key="NSWindowContentMinSize">{213, 107}</string> <object class="NSView" key="NSWindowView" id="860968037"> - <nil key="NSNextResponder"/> + <reference key="NSNextResponder"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -7984,6 +7985,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <int key="NSvFlags">264</int> <string key="NSFrame">{{20, 233}, {140, 14}}</string> <reference key="NSSuperview" ref="860968037"/> + <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="326519111"> <int key="NSCellFlags">67239424</int> @@ -8010,6 +8012,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <int key="NSvFlags">2322</int> <string key="NSFrameSize">{352, 14}</string> <reference key="NSSuperview" ref="158897172"/> + <reference key="NSWindow"/> <object class="NSTextContainer" key="NSTextContainer" id="197710090"> <object class="NSLayoutManager" key="NSLayoutManager"> <object class="NSTextStorage" key="NSTextStorage"> @@ -8059,6 +8062,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <string key="NSFrame">{{1, 1}, {352, 178}}</string> <reference key="NSSuperview" ref="972781700"/> + <reference key="NSWindow"/> <reference key="NSNextKeyView" ref="347971361"/> <reference key="NSDocView" ref="347971361"/> <reference key="NSBGColor" ref="449903125"/> @@ -8070,6 +8074,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <int key="NSvFlags">256</int> <string key="NSFrame">{{353, 1}, {11, 178}}</string> <reference key="NSSuperview" ref="972781700"/> + <reference key="NSWindow"/> <int key="NSsFlags">256</int> <reference key="NSTarget" ref="972781700"/> <string key="NSAction">_doScroller:</string> @@ -8080,6 +8085,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <int key="NSvFlags">-2147483392</int> <string key="NSFrame">{{-100, -100}, {87, 18}}</string> <reference key="NSSuperview" ref="972781700"/> + <reference key="NSWindow"/> <int key="NSsFlags">257</int> <reference key="NSTarget" ref="972781700"/> <string key="NSAction">_doScroller:</string> @@ -8089,6 +8095,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <string key="NSFrame">{{20, 45}, {365, 180}}</string> <reference key="NSSuperview" ref="860968037"/> + <reference key="NSWindow"/> <reference key="NSNextKeyView" ref="158897172"/> <int key="NSsFlags">18</int> <reference key="NSVScroller" ref="84024470"/> @@ -8100,6 +8107,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <int key="NSvFlags">257</int> <string key="NSFrame">{{314, 13}, {76, 28}}</string> <reference key="NSSuperview" ref="860968037"/> + <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="693776804"> <int key="NSCellFlags">67239424</int> @@ -8118,6 +8126,8 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> </object> <string key="NSFrameSize">{405, 267}</string> + <reference key="NSSuperview"/> + <reference key="NSWindow"/> </object> <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string> <string key="NSMinSize">{213, 129}</string> @@ -8541,7 +8551,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> <string key="NSWindowContentMinSize">{350, 250}</string> <object class="NSView" key="NSWindowView" id="1024486775"> - <nil key="NSNextResponder"/> + <reference key="NSNextResponder"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -8926,6 +8936,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> </object> <string key="NSFrameSize">{465, 294}</string> + <reference key="NSSuperview"/> </object> <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string> <string key="NSMinSize">{350, 272}</string> @@ -12391,22 +12402,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <int key="connectionID">4524</int> </object> <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">closeSheet:</string> - <reference key="source" ref="225526897"/> - <reference key="destination" ref="322520441"/> - </object> - <int key="connectionID">4594</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">closeSheet:</string> - <reference key="source" ref="225526897"/> - <reference key="destination" ref="537769422"/> - </object> - <int key="connectionID">4596</int> - </object> - <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> <string key="label">recordCountLabel</string> <reference key="source" ref="225526897"/> @@ -15199,6 +15194,22 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <int key="connectionID">6752</int> </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">closeFieldMapperSheet:</string> + <reference key="source" ref="225526897"/> + <reference key="destination" ref="322520441"/> + </object> + <int key="connectionID">6758</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">closeFieldMapperSheet:</string> + <reference key="source" ref="225526897"/> + <reference key="destination" ref="537769422"/> + </object> + <int key="connectionID">6759</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -23548,9 +23559,9 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{603, 243}, {465, 294}}</string> + <string>{{315, 449}, {465, 294}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{603, 243}, {465, 294}}</string> + <string>{{315, 449}, {465, 294}}</string> <integer value="1"/> <string>{{387, 725}, {432, 282}}</string> <integer value="0"/> @@ -23661,10 +23672,10 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{239, 357}, {944, 550}}</string> + <string>{{116, 357}, {944, 550}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <boolean value="NO"/> - <string>{{239, 357}, {944, 550}}</string> + <string>{{116, 357}, {944, 550}}</string> <integer value="1"/> <integer value="1"/> <string>{{62, 352}, {845, 504}}</string> @@ -24850,7 +24861,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> </object> <nil key="sourceID"/> - <int key="maxID">6752</int> + <int key="maxID">6759</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -26434,6 +26445,169 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> </object> </object> + <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.1+"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBPartialClassDescription"> + <string key="className">TableDump</string> + <string key="superclassName">NSObject</string> + <object class="NSMutableDictionary" key="actions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>cancelProgressBar:</string> + <string>changeFormat:</string> + <string>changeTable:</string> + <string>closeFieldMapperSheet:</string> + <string>closeSheet:</string> + <string>panelSelectionDidChange:</string> + <string>reloadTables:</string> + <string>selectTables:</string> + <string>stepRow:</string> + <string>switchInput:</string> + <string>switchTab:</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + </object> + </object> + <object class="NSMutableDictionary" key="outlets"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>addCreateTableSwitch</string> + <string>addDropTableSwitch</string> + <string>addErrorsSwitch</string> + <string>addTableContentSwitch</string> + <string>csvFullStreamingSwitch</string> + <string>customQueryInstance</string> + <string>errorsSheet</string> + <string>errorsView</string> + <string>exportCSVView</string> + <string>exportDumpTableView</string> + <string>exportDumpView</string> + <string>exportFieldNamesSwitch</string> + <string>exportFieldsEnclosedField</string> + <string>exportFieldsEscapedField</string> + <string>exportFieldsTerminatedField</string> + <string>exportLinesTerminatedField</string> + <string>exportMultipleCSVTableView</string> + <string>exportMultipleCSVView</string> + <string>exportMultipleFieldNamesSwitch</string> + <string>exportMultipleFieldsEnclosedField</string> + <string>exportMultipleFieldsEscapedField</string> + <string>exportMultipleFieldsTerminatedField</string> + <string>exportMultipleLinesTerminatedField</string> + <string>exportMultipleXMLTableView</string> + <string>exportMultipleXMLView</string> + <string>exportTabBar</string> + <string>exportTableList</string> + <string>exportToolbar</string> + <string>exportWindow</string> + <string>fieldMappingPopup</string> + <string>fieldMappingSheet</string> + <string>fieldMappingTableView</string> + <string>importCSVBox</string> + <string>importCSVView</string> + <string>importFieldNamesSwitch</string> + <string>importFieldsEnclosedField</string> + <string>importFieldsEscapedField</string> + <string>importFieldsTerminatedField</string> + <string>importFormatPopup</string> + <string>importLinesTerminatedField</string> + <string>multiCSVFullStreamingSwitch</string> + <string>multiXMLFullStreamingSwitch</string> + <string>recordCountLabel</string> + <string>rowDownButton</string> + <string>rowUpButton</string> + <string>singleProgressBar</string> + <string>singleProgressSheet</string> + <string>singleProgressText</string> + <string>singleProgressTitle</string> + <string>sqlFullStreamingSwitch</string> + <string>tableContentInstance</string> + <string>tableDataInstance</string> + <string>tableDocumentInstance</string> + <string>tableSourceInstance</string> + <string>tableWindow</string> + <string>tablesListInstance</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>NSPopUpButton</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + </object> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBDocumentRelativeSource</string> + <string key="minorKey">../../Source/TableDump.h</string> + </object> + </object> + </object> <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBPartialClassDescription"> 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]]; |