aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/TableDump.h3
-rw-r--r--Source/TableDump.m24
2 files changed, 27 insertions, 0 deletions
diff --git a/Source/TableDump.h b/Source/TableDump.h
index c5f83cd0..3f89ab68 100644
--- a/Source/TableDump.h
+++ b/Source/TableDump.h
@@ -138,6 +138,9 @@
//additional methods
- (void)setConnection:(CMMCPConnection *)theConnection;
+// Import/export delegate notifications
+- (void)panelSelectionDidChange:(id)sender;
+
//last but not least
- (id)init;
- (void)dealloc;
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