diff options
author | Stuart Connolly <stuart02@gmail.com> | 2013-11-27 20:05:44 +0000 |
---|---|---|
committer | Stuart Connolly <stuart02@gmail.com> | 2013-11-27 20:05:44 +0000 |
commit | f153db9d267c7d2177ba6cb5fa08ee46f1a4ccf5 (patch) | |
tree | 28434b3af157b53875f453b0a4574ebc17758d0d | |
parent | f98bb26a8b8b3af09ad9744d1bd26c3078cd0cb7 (diff) | |
download | sequelpro-f153db9d267c7d2177ba6cb5fa08ee46f1a4ccf5.tar.gz sequelpro-f153db9d267c7d2177ba6cb5fa08ee46f1a4ccf5.tar.bz2 sequelpro-f153db9d267c7d2177ba6cb5fa08ee46f1a4ccf5.zip |
Remove use of deprecated save panel method.
-rw-r--r-- | Source/SPDataImport.h | 4 | ||||
-rw-r--r-- | Source/SPDataImport.m | 69 |
2 files changed, 33 insertions, 40 deletions
diff --git a/Source/SPDataImport.h b/Source/SPDataImport.h index 0d23b104..add9c5b4 100644 --- a/Source/SPDataImport.h +++ b/Source/SPDataImport.h @@ -133,15 +133,13 @@ typedef enum { // Import methods - (void)importFile; -- (void)importFileSheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo; - (void)importFromClipboard; -- (void)importFromClipboardSheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo; - (void)importSQLFile:(NSString *)filename; - (void)startSQLImportProcessWithFile:(NSString *)filename; - (void)importCSVFile:(NSString *)filename; - (IBAction)changeFormat:(id)sender; - (BOOL)buildFieldMappingArrayWithData:(NSArray *)importData isPreview:(BOOL)dataIsPreviewData ofSoureFile:(NSString*)filename; -- (void)fieldMapperDidEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo; + - (NSString *)mappedValueStringForRowArray:(NSArray *)csvRowArray; - (NSString *)mappedUpdateSetStatementStringForRowArray:(NSArray *)csvRowArray; diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m index cb9c1bb8..e1e314db 100644 --- a/Source/SPDataImport.m +++ b/Source/SPDataImport.m @@ -280,56 +280,51 @@ [openPanel setAccessoryView:importView]; [openPanel setDelegate:self]; + if ([prefs valueForKey:@"importFormatPopupValue"]) { [importFormatPopup selectItemWithTitle:[prefs valueForKey:@"importFormatPopupValue"]]; [self changeFormat:self]; } - - // Show openPanel - [openPanel beginSheetForDirectory:[prefs objectForKey:@"openPath"] - file:[lastFilename lastPathComponent] - modalForWindow:[tableDocumentInstance parentWindow] - modalDelegate:self - didEndSelector:@selector(importFileSheetDidEnd:returnCode:contextInfo:) - contextInfo:nil]; -} -/** - * Callback for when the import sheet is closed - */ -- (void)importFileSheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo -{ + if (lastFilename && [lastFilename lastPathComponent]) { + [openPanel setNameFieldStringValue:[lastFilename lastPathComponent]]; + } - // Ensure text inputs are completed, preventing dead character entry - [sheet makeFirstResponder:nil]; + [openPanel setDirectoryURL:[NSURL URLWithString:[prefs objectForKey:@"openPath"]]]; - // Save values to preferences - [prefs setObject:[(NSOpenPanel*)sheet directory] forKey:@"openPath"]; - [prefs setObject:[[importFormatPopup selectedItem] title] forKey:@"importFormatPopupValue"]; - - // Close NSOpenPanel sheet - [sheet orderOut:self]; + [openPanel beginSheetModalForWindow:[tableDocumentInstance parentWindow] completionHandler:^(NSInteger returnCode) { + // Ensure text inputs are completed, preventing dead character entry + [openPanel makeFirstResponder:nil]; - // Check if the user canceled - if (returnCode != NSOKButton) - return; + // Save values to preferences + [prefs setObject:[[openPanel directoryURL] path] forKey:@"openPath"]; + [prefs setObject:[[importFormatPopup selectedItem] title] forKey:@"importFormatPopupValue"]; - // Reset progress cancelled from any previous runs - progressCancelled = NO; + // Close NSOpenPanel sheet + [openPanel orderOut:self]; - if(lastFilename) [lastFilename release]; lastFilename = nil; - lastFilename = [[NSString stringWithString:[[(NSOpenPanel*)sheet URL] path]] retain]; + // Check if the user canceled + if (returnCode != NSOKButton) return; - NSString *importFileName = [NSString stringWithString:lastFilename]; - if (lastFilename == nil || ![lastFilename length]) { - NSBeep(); - return; - } + // Reset progress cancelled from any previous runs + progressCancelled = NO; - if (importFileName == nil) return; + if (lastFilename) [lastFilename release]; lastFilename = nil; - // Begin the import process - [NSThread detachNewThreadWithName:@"SPDataImport background import task" target:self selector:@selector(_importBackgroundProcess:) object:importFileName]; + lastFilename = [[NSString stringWithString:[[openPanel URL] path]] retain]; + + NSString *importFileName = [NSString stringWithString:lastFilename]; + + if (lastFilename == nil || ![lastFilename length]) { + NSBeep(); + return; + } + + if (importFileName == nil) return; + + // Begin the import process + [NSThread detachNewThreadWithName:@"SPDataImport background import task" target:self selector:@selector(_importBackgroundProcess:) object:importFileName]; + }]; } /** |