aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStuart Connolly <stuart02@gmail.com>2014-01-16 23:50:30 +0000
committerStuart Connolly <stuart02@gmail.com>2014-01-16 23:50:30 +0000
commitf3bad7a571142a284ac3e983530bd9d42ac7c7e2 (patch)
treed0731716768549153a5fe8d36c688ea055c47ffa /Source
parentf8a9ce93bcf9ee3db418c371106c9eb87d8b61d0 (diff)
downloadsequelpro-f3bad7a571142a284ac3e983530bd9d42ac7c7e2.tar.gz
sequelpro-f3bad7a571142a284ac3e983530bd9d42ac7c7e2.tar.bz2
sequelpro-f3bad7a571142a284ac3e983530bd9d42ac7c7e2.zip
Fix deprecation warnings.
Diffstat (limited to 'Source')
-rw-r--r--Source/SPBundleHTMLOutputController.m74
-rw-r--r--Source/SPContentFilterManager.m67
-rw-r--r--Source/SPQueryFavoriteManager.m35
3 files changed, 105 insertions, 71 deletions
diff --git a/Source/SPBundleHTMLOutputController.m b/Source/SPBundleHTMLOutputController.m
index e3def2db..773d737e 100644
--- a/Source/SPBundleHTMLOutputController.m
+++ b/Source/SPBundleHTMLOutputController.m
@@ -36,6 +36,8 @@
#import "SPAppController.h"
#import "SPBundleCommandRunner.h"
+static NSString *SPSaveDocumentAction = @"SPSaveDocument";
+
@class WebScriptCallFrame;
#pragma mark -
@@ -176,14 +178,13 @@
*/
- (void)sheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo
{
-
// Order out current sheet to suppress overlapping of sheets
if ([sheet respondsToSelector:@selector(orderOut:)])
[sheet orderOut:nil];
else if ([sheet respondsToSelector:@selector(window)])
[[sheet window] orderOut:nil];
- if([contextInfo isEqualToString:@"saveDocument"]) {
+ if ([contextInfo isEqualToString:SPSaveDocumentAction]) {
if (returnCode == NSOKButton) {
NSString *sourceCode = [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('html')[0].outerHTML"];
NSError *err = nil;
@@ -191,11 +192,10 @@
atomically:YES
encoding:NSUTF8StringEncoding
error:&err];
- if(err != nil) {
+ if (err != nil) {
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [self window], self, nil, nil,
[NSString stringWithFormat:@"%@", [err localizedDescription]]);
}
-
}
}
}
@@ -252,42 +252,52 @@
delegate:self
didRunSelector:nil
contextInfo:nil];
-
}
- (void)showSourceCode
{
NSString *sourceCode = [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('html')[0].outerHTML"];
+
SPBundleHTMLOutputController *c = [[SPBundleHTMLOutputController alloc] init];
+
[c displayHTMLContent:[NSString stringWithFormat:@"<pre>%@</pre>", [sourceCode HTMLEscapeString]] withOptions:nil];
+
[[NSApp delegate] addHTMLOutputController:c];
}
- (void)saveDocument
{
NSSavePanel *panel = [NSSavePanel savePanel];
-
- [panel setAllowedFileTypes:[NSArray arrayWithObject:@"html"]];
+
+ [panel setNameFieldStringValue:@"output"];
+ [panel setAllowedFileTypes:@[@"html"]];
[panel setExtensionHidden:NO];
[panel setAllowsOtherFileTypes:YES];
[panel setCanSelectHiddenExtension:YES];
[panel setCanCreateDirectories:YES];
- [panel beginSheetForDirectory:nil file:@"output" modalForWindow:[self window] modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"saveDocument"];
+ [panel beginSheetModalForWindow:[self window] completionHandler:^(NSInteger returnCode)
+ {
+ [self sheetDidEnd:panel returnCode:returnCode contextInfo:SPSaveDocumentAction];
+ }];
}
-
#pragma mark -
- (void)windowWillClose:(NSNotification *)notification
{
[[webView mainFrame] loadHTMLString:@"<html></html>" baseURL:nil];
+
[webView close];
+
[self setInitHTMLSourceString:@""];
+
windowUUID = @"";
docUUID = @"";
+
[[NSApp delegate] removeHTMLOutputController:self];
+
[self release];
}
@@ -333,12 +343,12 @@
- (void)webViewShow:(WebView *)sender
{
id newWebView = [[NSDocumentController sharedDocumentController] documentForWindow:[sender window]];
+
[newWebView showWindows];
}
- (void)webView:(WebView *)aWebView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener
{
-
NSInteger navigationType = [[actionInformation objectForKey:WebActionNavigationTypeKey] integerValue];
// sequelpro:// handler
@@ -369,9 +379,7 @@
default:
[listener use];
}
-
}
-
}
- (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame
@@ -436,7 +444,6 @@
- (void)webView:(WebView *)sender windowScriptObjectAvailable:(WebScriptObject *)windowScriptObject
{
-
[windowScriptObject setValue:self forKey:@"system"];
[webView setScriptDebugDelegate:self];
}
@@ -462,53 +469,68 @@
return @"";
}
-+ (BOOL)isSelectorExcludedFromWebScript:(SEL)selector {
++ (BOOL)isSelectorExcludedFromWebScript:(SEL)selector
+{
if (selector == @selector(run:)) {
return NO;
}
+
if (selector == @selector(getShellEnvironmentForName:)) {
return NO;
}
+
if (selector == @selector(insertText:)) {
return NO;
}
+
if (selector == @selector(setText:)) {
return NO;
}
+
if (selector == @selector(setSelectedTextRange:)) {
return NO;
}
+
if (selector == @selector(makeHTMLOutputWindowKeyWindow)) {
return NO;
}
+
if (selector == @selector(closeHTMLOutputWindow)) {
return NO;
}
+
if (selector == @selector(suppressExceptionAlert)) {
return NO;
}
+
return YES;
}
-+ (BOOL)isKeyExcludedFromWebScript:(const char *)property {
++ (BOOL)isKeyExcludedFromWebScript:(const char *)property
+{
if (strcmp(property, "run") == 0) {
return NO;
}
+
if (strcmp(property, "getShellEnvironmentForName") == 0) {
return NO;
}
+
if (strcmp(property, "insertText") == 0) {
return NO;
}
+
if (strcmp(property, "setText") == 0) {
return NO;
}
+
if (strcmp(property, "setSelectedTextRange") == 0) {
return NO;
}
if (strcmp(property, "makeHTMLOutputWindowKeyWindow") == 0) {
return NO;
}
+
return YES;
}
@@ -579,10 +601,12 @@
- (void)insertText:(NSString*)text
{
id firstResponder = [[NSApp keyWindow] firstResponder];
- if([firstResponder isKindOfClass:[NSTextView class]]) {
+
+ if ([firstResponder isKindOfClass:[NSTextView class]]) {
[firstResponder insertText:text];
return;
}
+
NSBeep();
}
@@ -593,11 +617,13 @@
- (void)setText:(NSString*)text
{
id firstResponder = [[NSApp keyWindow] firstResponder];
- if([firstResponder isKindOfClass:[NSTextView class]]) {
+
+ if ([firstResponder isKindOfClass:[NSTextView class]]) {
[firstResponder setSelectedRange:NSMakeRange(0, [[firstResponder string] length])];
[firstResponder insertText:text];
return;
}
+
NSBeep();
}
@@ -608,13 +634,15 @@
- (void)setSelectedTextRange:(NSString*)range
{
id firstResponder = [[NSApp keyWindow] firstResponder];
- if([firstResponder isKindOfClass:[NSTextView class]]) {
+
+ if ([firstResponder isKindOfClass:[NSTextView class]]) {
NSRange theRange = NSIntersectionRange(NSRangeFromString(range), NSMakeRange(0, [[firstResponder string] length]));
if(theRange.location != NSNotFound) {
[firstResponder setSelectedRange:theRange];
}
return;
}
+
NSBeep();
}
@@ -633,7 +661,6 @@
*/
- (NSString *)run:(id)call
{
-
NSError *err = nil;
NSString *command = nil;
NSString *uuid = nil;
@@ -703,21 +730,22 @@
NSBeep();
return @"";
}
-
}
#pragma mark -
-#pragma mark multi-touch trackpad support
+#pragma mark Multi-touch trackpad support
/**
* Trackpad two-finger zooming gesture for in/decreasing the font size
*/
- (void)magnifyWithEvent:(NSEvent *)anEvent
{
- if([anEvent deltaZ]>2.0)
+ if ([anEvent deltaZ] > 2.0) {
[webView makeTextLarger:nil];
- else if([anEvent deltaZ]<-2.0)
+ }
+ else if ([anEvent deltaZ] < -2.0) {
[webView makeTextSmaller:nil];
+ }
}
@end
diff --git a/Source/SPContentFilterManager.m b/Source/SPContentFilterManager.m
index 515dead0..0b4a376e 100644
--- a/Source/SPContentFilterManager.m
+++ b/Source/SPContentFilterManager.m
@@ -40,6 +40,8 @@
#import "SPConnectionController.h"
#import "SPSplitView.h"
+static NSString *SPExportFilterAction = @"SPExportFilterAction";
+
#define SP_MULTIPLE_SELECTION_PLACEHOLDER_STRING NSLocalizedString(@"[multiple selection]", @"[multiple selection]")
#define SP_NO_SELECTION_PLACEHOLDER_STRING NSLocalizedString(@"[no selection]", @"[no selection]")
#define SP_NAME_REQUIRED_PLACEHOLDER_STRING NSLocalizedString(@"[name required]", @"displayed when new content filter has empty Name field (ContentFilterManager)")
@@ -63,6 +65,7 @@
if (managerDelegate == nil) {
NSBeep();
NSLog(@"ContentFilterManager was called without a delegate.");
+
return nil;
}
@@ -82,7 +85,6 @@
*/
- (void)awakeFromNib
{
-
// Set up the split view
[contentFilterSplitView setMinSize:120.f ofSubviewAtIndex:0];
[contentFilterSplitView setMaxSize:245.f ofSubviewAtIndex:0];
@@ -98,11 +100,15 @@
#ifndef SP_CODA /* prefs access */
// Build data source for global content filter (as mutable copy! otherwise each
// change will be stored in the prefs at once)
- if([[prefs objectForKey:SPContentFilters] objectForKey:filterType]) {
- for(id fav in [[prefs objectForKey:SPContentFilters] objectForKey:filterType]) {
+ if ([[prefs objectForKey:SPContentFilters] objectForKey:filterType]) {
+ for (id fav in [[prefs objectForKey:SPContentFilters] objectForKey:filterType])
+ {
id f = [[fav mutableCopy] autorelease];
- if([f objectForKey:@"ConjunctionLabels"])
+
+ if ([f objectForKey:@"ConjunctionLabels"]) {
[f setObject:[[f objectForKey:@"ConjunctionLabels"] objectAtIndex:0] forKey:@"ConjunctionLabel"];
+ }
+
[contentFilters addObject:f];
}
}
@@ -114,7 +120,7 @@
@"", @"Clause",
nil]];
- if([[SPQueryController sharedQueryController] contentFilterForFileURL:delegatesFileURL]) {
+ if ([[SPQueryController sharedQueryController] contentFilterForFileURL:delegatesFileURL]) {
id filters = [[SPQueryController sharedQueryController] contentFilterForFileURL:delegatesFileURL];
if([filters objectForKey:filterType])
for(id fav in [filters objectForKey:filterType])
@@ -122,7 +128,6 @@
}
#endif
-
// Select the first query if any
NSUInteger i = 0;
@@ -162,19 +167,17 @@
- (NSMutableArray *)contentFilterForFileURL:(NSURL *)fileURL
{
NSMutableArray *filters = [NSMutableArray array];
- NSString *fileURLstring;
- if(fileURL == nil)
- fileURLstring = @"";
- else
- fileURLstring = [fileURL absoluteString];
+ NSString *fileURLstring = (fileURL == nil) ? @"" : [fileURL absoluteString];
NSUInteger i = 0;
// Look for the header specified by fileURL
- while(i<[contentFilters count]) {
- if ([[contentFilters objectAtIndex:i] objectForKey:@"headerOfFileURL"]
- && [[[contentFilters objectAtIndex:i] objectForKey:@"headerOfFileURL"] isEqualToString:fileURLstring]) {
+ while (i<[contentFilters count])
+ {
+ if ([[contentFilters objectAtIndex:i] objectForKey:@"headerOfFileURL"] &&
+ [[[contentFilters objectAtIndex:i] objectForKey:@"headerOfFileURL"] isEqualToString:fileURLstring])
+ {
i++;
break;
}
@@ -185,8 +188,8 @@
// Take all content filters until the next header or end of all content filters
NSUInteger numOfArgs;
- for ( ; i<[contentFilters count]; i++) {
-
+ for (; i < [contentFilters count]; i++)
+ {
if(![[contentFilters objectAtIndex:i] objectForKey:@"headerOfFileURL"]) {
NSMutableDictionary *d = [[NSMutableDictionary alloc] init];
[d setDictionary:[contentFilters objectAtIndex:i]];
@@ -205,9 +208,10 @@
[d setObject:[NSNumber numberWithInteger:numOfArgs] forKey:@"NumberOfArguments"];
[filters addObject:d];
[d release];
- } else
+ }
+ else {
break;
-
+ }
}
return filters;
@@ -337,7 +341,10 @@
[panel setCanSelectHiddenExtension:YES];
[panel setCanCreateDirectories:YES];
- [panel beginSheetForDirectory:nil file:nil modalForWindow:[self window] modalDelegate:self didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:@"exportFilter"];
+ [panel beginSheetModalForWindow:[self window] completionHandler:^(NSInteger returnCode)
+ {
+ [self savePanelDidEnd:panel returnCode:returnCode contextInfo:SPExportFilterAction];
+ }];
#endif
}
@@ -348,19 +355,18 @@
{
#ifndef SP_CODA
NSOpenPanel *panel = [NSOpenPanel openPanel];
+
[panel setCanSelectHiddenExtension:YES];
[panel setDelegate:self];
[panel setCanChooseDirectories:NO];
[panel setAllowsMultipleSelection:NO];
- // [panel setResolvesAliases:YES];
-
- [panel beginSheetForDirectory:nil
- file:@""
- types:[NSArray arrayWithObjects:SPFileExtensionDefault, nil]
- modalForWindow:[self window]
- modalDelegate:self
- didEndSelector:@selector(importPanelDidEnd:returnCode:contextInfo:)
- contextInfo:NULL];
+
+ [panel setAllowedFileTypes:@[SPFileExtensionDefault]];
+
+ [panel beginSheetModalForWindow:[self window] completionHandler:^(NSInteger returnCode)
+ {
+ [self importPanelDidEnd:panel returnCode:returnCode contextInfo:nil];
+ }];
#endif
}
@@ -377,7 +383,6 @@
*/
- (IBAction)closeContentFilterManagerSheet:(id)sender
{
-
[NSApp endSheet:[self window] returnCode:0];
[[self window] orderOut:self];
@@ -404,11 +409,9 @@
for(id doc in [[NSApp delegate] orderedDocuments])
if([[doc valueForKeyPath:@"tableContentInstance"] respondsToSelector:@selector(setCompareTypes:)])
[[doc valueForKeyPath:@"tableContentInstance"] setCompareTypes:nil];
-
#endif
}
-
}
/**
@@ -919,7 +922,7 @@
{
#ifndef SP_CODA
- if([contextInfo isEqualToString:@"exportFilter"]) {
+ if([contextInfo isEqualToString:SPExportFilterAction]) {
if (returnCode == NSOKButton) {
// Build a SPF with format = "content filters"
diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m
index 32563964..0f5b68ff 100644
--- a/Source/SPQueryFavoriteManager.m
+++ b/Source/SPQueryFavoriteManager.m
@@ -321,8 +321,13 @@
[panel setAccessoryView:[SPEncodingPopupAccessory encodingAccessory:[prefs integerForKey:SPLastSQLFileEncoding] includeDefaultEntry:NO encodingPopUp:&encodingPopUp]];
[encodingPopUp setEnabled:YES];
-
- [panel beginSheetForDirectory:nil file:[favoriteNameTextField stringValue] modalForWindow:[self window] modalDelegate:self didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:@"saveQuery"];
+
+ [panel setNameFieldStringValue:[favoriteNameTextField stringValue]];
+
+ [panel beginSheetModalForWindow:[self window] completionHandler:^(NSInteger returnCode)
+ {
+ [self savePanelDidEnd:panel returnCode:returnCode contextInfo:@"saveQuery"];
+ }];
#endif
}
@@ -338,7 +343,10 @@
[panel setCanSelectHiddenExtension:YES];
[panel setCanCreateDirectories:YES];
- [panel beginSheetForDirectory:nil file:nil modalForWindow:[self window] modalDelegate:self didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:@"exportFavorites"];
+ [panel beginSheetModalForWindow:[self window] completionHandler:^(NSInteger returnCode)
+ {
+ [self savePanelDidEnd:panel returnCode:returnCode contextInfo:@"exportFavorites"];
+ }];
#endif
}
@@ -346,19 +354,18 @@
{
#ifndef SP_CODA
NSOpenPanel *panel = [NSOpenPanel openPanel];
+
[panel setCanSelectHiddenExtension:YES];
[panel setDelegate:self];
[panel setCanChooseDirectories:NO];
[panel setAllowsMultipleSelection:NO];
- // [panel setResolvesAliases:YES];
-
- [panel beginSheetForDirectory:nil
- file:@""
- types:[NSArray arrayWithObjects:SPFileExtensionDefault, SPFileExtensionSQL, nil]
- modalForWindow:[self window]
- modalDelegate:self
- didEndSelector:@selector(importPanelDidEnd:returnCode:contextInfo:)
- contextInfo:NULL];
+
+ [panel setAllowedFileTypes:@[SPFileExtensionDefault, SPFileExtensionSQL]];
+
+ [panel beginSheetModalForWindow:[self window] completionHandler:^(NSInteger returnCode)
+ {
+ [self importPanelDidEnd:panel returnCode:returnCode contextInfo:NULL];
+ }];
#endif
}
@@ -372,7 +379,6 @@
*/
- (IBAction)insertPlaceholder:(id)sender
{
-
// Look up the sender's tag to determine the placeholder to insert.
// Note that tag values alter behaviour slightly - see below.
NSDictionary *lookupTable = [NSDictionary dictionaryWithObjectsAndKeys:
@@ -476,8 +482,6 @@
for(id doc in [[NSApp delegate] orderedDocuments])
if([[doc valueForKeyPath:@"customQueryInstance"] respondsToSelector:@selector(queryFavoritesHaveBeenUpdated:)])
[[doc valueForKeyPath:@"customQueryInstance"] queryFavoritesHaveBeenUpdated:self];
-
-
}
#endif
@@ -888,7 +892,6 @@
#endif
}
-
/**
* Save panel did end method.
*/