diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-08-22 10:54:17 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-08-22 10:54:17 +0000 |
commit | a35bbeac66279cd42230e301332dee1c26ae4be2 (patch) | |
tree | 36f59f1f918484d6da7493350287d040467fbd2f /Source/SPAppController.m | |
parent | a946912ea562fe7eb02ec51b77420e63db3a38da (diff) | |
download | sequelpro-a35bbeac66279cd42230e301332dee1c26ae4be2.tar.gz sequelpro-a35bbeac66279cd42230e301332dee1c26ae4be2.tar.bz2 sequelpro-a35bbeac66279cd42230e301332dee1c26ae4be2.zip |
• further improvements for open/save SQL/SPF files
Diffstat (limited to 'Source/SPAppController.m')
-rw-r--r-- | Source/SPAppController.m | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/Source/SPAppController.m b/Source/SPAppController.m index 9b0bce1d..2dba0c68 100644 --- a/Source/SPAppController.m +++ b/Source/SPAppController.m @@ -47,6 +47,33 @@ return self; } +- (IBAction)openConnectionSheet:(id)sender +{ + NSOpenPanel *panel = [NSOpenPanel openPanel]; + [panel setCanSelectHiddenExtension:YES]; + [panel setDelegate:self]; + [panel setCanChooseDirectories:NO]; + [panel setAllowsMultipleSelection:YES]; + [panel setResolvesAliases:YES]; + // [panel setAccessoryView:encodingAccessoryView]; + + // Set up encoding list + // [encodingPopUp setEnabled:NO]; + + // If no lastSqlFileEncoding in prefs set it to UTF-8 + if(![[NSUserDefaults standardUserDefaults] integerForKey:@"lastSqlFileEncoding"]) { + [[NSUserDefaults standardUserDefaults] setInteger:4 forKey:@"lastSqlFileEncoding"]; + [[NSUserDefaults standardUserDefaults] synchronize]; + } + + // [self setupPopUp:encodingPopUp selectedEncoding:[prefs integerForKey:@"lastSqlFileEncoding"] withDefaultEntry:NO]; + int returnCode = [panel runModalForDirectory:nil file:nil types:[NSArray arrayWithObjects:@"spf", @"sql", nil]]; + + if( returnCode ) + [self application:nil openFiles:[panel filenames]]; + +} + /** * Called if user drag and drops files on Sequel Pro's dock item or double-clicked * at files *.spf or *.sql @@ -61,8 +88,7 @@ // Check if at least one document exists if (![[[NSDocumentController sharedDocumentController] documents] count]) { - // TODO : maybe open a connection first - // return; + TableDocument *firstTableDocument; // Manually open a new document, setting SPAppController as sender to trigger autoconnection @@ -82,7 +108,18 @@ } else if([[[filename pathExtension] lowercaseString] isEqualToString:@"spf"]) { - NSLog(@"open connection %@", filename); + + TableDocument *newTableDocument; + + // Manually open a new document, setting SPAppController as sender to trigger autoconnection + if (newTableDocument = [[NSDocumentController sharedDocumentController] makeUntitledDocumentOfType:@"DocumentType" error:nil]) { + [newTableDocument setShouldAutomaticallyConnect:NO]; + [[NSDocumentController sharedDocumentController] addDocument:newTableDocument]; + [newTableDocument makeWindowControllers]; + [newTableDocument showWindows]; + [newTableDocument initWithConnectionFile:filename]; + } + } else { NSLog(@"Only files with the extensions ‘spf’ or ‘sql’ are allowed."); |