aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDataImport.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/SPDataImport.m')
-rw-r--r--Source/SPDataImport.m69
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];
+ }];
}
/**