aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/BundleHTMLOutput.xib8
-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
9 files changed, 123 insertions, 36 deletions
diff --git a/Interfaces/English.lproj/BundleHTMLOutput.xib b/Interfaces/English.lproj/BundleHTMLOutput.xib
index 5db10cdd..0aad6be0 100644
--- a/Interfaces/English.lproj/BundleHTMLOutput.xib
+++ b/Interfaces/English.lproj/BundleHTMLOutput.xib
@@ -60,12 +60,12 @@
<string key="NSWindowContentMinSize">{50, 50}</string>
<object class="NSView" key="NSWindowView" id="1006">
<reference key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
+ <int key="NSvFlags">4352</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="WebView" id="472558256">
<reference key="NSNextResponder" ref="1006"/>
- <int key="NSvFlags">274</int>
+ <int key="NSvFlags">4370</int>
<object class="NSMutableSet" key="NSDragTypes">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="set.sortedObjects">
@@ -98,12 +98,16 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <string>Sequel Pro BundleHTMLOutputWebKitDefaultFixedFontSize</string>
+ <string>Sequel Pro BundleHTMLOutputWebKitDefaultFontSize</string>
<string>Sequel Pro BundleHTMLOutputWebKitFixedFont</string>
<string>Sequel Pro BundleHTMLOutputWebKitMinimumFontSize</string>
<string>Sequel Pro BundleHTMLOutputWebKitStandardFont</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="12"/>
+ <integer value="12"/>
<string>Monaco</string>
<integer value="5"/>
<string>Lucida Grande</string>
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];
}
}