aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-11-22 13:01:45 +0000
committerBibiko <bibiko@eva.mpg.de>2010-11-22 13:01:45 +0000
commit151ef11fca8f5d95d0383188b7f5cc3b67461be6 (patch)
tree5b3f2cde4f9fd15cbebd9783d8240af675decfe0 /Source
parente30cdeb6ee289fc4221d7b3fc5ec9e58be059675 (diff)
downloadsequelpro-151ef11fca8f5d95d0383188b7f5cc3b67461be6.tar.gz
sequelpro-151ef11fca8f5d95d0383188b7f5cc3b67461be6.tar.bz2
sequelpro-151ef11fca8f5d95d0383188b7f5cc3b67461be6.zip
• sequelpro url scheme support
• added commands: SelectDocumentView, ReloadContentTableWithWHEREClause • fixed typos • tried to queue incoming commands
Diffstat (limited to 'Source')
-rw-r--r--Source/SPAppController.m10
-rw-r--r--Source/SPDatabaseDocument.m46
-rw-r--r--Source/SPTableContent.h3
-rw-r--r--Source/SPTableContent.m12
4 files changed, 66 insertions, 5 deletions
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index d5a3cef2..0a59287c 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -562,6 +562,16 @@
}
}
+ while(1) {
+ NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
+ untilDate:[NSDate distantPast]
+ inMode:NSDefaultRunLoopMode
+ dequeue:YES];
+ // if(!event) continue;
+ [NSApp sendEvent:event];
+ if(![processDocument isWorking]) break;
+ usleep(1000);
+ }
if(processDocument && command && [command isEqualToString:@"passToDoc"]) {
NSMutableDictionary *cmdDict = [NSMutableDictionary dictionary];
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index 7c838a0e..4e26a8c4 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -4395,6 +4395,29 @@
// Authenticate command
if(![docProcessID isEqualToString:[commandDict objectForKey:@"id"]]) return;
+ if([command isEqualToString:@"SelectDocumentView"]) {
+ if([params count] == 2) {
+ NSString *view = [params objectAtIndex:1];
+ if([view length]) {
+ if([[view lowercaseString] hasPrefix:@"str"])
+ [self viewStructure:self];
+ else if([[view lowercaseString] hasPrefix:@"con"])
+ [self viewContent:self];
+ else if([[view lowercaseString] hasPrefix:@"que"])
+ [self viewQuery:self];
+ else if([[view lowercaseString] hasPrefix:@"tab"])
+ [self viewStatus:self];
+ else if([[view lowercaseString] hasPrefix:@"rel"])
+ [self viewRelations:self];
+ else if([[view lowercaseString] hasPrefix:@"tri"])
+ [self viewTriggers:self];
+
+ [self updateWindowTitle:self];
+ }
+ }
+ return;
+ }
+
if([command isEqualToString:@"SelectTable"]) {
if([params count] == 2) {
NSString *tableName = [params objectAtIndex:1];
@@ -4413,16 +4436,16 @@
}
if([command isEqualToString:@"ReloadContentTable"]) {
- [tablesListInstance updateTables:self];
+ [tableContentInstance reloadTable:self];
return;
}
if([command isEqualToString:@"ReloadTablesList"]) {
- [tableContentInstance reloadTable:self];
+ [tablesListInstance updateTables:self];
return;
}
- else if([command isEqualToString:@"SelectDatabase"]) {
+ if([command isEqualToString:@"SelectDatabase"]) {
if (_isWorkingLevel) return;
if([params count] > 1) {
NSString *dbName = [params objectAtIndex:1];
@@ -4437,7 +4460,22 @@
return;
}
- else if([command isEqualToString:@"ExecuteQuery"]) {
+ if([command isEqualToString:@"ReloadContentTableWithWHEREClause"]) {
+ NSString *queryFileName = [NSString stringWithFormat:@"%@%@", SPURLSchemeQueryInputPathHeader, docProcessID];
+ NSFileManager *fm = [NSFileManager defaultManager];
+ BOOL isDir;
+ if([fm fileExistsAtPath:queryFileName isDirectory:&isDir] && !isDir) {
+ NSError *inError = nil;
+ NSString *query = [NSString stringWithContentsOfFile:queryFileName encoding:NSUTF8StringEncoding error:inError];
+ [fm removeItemAtPath:queryFileName error:nil];
+ if(inError == nil && query && [query length]) {
+ [tableContentInstance filterTable:query];
+ }
+ }
+ return;
+ }
+
+ if([command isEqualToString:@"ExecuteQuery"]) {
// Bail if document is busy
if (_isWorkingLevel) return;
diff --git a/Source/SPTableContent.h b/Source/SPTableContent.h
index 893d767d..96058a0f 100644
--- a/Source/SPTableContent.h
+++ b/Source/SPTableContent.h
@@ -107,7 +107,8 @@
BOOL filterTableIsSwapped;
NSString *filterTableDefaultOperator;
NSString *lastEditedFilterTableValue;
- NSInteger activeFilter; // 0 = default filter; 1 = filter table
+ NSInteger activeFilter; // 0 = default filter; 1 = filter table; 2 = sequelpro url scheme
+ NSString *schemeFilter;
BOOL sortColumnToRestoreIsAsc;
BOOL tableRowsSelectable;
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index 7d694e07..2f0cec21 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -72,6 +72,7 @@
filterTableIsSwapped = NO;
lastEditedFilterTableValue = nil;
activeFilter = 0;
+ schemeFilter = nil;
selectedTable = nil;
sortCol = nil;
@@ -866,6 +867,12 @@
- (NSString *)tableFilterString
{
+ // If filter command was passed by sequelpro url scheme
+ if(activeFilter == 2) {
+ if(schemeFilter)
+ return schemeFilter;
+ }
+
// Call did come from filter table and is filter table window still open?
if(activeFilter == 1 && [filterTableWindow isVisible]) {
@@ -1255,6 +1262,11 @@
if(sender == filterTableFilterButton)
activeFilter = 1;
+ else if([sender isKindOfClass:[NSString class]] && [sender length]) {
+ if(schemeFilter) [schemeFilter release], schemeFilter = nil;
+ schemeFilter = [sender retain];
+ activeFilter = 2;
+ }
else
activeFilter = 0;