aboutsummaryrefslogtreecommitdiffstats
path: root/Source/MainController.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-08-05 21:14:15 +0000
committerBibiko <bibiko@eva.mpg.de>2009-08-05 21:14:15 +0000
commited4617c7fc292ac15a3cb340b2247d58793d3ca4 (patch)
treecc32cc3a93ed8a8001945d85d9242aa6a8d42682 /Source/MainController.m
parent493fb09f6169864726be9909907fa1b84b3d0a21 (diff)
downloadsequelpro-ed4617c7fc292ac15a3cb340b2247d58793d3ca4.tar.gz
sequelpro-ed4617c7fc292ac15a3cb340b2247d58793d3ca4.tar.bz2
sequelpro-ed4617c7fc292ac15a3cb340b2247d58793d3ca4.zip
• open a SQL file via Finder or Terminal (open *.sql if SP is the default app for sql files) will insert the file content into the Custom Query editor of the current active doc
- this action starts SP and asks for a connection if it is not running - same for drag&drop a SQL file onto SP's dock icon
Diffstat (limited to 'Source/MainController.m')
-rw-r--r--Source/MainController.m20
1 files changed, 15 insertions, 5 deletions
diff --git a/Source/MainController.m b/Source/MainController.m
index 4e1119a6..17aa2652 100644
--- a/Source/MainController.m
+++ b/Source/MainController.m
@@ -56,17 +56,27 @@
for( NSString* filename in filenames ) {
- // Opens a sql file and insert its content to the Custom Query editor
+ // Opens a sql file and insert its content into the Custom Query editor
if([[[filename pathExtension] lowercaseString] isEqualToString:@"sql"]) {
// Check if at least one document exists
if (![[[NSDocumentController sharedDocumentController] documents] count]) {
// TODO : maybe open a connection first
- return;
- }
+ // return;
+ TableDocument *firstTableDocument;
+
+ // Manually open a new document, setting MainController as sender to trigger autoconnection
+ if (firstTableDocument = [[NSDocumentController sharedDocumentController] makeUntitledDocumentOfType:@"DocumentType" error:nil]) {
+ [firstTableDocument setShouldAutomaticallyConnect:NO];
+ [firstTableDocument initQueryEditorWithString:[self contentOfFile:filename]];
+ [[NSDocumentController sharedDocumentController] addDocument:firstTableDocument];
+ [firstTableDocument makeWindowControllers];
+ [firstTableDocument showWindows];
+ }
+ } else
- // Pass query to last created document
- [[[[NSDocumentController sharedDocumentController] documents] objectAtIndex:([[[NSDocumentController sharedDocumentController] documents] count] - 1)] doPerformQueryService:[self contentOfFile:filename]];
+ // Pass query to the Query editor of the current document
+ [[[NSDocumentController sharedDocumentController] currentDocument] doPerformLoadQueryService:[self contentOfFile:filename]];
}
else if([[[filename pathExtension] lowercaseString] isEqualToString:@"spf"]) {