aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-12-01 23:49:55 +0000
committerBibiko <bibiko@eva.mpg.de>2010-12-01 23:49:55 +0000
commit4801fedd91e3a6abb1ee6a7aa1174a089bf6e547 (patch)
tree83de108f27534334f95c2198de13ad4686e3164d /Source
parent842e85a37b698be1245dee0948a1abd99973638c (diff)
downloadsequelpro-4801fedd91e3a6abb1ee6a7aa1174a089bf6e547.tar.gz
sequelpro-4801fedd91e3a6abb1ee6a7aa1174a089bf6e547.tar.bz2
sequelpro-4801fedd91e3a6abb1ee6a7aa1174a089bf6e547.zip
• Bundle Commands
- make sure that each HTML output window will be released - if a triggered command will outputs its result in an HTML window invoke it only if the HTML output window is already open; this enables the user to "switch on/off" such a trigger
Diffstat (limited to 'Source')
-rw-r--r--Source/SPAppController.h3
-rw-r--r--Source/SPAppController.m24
-rw-r--r--Source/SPBundleHTMLOutputController.m14
-rw-r--r--Source/SPCopyTable.m1
-rw-r--r--Source/SPDatabaseDocument.m36
-rw-r--r--Source/SPDatabaseViewController.m36
-rw-r--r--Source/SPTableContent.m36
-rw-r--r--Source/SPTextViewAdditions.m1
8 files changed, 117 insertions, 34 deletions
diff --git a/Source/SPAppController.h b/Source/SPAppController.h
index 8742607d..e1f1e60c 100644
--- a/Source/SPAppController.h
+++ b/Source/SPAppController.h
@@ -48,6 +48,7 @@
NSMutableDictionary *bundleCategories;
NSMutableDictionary *bundleTriggers;
NSMutableArray *bundleUsedScopes;
+ NSMutableArray *bundleHTMLOutputController;
NSMutableDictionary *bundleKeyEquivalents;
NSMutableDictionary *installedBundleUUIDs;
@@ -107,4 +108,6 @@
- (IBAction)executeBundleItemForApp:(id)sender;
+- (void)addHTMLOutputController:(id)controller;
+
@end
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index 3cd718db..45e9892a 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -56,6 +56,7 @@
bundleCategories = [[NSMutableDictionary alloc] initWithCapacity:1];
bundleTriggers = [[NSMutableDictionary alloc] initWithCapacity:1];
bundleUsedScopes = [[NSMutableArray alloc] initWithCapacity:1];
+ bundleHTMLOutputController = [[NSMutableArray alloc] initWithCapacity:1];
bundleKeyEquivalents = [[NSMutableDictionary alloc] initWithCapacity:1];
installedBundleUUIDs = [[NSMutableDictionary alloc] initWithCapacity:1];
runningActivitiesArray = [[NSMutableArray alloc] init];
@@ -836,6 +837,7 @@
SPBundleHTMLOutputController *c = [[SPBundleHTMLOutputController alloc] init];
[c setWindowUUID:[cmdData objectForKey:SPBundleFileUUIDKey]];
[c displayHTMLContent:output withOptions:nil];
+ [[NSApp delegate] addHTMLOutputController:c];
}
}
}
@@ -1172,13 +1174,25 @@
[bundleEditorController showWindow:self];
}
+- (void)addHTMLOutputController:(id)controller
+{
+ [bundleHTMLOutputController addObject:controller];
+}
+
- (IBAction)reloadBundles:(id)sender
{
+ for(id c in bundleHTMLOutputController) {
+ if(![[c window] isVisible]) {
+ [c release];
+ }
+ }
+
BOOL foundInstalledBundles = NO;
[bundleItems removeAllObjects];
[bundleUsedScopes removeAllObjects];
+ [bundleHTMLOutputController removeAllObjects];
[bundleCategories removeAllObjects];
[bundleTriggers removeAllObjects];
[bundleKeyEquivalents removeAllObjects];
@@ -1240,7 +1254,7 @@
if([cmdData objectForKey:SPBundleFileTriggerKey]) {
if(![bundleTriggers objectForKey:[cmdData objectForKey:SPBundleFileTriggerKey]])
[bundleTriggers setObject:[NSMutableArray array] forKey:[cmdData objectForKey:SPBundleFileTriggerKey]];
- [[bundleTriggers objectForKey:[cmdData objectForKey:SPBundleFileTriggerKey]] addObject:[NSString stringWithFormat:@"%@|%@", infoPath, [cmdData objectForKey:SPBundleFileScopeKey]]];
+ [[bundleTriggers objectForKey:[cmdData objectForKey:SPBundleFileTriggerKey]] addObject:[NSString stringWithFormat:@"%@|%@|%@", infoPath, [cmdData objectForKey:SPBundleFileScopeKey], ([[cmdData objectForKey:SPBundleFileOutputActionKey] isEqualToString:SPBundleOutputActionShowAsHTML])?[cmdData objectForKey:SPBundleFileUUIDKey]:@""]];
}
if([cmdData objectForKey:SPBundleFileKeyEquivalentKey] && [[cmdData objectForKey:SPBundleFileKeyEquivalentKey] length]) {
@@ -1563,7 +1577,7 @@
}
/**
- * If Sequel Pro is terminating kill all running BASH scripts
+ * If Sequel Pro is terminating kill all running BASH scripts and release all HTML output controller
*/
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
@@ -1593,6 +1607,11 @@
[killTask waitUntilExit];
[killTask release];
}
+
+ for(id c in bundleHTMLOutputController) {
+ [c release];
+ }
+
return YES;
}
@@ -1608,6 +1627,7 @@
if(bundleItems) [bundleItems release];
if(bundleUsedScopes) [bundleUsedScopes release];
+ if(bundleHTMLOutputController) [bundleHTMLOutputController release];
if(bundleCategories) [bundleCategories release];
if(bundleTriggers) [bundleTriggers release];
if(bundleKeyEquivalents) [bundleKeyEquivalents release];
diff --git a/Source/SPBundleHTMLOutputController.m b/Source/SPBundleHTMLOutputController.m
index a4c79edc..b89606f9 100644
--- a/Source/SPBundleHTMLOutputController.m
+++ b/Source/SPBundleHTMLOutputController.m
@@ -63,7 +63,7 @@
[webView setDrawsBackground:YES];
[webView setEditable:NO];
[webView setShouldCloseWithWindow:YES];
- [webView setShouldUpdateWhileOffscreen:YES];
+ [webView setShouldUpdateWhileOffscreen:NO];
}
@@ -74,8 +74,8 @@
NSString *fullContent = @"%@";
fullContent = [NSString stringWithFormat:fullContent, content];
-
[self setInitHTMLSourceString:fullContent];
+ [[webView mainFrame] loadHTMLString:@"<html></html>" baseURL:nil];
[[webView mainFrame] loadHTMLString:fullContent baseURL:nil];
}
@@ -115,10 +115,10 @@
{
if(webView) [webView release];
if(webPreferences) [webPreferences release];
- [super dealloc];
+ // [super dealloc];
}
-- (void) keyDown:(NSEvent *)theEvent
+- (void)keyDown:(NSEvent *)theEvent
{
long allFlags = (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask);
@@ -164,10 +164,13 @@
#pragma mark -
-- (void)windowShouldClose:(NSNotification *)notification
+- (void)windowWillClose:(NSNotification *)notification
{
+ [[webView mainFrame] loadHTMLString:@"<html></html>" baseURL:nil];
[webView close];
+ [self setInitHTMLSourceString:@""];
windowUUID = @"";
+ // [[notification object] release];
}
#pragma mark -
@@ -177,6 +180,7 @@
if(request != nil) {
SPBundleHTMLOutputController *c = [[SPBundleHTMLOutputController alloc] init];
[c displayURLString:[[request URL] absoluteString] withOptions:nil];
+ [[NSApp delegate] addHTMLOutputController:c];
return [c webView];
}
return nil;
diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m
index 86fb9d85..687cb2e4 100644
--- a/Source/SPCopyTable.m
+++ b/Source/SPCopyTable.m
@@ -964,6 +964,7 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003;
SPBundleHTMLOutputController *c = [[SPBundleHTMLOutputController alloc] init];
[c setWindowUUID:[cmdData objectForKey:SPBundleFileUUIDKey]];
[c displayHTMLContent:output withOptions:nil];
+ [[NSApp delegate] addHTMLOutputController:c];
}
}
}
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index 2729932f..43d71b01 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -5320,16 +5320,34 @@
NSMenuItem *aMenuItem = [[[NSMenuItem alloc] init] autorelease];
[aMenuItem setTag:0];
[aMenuItem setToolTip:[data objectAtIndex:0]];
- if([[data objectAtIndex:1] isEqualToString:SPBundleScopeGeneral]) {
- [[[NSApp delegate] onMainThread] executeBundleItemForApp:aMenuItem];
- }
- else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeDataTable]) {
- if([[[NSApp mainWindow] firstResponder] isKindOfClass:[SPCopyTable class]])
- [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForDataTable:aMenuItem];
+
+ // For HTML output check if corresponding window already exists
+ BOOL stopTrigger = NO;
+ if([[data objectAtIndex:2] length]) {
+ BOOL correspondingWindowFound = NO;
+ NSString *uuid = [data objectAtIndex:2];
+ for(id win in [NSApp windows]) {
+ if([[[[win delegate] class] description] isEqualToString:@"SPBundleHTMLOutputController"]) {
+ if([[[win delegate] windowUUID] isEqualToString:uuid]) {
+ correspondingWindowFound = YES;
+ break;
+ }
+ }
+ }
+ if(!correspondingWindowFound) stopTrigger = YES;
}
- else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeInputField]) {
- if([[[NSApp mainWindow] firstResponder] isKindOfClass:[NSTextView class]])
- [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForInputField:aMenuItem];
+ if(!stopTrigger) {
+ if([[data objectAtIndex:1] isEqualToString:SPBundleScopeGeneral]) {
+ [[[NSApp delegate] onMainThread] executeBundleItemForApp:aMenuItem];
+ }
+ else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeDataTable]) {
+ if([[[[[NSApp mainWindow] firstResponder] class] description] isEqualToString:@"SPCopyTable"])
+ [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForDataTable:aMenuItem];
+ }
+ else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeInputField]) {
+ if([[[NSApp mainWindow] firstResponder] isKindOfClass:[NSTextView class]])
+ [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForInputField:aMenuItem];
+ }
}
}
diff --git a/Source/SPDatabaseViewController.m b/Source/SPDatabaseViewController.m
index 8cf97998..e95b6b41 100644
--- a/Source/SPDatabaseViewController.m
+++ b/Source/SPDatabaseViewController.m
@@ -488,16 +488,34 @@
NSMenuItem *aMenuItem = [[[NSMenuItem alloc] init] autorelease];
[aMenuItem setTag:0];
[aMenuItem setToolTip:[data objectAtIndex:0]];
- if([[data objectAtIndex:1] isEqualToString:SPBundleScopeGeneral]) {
- [[[NSApp delegate] onMainThread] executeBundleItemForApp:aMenuItem];
- }
- else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeDataTable]) {
- if([[[[NSApp mainWindow] firstResponder] description] isEqualToString:@"SPCopyTable"])
- [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForDataTable:aMenuItem];
+
+ // For HTML output check if corresponding window already exists
+ BOOL stopTrigger = NO;
+ if([[data objectAtIndex:2] length]) {
+ BOOL correspondingWindowFound = NO;
+ NSString *uuid = [data objectAtIndex:2];
+ for(id win in [NSApp windows]) {
+ if([[[[win delegate] class] description] isEqualToString:@"SPBundleHTMLOutputController"]) {
+ if([[[win delegate] windowUUID] isEqualToString:uuid]) {
+ correspondingWindowFound = YES;
+ break;
+ }
+ }
+ }
+ if(!correspondingWindowFound) stopTrigger = YES;
}
- else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeInputField]) {
- if([[[NSApp mainWindow] firstResponder] isKindOfClass:[NSTextView class]])
- [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForInputField:aMenuItem];
+ if(!stopTrigger) {
+ if([[data objectAtIndex:1] isEqualToString:SPBundleScopeGeneral]) {
+ [[[NSApp delegate] onMainThread] executeBundleItemForApp:aMenuItem];
+ }
+ else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeDataTable]) {
+ if([[[[[NSApp mainWindow] firstResponder] class] description] isEqualToString:@"SPCopyTable"])
+ [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForDataTable:aMenuItem];
+ }
+ else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeInputField]) {
+ if([[[NSApp mainWindow] firstResponder] isKindOfClass:[NSTextView class]])
+ [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForInputField:aMenuItem];
+ }
}
}
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index b8656845..498b6a2a 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -3873,16 +3873,34 @@
NSMenuItem *aMenuItem = [[[NSMenuItem alloc] init] autorelease];
[aMenuItem setTag:0];
[aMenuItem setToolTip:[data objectAtIndex:0]];
- if([[data objectAtIndex:1] isEqualToString:SPBundleScopeGeneral]) {
- [[[NSApp delegate] onMainThread] executeBundleItemForApp:aMenuItem];
- }
- else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeDataTable]) {
- if([[[[[NSApp mainWindow] firstResponder] class] description] isEqualToString:@"SPCopyTable"])
- [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForDataTable:aMenuItem];
+
+ // For HTML output check if corresponding window already exists
+ BOOL stopTrigger = NO;
+ if([[data objectAtIndex:2] length]) {
+ BOOL correspondingWindowFound = NO;
+ NSString *uuid = [data objectAtIndex:2];
+ for(id win in [NSApp windows]) {
+ if([[[[win delegate] class] description] isEqualToString:@"SPBundleHTMLOutputController"]) {
+ if([[[win delegate] windowUUID] isEqualToString:uuid]) {
+ correspondingWindowFound = YES;
+ break;
+ }
+ }
+ }
+ if(!correspondingWindowFound) stopTrigger = YES;
}
- else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeInputField]) {
- if([[[NSApp mainWindow] firstResponder] isKindOfClass:[NSTextView class]])
- [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForInputField:aMenuItem];
+ if(!stopTrigger) {
+ if([[data objectAtIndex:1] isEqualToString:SPBundleScopeGeneral]) {
+ [[[NSApp delegate] onMainThread] executeBundleItemForApp:aMenuItem];
+ }
+ else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeDataTable]) {
+ if([[[[[NSApp mainWindow] firstResponder] class] description] isEqualToString:@"SPCopyTable"])
+ [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForDataTable:aMenuItem];
+ }
+ else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeInputField]) {
+ if([[[NSApp mainWindow] firstResponder] isKindOfClass:[NSTextView class]])
+ [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForInputField:aMenuItem];
+ }
}
}
diff --git a/Source/SPTextViewAdditions.m b/Source/SPTextViewAdditions.m
index 70548bf3..10f3f2e5 100644
--- a/Source/SPTextViewAdditions.m
+++ b/Source/SPTextViewAdditions.m
@@ -642,6 +642,7 @@
SPBundleHTMLOutputController *c = [[SPBundleHTMLOutputController alloc] init];
[c setWindowUUID:[cmdData objectForKey:SPBundleFileUUIDKey]];
[c displayHTMLContent:output withOptions:nil];
+ [[NSApp delegate] addHTMLOutputController:c];
}
}