diff options
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 |