aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPBundleEditorController.h5
-rw-r--r--Source/SPBundleHTMLOutputController.m65
-rw-r--r--Source/SPDatabaseDocument.m49
-rw-r--r--Source/SPDatabaseViewController.m4
-rw-r--r--Source/SPEditorPreferencePane.m57
-rw-r--r--Source/SPTableContent.m34
6 files changed, 155 insertions, 59 deletions
diff --git a/Source/SPBundleEditorController.h b/Source/SPBundleEditorController.h
index 1c3c0dab..5ea1658f 100644
--- a/Source/SPBundleEditorController.h
+++ b/Source/SPBundleEditorController.h
@@ -29,8 +29,8 @@
@class SRRecorderControl, BWSplitView;
-@interface SPBundleEditorController : NSWindowController {
-
+@interface SPBundleEditorController : NSWindowController
+{
IBOutlet SPBundleCommandTextView *commandTextView;
IBOutlet SPOutlineView *commandsOutlineView;
IBOutlet NSTextField *authorTextField;
@@ -112,7 +112,6 @@
NSArray *shellVariableSuggestions;
NSMutableArray *deletedDefaultBundles;
-
}
- (IBAction)inputPopupButtonChanged:(id)sender;
diff --git a/Source/SPBundleHTMLOutputController.m b/Source/SPBundleHTMLOutputController.m
index 3c47964a..4b1567bb 100644
--- a/Source/SPBundleHTMLOutputController.m
+++ b/Source/SPBundleHTMLOutputController.m
@@ -24,6 +24,7 @@
#import "SPBundleHTMLOutputController.h"
#import "SPAlertSheets.h"
+#import "SPPrintAccessory.h"
@class WebScriptCallFrame;
@@ -178,7 +179,57 @@
- (IBAction)printDocument:(id)sender
{
- [[[[webView mainFrame] frameView] documentView] print:sender];
+
+ NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
+
+ NSSize paperSize = [printInfo paperSize];
+ NSRect printableRect = [printInfo imageablePageBounds];
+
+ // Calculate page margins
+ CGFloat marginL = printableRect.origin.x;
+ CGFloat marginR = paperSize.width - (printableRect.origin.x + printableRect.size.width);
+ CGFloat marginB = printableRect.origin.y;
+ CGFloat marginT = paperSize.height - (printableRect.origin.y + printableRect.size.height);
+
+ // Make sure margins are symetric and positive
+ CGFloat marginLR = MAX(0, MAX(marginL, marginR));
+ CGFloat marginTB = MAX(0, MAX(marginT, marginB));
+
+ // Set the margins
+ [printInfo setLeftMargin:marginLR];
+ [printInfo setRightMargin:marginLR];
+ [printInfo setTopMargin:marginTB];
+ [printInfo setBottomMargin:marginTB];
+
+ [printInfo setHorizontalPagination:NSFitPagination];
+ [printInfo setVerticalPagination:NSFitPagination];
+ [printInfo setVerticallyCentered:NO];
+
+ NSPrintOperation *op = [NSPrintOperation printOperationWithView:[[[webView mainFrame] frameView] documentView] printInfo:printInfo];
+
+ // Perform the print operation on a background thread
+ [op setCanSpawnSeparateThread:YES];
+
+ // Add the ability to select the orientation to print panel
+ NSPrintPanel *printPanel = [op printPanel];
+
+ [printPanel setOptions:[printPanel options] + NSPrintPanelShowsOrientation + NSPrintPanelShowsScaling + NSPrintPanelShowsPaperSize];
+
+ [op setPrintPanel:printPanel];
+
+ SPPrintAccessory *printAccessory = [[SPPrintAccessory alloc] initWithNibName:@"PrintAccessory" bundle:nil];
+
+ [printAccessory setPrintView:webView];
+ [printPanel addAccessoryController:printAccessory];
+
+ [[NSPageLayout pageLayout] addAccessoryController:printAccessory];
+ [printAccessory release];
+
+ [op runOperationModalForWindow:[self window]
+ delegate:self
+ didRunSelector:nil
+ contextInfo:nil];
+
}
- (void)showSourceCode
@@ -263,6 +314,7 @@
- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener
{
+
NSInteger navigationType = [[actionInformation objectForKey:WebActionNavigationTypeKey] integerValue];
// sequelpro:// handler
@@ -270,9 +322,14 @@
[[NSApp delegate] handleEventWithURL:[request URL]];
[listener ignore];
}
- // file://a_file_path opens the reveal the file in Finder
- else if([[[request URL] scheme] isEqualToString:@"file"] && navigationType == WebNavigationTypeLinkClicked) {
- [[NSWorkspace sharedWorkspace] selectFile:[[[request mainDocumentURL] absoluteString] substringFromIndex:6] inFileViewerRootedAtPath:nil];
+ // sp-reveal-file://a_file_path reveals the file in Finder
+ else if([[[request URL] scheme] isEqualToString:@"sp-reveal-file"] && navigationType == WebNavigationTypeLinkClicked) {
+ [[NSWorkspace sharedWorkspace] selectFile:[[[request mainDocumentURL] absoluteString] substringFromIndex:16] inFileViewerRootedAtPath:nil];
+ [listener ignore];
+ }
+ // sp-open-file://a_file_path opens the file with the default
+ else if([[[request URL] scheme] isEqualToString:@"sp-open-file"] && navigationType == WebNavigationTypeLinkClicked) {
+ [[NSWorkspace sharedWorkspace] openFile:[[[request mainDocumentURL] absoluteString] substringFromIndex:14]];
[listener ignore];
}
else {
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index e122205e..1d4b4fc6 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -835,12 +835,12 @@
if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil;
selectedDatabase = [[NSString alloc] initWithString:dbName];
[chooseDatabaseButton selectItemWithTitle:selectedDatabase];
- [[self onMainThread] updateWindowTitle:self];
+ [self updateWindowTitle:self];
}
} else {
if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil;
[chooseDatabaseButton selectItemAtIndex:0];
- [[self onMainThread] updateWindowTitle:self];
+ [self updateWindowTitle:self];
}
}
@@ -871,30 +871,31 @@
*/
- (void)toggleConsole:(id)sender
{
- BOOL isConsoleVisible = [[[SPQueryController sharedQueryController] window] isVisible];
- // If the Console window is not visible data are not reloaded (for speed).
- // Due to that update list if user opens the Console window.
- if(!isConsoleVisible) {
- [[SPQueryController sharedQueryController] updateEntries];
- }
+ // Toggle Console will show the Console window if it isn't visible or if it isn't
+ // the front most window and hide it if it is the front most window
+ if ([[[SPQueryController sharedQueryController] window] isVisible]
+ && [[[NSApp keyWindow] windowController] isKindOfClass:[SPQueryController class]])
+
+ [[[SPQueryController sharedQueryController] window] setIsVisible:NO];
+ else
+
+ [self showConsole:nil];
- // Show or hide the console
- [[[SPQueryController sharedQueryController] window] setIsVisible:(!isConsoleVisible)];
}
/**
- * Brings the console to the fron
+ * Brings the console to the front
*/
- (void)showConsole:(id)sender
{
- BOOL isConsoleVisible = [[[SPQueryController sharedQueryController] window] isVisible];
- if (!isConsoleVisible) {
- [self toggleConsole:sender];
- } else {
- [[[SPQueryController sharedQueryController] window] makeKeyAndOrderFront:self];
- }
+ // If the Console window is not visible data are not reloaded (for speed).
+ // Due to that update list if user opens the Console window.
+ if(![[[SPQueryController sharedQueryController] window] isVisible])
+ [[SPQueryController sharedQueryController] updateEntries];
+
+ [[[SPQueryController sharedQueryController] window] makeKeyAndOrderFront:self];
}
@@ -3209,7 +3210,7 @@
// Show/hide console
if ([menuItem action] == @selector(toggleConsole:)) {
- [menuItem setTitle:([[[SPQueryController sharedQueryController] window] isVisible]) ? NSLocalizedString(@"Hide Console", @"hide console") : NSLocalizedString(@"Show Console", @"show console")];
+ [menuItem setTitle:([[[SPQueryController sharedQueryController] window] isVisible] && [[[NSApp keyWindow] windowController] isKindOfClass:[SPQueryController class]]) ? NSLocalizedString(@"Hide Console", @"hide console") : NSLocalizedString(@"Show Console", @"show console")];
}
// Clear console
@@ -3305,6 +3306,10 @@
*/
- (void) updateWindowTitle:(id)sender
{
+
+ // Ensure a call on the main thread
+ if (![NSThread isMainThread]) return [[self onMainThread] updateWindowTitle:sender];
+
NSMutableString *tabTitle;
NSMutableString *windowTitle;
SPDatabaseDocument *frontTableDocument = [parentWindowController selectedTableDocument];
@@ -4543,7 +4548,7 @@
- (void)connectionControllerConnectAttemptFailed:(id)controller
{
// Reset the window title
- [[self onMainThread] updateWindowTitle:self];
+ [self updateWindowTitle:self];
}
#pragma mark -
@@ -5506,7 +5511,7 @@
[tablesListInstance setConnection:mySQLConnection];
[tableDumpInstance setConnection:mySQLConnection];
- [[self onMainThread] updateWindowTitle:self];
+ [self updateWindowTitle:self];
}
/**
@@ -5545,7 +5550,7 @@
[tablesListInstance setConnection:mySQLConnection];
[tableDumpInstance setConnection:mySQLConnection];
- [[self onMainThread] updateWindowTitle:self];
+ [self updateWindowTitle:self];
}
/**
@@ -5602,7 +5607,7 @@
[tableDumpInstance setConnection:mySQLConnection];
// Update the window title
- [[self onMainThread] updateWindowTitle:self];
+ [self updateWindowTitle:self];
// Add a history entry
if (!historyStateChanging) {
diff --git a/Source/SPDatabaseViewController.m b/Source/SPDatabaseViewController.m
index e95b6b41..a7867c53 100644
--- a/Source/SPDatabaseViewController.m
+++ b/Source/SPDatabaseViewController.m
@@ -287,7 +287,7 @@
triggersLoaded = NO;
// Update the window title
- [[self onMainThread] updateWindowTitle:self];
+ [self updateWindowTitle:self];
// Add a history entry
[spHistoryControllerInstance updateHistoryEntries];
@@ -391,7 +391,7 @@
NSString *tableEncoding = nil;
// Update the window title
- [[self onMainThread] updateWindowTitle:self];
+ [self updateWindowTitle:self];
// Reset table information caches
[tableDataInstance resetAllData];
diff --git a/Source/SPEditorPreferencePane.m b/Source/SPEditorPreferencePane.m
index 6176c742..50388e8a 100644
--- a/Source/SPEditorPreferencePane.m
+++ b/Source/SPEditorPreferencePane.m
@@ -29,6 +29,16 @@
#import "SPAlertSheets.h"
#import "SPCategoryAdditions.h"
+// Constants
+static const NSString *SPImportColorScheme = @"ImportColorScheme";
+static const NSString *SPExportColorScheme = @"ExportColorScheme";
+static const NSString *SPSaveColorScheme = @"SaveColorScheme";
+static const NSString *SPDefaultColorSchemeName = @"Default";
+static const NSString *SPDefaultColorSchemeNameLC = @"default";
+static const NSString *SPCustomColorSchemeName = @"User-defined";
+static const NSString *SPCustomColorSchemeNameLC = @"user-defined";
+static const NSString *SPDefaultExportColourSchemeName = @"MyTheme";
+
@interface SPEditorPreferencePane (PrivateAPI)
- (BOOL)_checkForUnsavedTheme;
@@ -38,7 +48,6 @@
@end
-
@implementation SPEditorPreferencePane
#pragma mark -
@@ -127,11 +136,11 @@
[panel setCanCreateDirectories:YES];
[panel beginSheetForDirectory:nil
- file:[@"MyTheme" stringByAppendingPathExtension:SPColorThemeFileExtension]
+ file:[SPDefaultExportColourSchemeName stringByAppendingPathExtension:SPColorThemeFileExtension]
modalForWindow:[[self view] window]
modalDelegate:self
didEndSelector:@selector(panelDidEnd:returnCode:contextInfo:)
- contextInfo:@"exportColorScheme"];
+ contextInfo:SPExportColorScheme];
}
- (IBAction)importColorScheme:(id)sender
@@ -151,7 +160,7 @@
modalForWindow:[[self view] window]
modalDelegate:self
didEndSelector:@selector(panelDidEnd:returnCode:contextInfo:)
- contextInfo:@"importColorScheme"];
+ contextInfo:SPImportColorScheme];
}
@@ -178,7 +187,7 @@
modalForWindow:[[self view] window]
modalDelegate:self
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
- contextInfo:@"saveTheme"];
+ contextInfo:SPSaveColorScheme];
}
@@ -224,7 +233,7 @@
// Refresh current color theme setting name
if ([[[prefs objectForKey:SPCustomQueryEditorThemeName] lowercaseString] isEqualToString:[[editThemeListItems objectAtIndex:[editThemeListTable selectedRow]] lowercaseString]]) {
- [prefs setObject:@"User-defined" forKey:SPCustomQueryEditorThemeName];
+ [prefs setObject:SPCustomColorSchemeName forKey:SPCustomQueryEditorThemeName];
}
if (editThemeListItems) [editThemeListItems release], editThemeListItems = nil;
@@ -271,7 +280,7 @@
[[NSColorPanel sharedColorPanel] close];
- [prefs setObject:@"Default" forKey:SPCustomQueryEditorThemeName];
+ [prefs setObject:SPDefaultColorSchemeName forKey:SPCustomQueryEditorThemeName];
[prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor colorWithDeviceRed:0.000 green:0.455 blue:0.000 alpha:1.000]] forKey:SPCustomQueryEditorCommentColor];
[prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor colorWithDeviceRed:0.769 green:0.102 blue:0.086 alpha:1.000]] forKey:SPCustomQueryEditorQuoteColor];
[prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor colorWithDeviceRed:0.200 green:0.250 blue:1.000 alpha:1.000]] forKey:SPCustomQueryEditorSQLKeywordColor];
@@ -379,7 +388,7 @@
return;
}
- if ([[[prefs objectForKey:SPCustomQueryEditorThemeName] lowercaseString] isEqualToString:@"user-defined"]) {
+ if ([[[prefs objectForKey:SPCustomQueryEditorThemeName] lowercaseString] isEqualToString:SPCustomColorSchemeNameLC]) {
[colorThemeName setHidden:YES];
[colorThemeNameLabel setHidden:YES];
@@ -388,7 +397,7 @@
NSString *currentThemeName = [[prefs objectForKey:SPCustomQueryEditorThemeName] lowercaseString];
- if ([currentThemeName isEqualToString:@"default"]) {
+ if ([currentThemeName isEqualToString:SPDefaultColorSchemeNameLC]) {
[colorThemeName setHidden:NO];
[colorThemeNameLabel setHidden:NO];
@@ -412,7 +421,7 @@
return;
}
else {
- [prefs setObject:@"User-defined" forKey:SPCustomQueryEditorThemeName];
+ [prefs setObject:SPCustomColorSchemeName forKey:SPCustomQueryEditorThemeName];
[colorThemeName setHidden:YES];
[colorThemeNameLabel setHidden:YES];
@@ -456,7 +465,7 @@
[prefs setObject:[NSArchiver archivedDataWithRootObject:[sender color]] forKey:[editorColors objectAtIndex:colorRow]];
[colorSettingTableView reloadData];
- [prefs setObject:@"User-defined" forKey:SPCustomQueryEditorThemeName];
+ [prefs setObject:SPCustomColorSchemeName forKey:SPCustomQueryEditorThemeName];
[self updateDisplayColorThemeName];
}
@@ -487,7 +496,7 @@
[[sheet window] orderOut:nil];
}
- if ([contextInfo isEqualToString:@"saveTheme"]) {
+ if ([contextInfo isEqualToString:SPSaveColorScheme]) {
if (returnCode == NSOKButton) {
NSFileManager *fm = [NSFileManager defaultManager];
@@ -510,15 +519,15 @@
- (void)panelDidEnd:(NSSavePanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo
{
- if ([contextInfo isEqualToString:@"exportColorScheme"]) {
+ if ([contextInfo isEqualToString:SPExportColorScheme]) {
if (returnCode == NSOKButton) {
[self _saveColorThemeAtPath:[panel filename]];
}
}
- else if ([contextInfo isEqualToString:@"importColorScheme"]) {
+ else if ([contextInfo isEqualToString:SPImportColorScheme]) {
if (returnCode == NSOKButton) {
if ([self _loadColorSchemeFromFile:[[panel filenames] objectAtIndex:0]]) {
- [prefs setObject:@"User-defined" forKey:SPCustomQueryEditorThemeName];
+ [prefs setObject:SPCustomColorSchemeName forKey:SPCustomQueryEditorThemeName];
[self updateDisplayColorThemeName];
}
}
@@ -560,7 +569,7 @@
NSString *newName = (NSString*)anObject;
// Check for non-valid names
- if (![newName length] || [[newName lowercaseString] isEqualToString:@"default"] || [[newName lowercaseString] isEqualToString:@"user-defined"]) {
+ if (![newName length] || [[newName lowercaseString] isEqualToString:SPDefaultColorSchemeNameLC] || [[newName lowercaseString] isEqualToString:SPCustomColorSchemeNameLC]) {
NSBeep();
[editThemeListTable reloadData];
return;
@@ -673,7 +682,7 @@
if (field == enterNameInputField) {
NSString *name = [[enterNameInputField stringValue] lowercaseString];
- if (![name length] || [name isEqualToString:@"default"] || [name isEqualToString:@"user-defined"]) {
+ if (![name length] || [name isEqualToString:SPDefaultColorSchemeNameLC] || [name isEqualToString:SPCustomColorSchemeNameLC]) {
[themeNameSaveButton setEnabled:NO];
}
else {
@@ -733,17 +742,21 @@
- (BOOL)_checkForUnsavedTheme
{
- if (![prefs objectForKey:SPCustomQueryEditorThemeName] || [[[prefs objectForKey:SPCustomQueryEditorThemeName] lowercaseString] isEqualToString:@"user-defined"]) {
+ if (![prefs objectForKey:SPCustomQueryEditorThemeName] || [[[prefs objectForKey:SPCustomQueryEditorThemeName] lowercaseString] isEqualToString:SPCustomColorSchemeNameLC]) {
[[NSColorPanel sharedColorPanel] close];
SPBeginWaitingAlertSheet(@"title",
- NSLocalizedString(@"Proceed", @"proceed button"), NSLocalizedString(@"Cancel", @"cancel button"), nil,
- NSWarningAlertStyle, [[self view] window], self,
+ NSLocalizedString(@"Proceed", @"proceed button"),
+ NSLocalizedString(@"Cancel", @"cancel button"),
+ nil,
+ NSWarningAlertStyle,
+ [[self view] window],
+ self,
@selector(checkForUnsavedThemeDidEndSheet:returnCode:contextInfo:),
nil,
- NSLocalizedString(@"Warning", @"warning"),
- NSLocalizedString(@"Current color theme is unsaved. Do you want to proceed without saving it?", @"Current color theme is unsaved. Do you want to proceed without saving it message"),
+ NSLocalizedString(@"Unsaved Theme", @"unsaved theme message"),
+ NSLocalizedString(@"The current color theme is unsaved. Do you want to proceed without saving it?", @"unsaved theme informative message"),
checkForUnsavedThemeSheetStatus
);
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index b136d90a..7acc0187 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -244,14 +244,14 @@
// Scroll the viewport to the saved location
selectionViewportToRestore.size = [tableContentView visibleRect].size;
- [tableContentView scrollRectToVisible:selectionViewportToRestore];
+ [[tableContentView onMainThread] scrollRectToVisible:selectionViewportToRestore];
}
// Restore selection indexes if appropriate
if (selectionIndexToRestore) {
BOOL previousTableRowsSelectable = tableRowsSelectable;
tableRowsSelectable = YES;
- [tableContentView selectRowIndexes:selectionIndexToRestore byExtendingSelection:NO];
+ [[tableContentView onMainThread] selectRowIndexes:selectionIndexToRestore byExtendingSelection:NO];
tableRowsSelectable = previousTableRowsSelectable;
}
@@ -758,7 +758,7 @@
[self updateCountText];
// Update pagination
- [self updatePaginationState];
+ [[self onMainThread] updatePaginationState];
// Retrieve and cache the column definitions for editing views
if (cqColumnDefinition) [cqColumnDefinition release];
@@ -784,7 +784,7 @@
} else {
// Trigger a full reload if required
if (fullTableReloadRequired) [self reloadTable:self];
- [filterTableWindow setTitle:NSLocalizedString(@"Filter", @"filter label")];
+ [[filterTableWindow onMainThread] setTitle:NSLocalizedString(@"Filter", @"filter label")];
}
}
@@ -1467,6 +1467,7 @@
/**
* Update the state of the pagination buttons and text.
+ * This function is not thread-safe and should be called on the main thread.
*/
- (void) updatePaginationState
{
@@ -2062,6 +2063,28 @@
[tempRow addObject:NSLocalizedString(@"(not loaded)", @"value shown for hidden blob and text fields")];
else if([o isKindOfClass:[NSString class]])
[tempRow addObject:[o description]];
+ else if([o isKindOfClass:[MCPGeometryData class]]) {
+ SPGeometryDataView *v = [[SPGeometryDataView alloc] initWithCoordinates:[o coordinates]];
+ NSImage *image = [v thumbnailImage];
+ NSString *imageStr = @"";
+ if(image) {
+ NSString *maxSizeValue = @"WIDTH";
+ NSInteger imageWidth = [image size].width;
+ NSInteger imageHeight = [image size].height;
+ if(imageHeight > imageWidth) {
+ maxSizeValue = @"HEIGHT";
+ imageWidth = imageHeight;
+ }
+ if (imageWidth > 100) imageWidth = 100;
+ imageStr = [NSString stringWithFormat:
+ @"<BR><IMG %@='%ld' SRC=\"data:image/auto;base64,%@\">",
+ maxSizeValue,
+ (long)imageWidth,
+ [[image TIFFRepresentationUsingCompression:NSTIFFCompressionJPEG factor:0.01] base64EncodingWithLineLength:0]];
+ }
+ [v release];
+ [tempRow addObject:[NSString stringWithFormat:@"%@%@", [o wktString], imageStr]];
+ }
else {
NSImage *image = [[NSImage alloc] initWithData:o];
if (image) {
@@ -2476,8 +2499,7 @@
for (i = 0; i < [rowFieldsToSave count]; i++) {
if (i) [queryString appendString:@", "];
[queryString appendFormat:@"%@ = %@",
- [NSArrayObjectAtIndex(rowFieldsToSave, i) backtickQuotedString],
- NSArrayObjectAtIndex(rowValuesToSave, i)];
+ [NSArrayObjectAtIndex(rowFieldsToSave, i) backtickQuotedString], NSArrayObjectAtIndex(rowValuesToSave, i)];
}
[queryString appendFormat:@" WHERE %@", [self argumentForRow:-2]];
}