aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-03-04 21:57:35 +0000
committerrowanbeentje <rowan@beent.je>2009-03-04 21:57:35 +0000
commitb267968964adb3402b38df683debee16c6c310d1 (patch)
tree23f51d5a56eef0706c3edb86b29a28d280c4c8bb /Source
parent6b62af2bf9c02d2f57c93653e562deb20d9298fa (diff)
downloadsequelpro-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')
-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