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 /Source/SPDataImport.m | |
parent | f98bb26a8b8b3af09ad9744d1bd26c3078cd0cb7 (diff) | |
download | sequelpro-f153db9d267c7d2177ba6cb5fa08ee46f1a4ccf5.tar.gz sequelpro-f153db9d267c7d2177ba6cb5fa08ee46f1a4ccf5.tar.bz2 sequelpro-f153db9d267c7d2177ba6cb5fa08ee46f1a4ccf5.zip |
Remove use of deprecated save panel method.
Diffstat (limited to 'Source/SPDataImport.m')
-rw-r--r-- | Source/SPDataImport.m | 69 |
1 files changed, 32 insertions, 37 deletions
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]; + }]; } /** |