diff options
author | rowanbeentje <rowan@beent.je> | 2010-11-29 00:42:32 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2010-11-29 00:42:32 +0000 |
commit | 2510f9b62f30cb3ea61c3ce7d0d12fef72af8f7e (patch) | |
tree | 515d5236117f77ee17255cbaf14d3813a37f17e9 /Source | |
parent | 10117475bae9659b41d41c8d408bee3a3c0d6cf2 (diff) | |
download | sequelpro-2510f9b62f30cb3ea61c3ce7d0d12fef72af8f7e.tar.gz sequelpro-2510f9b62f30cb3ea61c3ce7d0d12fef72af8f7e.tar.bz2 sequelpro-2510f9b62f30cb3ea61c3ce7d0d12fef72af8f7e.zip |
- Change the CSV import accessory view to a general import accessory view, based on a tab view
- When importing SQL, use the accessory view to ask how to handle errors: Ask (the new default), which prompts the user on each error whether to continue, stop, or ignore all errors; and ignoring all errors, which matches the old behaviour. This addresses Issue #901.
- When showing the reconnection dialog ensure the window isn't minimised
- Update localisable strings
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPConnectionDelegate.m | 3 | ||||
-rw-r--r-- | Source/SPConstants.h | 7 | ||||
-rw-r--r-- | Source/SPDataImport.h | 6 | ||||
-rw-r--r-- | Source/SPDataImport.m | 44 |
4 files changed, 54 insertions, 6 deletions
diff --git a/Source/SPConnectionDelegate.m b/Source/SPConnectionDelegate.m index 4b928652..f02d5648 100644 --- a/Source/SPConnectionDelegate.m +++ b/Source/SPConnectionDelegate.m @@ -130,6 +130,9 @@ // Only display the reconnect dialog if the window is visible if ([self parentWindow] && [[self parentWindow] isVisible]) { + // Ensure the window isn't miniaturized + if ([[self parentWindow] isMiniaturized]) [[self parentWindow] deminiaturize:self]; + // Ensure the window and tab are frontmost [self makeKeyDocument]; diff --git a/Source/SPConstants.h b/Source/SPConstants.h index fadf8573..c8a53b0a 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -188,6 +188,13 @@ typedef enum SPBzip2Compression = 2 } SPFileCompressionFormat; +// Import SQL error handling tags/choices +typedef enum +{ + SPSQLImportAskOnError = 0, + SPSQLImportIgnoreErrors = 1 +} SPSQLImportErrorHandling; + // Export file handle creation typedef enum { diff --git a/Source/SPDataImport.h b/Source/SPDataImport.h index 8ea49fa1..a8888ab8 100644 --- a/Source/SPDataImport.h +++ b/Source/SPDataImport.h @@ -36,8 +36,8 @@ IBOutlet id tableDataInstance; IBOutlet id customQueryInstance; - IBOutlet id importCSVView; - IBOutlet id importCSVBox; + IBOutlet id importView; + IBOutlet id importTabView; IBOutlet id importFieldNamesSwitch; IBOutlet id importFieldsTerminatedField; IBOutlet id importFieldsEnclosedField; @@ -47,6 +47,8 @@ IBOutlet NSPopUpButton *importFormatPopup; IBOutlet NSPopUpButton *importEncodingPopup; + + IBOutlet NSPopUpButton *importSQLErrorHandlingPopup; IBOutlet id importFromClipboardSheet; IBOutlet id importFromClipboardAccessoryView; diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m index dff20466..0879228a 100644 --- a/Source/SPDataImport.m +++ b/Source/SPDataImport.m @@ -107,6 +107,9 @@ [nibObjectsToRelease addObjectsFromArray:importAccessoryTopLevelObjects]; [nibLoader release]; + // Set the accessory view's tabview to tabless (left in for easier editing in IB) + [importTabView setTabViewType:NSNoTabsNoBorder]; + // Set up the encodings menu NSMutableArray *encodings = [NSMutableArray arrayWithArray:[SPEncodingPopupAccessory enabledEncodings]]; [importEncodingPopup removeAllItems]; @@ -126,7 +129,7 @@ */ - (IBAction)changeFormat:(id)sender { - [importCSVBox setHidden:![[[importFormatPopup selectedItem] title] isEqualToString:@"CSV"]]; + [importTabView selectTabViewItemAtIndex:[importFormatPopup indexOfSelectedItem]]; } /** @@ -199,9 +202,9 @@ [importEncodingPopup setEnabled:NO]; // Add the view, and resize it to fit the accessory view size - [importFromClipboardAccessoryView addSubview:importCSVView]; + [importFromClipboardAccessoryView addSubview:importView]; NSRect accessoryViewRect = [importFromClipboardAccessoryView frame]; - [importCSVView setFrame:NSMakeRect(0, 0, accessoryViewRect.size.width, accessoryViewRect.size.height)]; + [importView setFrame:NSMakeRect(0, 0, accessoryViewRect.size.width, accessoryViewRect.size.height)]; [NSApp beginSheet:importFromClipboardSheet modalForWindow:[tableDocumentInstance parentWindow] @@ -268,7 +271,7 @@ [importFieldsEnclosedField setStringValue:[prefs objectForKey:SPCSVImportFieldEnclosedBy]]; [importFieldNamesSwitch setState:[[prefs objectForKey:SPCSVImportFirstLineIsHeader] boolValue]]; - [openPanel setAccessoryView:importCSVView]; + [openPanel setAccessoryView:importView]; [openPanel setDelegate:self]; if ([prefs valueForKey:@"importFormatPopupValue"]) { [importFormatPopup selectItemWithTitle:[prefs valueForKey:@"importFormatPopupValue"]]; @@ -362,6 +365,7 @@ BOOL fileIsCompressed; BOOL importSQLAsUTF8 = YES; BOOL allDataRead = NO; + BOOL ignoreSQLErrors = ([importSQLErrorHandlingPopup selectedTag] == SPSQLImportIgnoreErrors); NSStringEncoding sqlEncoding = NSUTF8StringEncoding; NSString *connectionEncodingToRestore = nil; NSCharacterSet *whitespaceAndNewlineCharset = [NSCharacterSet whitespaceAndNewlineCharacterSet]; @@ -559,6 +563,38 @@ // Check for any errors if ([mySQLConnection queryErrored] && ![[mySQLConnection getLastErrorMessage] isEqualToString:@"Query was empty"]) { [errors appendFormat:NSLocalizedString(@"[ERROR in query %ld] %@\n", @"error text when multiple custom query failed"), (long)(queriesPerformed+1), [mySQLConnection getLastErrorMessage]]; + + // If not set to ignore errors, ask what to do. Use NSAlert rather than + // SPBeginWaitingAlertSheet as there is already a modal sheet in progress. + if (!ignoreSQLErrors) { + NSInteger sqlImportErrorSheetReturnCode; + + NSAlert *sqlErrorAlert = [NSAlert + alertWithMessageText:NSLocalizedString(@"An error occurred while importing SQL", @"sql import error message") + defaultButton:NSLocalizedString(@"Continue", @"continue button") + alternateButton:NSLocalizedString(@"Ignore All Errors", @"ignore errors button") + otherButton:NSLocalizedString(@"Stop", @"stop button") + informativeTextWithFormat:NSLocalizedString(@"[ERROR in query %ld] %@\n", @"error text when multiple custom query failed"), (long)(queriesPerformed+1), [mySQLConnection getLastErrorMessage] + ]; + [sqlErrorAlert setAlertStyle:NSWarningAlertStyle]; + sqlImportErrorSheetReturnCode = [sqlErrorAlert runModal]; + + switch (sqlImportErrorSheetReturnCode) { + + // On "continue", no additional action is required + case NSAlertDefaultReturn: + break; + + // Ignore all future errors if asked to + case NSAlertAlternateReturn: + ignoreSQLErrors = YES; + break; + + // Otherwise, stop + default: + progressCancelled = YES; + } + } } // Increment the processed queries count |