diff options
author | rowanbeentje <rowan@beent.je> | 2009-03-04 21:57:35 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2009-03-04 21:57:35 +0000 |
commit | b267968964adb3402b38df683debee16c6c310d1 (patch) | |
tree | 23f51d5a56eef0706c3edb86b29a28d280c4c8bb /Source/TableDump.m | |
parent | 6b62af2bf9c02d2f57c93653e562deb20d9298fa (diff) | |
download | sequelpro-b267968964adb3402b38df683debee16c6c310d1.tar.gz sequelpro-b267968964adb3402b38df683debee16c6c310d1.tar.bz2 sequelpro-b267968964adb3402b38df683debee16c6c310d1.zip |
Alter the open panel to recognise .csv and .sql extensions on selected files and automatically change the format dropdown to match
Diffstat (limited to 'Source/TableDump.m')
-rw-r--r-- | Source/TableDump.m | 24 |
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 |