aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableDump.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/TableDump.m')
-rw-r--r--Source/TableDump.m24
1 files changed, 24 insertions, 0 deletions
diff --git a/Source/TableDump.m b/Source/TableDump.m
index 5c813407..f7fd3a80 100644
--- a/Source/TableDump.m
+++ b/Source/TableDump.m
@@ -330,6 +330,7 @@
// prepare open panel and accessory view
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
[openPanel setAccessoryView:importCSVView];
+ [openPanel setDelegate:self];
if ([prefs valueForKey:@"importFormatPopupValue"]) {
[importFormatPopup selectItemWithTitle:[prefs valueForKey:@"importFormatPopupValue"]];
[self changeFormat:self];
@@ -1874,6 +1875,29 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
}
}
+
+#pragma mark -
+#pragma mark Import/export delegate notifications
+
+// Called when the selection within an open/save panel changes
+- (void)panelSelectionDidChange:(id)sender
+{
+ NSArray *selectedFilenames = [sender filenames];
+ NSString *pathExtension;
+
+ // If a single file is selected and the extension is recognised, change the format dropdown automatically
+ if ( [selectedFilenames count] != 1 ) return;
+ pathExtension = [[[selectedFilenames objectAtIndex:0] pathExtension] uppercaseString];
+ if ([pathExtension isEqualToString:@"SQL"]) {
+ [importFormatPopup selectItemWithTitle:@"SQL"];
+ [self changeFormat:self];
+ } else if ([pathExtension isEqualToString:@"CSV"]) {
+ [importFormatPopup selectItemWithTitle:@"CSV"];
+ [self changeFormat:self];
+ }
+}
+
+
#pragma mark -
#pragma mark other
//last but not least