diff options
author | Max <post@wickenrode.com> | 2018-01-20 03:09:01 +0100 |
---|---|---|
committer | Max <post@wickenrode.com> | 2018-01-20 03:09:01 +0100 |
commit | d403528b2e2be083fe80f5a915d1f6867ec9074e (patch) | |
tree | cd4daf91b4dc49c46a07d9223576995c48aaeadd /Source/SPQueryControllerInitializer.m | |
parent | ef21bc5c3749756c21804d1592f3a3fe2faf7cab (diff) | |
parent | b04243d4d7befb33383d434fe05ea3d7915ef27d (diff) | |
download | sequelpro-d403528b2e2be083fe80f5a915d1f6867ec9074e.tar.gz sequelpro-d403528b2e2be083fe80f5a915d1f6867ec9074e.tar.bz2 sequelpro-d403528b2e2be083fe80f5a915d1f6867ec9074e.zip |
Merge remote-tracking branch 'origin/mergeclasses'
Conflicts:
Source/SPQueryControllerInitializer.m
Source/SPQueryDocumentsController.m
Source/SPQueryFavoriteManager.m
Diffstat (limited to 'Source/SPQueryControllerInitializer.m')
-rw-r--r-- | Source/SPQueryControllerInitializer.m | 151 |
1 files changed, 0 insertions, 151 deletions
diff --git a/Source/SPQueryControllerInitializer.m b/Source/SPQueryControllerInitializer.m deleted file mode 100644 index 6dc703ba..00000000 --- a/Source/SPQueryControllerInitializer.m +++ /dev/null @@ -1,151 +0,0 @@ -// -// SPQueryControllerInitializer.m -// sequel-pro -// -// Created by Stuart Connolly (stuconnolly.com) on September 1, 2011. -// Copyright (c) 2011 Stuart Connolly. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// -// More info at <https://github.com/sequelpro/sequelpro> - -#import "SPQueryControllerInitializer.h" - -static NSString *SPCompletionTokensFilename = @"CompletionTokens.plist"; - -static NSString *SPCompletionTokensKeywordsKey = @"core_keywords"; -static NSString *SPCompletionTokensFunctionsKey = @"core_builtin_functions"; -static NSString *SPCompletionTokensSnippetsKey = @"function_argument_snippets"; - -@interface SPQueryController () - -- (void)_updateFilterState; - -@end - -@implementation SPQueryController (SPQueryControllerInitializer) - -/** - * Set the window's auto save name and initialise display. - */ -- (void)awakeFromNib -{ -#ifndef SP_CODA /* init ivars */ - prefs = [NSUserDefaults standardUserDefaults]; - - [self setWindowFrameAutosaveName:SPQueryConsoleWindowAutoSaveName]; - - // Show/hide table columns - [[consoleTableView tableColumnWithIdentifier:SPTableViewDateColumnID] setHidden:![prefs boolForKey:SPConsoleShowTimestamps]]; - [[consoleTableView tableColumnWithIdentifier:SPTableViewConnectionColumnID] setHidden:![prefs boolForKey:SPConsoleShowConnections]]; - [[consoleTableView tableColumnWithIdentifier:SPTableViewDatabaseColumnID] setHidden:![prefs boolForKey:SPConsoleShowDatabases]]; - - showSelectStatementsAreDisabled = ![prefs boolForKey:SPConsoleShowSelectsAndShows]; - showHelpStatementsAreDisabled = ![prefs boolForKey:SPConsoleShowHelps]; - - [self _updateFilterState]; - - [loggingDisabledTextField setStringValue:([prefs boolForKey:SPConsoleEnableLogging]) ? @"" : NSLocalizedString(@"Query logging is currently disabled", @"query logging disabled label")]; - - // Setup data formatter - dateFormatter = [[NSDateFormatter alloc] init]; - - [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; - - [dateFormatter setDateStyle:NSDateFormatterNoStyle]; - [dateFormatter setTimeStyle:NSDateFormatterMediumStyle]; - - // Set the process table view's vertical gridlines if required - [consoleTableView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; - - // Set the strutcture and index view's font - BOOL useMonospacedFont = [prefs boolForKey:SPUseMonospacedFonts]; - CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; - - for (NSTableColumn *column in [consoleTableView tableColumns]) - { - [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - } - - //allow drag-out copying of selected rows - [consoleTableView setDraggingSourceOperationMask:NSDragOperationCopy forLocal:NO]; -#endif -} - -/** - * Loads the query controller's completion tokens data. - */ -- (NSError *)loadCompletionLists -{ - NSError *readError = nil; - NSString *errorDescription = nil; - - NSString *filePath = [NSBundle pathForResource:SPCompletionTokensFilename - ofType:nil - inDirectory:[[NSBundle mainBundle] bundlePath]]; - - NSData *completionTokensData = [NSData dataWithContentsOfFile:filePath - options:NSMappedRead - error:&readError]; - - NSDictionary *completionPlist = nil; - if(completionTokensData && !readError) { - NSDictionary *plistDict = [NSPropertyListSerialization propertyListWithData:completionTokensData - options:NSPropertyListMutableContainersAndLeaves - format:NULL - error:&readError]; - - if(plistDict && !readError) { - completionPlist = [NSDictionary dictionaryWithDictionary:plistDict]; - } - } - - if (completionPlist == nil || readError) { - errorDescription = [NSString stringWithFormat:@"Error reading '%@': %@", SPCompletionTokensFilename, readError]; - } - else { - if ([completionPlist objectForKey:SPCompletionTokensKeywordsKey]) { - completionKeywordList = [[NSArray arrayWithArray:[completionPlist objectForKey:SPCompletionTokensKeywordsKey]] retain]; - } - else { - errorDescription = [NSString stringWithFormat:@"No '%@' array found.", SPCompletionTokensKeywordsKey]; - } - - if ([completionPlist objectForKey:SPCompletionTokensFunctionsKey]) { - completionFunctionList = [[NSArray arrayWithArray:[completionPlist objectForKey:SPCompletionTokensFunctionsKey]] retain]; - } - else { - errorDescription = [NSString stringWithFormat:@"No '%@' array found.", SPCompletionTokensFunctionsKey]; - } - - if ([completionPlist objectForKey:SPCompletionTokensSnippetsKey]) { - functionArgumentSnippets = [[NSDictionary dictionaryWithDictionary:[completionPlist objectForKey:SPCompletionTokensSnippetsKey]] retain]; - } - else { - errorDescription = [NSString stringWithFormat:@"No '%@' dictionary found.", SPCompletionTokensSnippetsKey]; - } - } - - return errorDescription ? [NSError errorWithDomain:NSCocoaErrorDomain code:1 userInfo:@{NSLocalizedDescriptionKey : errorDescription}] : nil; -} - -@end |