diff options
author | sqlprodev <sqlprodev@northofthree.com> | 2013-02-14 20:14:07 +0000 |
---|---|---|
committer | sqlprodev <sqlprodev@northofthree.com> | 2013-02-14 20:14:07 +0000 |
commit | 7d71d9d773ca7ee8b5920e304b7b41b92120943f (patch) | |
tree | 305655c168173f1d2bbfa7896a35f245b01f71a1 | |
parent | 47069472a4b5dc6655338a77ec8b1eb9a5f5c3d9 (diff) | |
download | sequelpro-7d71d9d773ca7ee8b5920e304b7b41b92120943f.tar.gz sequelpro-7d71d9d773ca7ee8b5920e304b7b41b92120943f.tar.bz2 sequelpro-7d71d9d773ca7ee8b5920e304b7b41b92120943f.zip |
Changing SP_REFACTOR macro to SP_CODA
59 files changed, 1356 insertions, 1354 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQL.h b/Frameworks/SPMySQLFramework/Source/SPMySQL.h index bfdacf3e..aa9008b6 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQL.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQL.h @@ -37,7 +37,7 @@ #import "SPMySQLConstants.h" // Required category additions -#ifndef SP_REFACTOR +#ifndef SP_CODA #import "SPMySQLStringAdditions.h" #else #import <SPMySQL/SPMySQL.h> diff --git a/Source/NoodleLineNumberView.m b/Source/NoodleLineNumberView.m index 1f8e4e50..007e5f0b 100644 --- a/Source/NoodleLineNumberView.m +++ b/Source/NoodleLineNumberView.m @@ -5,26 +5,26 @@ // Created by Paul Kim on September 28, 2008. // Copyright (c) 2008 Noodlesoft, LLC. 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: +// 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 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. +// 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. // This version of the NoodleLineNumberView for Sequel Pro removes marker // functionality and adds selection by clicking on the ruler. Furthermore @@ -79,7 +79,7 @@ typedef NSRange (*RangeOfLineIMP)(id object, SEL selector, NSRange range); [self font], NSFontAttributeName, [self textColor], NSForegroundColorAttributeName, nil] retain]; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSSize s = [[NSString stringWithString:@"8"] sizeWithAttributes:textAttributes]; #else NSSize s = [@"8" sizeWithAttributes:textAttributes]; @@ -135,7 +135,7 @@ typedef NSRange (*RangeOfLineIMP)(id object, SEL selector, NSRange range); font, NSFontAttributeName, [self textColor], NSForegroundColorAttributeName, nil] retain]; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSSize s = [[NSString stringWithString:@"8"] sizeWithAttributes:textAttributes]; #else NSSize s = [@"8" sizeWithAttributes:textAttributes]; @@ -165,7 +165,7 @@ typedef NSRange (*RangeOfLineIMP)(id object, SEL selector, NSRange range); [self font], NSFontAttributeName, textColor, NSForegroundColorAttributeName, nil] retain]; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSSize s = [[NSString stringWithString:@"8"] sizeWithAttributes:textAttributes]; #else NSSize s = [@"8" sizeWithAttributes:textAttributes]; diff --git a/Source/SPAppController.h b/Source/SPAppController.h index 85850b50..b74608a7 100644 --- a/Source/SPAppController.h +++ b/Source/SPAppController.h @@ -31,7 +31,7 @@ // // More info at <http://code.google.com/p/sequel-pro/> -#ifndef SP_REFACTOR +#ifndef SP_CODA #import <FeedbackReporter/FRFeedbackReporter.h> #endif diff --git a/Source/SPBundleCommandRunner.h b/Source/SPBundleCommandRunner.h index b41b8a01..b122c203 100644 --- a/Source/SPBundleCommandRunner.h +++ b/Source/SPBundleCommandRunner.h @@ -32,7 +32,7 @@ @interface SPBundleCommandRunner : NSObject -#ifndef SP_REFACTOR /* run self as bash commands */ +#ifndef SP_CODA /* run self as bash commands */ + (NSString *)runBashCommand:(NSString *)command withEnvironment:(NSDictionary *)shellEnvironment atCurrentDirectoryPath:(NSString *)path error:(NSError **)theError; + (NSString *)runBashCommand:(NSString *)command withEnvironment:(NSDictionary *)shellEnvironment atCurrentDirectoryPath:(NSString *)path callerInstance:(id)caller contextInfo:(NSDictionary *)contextInfo error:(NSError **)theError; diff --git a/Source/SPBundleCommandRunner.m b/Source/SPBundleCommandRunner.m index 84ef4dc8..79473109 100644 --- a/Source/SPBundleCommandRunner.m +++ b/Source/SPBundleCommandRunner.m @@ -50,7 +50,7 @@ @implementation SPBundleCommandRunner -#ifndef SP_REFACTOR /* run commands */ +#ifndef SP_CODA /* run commands */ /** * Run the supplied string as a BASH command(s) and return the result. diff --git a/Source/SPConnectionController.h b/Source/SPConnectionController.h index 014454bf..9ee438b3 100644 --- a/Source/SPConnectionController.h +++ b/Source/SPConnectionController.h @@ -41,7 +41,7 @@ SPFavoritesOutlineView, SPMySQLConnection, SPSplitView -#ifndef SP_REFACTOR /* class decl */ +#ifndef SP_CODA /* class decl */ ,SPKeychain, SPFavoriteNode, SPFavoriteTextFieldCell @@ -56,7 +56,7 @@ SPSSHTunnel *sshTunnel; SPMySQLConnection *mySQLConnection; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ SPKeychain *keychain; NSView *databaseConnectionSuperview; NSSplitView *databaseConnectionView; @@ -68,7 +68,7 @@ BOOL isConnecting; BOOL isEditingConnection; BOOL isTestingConnection; - + // Standard details NSInteger previousType; NSInteger type; @@ -154,13 +154,13 @@ IBOutlet NSMenuItem *favoritesSortByMenuItem; IBOutlet NSView *exportPanelAccessoryView; IBOutlet NSView *editButtonsView; - + BOOL isEditingItemName; BOOL reverseFavoritesSort; BOOL initComplete; BOOL favoriteNameFieldWasAutogenerated; - -#ifndef SP_REFACTOR /* ivars */ + +#ifndef SP_CODA /* ivars */ NSArray *draggedNodes; NSImage *folderImage; @@ -202,7 +202,7 @@ @property (readwrite, retain) NSString *connectionSSHKeychainItemName; @property (readwrite, retain) NSString *connectionSSHKeychainItemAccount; -#ifdef SP_REFACTOR +#ifdef SP_CODA @property (readwrite, assign) SPDatabaseDocument *dbDocument; #endif @@ -212,11 +212,11 @@ // Connection processes - (IBAction)initiateConnection:(id)sender; - (IBAction)cancelConnection:(id)sender; -#ifdef SP_REFACTOR +#ifdef SP_CODA - (BOOL)cancellingConnection; #endif -#ifndef SP_REFACTOR +#ifndef SP_CODA // Interface interaction - (IBAction)nodeDoubleClicked:(id)sender; - (IBAction)chooseKeyLocation:(id)sender; diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index 00ec3283..9e0d50cd 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -34,7 +34,7 @@ #import "SPConnectionHandler.h" #import "SPDatabaseDocument.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPAppController.h" #import "SPPreferenceController.h" #import "ImageAndTextCell.h" @@ -56,7 +56,7 @@ #import <SPMySQL/SPMySQL.h> // Constants -#ifndef SP_REFACTOR +#ifndef SP_CODA static NSString *SPRemoveNode = @"RemoveNode"; static NSString *SPImportFavorites = @"ImportFavorites"; static NSString *SPExportFavorites = @"ExportFavorites"; @@ -76,7 +76,7 @@ static NSString *SPExportFavoritesFilename = @"SequelProFavorites.plist"; - (void)_saveCurrentDetailsCreatingNewFavorite:(BOOL)createNewFavorite validateDetails:(BOOL)validateDetails; - (BOOL)_checkHost; -#ifndef SP_REFACTOR +#ifndef SP_CODA - (void)_sortFavorites; - (void)_sortTreeNode:(SPTreeNode *)node usingKey:(NSString *)key; - (void)_favoriteTypeDidChange; @@ -134,7 +134,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, @synthesize sshKeyLocation; @synthesize sshPort; -#ifdef SP_REFACTOR +#ifdef SP_CODA @synthesize dbDocument; #endif @@ -159,10 +159,10 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, { // If this action was triggered via a double-click on the favorites outline view, // ensure that one of the connections was double-clicked, not the area above or below -#ifndef SP_REFACTOR +#ifndef SP_CODA if (sender == favoritesOutlineView && [favoritesOutlineView clickedRow] <= 0) return; #endif - + // If triggered via the "Test Connection" button, set the state - otherwise clear it isTestingConnection = (sender == testConnectButton); @@ -171,7 +171,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, SPBeginAlertSheet(NSLocalizedString(@"Insufficient connection details", @"insufficient details message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [dbDocument parentWindow], self, nil, nil, NSLocalizedString(@"Insufficient details provided to establish a connection. Please enter at least the hostname.", @"insufficient details informative message")); return; } - + // If SSH is enabled, ensure that the SSH host is not nil if ([self type] == SPSSHTunnelConnection && ![[self sshHost] length]) { SPBeginAlertSheet(NSLocalizedString(@"Insufficient connection details", @"insufficient details message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [dbDocument parentWindow], self, nil, nil, NSLocalizedString(@"Insufficient details provided to establish a connection. Please enter the hostname for the SSH Tunnel, or disable the SSH Tunnel.", @"insufficient SSH tunnel details informative message")); @@ -230,11 +230,11 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, // Basic details have validated - start the connection process animating isConnecting = YES; cancellingConnection = NO; - -#ifndef SP_REFACTOR + +#ifndef SP_CODA // Disable the favorites outline view to prevent further connections attempts [favoritesOutlineView setEnabled:NO]; - + [helpButton setHidden:YES]; [connectButton setEnabled:NO]; [testConnectButton setEnabled:NO]; @@ -248,7 +248,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, // If the password(s) are marked as having been originally sourced from a keychain, check whether they // have been changed or not; if not, leave the mark in place and remove the password from the field // for increased security. -#ifndef SP_REFACTOR +#ifndef SP_CODA if (connectionKeychainItemName && !isTestingConnection) { if ([[keychain getPasswordForName:connectionKeychainItemName account:connectionKeychainItemAccount] isEqualToString:[self password]]) { [self setPassword:[[NSString string] stringByPaddingToLength:[[self password] length] withString:@"sp" startingAtIndex:0]]; @@ -274,23 +274,23 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, } } #endif - + // Inform the delegate that we are starting the connection process if (delegate && [delegate respondsToSelector:@selector(connectionControllerInitiatingConnection:)]) { [delegate connectionControllerInitiatingConnection:self]; } - + // Trim whitespace and newlines from the host field before attempting to connect [self setHost:[[self host] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; - + // Initiate the SSH connection process for tunnels if ([self type] == SPSSHTunnelConnection) { [self performSelector:@selector(initiateSSHTunnelConnection) withObject:nil afterDelay:0.0]; return; } - - // ...or start the MySQL connection process directly + + // ...or start the MySQL connection process directly [self performSelector:@selector(initiateMySQLConnection) withObject:nil afterDelay:0.0]; } @@ -299,9 +299,9 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, */ - (IBAction)cancelConnection:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA [connectButton setEnabled:NO]; - + [progressIndicatorText setStringValue:NSLocalizedString(@"Cancelling...", @"cancelling task status message")]; [progressIndicatorText display]; #endif @@ -323,13 +323,13 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, sshTunnel = nil; } -#ifndef SP_REFACTOR +#ifndef SP_CODA // Restore the connection interface [self _restoreConnectionInterface]; #endif } -#ifdef SP_REFACTOR +#ifdef SP_CODA - (BOOL)cancellingConnection { return cancellingConnection; @@ -345,9 +345,9 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, */ - (IBAction)nodeDoubleClicked:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA SPTreeNode *node = [self selectedFavoriteNode]; - + if (node) { if (node == quickConnectItem) { return; @@ -356,7 +356,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, // Only proceed to initiate a connection if a leaf node (i.e. a favorite and not a group) was double clicked. if (![node isGroup]) { [self initiateConnection:self]; - } + } // Otherwise start editing the group node's name else { @@ -371,7 +371,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, */ - (IBAction)chooseKeyLocation:(NSButton *)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSString *directoryPath = nil; NSString *filePath = nil; keySelectionPanel = [NSOpenPanel openPanel]; @@ -415,7 +415,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [self setSslCertificateFileLocation:nil]; return; } - + [keySelectionPanel setAccessoryView:sslCertificateLocationHelp]; } // SSL CA certificate file location: @@ -429,12 +429,12 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, } [keySelectionPanel beginSheetForDirectory:directoryPath - file:filePath + file:filePath types:nil modalForWindow:[dbDocument parentWindow] - modalDelegate:self - didEndSelector:@selector(chooseKeyLocationSheetDidEnd:returnCode:contextInfo:) - contextInfo:sender]; + modalDelegate:self + didEndSelector:@selector(chooseKeyLocationSheetDidEnd:returnCode:contextInfo:) + contextInfo:sender]; #endif } @@ -451,7 +451,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, */ - (IBAction)updateSSLInterface:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA [self resizeTabViewToConnectionType:[self type] animating:YES]; [self _startEditingConnection]; #endif @@ -470,7 +470,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, */ - (void)updateSplitViewSize { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([dbDocument getConnection]) { return; } @@ -510,7 +510,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, case SPSSHTunnelConnection: targetResizeRect = [sshConnectionFormContainer frame]; break; - } + } frameRect.size.height = targetResizeRect.size.height + additionalFormHeight; @@ -518,7 +518,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [[connectionResizeContainer animator] setFrame:frameRect]; } else { - [connectionResizeContainer setFrame:frameRect]; + [connectionResizeContainer setFrame:frameRect]; } } @@ -529,18 +529,18 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, * Sorts the favorites table view based on the selected sort by item. */ - (void)sortFavorites:(id)sender -{ -#ifndef SP_REFACTOR +{ +#ifndef SP_CODA SPFavoritesSortItem previousSortItem = currentSortItem; currentSortItem = (SPFavoritesSortItem)[[sender menu] indexOfItem:sender]; - + [prefs setInteger:currentSortItem forKey:SPFavoritesSortedBy]; - + // Perform sorting [self _sortFavorites]; - + if (previousSortItem > SPFavoritesSortUnsorted) [[[sender menu] itemAtIndex:previousSortItem] setState:NSOffState]; - + [[[sender menu] itemAtIndex:currentSortItem] setState:NSOnState]; #endif } @@ -550,15 +550,15 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, */ - (void)reverseSortFavorites:(NSMenuItem *)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA reverseFavoritesSort = (![sender state]); - + [prefs setBool:reverseFavoritesSort forKey:SPFavoritesSortedInReverse]; - + // Perform re-sorting [self _sortFavorites]; - - [(NSMenuItem *)sender setState:reverseFavoritesSort]; + + [(NSMenuItem *)sender setState:reverseFavoritesSort]; #endif } @@ -567,7 +567,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, */ - (void)updateFavoriteSelection:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Clear the keychain referral items as appropriate if (connectionKeychainID) [connectionKeychainID release], connectionKeychainID = nil; @@ -575,7 +575,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, if (connectionKeychainItemAccount) [connectionKeychainItemAccount release], connectionKeychainItemAccount = nil; if (connectionSSHKeychainItemName) [connectionSSHKeychainItemName release], connectionSSHKeychainItemName = nil; if (connectionSSHKeychainItemAccount) [connectionSSHKeychainItemAccount release], connectionSSHKeychainItemAccount = nil; - + SPTreeNode *node = [self selectedFavoriteNode]; if ([node isGroup]) node = nil; @@ -601,7 +601,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [self setUser:([fav objectForKey:SPFavoriteUserKey] ? [fav objectForKey:SPFavoriteUserKey] : @"")]; [self setPort:([fav objectForKey:SPFavoritePortKey] ? [fav objectForKey:SPFavoritePortKey] : @"")]; [self setDatabase:([fav objectForKey:SPFavoriteDatabaseKey] ? [fav objectForKey:SPFavoriteDatabaseKey] : @"")]; - + // SSL details [self setUseSSL:([fav objectForKey:SPFavoriteUseSSLKey] ? [[fav objectForKey:SPFavoriteUseSSLKey] intValue] : NSOffState)]; [self setSslKeyFileLocationEnabled:([fav objectForKey:SPFavoriteSSLKeyFileLocationEnabledKey] ? [[fav objectForKey:SPFavoriteSSLKeyFileLocationEnabledKey] intValue] : NSOffState)]; @@ -610,24 +610,24 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [self setSslCertificateFileLocation:([fav objectForKey:SPFavoriteSSLCertificateFileLocationKey] ? [fav objectForKey:SPFavoriteSSLCertificateFileLocationKey] : @"")]; [self setSslCACertFileLocationEnabled:([fav objectForKey:SPFavoriteSSLCACertFileLocationEnabledKey] ? [[fav objectForKey:SPFavoriteSSLCACertFileLocationEnabledKey] intValue] : NSOffState)]; [self setSslCACertFileLocation:([fav objectForKey:SPFavoriteSSLCACertFileLocationKey] ? [fav objectForKey:SPFavoriteSSLCACertFileLocationKey] : @"")]; - + // SSH details [self setSshHost:([fav objectForKey:SPFavoriteSSHHostKey] ? [fav objectForKey:SPFavoriteSSHHostKey] : @"")]; [self setSshUser:([fav objectForKey:SPFavoriteSSHUserKey] ? [fav objectForKey:SPFavoriteSSHUserKey] : @"")]; [self setSshKeyLocationEnabled:([fav objectForKey:SPFavoriteSSHKeyLocationEnabledKey] ? [[fav objectForKey:SPFavoriteSSHKeyLocationEnabledKey] intValue] : NSOffState)]; [self setSshKeyLocation:([fav objectForKey:SPFavoriteSSHKeyLocationKey] ? [fav objectForKey:SPFavoriteSSHKeyLocationKey] : @"")]; [self setSshPort:([fav objectForKey:SPFavoriteSSHPortKey] ? [fav objectForKey:SPFavoriteSSHPortKey] : @"")]; - + // Trigger an interface update [self resizeTabViewToConnectionType:[self type] animating:(sender == self)]; - + // Check whether the password exists in the keychain, and if so add it; also record the // keychain details so we can pass around only those details if the password doesn't change connectionKeychainItemName = [[keychain nameForFavoriteName:[fav objectForKey:SPFavoriteNameKey] id:[fav objectForKey:SPFavoriteIDKey]] retain]; connectionKeychainItemAccount = [[keychain accountForUser:[fav objectForKey:SPFavoriteUserKey] host:(([self type] == SPSocketConnection) ? @"localhost" : [fav objectForKey:SPFavoriteHostKey]) database:[fav objectForKey:SPFavoriteDatabaseKey]] retain]; - + [self setPassword:[keychain getPasswordForName:connectionKeychainItemName account:connectionKeychainItemAccount]]; - + if (![[self password] length]) { [self setPassword:nil]; [connectionKeychainItemName release], connectionKeychainItemName = nil; @@ -640,15 +640,15 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, // And the same for the SSH password connectionSSHKeychainItemName = [[keychain nameForSSHForFavoriteName:[fav objectForKey:SPFavoriteNameKey] id:[fav objectForKey:SPFavoriteIDKey]] retain]; connectionSSHKeychainItemAccount = [[keychain accountForSSHUser:[fav objectForKey:SPFavoriteSSHUserKey] sshHost:[fav objectForKey:SPFavoriteSSHHostKey]] retain]; - + [self setSshPassword:[keychain getPasswordForName:connectionSSHKeychainItemName account:connectionSSHKeychainItemAccount]]; - + if (![[self sshPassword] length]) { [self setSshPassword:nil]; [connectionSSHKeychainItemName release], connectionSSHKeychainItemName = nil; [connectionSSHKeychainItemAccount release], connectionSSHKeychainItemAccount = nil; } - + [prefs setInteger:[[fav objectForKey:SPFavoriteIDKey] integerValue] forKey:SPLastFavoriteID]; // Set first responder to password field if it is empty @@ -659,13 +659,13 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, /** * Returns the selected favorite data dictionary or nil if nothing is selected. */ -#ifndef SP_REFACTOR +#ifndef SP_CODA - (NSMutableDictionary *)selectedFavorite -{ + { SPTreeNode *node = [self selectedFavoriteNode]; return (![node isGroup]) ? [[node representedObject] nodeFavorite] : nil; -} + } /** * Returns the selected favorite node or nil if nothing is selected. @@ -693,7 +693,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, currentIndex = [indexes indexGreaterThanIndex:currentIndex]; } - + return nodes; } @@ -748,7 +748,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, SPTreeNode *parent = ([selectedNode isGroup] && selectedNode != quickConnectItem) ? selectedNode : (SPTreeNode *)[selectedNode parentNode]; SPTreeNode *node = [favoritesController addFavoriteNodeWithData:favorite asChildOfNode:parent]; - + // Ensure the parent is expanded [favoritesOutlineView expandItem:parent]; @@ -782,12 +782,12 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, // Ensure the parent is expanded [favoritesOutlineView expandItem:parent]; - + SPTreeNode *node = [favoritesController addGroupNodeWithName:NSLocalizedString(@"New Folder", @"new folder placeholder name") asChildOfNode:parent]; [self _reloadFavoritesViewData]; [self _selectNode:node]; - + [favoritesOutlineView editColumn:0 row:[favoritesOutlineView selectedRow] withEvent:nil select:YES]; } @@ -980,7 +980,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { } - + #pragma mark - #pragma mark Sheet methods @@ -989,7 +989,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, * Called when the user dismisses the remove node sheet. */ - (void)sheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo -{ +{ // Remove the current favorite/group node if ([contextInfo isEqualToString:SPRemoveNode]) { if (returnCode == NSAlertDefaultReturn) { @@ -1041,7 +1041,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [self setSslCACertFileLocation:nil]; return; } - + [self setSslCACertFileLocation:abbreviatedFileName]; } @@ -1053,7 +1053,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, */ - (void)importExportFavoritesSheetDidEnd:(NSOpenPanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo -{ + { if (returnCode == NSOKButton) { if (contextInfo == SPExportFavorites) { SPFavoritesExporter *exporter = [[[SPFavoritesExporter alloc] init] autorelease]; @@ -1064,13 +1064,13 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, } else if (contextInfo == SPImportFavorites) { SPFavoritesImporter *importer = [[SPFavoritesImporter alloc] init]; - + [importer setDelegate:self]; [importer importFavoritesFromFileAtPath:[panel filename]]; } - } -} + } + } #endif @@ -1099,7 +1099,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, */ - (void)_saveCurrentDetailsCreatingNewFavorite:(BOOL)createNewFavorite validateDetails:(BOOL)validateDetails { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Complete any active editing if ([[connectionView window] firstResponder]) { [[connectionView window] endEditingFor:[[connectionView window] firstResponder]]; @@ -1384,11 +1384,11 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, * Sorts the connection favorites based on the selected criteria. */ -#ifndef SP_REFACTOR +#ifndef SP_CODA - (void)_sortFavorites { NSString *sortKey = SPFavoriteNameKey; - + switch (currentSortItem) { case SPFavoritesSortNameItem: @@ -1403,7 +1403,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, case SPFavoritesSortUnsorted: return; } - + // Store a copy of the selected nodes for re-selection NSArray *preSortSelection = [self selectedFavoriteNodes]; @@ -1436,9 +1436,9 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, // If this node only has one child and it's not another group node, don't bother proceeding if (([nodes count] == 1) && (![[nodes objectAtIndex:0] isGroup])) { [nodes release]; - return; + return; } - + for (SPTreeNode *treeNode in nodes) { if ([treeNode isGroup]) { @@ -1447,7 +1447,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, } NSMutableIndexSet *indexes = [[NSMutableIndexSet alloc] init]; - + NSUInteger i = [indexes lastIndex]; while (i != NSNotFound) @@ -1456,13 +1456,13 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, i = [indexes indexLessThanIndex:i]; } - + [indexes release]; [nodes sortUsingFunction:_compareFavoritesUsingKey context:key]; - + if (reverseFavoritesSort) [nodes reverse]; - + [[node mutableChildNodes] setArray:nodes]; [nodes release]; @@ -1513,14 +1513,14 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, */ - (void)_favoriteTypeDidChange -{ + { NSDictionary *favorite = [self selectedFavorite]; - + // If either socket or host is localhost, clear. if ((previousType != SPSocketConnection) && [[favorite objectForKey:SPFavoriteHostKey] isEqualToString:@"localhost"]) { [self setHost:@""]; } - + // Update the name for newly added favorites if not already touched by the user, by triggering a KVO update if (![[self name] length] || favoriteNameFieldWasAutogenerated) { NSString *favoriteName = [self _generateNameForConnection]; @@ -1528,7 +1528,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [self setName:favoriteName]; } } -} + } /** * Convenience method for reloading the outline view, expanding the root item and scrolling to the selected item. @@ -1578,13 +1578,13 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, { // Must be performed on the main thread if (![NSThread isMainThread]) return [[self onMainThread] _restoreConnectionInterface]; - + // Reset the window title [[dbDocument parentWindow] setTitle:[dbDocument displayName]]; // Stop the current tab's progress indicator [dbDocument setIsProcessing:NO]; - + // Reset the UI [helpButton setHidden:NO]; [helpButton display]; @@ -1625,7 +1625,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, { [favoritesOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:[favoritesOutlineView rowForItem:node]] byExtendingSelection:NO]; [self _scrollToSelectedNode]; -} + } /** * Scroll to the currently selected node. @@ -1636,7 +1636,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, if ([favoritesOutlineView selectedRow] == -1) return; [favoritesOutlineView scrollRowToVisible:[favoritesOutlineView selectedRow]]; -} + } /** * Removes the supplied tree node. @@ -1679,33 +1679,33 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, // Otherwise, remove details for the supplied node. - NSDictionary *favorite = [[node representedObject] nodeFavorite]; - - // Get selected favorite's details - NSString *favoriteName = [favorite objectForKey:SPFavoriteNameKey]; - NSString *favoriteUser = [favorite objectForKey:SPFavoriteUserKey]; - NSString *favoriteHost = [favorite objectForKey:SPFavoriteHostKey]; - NSString *favoriteDatabase = [favorite objectForKey:SPFavoriteDatabaseKey]; - NSString *favoriteSSHUser = [favorite objectForKey:SPFavoriteSSHUserKey]; - NSString *favoriteSSHHost = [favorite objectForKey:SPFavoriteSSHHostKey]; - NSString *favoriteID = [favorite objectForKey:SPFavoriteIDKey]; - - // Remove passwords from the Keychain - [keychain deletePasswordForName:[keychain nameForFavoriteName:favoriteName id:favoriteID] - account:[keychain accountForUser:favoriteUser host:((type == SPSocketConnection) ? @"localhost" : favoriteHost) database:favoriteDatabase]]; - [keychain deletePasswordForName:[keychain nameForSSHForFavoriteName:favoriteName id:favoriteID] - account:[keychain accountForSSHUser:favoriteSSHUser sshHost:favoriteSSHHost]]; - - // Reset last used favorite - if ([[favorite objectForKey:SPFavoriteIDKey] integerValue] == [prefs integerForKey:SPLastFavoriteID]) { - [prefs setInteger:0 forKey:SPLastFavoriteID]; - } - - // If required, reset the default favorite - if ([[favorite objectForKey:SPFavoriteIDKey] integerValue] == [prefs integerForKey:SPDefaultFavorite]) { - [prefs setInteger:[prefs integerForKey:SPLastFavoriteID] forKey:SPDefaultFavorite]; + NSDictionary *favorite = [[node representedObject] nodeFavorite]; + + // Get selected favorite's details + NSString *favoriteName = [favorite objectForKey:SPFavoriteNameKey]; + NSString *favoriteUser = [favorite objectForKey:SPFavoriteUserKey]; + NSString *favoriteHost = [favorite objectForKey:SPFavoriteHostKey]; + NSString *favoriteDatabase = [favorite objectForKey:SPFavoriteDatabaseKey]; + NSString *favoriteSSHUser = [favorite objectForKey:SPFavoriteSSHUserKey]; + NSString *favoriteSSHHost = [favorite objectForKey:SPFavoriteSSHHostKey]; + NSString *favoriteID = [favorite objectForKey:SPFavoriteIDKey]; + + // Remove passwords from the Keychain + [keychain deletePasswordForName:[keychain nameForFavoriteName:favoriteName id:favoriteID] + account:[keychain accountForUser:favoriteUser host:((type == SPSocketConnection) ? @"localhost" : favoriteHost) database:favoriteDatabase]]; + [keychain deletePasswordForName:[keychain nameForSSHForFavoriteName:favoriteName id:favoriteID] + account:[keychain accountForSSHUser:favoriteSSHUser sshHost:favoriteSSHHost]]; + + // Reset last used favorite + if ([[favorite objectForKey:SPFavoriteIDKey] integerValue] == [prefs integerForKey:SPLastFavoriteID]) { + [prefs setInteger:0 forKey:SPLastFavoriteID]; + } + + // If required, reset the default favorite + if ([[favorite objectForKey:SPFavoriteIDKey] integerValue] == [prefs integerForKey:SPDefaultFavorite]) { + [prefs setInteger:[prefs integerForKey:SPLastFavoriteID] forKey:SPDefaultFavorite]; + } } -} /** * Creates a new favorite ID based on the UNIX epoch time. @@ -1721,7 +1721,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, - (SPTreeNode *)_favoriteNodeForFavoriteID:(NSInteger)favoriteID { SPTreeNode *favoriteNode = nil; - + if (!favoritesRoot) return favoriteNode; if (!favoriteID) return quickConnectItem; @@ -1730,11 +1730,11 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, { if ([[[[node representedObject] nodeFavorite] objectForKey:SPFavoriteIDKey] integerValue] == favoriteID) { favoriteNode = node; - } + } } - + return favoriteNode; -} + } #endif /** @@ -1746,9 +1746,9 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, NSString *result = [subject stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; return [result stringByReplacingOccurrencesOfString:@"\n" withString:@""]; -} + } -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Generate a name for the current connection based on any other populated details. * Currently uses the host and database fields. @@ -1757,21 +1757,21 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, - (NSString *)_generateNameForConnection { NSString *aName; - + if ([self type] != SPSocketConnection && ![[self host] length]) { return nil; } - + aName = ([self type] == SPSocketConnection) ? @"localhost" : [self host]; - + if ([[self database] length]) { aName = [NSString stringWithFormat:@"%@/%@", aName, [self database]]; - } + } return aName; -} - + } + /** * If editing is not already active, mark editing as starting, triggering UI updates * to match. @@ -1782,7 +1782,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, // If not connecting, hide the connection status text to reflect changes if (!isConnecting) { [progressIndicatorText setHidden:YES]; - } + } if (isEditingConnection) return; @@ -1799,13 +1799,13 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, // Show the area to allow saving the changes [self setIsEditingConnection:YES]; [favoritesOutlineView setNeedsDisplayInRect:[favoritesOutlineView rectOfRow:[favoritesOutlineView selectedRow]]]; -} + } /** * If editing is active, mark editing as complete, triggering UI updates to match. */ - (void)_stopEditingConnection -{ + { if (!isEditingConnection) return; [self setIsEditingConnection:NO]; @@ -1813,23 +1813,23 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [editButtonsView setHidden:YES]; [progressIndicatorText setHidden:YES]; [(NSView *)favoritesOutlineView display]; -} + } #endif - (void)_documentWillClose:(NSNotification *)notification { cancellingConnection = YES; dbDocument = nil; - + if (mySQLConnection) { [mySQLConnection setDelegate:nil]; [NSThread detachNewThreadWithName:@"SPConnectionController close background disconnect" target:mySQLConnection selector:@selector(disconnect) object:nil]; [mySQLConnection autorelease]; mySQLConnection = nil; - } + } if (sshTunnel) [sshTunnel setConnectionStateChangeSelector:nil delegate:nil], [sshTunnel disconnect], [sshTunnel release]; -} + } #pragma mark - @@ -1839,7 +1839,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [NSObject cancelPreviousPerformRequestsWithTarget:self]; // Unregister observers -#ifndef SP_REFACTOR +#ifndef SP_CODA [self removeObserver:self forKeyPath:SPFavoriteTypeKey]; [self removeObserver:self forKeyPath:SPFavoriteNameKey]; [self removeObserver:self forKeyPath:SPFavoriteHostKey]; @@ -1860,20 +1860,20 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [self removeObserver:self forKeyPath:SPFavoriteSSLCACertFileLocationEnabledKey]; [self removeObserver:self forKeyPath:SPFavoriteSSLCACertFileLocationKey]; #endif - -#ifndef SP_REFACTOR + +#ifndef SP_CODA [keychain release]; #endif [prefs release]; - -#ifndef SP_REFACTOR + +#ifndef SP_CODA [folderImage release], folderImage = nil; [quickConnectItem release], quickConnectItem = nil; [quickConnectCell release], quickConnectCell = nil; #endif - + for (id retainedObject in nibObjectsToRelease) [retainedObject release]; - + [nibObjectsToRelease release]; if (connectionKeychainID) [connectionKeychainID release]; @@ -1882,10 +1882,10 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, if (connectionSSHKeychainItemName) [connectionSSHKeychainItemName release]; if (connectionSSHKeychainItemAccount) [connectionSSHKeychainItemAccount release]; -#ifndef SP_REFACTOR +#ifndef SP_CODA if (currentFavorite) [currentFavorite release], currentFavorite = nil; #endif - + [super dealloc]; } diff --git a/Source/SPConnectionControllerDataSource.m b/Source/SPConnectionControllerDataSource.m index daf2c3af..231737c7 100644 --- a/Source/SPConnectionControllerDataSource.m +++ b/Source/SPConnectionControllerDataSource.m @@ -45,7 +45,7 @@ @implementation SPConnectionController (SPConnectionControllerDataSource) -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Return the number of children for the specified item in the favourites tree. @@ -55,7 +55,7 @@ - (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item { SPTreeNode *node = (item == nil ? favoritesRoot : (SPTreeNode *)item); - + // If at the root, return the count plus one for the "Quick Connect" entry if (!item) { return [[node childNodes] count] + 1; @@ -110,7 +110,7 @@ if (![node isGroup]) { // Updating the name triggers a KVO update - [self setName:newName]; + [self setName:newName]; [self _saveCurrentDetailsCreatingNewFavorite:NO validateDetails:NO]; } else { diff --git a/Source/SPConnectionControllerDelegate.h b/Source/SPConnectionControllerDelegate.h index 230ceadb..a986b275 100644 --- a/Source/SPConnectionControllerDelegate.h +++ b/Source/SPConnectionControllerDelegate.h @@ -42,7 +42,7 @@ * Connection controller delegate category. */ @interface SPConnectionController (SPConnectionControllerDelegate) -#ifndef SP_REFACTOR +#ifndef SP_CODA <SPFavoritesImportProtocol, SPFavoritesExportProtocol> #endif diff --git a/Source/SPConnectionControllerDelegate.m b/Source/SPConnectionControllerDelegate.m index 191a5b32..a6001309 100644 --- a/Source/SPConnectionControllerDelegate.m +++ b/Source/SPConnectionControllerDelegate.m @@ -31,7 +31,7 @@ // More info at <http://code.google.com/p/sequel-pro/> #import "SPConnectionControllerDelegate.h" -#ifndef SP_REFACTOR +#ifndef SP_CODA #import "SPFavoritesController.h" #import "SPTableTextFieldCell.h" #import "SPPreferenceController.h" @@ -42,7 +42,7 @@ #import "SPTreeNode.h" #endif -#ifndef SP_REFACTOR +#ifndef SP_CODA static NSString *SPDatabaseImage = @"database-small"; static NSString *SPQuickConnectImage = @"quick-connect-icon.pdf"; static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; @@ -73,7 +73,7 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; #pragma mark - #pragma mark SplitView delegate methods -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * When the split view is resized, trigger a resize in the hidden table @@ -82,8 +82,8 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; - (void)splitViewDidResizeSubviews:(NSNotification *)notification { if (initComplete) { - [databaseConnectionView setPosition:[[[connectionSplitView subviews] objectAtIndex:0] frame].size.width ofDividerAtIndex:0]; - } + [databaseConnectionView setPosition:[[[connectionSplitView subviews] objectAtIndex:0] frame].size.width ofDividerAtIndex:0]; +} } - (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)dividerIndex @@ -96,13 +96,13 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; #pragma mark - #pragma mark Outline view delegate methods -#ifndef SP_REFACTOR +#ifndef SP_CODA - (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item { return ([[(SPTreeNode *)item parentNode] parentNode] == nil); } - + - (void)outlineViewSelectionIsChanging:(NSNotification *)notification { if (isEditingConnection) { @@ -112,15 +112,15 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; } - (void)outlineViewSelectionDidChange:(NSNotification *)notification -{ + { NSInteger selected = [favoritesOutlineView numberOfSelectedRows]; - + if (isEditingConnection) { [self _stopEditingConnection]; [[notification object] setNeedsDisplay:YES]; } - if (selected == 1) { + if (selected == 1) { [self updateFavoriteSelection:self]; favoriteNameFieldWasAutogenerated = NO; @@ -145,7 +145,7 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item { SPTreeNode *node = (SPTreeNode *)item; - + // Draw entries with the small system font by default [(SPTableTextFieldCell *)cell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; @@ -228,7 +228,7 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; } - (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item -{ +{ // If this is a top level item, only allow the "Quick Connect" item to be selectable if (![[item parentNode] parentNode]) { @@ -265,10 +265,10 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; - (void)outlineViewItemDidCollapse:(NSNotification *)notification { [self _setNodeIsExpanded:NO fromNotification:notification]; -} - + } + - (void)outlineViewItemDidExpand:(NSNotification *)notification -{ + { [self _setNodeIsExpanded:YES fromNotification:notification]; } @@ -277,7 +277,7 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; #pragma mark - #pragma mark Outline view drag & drop -#ifndef SP_REFACTOR +#ifndef SP_CODA - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard { @@ -308,9 +308,9 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; } - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)childIndex -{ + { NSDragOperation result = NSDragOperationNone; - + // Prevent the top level or the quick connect item from being a target if (!item || item == quickConnectItem) return result; @@ -332,35 +332,35 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; [outlineView setDropItem:item dropChildIndex:childIndex]; result = NSDragOperationMove; - } + } return result; -} - + } + - (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)childIndex -{ - BOOL acceptedDrop = NO; - + { + BOOL acceptedDrop = NO; + if ((!item) || ([info draggingSource] != outlineView)) return acceptedDrop; SPTreeNode *node = item ? item : [[[[favoritesRoot childNodes] objectAtIndex:0] childNodes] objectAtIndex:0]; // Cache the selected nodes for selection restoration afterwards NSArray *preDragSelection = [self selectedFavoriteNodes]; - - // Disable all automatic sorting - currentSortItem = -1; - reverseFavoritesSort = NO; - - [prefs setInteger:currentSortItem forKey:SPFavoritesSortedBy]; - [prefs setBool:NO forKey:SPFavoritesSortedInReverse]; - - // Uncheck sort by menu items - for (NSMenuItem *menuItem in [[favoritesSortByMenuItem submenu] itemArray]) - { - [menuItem setState:NSOffState]; - } - + + // Disable all automatic sorting + currentSortItem = -1; + reverseFavoritesSort = NO; + + [prefs setInteger:currentSortItem forKey:SPFavoritesSortedBy]; + [prefs setBool:NO forKey:SPFavoritesSortedInReverse]; + + // Uncheck sort by menu items + for (NSMenuItem *menuItem in [[favoritesSortByMenuItem submenu] itemArray]) + { + [menuItem setState:NSOffState]; + } + if (![draggedNodes count]) return acceptedDrop; if ([node isGroup]) { @@ -382,7 +382,7 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; NSMutableArray *childNodeArray = [node mutableChildNodes]; for (SPTreeNode *treeNode in draggedNodes) - { + { // Remove the node from its old location NSInteger oldIndex = [childNodeArray indexOfObject:treeNode]; NSInteger newIndex = childIndex; @@ -393,8 +393,8 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; if (childIndex > oldIndex) { newIndex--; - } - } + } + } else { [[[treeNode parentNode] mutableChildNodes] removeObject:treeNode]; } @@ -407,21 +407,21 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; [favoritesController saveFavorites]; [self _reloadFavoritesViewData]; - + [[NSNotificationCenter defaultCenter] postNotificationName:SPConnectionFavoritesChangedNotification object:self]; - - [[[[NSApp delegate] preferenceController] generalPreferencePane] updateDefaultFavoritePopup]; - + + [[[[NSApp delegate] preferenceController] generalPreferencePane] updateDefaultFavoritePopup]; + // Update the selection to account for rearranged faourites NSMutableIndexSet *restoredSelection = [NSMutableIndexSet indexSet]; for (SPTreeNode *eachNode in preDragSelection) { [restoredSelection addIndex:[favoritesOutlineView rowForItem:eachNode]]; } [favoritesOutlineView selectRowIndexes:restoredSelection byExtendingSelection:NO]; - - acceptedDrop = YES; - - return acceptedDrop; + + acceptedDrop = YES; + + return acceptedDrop; } #endif @@ -429,7 +429,7 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; #pragma mark - #pragma mark Textfield delegate methods -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * React to control text changes in the connection interface @@ -437,7 +437,7 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; - (void)controlTextDidChange:(NSNotification *)notification { id field = [notification object]; - + // Ignore changes in the outline view edit fields if ([field isKindOfClass:[NSOutlineView class]]) { return; @@ -450,41 +450,41 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; [self controlTextDidEndEditing:notification]; } } - + [self _startEditingConnection]; - + if (favoriteNameFieldWasAutogenerated && (field != standardNameField && field != socketNameField && field != sshNameField)) { [self setName:[self _generateNameForConnection]]; - } -} - + } + } + /** * React to the end of control text changes in the connection interface. */ - (void)controlTextDidEndEditing:(NSNotification *)notification { id field = [notification object]; - + // Handle updates to the 'name' field of the selected favourite. The favourite name should // have leading or trailing spaces removed at the end of editing, and if it's left empty, // should have a default name set. if (((field == standardNameField) || (field == socketNameField) || (field == sshNameField)) && [self selectedFavoriteNode]) { - + NSString *favoriteName = [self _stripInvalidCharactersFromString:[field stringValue]]; - + if (![favoriteName length]) { favoriteName = [self _generateNameForConnection]; if (favoriteName) { [self setName:favoriteName]; - } - + } + // Enable user@host update in reaction to other UI changes favoriteNameFieldWasAutogenerated = YES; } else if (![[field stringValue] isEqualToString:[self _generateNameForConnection]]) { favoriteNameFieldWasAutogenerated = NO; [self setName:favoriteName]; - } } +} // When a host field finishes editing, ensure that it hasn't been set to "localhost" to // ensure that socket connections don't inadvertently occur. @@ -498,7 +498,7 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; #pragma mark - #pragma mark Tab bar delegate methods -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Trigger a resize action whenever the tab view changes. The connection @@ -508,22 +508,22 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; * to be sized according to the detail type. */ - (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem -{ +{ NSInteger selectedTabView = [tabView indexOfTabViewItem:tabViewItem]; if (selectedTabView == previousType) return; - + [self resizeTabViewToConnectionType:selectedTabView animating:YES]; // Update the host as appropriate if ((selectedTabView != SPSocketConnection) && [[self host] isEqualToString:@"localhost"]) { [self setHost:@""]; } - + previousType = selectedTabView; - + [self _startEditingConnection]; - + [self _favoriteTypeDidChange]; } @@ -532,7 +532,7 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; #pragma mark - #pragma mark Scroll view notifications -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * As the scrollview resizes, keep the details centered within it if @@ -560,7 +560,7 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; [connectionResizeContainer setFrame:connectionDetailsFrame]; scrollDocumentFrame.size.height = scrollViewFrame.size.height; [[connectionDetailsScrollView documentView] setFrame:scrollDocumentFrame]; - } +} } #endif @@ -568,18 +568,18 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; #pragma mark - #pragma mark Menu Validation -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Menu item validation. */ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem -{ +{ SEL action = [menuItem action]; SPTreeNode *node = [self selectedFavoriteNode]; NSInteger selectedRows = [favoritesOutlineView numberOfSelectedRows]; - + if (node == quickConnectItem) { return NO; } @@ -598,8 +598,8 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; if (action == @selector(reverseSortFavorites:)) { [menuItem setState:reverseFavoritesSort]; } - } - +} + // Remove/rename the selected node if (action == @selector(removeNode:) || action == @selector(renameNode:)) { return selectedRows == 1; @@ -608,18 +608,18 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; // Duplicate and make the selected favorite the default if (action == @selector(duplicateFavorite:)) { return ((selectedRows == 1) && (![node isGroup])); - } - +} + // Make selected favorite the default if (action == @selector(makeSelectedFavoriteDefault:)) { NSInteger favoriteID = [[[self selectedFavorite] objectForKey:SPFavoriteIDKey] integerValue]; - + return ((selectedRows == 1) && (![node isGroup]) && (favoriteID != [prefs integerForKey:SPDefaultFavorite])); - } - +} + // Favorites export if (action == @selector(exportFavorites:)) { - + if ([[favoritesRoot allChildLeafs] count] == 0) { return NO; } @@ -628,7 +628,7 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; } else if (selectedRows > 1) { [menuItem setTitle:NSLocalizedString(@"Export Selected...", @"export selected favorites menu item")]; - } + } } return YES; @@ -639,26 +639,26 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; #pragma mark - #pragma mark Favorites import/export delegate methods -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Called by the favorites exporter when the export completes. */ - (void)favoritesExportCompletedWithError:(NSError *)error -{ +{ if (error) { NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Favorites export error", @"favorites export error message") defaultButton:NSLocalizedString(@"OK", @"OK") alternateButton:nil otherButton:nil informativeTextWithFormat:[NSString stringWithFormat:NSLocalizedString(@"The following error occurred during the export process:\n\n%@", @"favorites export error informative message"), [error localizedDescription]]]; - + [alert beginSheetModalForWindow:[dbDocument parentWindow] modalDelegate:self didEndSelector:NULL contextInfo:NULL]; } -} + } /** * Called by the favorites importer when the imported data is available. @@ -673,8 +673,8 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; if (currentSortItem > SPFavoritesSortUnsorted) { [self _sortFavorites]; - } - +} + [self _reloadFavoritesViewData]; } @@ -682,7 +682,7 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; * Called by the favorites importer when the import completes. */ - (void)favoritesImportCompletedWithError:(NSError *)error -{ +{ if (error) { NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Favorites import error", @"favorites import error message") defaultButton:NSLocalizedString(@"OK", @"OK") @@ -702,7 +702,7 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; #pragma mark - #pragma mark Private API -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Sets the expanded state of the node from the supplied outline view notification. diff --git a/Source/SPConnectionControllerInitializer.m b/Source/SPConnectionControllerInitializer.m index 66c39f2f..4bef6178 100644 --- a/Source/SPConnectionControllerInitializer.m +++ b/Source/SPConnectionControllerInitializer.m @@ -40,7 +40,7 @@ #import "SPDatabaseViewController.h" #import "SPSplitView.h" -#ifndef SP_REFACTOR +#ifndef SP_CODA static NSString *SPConnectionViewNibName = @"ConnectionView"; #endif @@ -64,11 +64,11 @@ static NSString *SPConnectionViewNibName = @"ConnectionView"; - (id)initWithDocument:(SPDatabaseDocument *)document { if ((self = [super init])) { - + // Weak reference dbDocument = document; -#ifndef SP_REFACTOR +#ifndef SP_CODA databaseConnectionSuperview = [dbDocument databaseView]; databaseConnectionView = [dbDocument valueForKey:@"contentViewSplitter"]; #endif @@ -92,7 +92,7 @@ static NSString *SPConnectionViewNibName = @"ConnectionView"; [self loadNib]; [self registerForNotifications]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Hide the main view and position and display the connection view [databaseConnectionView setHidden:YES]; [connectionView setFrame:[databaseConnectionView frame]]; @@ -101,11 +101,11 @@ static NSString *SPConnectionViewNibName = @"ConnectionView"; // Set up the splitview [connectionSplitView setMinSize:80.f ofSubviewAtIndex:0]; [connectionSplitView setMinSize:445.f ofSubviewAtIndex:1]; - + // Generic folder image for use in the outline view's groups folderImage = [[[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kGenericFolderIcon)] retain]; [folderImage setSize:NSMakeSize(16, 16)]; - + // Set up a keychain instance and preferences reference, and create the initial favorites list keychain = [[SPKeychain alloc] init]; prefs = [[NSUserDefaults standardUserDefaults] retain]; @@ -113,11 +113,11 @@ static NSString *SPConnectionViewNibName = @"ConnectionView"; // Create a reference to the favorites controller, forcing the data to be loaded from disk // and the tree to be constructed. favoritesController = [SPFavoritesController sharedFavoritesController]; - + // Tree references favoritesRoot = [favoritesController favoritesTree]; currentFavorite = nil; - + // Create the "Quick Connect" placeholder group quickConnectItem = [[SPTreeNode treeNodeWithRepresentedObject:[SPGroupNode groupNodeWithName:[NSLocalizedString(@"Quick Connect", @"Quick connect item label") uppercaseString]]] retain]; [quickConnectItem setIsGroup:YES]; @@ -154,7 +154,7 @@ static NSString *SPConnectionViewNibName = @"ConnectionView"; */ - (void)loadNib { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Load the connection nib, keeping references to the top-level objects for later release nibObjectsToRelease = [[NSMutableArray alloc] init]; @@ -179,7 +179,7 @@ static NSString *SPConnectionViewNibName = @"ConnectionView"; name:SPDocumentWillCloseNotification object:dbDocument]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scrollViewFrameChanged:) name:NSViewFrameDidChangeNotification @@ -306,20 +306,20 @@ static NSString *SPConnectionViewNibName = @"ConnectionView"; */ - (void)setUpSelectedConnectionFavorite { -#ifndef SP_REFACTOR +#ifndef SP_CODA SPTreeNode *favorite = [self _favoriteNodeForFavoriteID:[prefs integerForKey:[prefs boolForKey:SPSelectLastFavoriteUsed] ? SPLastFavoriteID : SPDefaultFavorite]]; if (favorite) { - + if (favorite == quickConnectItem) { [self _selectNode:favorite]; } else { - NSNumber *typeNumber = [[[favorite representedObject] nodeFavorite] objectForKey:SPFavoriteTypeKey]; - previousType = typeNumber ? [typeNumber integerValue] : SPTCPIPConnection; + NSNumber *typeNumber = [[[favorite representedObject] nodeFavorite] objectForKey:SPFavoriteTypeKey]; + previousType = typeNumber ? [typeNumber integerValue] : SPTCPIPConnection; - [self _selectNode:favorite]; - [self resizeTabViewToConnectionType:[[[[favorite representedObject] nodeFavorite] objectForKey:SPFavoriteTypeKey] integerValue] animating:NO]; + [self _selectNode:favorite]; + [self resizeTabViewToConnectionType:[[[[favorite representedObject] nodeFavorite] objectForKey:SPFavoriteTypeKey] integerValue] animating:NO]; } [self _scrollToSelectedNode]; @@ -341,7 +341,7 @@ static NSString *SPConnectionViewNibName = @"ConnectionView"; */ - (void)_processFavoritesDataChange:(NSNotification *)aNotification { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Check the supplied notification for the sender; if the sender // was this object, ignore it if ([aNotification object] == self) return; @@ -370,7 +370,7 @@ static NSString *SPConnectionViewNibName = @"ConnectionView"; * * @param node The node to traverse */ -#ifndef SP_REFACTOR +#ifndef SP_CODA - (void)_restoreOutlineViewStateNode:(SPTreeNode *)node { if ([node isGroup]) { diff --git a/Source/SPConnectionDelegate.m b/Source/SPConnectionDelegate.m index 473eef8c..ef5cfaa8 100644 --- a/Source/SPConnectionDelegate.m +++ b/Source/SPConnectionDelegate.m @@ -48,7 +48,7 @@ */ - (void)willQueryString:(NSString *)query connection:(id)connection { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([prefs boolForKey:SPConsoleEnableLogging]) { if ((_queryMode == SPInterfaceQueryMode && [prefs boolForKey:SPConsoleEnableInterfaceLogging]) || (_queryMode == SPCustomQueryQueryMode && [prefs boolForKey:SPConsoleEnableCustomQueryLogging]) @@ -65,7 +65,7 @@ */ - (void)queryGaveError:(NSString *)error connection:(id)connection { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([prefs boolForKey:SPConsoleEnableLogging] && [prefs boolForKey:SPConsoleEnableErrorLogging]) { [[SPQueryController sharedQueryController] showErrorInConsole:error connection:[self name]]; } @@ -139,7 +139,7 @@ // Ensure the window isn't miniaturized if ([[self parentWindow] isMiniaturized]) [[self parentWindow] deminiaturize:self]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Ensure the window and tab are frontmost [self makeKeyDocument]; #endif @@ -181,9 +181,9 @@ /** * Close the connection - should be performed on the main thread. */ -- (void)closeAndDisconnect +- (void) closeAndDisconnect { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSWindow *theParentWindow = [self parentWindow]; _isConnected = NO; diff --git a/Source/SPConnectionHandler.m b/Source/SPConnectionHandler.m index 79ec0aba..ce42c17b 100644 --- a/Source/SPConnectionHandler.m +++ b/Source/SPConnectionHandler.m @@ -64,7 +64,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; */ - (void)initiateMySQLConnection { -#ifndef SP_REFACTOR +#ifndef SP_CODA if (isTestingConnection) { if (sshTunnel) { [progressIndicatorText setStringValue:NSLocalizedString(@"Testing MySQL...", @"MySQL connection test very short status message")]; @@ -81,13 +81,13 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; } [progressIndicatorText display]; - + [connectButton setTitle:NSLocalizedString(@"Cancel", @"cancel button")]; [connectButton setAction:@selector(cancelConnection:)]; [connectButton setEnabled:YES]; [connectButton display]; #endif - + [NSThread detachNewThreadWithName:@"SPConnectionHandler MySQL connection task" target:self selector:@selector(initiateMySQLConnectionInBackground) object:nil]; } @@ -99,7 +99,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; mySQLConnection = [[SPMySQLConnection alloc] init]; - + // Set up shared details [mySQLConnection setUsername:[self user]]; @@ -213,7 +213,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; if (sshTunnel) [sshTunnel disconnect], [sshTunnel release], sshTunnel = nil; [mySQLConnection release], mySQLConnection = nil; -#ifndef SP_REFACTOR +#ifndef SP_CODA if (!cancellingConnection) [self _restoreConnectionInterface]; #endif [pool release]; @@ -225,7 +225,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; if ([self database] && ![[self database] isEqualToString:@""]) { if (![mySQLConnection selectDatabase:[self database]]) { if (!isTestingConnection) { - [[self onMainThread] failConnectionWithTitle:NSLocalizedString(@"Could not select database", @"message when database selection failed") errorMessage:[NSString stringWithFormat:NSLocalizedString(@"Connected to host, but unable to connect to database %@.\n\nBe sure that the database exists and that you have the necessary privileges.\n\nMySQL said: %@", @"message of panel when connection to db failed"), [self database], [mySQLConnection lastErrorMessage]] detail:nil rawErrorText:[mySQLConnection lastErrorMessage]]; + [[self onMainThread] failConnectionWithTitle:NSLocalizedString(@"Could not select database", @"message when database selection failed") errorMessage:[NSString stringWithFormat:NSLocalizedString(@"Connected to host, but unable to connect to database %@.\n\nBe sure that the database exists and that you have the necessary privileges.\n\nMySQL said: %@", @"message of panel when connection to db failed"), [self database], [mySQLConnection lastErrorMessage]] detail:nil rawErrorText:[mySQLConnection lastErrorMessage]]; } // Tidy up @@ -261,7 +261,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; if (isTestingConnection) { [progressIndicatorText setStringValue:NSLocalizedString(@"Testing SSH...", @"SSH testing very short status message")]; } else { - [progressIndicatorText setStringValue:NSLocalizedString(@"SSH connecting...", @"SSH connecting very short status message")]; + [progressIndicatorText setStringValue:NSLocalizedString(@"SSH connecting...", @"SSH connecting very short status message")]; } [progressIndicatorText display]; @@ -308,18 +308,18 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; // If the user is only testing the connection, kill the connection // once established and reset the UI. Also catch connection cancels. if (isTestingConnection || cancellingConnection) { - + // Clean up any connections remaining, and reset the UI [self cancelConnection:self]; - + if (isTestingConnection) { [self _showConnectionTestResult:NSLocalizedString(@"Connection succeeded", @"Connection success very short status message")]; } - + return; } -#ifndef SP_REFACTOR +#ifndef SP_CODA [progressIndicatorText setStringValue:NSLocalizedString(@"Connected", @"connection established message")]; [progressIndicatorText display]; #endif @@ -328,7 +328,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; [dbDocument setIsProcessing:NO]; // Successful connection! -#ifndef SP_REFACTOR +#ifndef SP_CODA [connectButton setEnabled:NO]; [connectButton display]; [progressIndicator stopAnimation:self]; @@ -341,13 +341,13 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; SPBeginAlertSheet(NSLocalizedString(@"SSL connection not established", @"SSL requested but not used title"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [dbDocument parentWindow], nil, nil, nil, NSLocalizedString(@"You requested that the connection should be established using SSL, but MySQL made the connection without SSL.\n\nThis may be because the server does not support SSL connections, or has SSL disabled; or insufficient details were supplied to establish an SSL connection.\n\nThis connection is not encrypted.", @"SSL connection requested but not established error detail")); } else { -#ifndef SP_REFACTOR +#ifndef SP_CODA [dbDocument setStatusIconToImageWithName:@"titlebarlock"]; #endif } } -#ifndef SP_REFACTOR +#ifndef SP_CODA // Re-enable favorites table view [favoritesOutlineView setEnabled:YES]; [(NSView *)favoritesOutlineView display]; @@ -387,21 +387,21 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; return; } -#ifndef SP_REFACTOR +#ifndef SP_CODA [dbDocument setTitlebarStatus:NSLocalizedString(@"SSH Disconnected", @"SSH disconnected titlebar marker")]; #endif [[self onMainThread] failConnectionWithTitle:NSLocalizedString(@"SSH connection failed!", @"SSH connection failed title") errorMessage:[theTunnel lastError] detail:[sshTunnel debugMessages] rawErrorText:[theTunnel lastError]]; } else if (newState == SPMySQLProxyConnected) { -#ifndef SP_REFACTOR +#ifndef SP_CODA [dbDocument setTitlebarStatus:NSLocalizedString(@"SSH Connected", @"SSH connected titlebar marker")]; #endif [self initiateMySQLConnection]; } else { -#ifndef SP_REFACTOR +#ifndef SP_CODA [dbDocument setTitlebarStatus:NSLocalizedString(@"SSH Connecting…", @"SSH connecting titlebar marker")]; #endif } @@ -413,7 +413,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; */ - (void)addConnectionToDocument { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Hide the connection view and restore the main view [connectionView removeFromSuperviewWithoutNeedingDisplay]; [databaseConnectionView setHidden:NO]; @@ -439,7 +439,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; { BOOL isSSHTunnelBindError = NO; -#ifndef SP_REFACTOR +#ifndef SP_CODA [self _restoreConnectionInterface]; #endif @@ -471,7 +471,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; * Alert sheet callback method - invoked when an error sheet is closed. */ - (void)connectionFailureSheetDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo -{ +{ if (returnCode == NSAlertAlternateReturn) { [errorDetailText setFont:[NSFont userFontOfSize:12]]; [errorDetailText setAlignment:NSLeftTextAlignment]; @@ -492,7 +492,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; [self setPort:tunnelPort]; [self setHost:SPLocalhostAddress]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Change to standard TCP/IP connection view [self resizeTabViewToConnectionType:SPTCPIPConnection animating:YES]; #endif diff --git a/Source/SPConstants.m b/Source/SPConstants.m index 24065072..3ac465fb 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -94,7 +94,7 @@ NSString *SPLoadBlobsAsNeeded = @"LoadBlobsAsNeeded"; NSString *SPTableRowCountQueryLevel = @"TableRowCountQueryLevel"; NSString *SPTableRowCountCheapSizeBoundary = @"TableRowCountCheapLookupSizeBoundary"; NSString *SPNewFieldsAllowNulls = @"NewFieldsAllowNulls"; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSString *SPLimitResults = @"LimitResults"; NSString *SPLimitResultsValue = @"LimitResultsValue"; NSString *SPNullValue = @"NullValue"; @@ -120,7 +120,7 @@ NSString *SPConsoleEnableImportExportLogging = @"ConsoleEnableImportExportLo NSString *SPConsoleEnableErrorLogging = @"ConsoleEnableErrorLogging"; // Network Prefpane -#ifndef SP_REFACTOR +#ifndef SP_CODA NSString *SPConnectionTimeoutValue = @"ConnectionTimeoutValue"; NSString *SPUseKeepAlive = @"UseKeepAlive"; NSString *SPKeepAliveInterval = @"KeepAliveInterval"; diff --git a/Source/SPContentFilterManager.h b/Source/SPContentFilterManager.h index ad34621e..4911fb7e 100644 --- a/Source/SPContentFilterManager.h +++ b/Source/SPContentFilterManager.h @@ -41,15 +41,15 @@ @interface SPContentFilterManager : NSWindowController <NSOpenSavePanelDelegate> { -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ NSUserDefaults *prefs; #endif SPDatabaseDocument *tableDocumentInstance; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ NSURL *delegatesFileURL; #endif - + IBOutlet id encodingPopUp; IBOutlet id contentFilterTableView; IBOutlet id contentFilterNameTextField; diff --git a/Source/SPContentFilterManager.m b/Source/SPContentFilterManager.m index d24e0faa..d0282612 100644 --- a/Source/SPContentFilterManager.m +++ b/Source/SPContentFilterManager.m @@ -54,7 +54,7 @@ { if ((self = [super initWithWindowNibName:@"ContentFilterManager"])) { -#ifndef SP_REFACTOR +#ifndef SP_CODA prefs = [NSUserDefaults standardUserDefaults]; #endif @@ -67,7 +67,7 @@ } tableDocumentInstance = [managerDelegate valueForKeyPath:@"tableDocumentInstance"]; -#ifndef SP_REFACTOR +#ifndef SP_CODA delegatesFileURL = [tableDocumentInstance fileURL]; #endif @@ -95,7 +95,7 @@ @"", @"ConjunctionLabel", nil]]; -#ifndef SP_REFACTOR /* prefs access */ +#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]) { @@ -243,12 +243,12 @@ filter = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:NSLocalizedString(@"New Filter",@"Content Filter Manager : Initial name for new filter"), @"", @"", nil] forKeys:[NSArray arrayWithObjects:@"MenuLabel", @"Clause", @"ConjunctionLabel", nil]]; // If a favourite is currently selected, add the new favourite next to it - if ([contentFilterTableView numberOfSelectedRows] > 0) { + if([contentFilterTableView numberOfSelectedRows] > 0) { insertIndex = [[contentFilterTableView selectedRowIndexes] lastIndex]+1; [contentFilters insertObject:filter atIndex:insertIndex]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA // If the DatabaseDocument is an on-disk document, add the favourite to the bottom of that document's favourites else if (![tableDocumentInstance isUntitled]) { insertIndex = [contentFilters count] - 1; @@ -323,7 +323,7 @@ */ - (IBAction)exportContentFilter:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSSavePanel *panel = [NSSavePanel savePanel]; [panel setAllowedFileTypes:[NSArray arrayWithObject:SPFileExtensionDefault]]; @@ -342,7 +342,7 @@ */ - (IBAction)importContentFilterByAdding:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSOpenPanel *panel = [NSOpenPanel openPanel]; [panel setCanSelectHiddenExtension:YES]; [panel setDelegate:self]; @@ -385,7 +385,7 @@ if ([contentFilterTableView numberOfSelectedRows] == 1) [[self window] makeFirstResponder:contentFilterTableView]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Update current document's content filters in the SPQueryController [[SPQueryController sharedQueryController] replaceContentFilterByArray: [self contentFilterForFileURL:delegatesFileURL] ofType:filterType forFileURL:delegatesFileURL]; @@ -446,7 +446,7 @@ * Returns the value for the requested table column and row index. */ - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex -{ +{ if (![[contentFilters objectAtIndex:rowIndex] objectForKey:[aTableColumn identifier]]) return @""; return [[contentFilters objectAtIndex:rowIndex] objectForKey:[aTableColumn identifier]]; @@ -480,7 +480,7 @@ [resultingClauseLabel setHidden:!enable]; [resultingClauseContentLabel setHidden:!enable]; [insertPlaceholderButton setEnabled:enable]; - + return (rowIndex >= 0 && [[contentFilters objectAtIndex:rowIndex] objectForKey:@"headerOfFileURL"]) ? NO : YES; } @@ -808,14 +808,14 @@ // Get next index (beginning from the end) currentIndex = [indexes indexLessThanIndex:currentIndex]; } - + if ([contentFilters count] == 2) { [contentFilterNameTextField setStringValue:@""]; } [contentFilterArrayController rearrangeObjects]; [contentFilterTableView reloadData]; - + // Set focus to filter list to avoid an unstable state [[self window] makeFirstResponder:contentFilterTableView]; @@ -829,7 +829,7 @@ */ - (void)importPanelDidEnd:(NSOpenPanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { -#ifndef SP_REFACTOR +#ifndef SP_CODA if (returnCode == NSOKButton) { NSString *filename = [[panel filenames] objectAtIndex:0]; @@ -897,7 +897,7 @@ - (void)savePanelDidEnd:(NSSavePanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { -#ifndef SP_REFACTOR +#ifndef SP_CODA if([contextInfo isEqualToString:@"exportFilter"]) { if (returnCode == NSOKButton) { diff --git a/Source/SPCopyTable.h b/Source/SPCopyTable.h index 6dc5bc3a..a062b1ed 100644 --- a/Source/SPCopyTable.h +++ b/Source/SPCopyTable.h @@ -98,7 +98,7 @@ extern NSInteger SPEditCopyAsSQL; */ - (NSUInteger)draggingSourceOperationMaskForLocal:(BOOL)isLocal; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ /*! @method rowsAsTabStringWithHeaders:onlySelectedRows: @abstract getter of the selected rows or all of the table for copy diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m index a11f3a04..c5d3f62d 100644 --- a/Source/SPCopyTable.m +++ b/Source/SPCopyTable.m @@ -41,11 +41,11 @@ #import "SPTextAndLinkCell.h" #import "SPTooltip.h" #import "SPAlertSheets.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPBundleHTMLOutputController.h" #endif #import "SPGeometryDataView.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPBundleEditorController.h" #import "SPAppController.h" #endif @@ -99,7 +99,7 @@ static const NSInteger kBlobAsImageFile = 4; */ - (void)copy:(id)sender { -#ifndef SP_REFACTOR /* copy table rows */ +#ifndef SP_CODA /* copy table rows */ NSString *tmp = nil; if ([sender tag] == SPEditCopyAsSQL) { @@ -128,11 +128,11 @@ static const NSInteger kBlobAsImageFile = 4; #endif } -#ifdef SP_REFACTOR +#ifdef SP_CODA - (void)delete:(id)sender { - [tableInstance removeRow:self]; + [tableInstance removeRow:self]; } #endif @@ -141,7 +141,7 @@ static const NSInteger kBlobAsImageFile = 4; * Get selected rows a string of newline separated lines of tab separated fields * the value in each field is from the objects description method */ -#ifndef SP_REFACTOR /* get rows as string */ +#ifndef SP_CODA /* get rows as string */ - (NSString *)rowsAsTabStringWithHeaders:(BOOL)withHeaders onlySelectedRows:(BOOL)onlySelected blobHandling:(NSInteger)withBlobHandling { if (onlySelected && [self numberOfSelectedRows] == 0) return nil; @@ -487,7 +487,7 @@ static const NSInteger kBlobAsImageFile = 4; cellData = nil; rowCounter++; NSMutableArray *rowValues = [[NSMutableArray alloc] initWithCapacity:numColumns]; - + for (c = 0; c < numColumns; c++) { cellData = SPDataStorageObjectAtRowAndColumn(tableStorage, rowIndex, columnMappings[c]); @@ -775,7 +775,7 @@ static const NSInteger kBlobAsImageFile = 4; NSRange linebreakRange; double rowStep; unichar breakChar; -#ifndef SP_REFACTOR /* patch */ +#ifndef SP_CODA /* patch */ NSFont *tableFont = [NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPGlobalResultTableFont]]; #else NSFont *tableFont = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; @@ -877,7 +877,7 @@ static const NSInteger kBlobAsImageFile = 4; - (NSMenu *)menuForEvent:(NSEvent *)event { NSMenu *menu = [self menu]; -#ifndef SP_REFACTOR /* menuForEvent: */ +#ifndef SP_CODA /* menuForEvent: */ if(![[self delegate] isKindOfClass:[SPCustomQuery class]] && ![[self delegate] isKindOfClass:[SPTableContent class]]) return menu; @@ -966,7 +966,7 @@ static const NSInteger kBlobAsImageFile = 4; if (i >= 0 && i < rows) { [selection addIndex:i]; - } + } } [self selectRowIndexes:selection byExtendingSelection:NO]; @@ -979,7 +979,7 @@ static const NSInteger kBlobAsImageFile = 4; */ - (BOOL)validateMenuItem:(NSMenuItem*)anItem { -#ifndef SP_REFACTOR /* validateMenuItem: */ +#ifndef SP_CODA /* validateMenuItem: */ NSInteger menuItemTag = [anItem tag]; if ([anItem action] == @selector(performFindPanelAction:)) { @@ -1006,7 +1006,7 @@ static const NSInteger kBlobAsImageFile = 4; return (columnDefinitions != nil && [self numberOfSelectedRows] > 0); } #endif -#ifdef SP_REFACTOR +#ifdef SP_CODA if ( [anItem action] == @selector(selectAll:) ) return YES; @@ -1093,7 +1093,7 @@ static const NSInteger kBlobAsImageFile = 4; if (NSMaxRange([[textView string] lineRangeForRange:[textView selectedRange]]) < [[textView string] length]) return NO; - NSInteger newRow = row + 1; + NSInteger newRow = row+1; // Check if we're already at the end of the list if (newRow >= [(id<NSTableViewDataSource>)[self delegate] numberOfRowsInTableView:self]) return YES; @@ -1127,11 +1127,11 @@ static const NSInteger kBlobAsImageFile = 4; // Already at the beginning of the list if (row == 0) return YES; - - NSInteger newRow = row - 1; + + NSInteger newRow = row-1; [[control window] makeFirstResponder:control]; - + if ([[self delegate] isKindOfClass:[SPTableContent class]] && ![self isCellEditingMode] && [[self delegate] respondsToSelector:@selector(saveRowToTable)]) { [(SPTableContent *)[self delegate] saveRowToTable]; } @@ -1187,7 +1187,7 @@ static const NSInteger kBlobAsImageFile = 4; { // Retrieve the column definition -#ifdef SP_REFACTOR +#ifdef SP_CODA NSDictionary *columnDefinition = nil; if ( [[self delegate] isKindOfClass:[SPTableContent class]] ) @@ -1202,7 +1202,7 @@ static const NSInteger kBlobAsImageFile = 4; NSString *columnType = [columnDefinition objectForKey:@"typegrouping"]; // Return YES if the multiple line editing button is enabled - triggers sheet editing on all cells. -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([prefs boolForKey:SPEditInSheetEnabled]) return YES; #endif @@ -1231,7 +1231,7 @@ static const NSInteger kBlobAsImageFile = 4; - (IBAction)executeBundleItemForDataTable:(id)sender { -#ifndef SP_REFACTOR /* executeBundleItemForDataTable: */ +#ifndef SP_CODA /* executeBundleItemForDataTable: */ NSInteger idx = [sender tag] - 1000000; NSString *infoPath = nil; NSArray *bundleItems = [[NSApp delegate] bundleItemsForScope:SPBundleScopeDataTable]; @@ -1414,13 +1414,13 @@ static const NSInteger kBlobAsImageFile = 4; NSString *output = [SPBundleCommandRunner runBashCommand:cmd withEnvironment:env - atCurrentDirectoryPath:nil - callerInstance:[[NSApp delegate] frontDocument] - contextInfo:[NSDictionary dictionaryWithObjectsAndKeys: - ([cmdData objectForKey:SPBundleFileNameKey])?:@"-", @"name", - NSLocalizedString(@"Data Table", @"data table menu item label"), @"scope", + atCurrentDirectoryPath:nil + callerInstance:[[NSApp delegate] frontDocument] + contextInfo:[NSDictionary dictionaryWithObjectsAndKeys: + ([cmdData objectForKey:SPBundleFileNameKey])?:@"-", @"name", + NSLocalizedString(@"Data Table", @"data table menu item label"), @"scope", uuid, SPBundleFileInternalexecutionUUID, nil] - error:&err]; + error:&err]; [[NSFileManager defaultManager] removeItemAtPath:bundleInputFilePath error:nil]; @@ -1523,7 +1523,7 @@ static const NSInteger kBlobAsImageFile = 4; - (void)dealloc { if (columnDefinitions) [columnDefinitions release]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs release]; #endif diff --git a/Source/SPCustomQuery.h b/Source/SPCustomQuery.h index 85c52e91..c34c0bc1 100644 --- a/Source/SPCustomQuery.h +++ b/Source/SPCustomQuery.h @@ -42,12 +42,12 @@ #define SP_HELP_GOFORWARD_BUTTON 2 #define SP_HELP_NOT_AVAILABLE @"__no_help_available" -#define SP_SAVE_ALL_FAVORTITE_MENUITEM_TAG 100001 -#define SP_SAVE_SELECTION_FAVORTITE_MENUITEM_TAG 100000 -#define SP_FAVORITE_HEADER_MENUITEM_TAG 200000 -#define SP_HISTORY_COPY_MENUITEM_TAG 300000 -#define SP_HISTORY_SAVE_MENUITEM_TAG 300001 -#define SP_HISTORY_CLEAR_MENUITEM_TAG 300002 +#define SP_SAVE_ALL_FAVORTITE_MENUITEM_TAG 100001 +#define SP_SAVE_SELECTION_FAVORTITE_MENUITEM_TAG 100000 +#define SP_FAVORITE_HEADER_MENUITEM_TAG 200000 +#define SP_HISTORY_COPY_MENUITEM_TAG 300000 +#define SP_HISTORY_SAVE_MENUITEM_TAG 300001 +#define SP_HISTORY_CLEAR_MENUITEM_TAG 300002 @class SPCopyTable; @class SPQueryFavoriteManager; @@ -58,7 +58,7 @@ @class SPMySQLFastStreamingResult; @class SPTextView; -#ifdef SP_REFACTOR +#ifdef SP_CODA @class SPDatabaseDocument; @class SPTablesList; #endif @@ -69,7 +69,7 @@ IBOutlet id tableDocumentInstance; IBOutlet id tablesListInstance; -#ifndef SP_REFACTOR +#ifndef SP_CODA IBOutlet id queryFavoritesButton; IBOutlet NSMenuItem *queryFavoritesSearchMenuItem; IBOutlet NSMenuItem *queryFavoritesSaveAsMenuItem; @@ -115,12 +115,12 @@ IBOutlet NSMenuItem *autouppercaseKeywordsMenuItem; IBOutlet NSMenuItem *commentCurrentQueryMenuItem; IBOutlet NSMenuItem *commentLineOrSelectionMenuItem; -#ifndef SP_REFACTOR +#ifndef SP_CODA IBOutlet NSMenuItem *previousHistoryMenuItem; IBOutlet NSMenuItem *nextHistoryMenuItem; #endif -#ifndef SP_REFACTOR +#ifndef SP_CODA IBOutlet NSWindow *helpWebViewWindow; IBOutlet WebView *helpWebView; IBOutlet NSSearchField *helpSearchField; @@ -150,7 +150,7 @@ NSUInteger queryStartPosition; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSUInteger helpTarget; WebHistory *helpHistory; NSString *helpHTMLTemplate; @@ -193,7 +193,7 @@ NSString *kCellEditorErrorTooManyMatches; } -#ifdef SP_REFACTOR +#ifdef SP_CODA @property (assign) SPDatabaseDocument* tableDocumentInstance; @property (assign) SPTablesList* tablesListInstance; @property (assign) SPTextView *textView; @@ -211,7 +211,7 @@ - (IBAction)chooseQueryHistory:(id)sender; - (IBAction)closeSheet:(id)sender; - (IBAction)gearMenuItemSelected:(id)sender; -#ifndef SP_REFACTOR +#ifndef SP_CODA - (IBAction)showHelpForCurrentWord:(id)sender; - (IBAction)showHelpForSearchString:(id)sender; - (IBAction)helpSegmentDispatcher:(id)sender; @@ -235,12 +235,12 @@ - (NSString *)queryAtPosition:(NSUInteger)position lookBehind:(BOOL *)doLookBehind; - (NSRange)queryRangeAtPosition:(NSUInteger)position lookBehind:(BOOL *)doLookBehind; - (NSRange)queryTextRangeForQuery:(NSInteger)anIndex startPosition:(NSUInteger)position; -- (void)updateStatusInterfaceWithDetails:(NSDictionary *)errorDetails; +- (void) updateStatusInterfaceWithDetails:(NSDictionary *)errorDetails; // Query load actions -- (void)initQueryLoadTimer; -- (void)clearQueryLoadTimer; -- (void)queryLoadUpdate:(NSTimer *)theTimer; +- (void) initQueryLoadTimer; +- (void) clearQueryLoadTimer; +- (void) queryLoadUpdate:(NSTimer *)theTimer; // Accessors - (NSArray *)currentResult; @@ -248,17 +248,17 @@ - (void)processResultIntoDataStorage:(SPMySQLFastStreamingResult *)theResult; // Retrieving and setting table state -- (void)updateTableView; -- (NSIndexSet *)resultSelectedRowIndexes; -- (NSRect)resultViewport; +- (void) updateTableView; +- (NSIndexSet *) resultSelectedRowIndexes; +- (NSRect) resultViewport; - (NSArray *)dataColumnDefinitions; -- (void)setResultSelectedRowIndexesToRestore:(NSIndexSet *)theIndexSet; -- (void)setResultViewportToRestore:(NSRect)theViewport; -- (void)storeCurrentResultViewForRestoration; -- (void)clearResultViewDetailsToRestore; -- (void)autosizeColumns; +- (void) setResultSelectedRowIndexesToRestore:(NSIndexSet *)theIndexSet; +- (void) setResultViewportToRestore:(NSRect)theViewport; +- (void) storeCurrentResultViewForRestoration; +- (void) clearResultViewDetailsToRestore; +- (void) autosizeColumns; -#ifndef SP_REFACTOR +#ifndef SP_CODA // MySQL Help - (void)showAutoHelpForCurrentWord:(id)sender; - (NSString *)getHTMLformattedMySQLHelpFor:(NSString *)searchString calledByAutoHelp:(BOOL)autoHelp; @@ -270,8 +270,8 @@ - (void)setMySQLversion:(NSString *)theVersion; // Task interaction -- (void)startDocumentTaskForTab:(NSNotification *)aNotification; -- (void)endDocumentTaskForTab:(NSNotification *)aNotification; +- (void) startDocumentTaskForTab:(NSNotification *)aNotification; +- (void) endDocumentTaskForTab:(NSNotification *)aNotification; // Tableview interaction - (void)tableSortCallback; diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index 9fc4f1c6..18b14c58 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -33,7 +33,7 @@ #import "SPCustomQuery.h" #import "SPSQLParser.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPGrowlController.h" #endif #import "SPDataCellFormatter.h" @@ -44,7 +44,7 @@ #import "SPTextAndLinkCell.h" #import "SPTooltip.h" #import "SPCopyTable.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPQueryFavoriteManager.h" #endif #import "SPQueryController.h" @@ -58,7 +58,7 @@ #import "SPTextView.h" #import "RegexKitLite.h" #import "SPThreadAdditions.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPAppController.h" #import "SPBundleHTMLOutputController.h" #endif @@ -76,7 +76,7 @@ @implementation SPCustomQuery -#ifdef SP_REFACTOR +#ifdef SP_CODA @synthesize textView; @synthesize customQueryView; @synthesize runAllButton; @@ -206,7 +206,7 @@ */ - (IBAction)chooseQueryFavorite:(id)sender { -#ifndef SP_REFACTOR /* ui manip for query favorites */ +#ifndef SP_CODA /* ui manip for query favorites */ if ([queryFavoritesButton indexOfSelectedItem] == 1) { // This should never evaluate to true as we are now performing menu validation, meaning the 'Save Query to Favorites' menu item will @@ -280,7 +280,7 @@ */ - (IBAction)chooseQueryHistory:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs synchronize]; // Choose history item @@ -313,7 +313,7 @@ */ - (IBAction)gearMenuItemSelected:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ( sender == previousHistoryMenuItem ) { NSInteger numberOfHistoryItems = [[SPQueryController sharedQueryController] numberOfHistoryItemsForFileURL:[tableDocumentInstance fileURL]]; currentHistoryOffsetIndex++; @@ -391,7 +391,7 @@ // "Indent new lines" toggle if (sender == autoindentMenuItem) { BOOL enableAutoindent = !([autoindentMenuItem state] == NSOffState); -#ifndef SP_REFACTOR /* prefs access */ +#ifndef SP_CODA /* prefs access */ [prefs setBool:enableAutoindent forKey:SPCustomQueryAutoIndent]; [prefs synchronize]; #endif @@ -402,7 +402,7 @@ // "Auto-pair characters" toggle if (sender == autopairMenuItem) { BOOL enableAutopair = !([autopairMenuItem state] == NSOffState); -#ifndef SP_REFACTOR /* prefs access */ +#ifndef SP_CODA /* prefs access */ [prefs setBool:enableAutopair forKey:SPCustomQueryAutoPairCharacters]; [prefs synchronize]; #endif @@ -410,7 +410,7 @@ [textView setAutopair:enableAutopair]; } -#ifndef SP_REFACTOR /* prefs access */ +#ifndef SP_CODA /* prefs access */ // "Auto-help" toggle if (sender == autohelpMenuItem) { BOOL enableAutohelp = !([autohelpMenuItem state] == NSOffState); @@ -424,7 +424,7 @@ // "Auto-uppercase keywords" toggle if (sender == autouppercaseKeywordsMenuItem) { BOOL enableAutouppercaseKeywords = !([autouppercaseKeywordsMenuItem state] == NSOffState); -#ifndef SP_REFACTOR /* prefs access */ +#ifndef SP_CODA /* prefs access */ [prefs setBool:enableAutouppercaseKeywords forKey:SPCustomQueryAutoUppercaseKeywords]; [prefs synchronize]; #endif @@ -435,7 +435,7 @@ - (IBAction)saveQueryHistory:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSSavePanel *panel = [NSSavePanel savePanel]; [panel setAllowedFileTypes:[NSArray arrayWithObject:SPFileExtensionSQL]]; @@ -467,7 +467,7 @@ */ - (IBAction)clearQueryHistory:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSString *infoString; if ([tableDocumentInstance isUntitled]) @@ -543,12 +543,12 @@ - (void)performQueriesTask:(NSDictionary *)taskArguments { - NSAutoreleasePool *queryRunningPool = [[NSAutoreleasePool alloc] init]; - NSArray *queries = [taskArguments objectForKey:@"queries"]; + NSAutoreleasePool *queryRunningPool = [[NSAutoreleasePool alloc] init]; + NSArray *queries = [taskArguments objectForKey:@"queries"]; SPMySQLFastStreamingResult *streamingResult = nil; - NSMutableString *errors = [NSMutableString string]; - SEL callbackMethod = NULL; - NSString *taskButtonString; + NSMutableString *errors = [NSMutableString string]; + SEL callbackMethod = NULL; + NSString *taskButtonString; NSUInteger i, totalQueriesRun = 0, totalAffectedRows = 0; double executionTime = 0; @@ -559,14 +559,14 @@ // BOOL queriesSeparatedByDelimiter = NO; NSCharacterSet *whitespaceAndNewlineSet = [NSCharacterSet whitespaceAndNewlineCharacterSet]; -#ifndef SP_REFACTOR /* [tableDocumentInstance setQueryMode:] */ +#ifndef SP_CODA /* [tableDocumentInstance setQueryMode:] */ [tableDocumentInstance setQueryMode:SPCustomQueryQueryMode]; #endif // Notify listeners that a query has started [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"SMySQLQueryWillBePerformed" object:tableDocumentInstance]; -#ifndef SP_REFACTOR /* growl */ +#ifndef SP_CODA /* growl */ // Start the notification timer to allow notifications to be shown even if frontmost for long queries [[SPGrowlController sharedGrowlController] setVisibilityForNotificationName:@"Query Finished"]; #endif @@ -768,7 +768,7 @@ [errors setString:[mySQLConnection lastErrorMessage]]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA // add query to history if(!reloadingExistingResult && [usedQuery length]) [self performSelectorOnMainThread:@selector(addHistoryEntry:) withObject:usedQuery waitUntilDone:NO]; @@ -832,7 +832,7 @@ // Restore automatic query retries [mySQLConnection setRetryQueriesOnConnectionFailure:YES]; -#ifndef SP_REFACTOR /* [tableDocumentInstance setQueryMode:] */ +#ifndef SP_CODA /* [tableDocumentInstance setQueryMode:] */ [tableDocumentInstance setQueryMode:SPInterfaceQueryMode]; #endif @@ -843,7 +843,7 @@ // Notify any listeners that the query has completed [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; -#ifndef SP_REFACTOR /* growl */ +#ifndef SP_CODA /* growl */ // Perform the Growl notification for query completion [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Query Finished" description:[NSString stringWithFormat:NSLocalizedString(@"%@",@"description for query finished growl notification"), [errorText string]] @@ -876,7 +876,7 @@ //query finished [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; -#ifndef SP_REFACTOR /* growl */ +#ifndef SP_CODA /* growl */ // Query finished Growl notification [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Query Finished" description:[NSString stringWithFormat:NSLocalizedString(@"%@",@"description for query finished growl notification"), [errorText string]] @@ -1258,7 +1258,7 @@ // If errors occur, display them if ( [mySQLConnection lastQueryWasCancelled] || ([errorsString length] && !queryIsTableSorter)) { -#ifndef SP_REFACTOR +#ifndef SP_CODA // set the error text [errorText setString:[errorsString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; [[errorTextScrollView verticalScroller] setFloatValue:1.0f]; @@ -1327,7 +1327,7 @@ [errorText setString:NSLocalizedString(@"There were no errors.", @"text shown when query was successfull")]; } -#ifndef SP_REFACTOR /* show/hide errror view */ +#ifndef SP_CODA /* show/hide errror view */ // Show or hide the error area if necessary if ([errorsString length] && [queryInfoPaneSplitView isCollapsibleSubviewCollapsed]) { [queryInfoPaneSplitView toggleCollapse:self]; @@ -1450,7 +1450,7 @@ NSMutableArray *currentResult = [NSMutableArray array]; [currentResult addObject:[NSArray arrayWithArray:tempRow]]; - + // Add rows for (i = 0; i < [self numberOfRowsInTableView:customQueryView]; i++) { @@ -1487,7 +1487,7 @@ // Set up the interface [customQueryView setVerticalMotionCanBeginDrag:NO]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [autoindentMenuItem setState:([prefs boolForKey:SPCustomQueryAutoIndent]?NSOnState:NSOffState)]; [autopairMenuItem setState:([prefs boolForKey:SPCustomQueryAutoPairCharacters]?NSOnState:NSOffState)]; [autohelpMenuItem setState:([prefs boolForKey:SPCustomQueryUpdateAutoHelp]?NSOnState:NSOffState)]; @@ -1499,7 +1499,7 @@ [autouppercaseKeywordsMenuItem setState:(YES?NSOnState:NSOffState)]; #endif -#ifndef SP_REFACTOR +#ifndef SP_CODA if ( [[SPQueryController sharedQueryController] historyForFileURL:[tableDocumentInstance fileURL]] ) [self performSelectorOnMainThread:@selector(historyItemsHaveBeenUpdated:) withObject:self waitUntilDone:YES]; @@ -1555,7 +1555,7 @@ } // Update font size on the table -#ifndef SP_REFACTOR +#ifndef SP_CODA NSFont *tableFont = [NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPGlobalResultTableFont]]; [customQueryView setRowHeight:2.0f+NSSizeToCGSize([[NSString stringWithString:@"{ǞṶḹÜ∑zgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; #else @@ -1598,7 +1598,7 @@ [[theCol headerCell] setStringValue:[columnDefinition objectForKey:@"name"]]; [theCol setHeaderToolTip:[NSString stringWithFormat:@"%@ – %@%@", [columnDefinition objectForKey:@"name"], [columnDefinition objectForKey:@"type"], ([columnDefinition objectForKey:@"char_length"]) ? [NSString stringWithFormat:@"(%@)", [columnDefinition objectForKey:@"char_length"]] : @""]]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Set the width of this column to saved value if exists and maps to a real column if ([columnDefinition objectForKey:@"org_name"] && [(NSString *)[columnDefinition objectForKey:@"org_name"] length]) { NSNumber *colWidth = [[[[prefs objectForKey:SPTableColumnWidths] objectForKey:[NSString stringWithFormat:@"%@@%@", [columnDefinition objectForKey:@"db"], [tableDocumentInstance host]]] objectForKey:[columnDefinition objectForKey:@"org_table"]] objectForKey:[columnDefinition objectForKey:@"org_name"]]; @@ -1685,7 +1685,7 @@ [customQueryView setDelegate:nil]; for (NSDictionary *columnDefinition in cqColumnDefinition) { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Skip columns with saved widths if ([[[[prefs objectForKey:SPTableColumnWidths] objectForKey:[NSString stringWithFormat:@"%@@%@", [tableDocumentInstance database], [tableDocumentInstance host]]] objectForKey:[tablesListInstance tableName]] objectForKey:[columnDefinition objectForKey:@"name"]]) continue; #endif @@ -1927,7 +1927,7 @@ // This shouldn't happen – for safety reasons if ( ![mySQLConnection rowsAffectedByLastQuery] ) { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ( [prefs boolForKey:SPShowNoAffectedRowsError] ) { SPBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil, NSLocalizedString(@"The row was not written to the MySQL database. You probably haven't changed anything.\nReload the table to be sure that the row exists and use a primary key for your table.\n(This error can be turned off in the preferences.)", @"message of panel when no rows have been affected after writing to the db")); @@ -1939,7 +1939,7 @@ } // On success reload table data by executing the last query if reloading is enabled -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([prefs boolForKey:SPReloadAfterEditingRow]) { reloadingExistingResult = YES; [self storeCurrentResultViewForRestoration]; @@ -1948,7 +1948,7 @@ #endif // otherwise, just update the data in the data storage SPDataStorageReplaceObjectAtRowAndColumn(resultData, rowIndex, [[aTableColumn identifier] intValue], anObject); -#ifndef SP_REFACTOR +#ifndef SP_CODA } #endif } else { @@ -2407,7 +2407,7 @@ return NO; } - + return YES; } else { @@ -2435,7 +2435,7 @@ // Check our notification object is our table content view if ([aNotification object] != customQueryView) return; -#ifndef SP_REFACTOR /* triggered commands */ +#ifndef SP_CODA /* triggered commands */ NSArray *triggeredCommands = [[NSApp delegate] bundleCommandsForTrigger:SPBundleTriggerActionTableRowChanged]; for(NSString* cmdPath in triggeredCommands) { NSArray *data = [cmdPath componentsSeparatedByString:@"|"]; @@ -2497,13 +2497,13 @@ NSString *host_db = [NSString stringWithFormat:@"%@@%@", [columnDefinition objectForKey:@"db"], [tableDocumentInstance host]]; // Retrieve or instantiate the tableColumnWidths object -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([prefs objectForKey:SPTableColumnWidths] != nil) { tableColumnWidths = [NSMutableDictionary dictionaryWithDictionary:[prefs objectForKey:SPTableColumnWidths]]; } else { #endif tableColumnWidths = [NSMutableDictionary dictionary]; -#ifndef SP_REFACTOR +#ifndef SP_CODA } #endif @@ -2523,7 +2523,7 @@ // Save the column size [[[tableColumnWidths objectForKey:host_db] objectForKey:table] setObject:[NSNumber numberWithDouble:[(NSTableColumn *)[[aNotification userInfo] objectForKey:@"NSTableColumn"] width]] forKey:col]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs setObject:tableColumnWidths forKey:SPTableColumnWidths]; #endif } @@ -2540,7 +2540,7 @@ NSUInteger targetWidth = [customQueryView autodetectWidthForColumnDefinition:columnDefinition maxRows:500]; // Clear any saved widths for the column -#ifndef SP_REFACTOR +#ifndef SP_CODA NSString *dbKey = [NSString stringWithFormat:@"%@@%@", [tableDocumentInstance database], [tableDocumentInstance host]]; NSString *tableKey = [tablesListInstance tableName]; NSMutableDictionary *savedWidths = [NSMutableDictionary dictionaryWithDictionary:[prefs objectForKey:SPTableColumnWidths]]; @@ -2698,7 +2698,7 @@ */ - (void)controlTextDidChange:(NSNotification *)notification { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([notification object] == queryFavoriteNameTextField) [saveQueryFavoriteButton setEnabled:[[queryFavoriteNameTextField stringValue] length]]; else if ([notification object] == queryFavoritesSearchField){ @@ -2710,7 +2710,7 @@ #endif } -#ifndef SP_REFACTOR +#ifndef SP_CODA - (NSUndoManager *)undoManagerForTextView:(NSTextView *)aTextView { return [tableDocumentInstance undoManager]; @@ -2720,7 +2720,7 @@ #pragma mark - #pragma mark SplitView delegate methods -#ifndef SP_REFACTOR /* splitview delegate methods */ +#ifndef SP_CODA /* splitview delegate methods */ /** * Tells the split views that they can collapse views @@ -2752,7 +2752,7 @@ [textView setConnection:mySQLConnection withVersion:[[[mySQLversion componentsSeparatedByString:@"."] objectAtIndex:0] integerValue]]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Return the Help window. */ @@ -2971,7 +2971,7 @@ } } -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Show the data for "HELP 'currentWord' invoked by autohelp" */ @@ -3054,7 +3054,7 @@ theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"HELP '%@%%'", [searchString stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"]]]; // really nothing found? - if (![theResult numberOfRows]) + if(![theResult numberOfRows]) return [NSString stringWithFormat:@"<em style='color: gray'>%@</em>", NSLocalizedString(@"No results found.", @"Mysql Help Viewer : Search : No results")]; } @@ -3273,7 +3273,7 @@ #pragma mark - #pragma mark Query favorites manager delegate methods -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Rebuild history popup menu. @@ -3374,7 +3374,7 @@ { isWorking = YES; -#ifndef SP_REFACTOR /* check selected view */ +#ifndef SP_CODA /* check selected view */ // Only proceed if this view is selected. if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarCustomQuery]) return; @@ -3394,7 +3394,7 @@ { isWorking = NO; -#ifndef SP_REFACTOR /* check active tab */ +#ifndef SP_CODA /* check active tab */ // Only proceed if this view is selected. if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarCustomQuery]) return; @@ -3454,7 +3454,7 @@ // Result Table Font preference changed else if ([keyPath isEqualToString:SPGlobalResultTableFont]) { NSFont *tableFont = [NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [customQueryView setRowHeight:2.0f+NSSizeToCGSize([[NSString stringWithString:@"{ǞṶḹÜ∑zgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; #else [customQueryView setRowHeight:2.0f+NSSizeToCGSize([@"{ǞṶḹÜ∑zgyf" sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; @@ -3474,7 +3474,7 @@ return; } -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([contextInfo isEqualToString:@"clearHistory"]) { if (returnCode == NSOKButton) { // Remove items in the query controller @@ -3531,7 +3531,7 @@ - (void)savePanelDidEnd:(NSSavePanel *)panel returnCode:(NSInteger)returnCode contextInfo:(id)contextInfo { -#ifndef SP_REFACTOR +#ifndef SP_CODA if([contextInfo isEqualToString:@"saveHistory"]) { if (returnCode == NSOKButton) { NSError *error = nil; @@ -3540,9 +3540,9 @@ [prefs synchronize]; [[self buildHistoryString] writeToURL:[panel URL] - atomically:YES - encoding:[[encodingPopUp selectedItem] tag] - error:&error]; + atomically:YES + encoding:[[encodingPopUp selectedItem] tag] + error:&error]; if (error) [[NSAlert alertWithError:error] runModal]; } @@ -3555,7 +3555,7 @@ */ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Control "Save ... to Favorites" if ( [menuItem tag] == SP_SAVE_SELECTION_FAVORTITE_MENUITEM_TAG ) { if ([[textView string] length] < 1) return NO; @@ -3643,7 +3643,7 @@ { if ((self = [super init])) { -#ifndef SP_REFACTOR +#ifndef SP_CODA usedQuery = [[NSString stringWithString:@""] retain]; #else usedQuery = [@"" retain]; @@ -3662,7 +3662,7 @@ selectionIndexToRestore = nil; selectionViewportToRestore = NSZeroRect; -#ifndef SP_REFACTOR +#ifndef SP_CODA // init helpHTMLTemplate NSError *error; @@ -3703,7 +3703,7 @@ return self; } -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Filters the query favorites menu. */ @@ -3818,7 +3818,7 @@ */ - (BOOL)control:(NSControl*)control textView:(NSTextView*)aTextView doCommandBySelector:(SEL)command { -#ifndef SP_REFACTOR +#ifndef SP_CODA if(control == queryHistorySearchField || control == queryFavoritesSearchField) { if(command == @selector(moveDown:) || command == @selector(moveUp:)) { [queryHistorySearchField abortEditing]; @@ -3841,7 +3841,7 @@ if([control isKindOfClass:[SPCopyTable class]]) { // Check firstly if SPCopyTable can handle command -#ifndef SP_REFACTOR +#ifndef SP_CODA if([customQueryView control:control textView:aTextView doCommandBySelector:(SEL)command]) #else if([customQueryView control:control textView:aTextView doCommandBySelector:command]) @@ -3873,7 +3873,7 @@ [customQueryView setFieldEditorSelectedRange:NSMakeRange(0,0)]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Set pre-defined menu tags [queryFavoritesSaveAsMenuItem setTag:SP_SAVE_SELECTION_FAVORTITE_MENUITEM_TAG]; [queryFavoritesSaveAllMenuItem setTag:SP_SAVE_ALL_FAVORTITE_MENUITEM_TAG]; @@ -3887,7 +3887,7 @@ [queryInfoPaneSplitView setCollapsibleSubviewCollapsed:YES animate:NO]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Set the structure and index view's vertical gridlines if required [customQueryView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; #endif @@ -3902,7 +3902,7 @@ name:SPDocumentTaskEndNotification object:tableDocumentInstance]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs addObserver:self forKeyPath:SPGlobalResultTableFont options:NSKeyValueObservingOptionNew context:NULL]; #endif @@ -3977,7 +3977,7 @@ - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs removeObserver:self forKeyPath:SPGlobalResultTableFont]; #endif [NSObject cancelPreviousPerformRequestsWithTarget:customQueryView]; @@ -3990,7 +3990,7 @@ if(fieldEditor) [fieldEditor release], fieldEditor = nil; -#ifndef SP_REFACTOR +#ifndef SP_CODA if (helpHTMLTemplate) [helpHTMLTemplate release]; #endif if (mySQLversion) [mySQLversion release]; diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h index 9f9b72b2..05dd8639 100644 --- a/Source/SPDatabaseDocument.h +++ b/Source/SPDatabaseDocument.h @@ -7,7 +7,7 @@ // Created by Lorenz Textor (lorenz@textor.ch) on May 1, 2002. // Copyright (c) 2002-2003 Lorenz Textor. All rights reserved. // Copyright (c) 2012 Sequel Pro Team. 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 @@ -31,13 +31,13 @@ // // More info at <http://code.google.com/p/sequel-pro/> -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import <WebKit/WebKit.h> #endif @class SPConnectionController; -#ifdef SP_REFACTOR +#ifdef SP_CODA @class BottomBarSegmentedControl; #else @class SPProcessListController; @@ -66,8 +66,9 @@ */ @interface SPDatabaseDocument : NSObject <SPConnectionControllerDelegateProtocol, SPMySQLConnectionDelegate, NSTextFieldDelegate, NSToolbarDelegate> { -#ifdef SP_REFACTOR /* patch */ +#ifdef SP_CODA /* patch */ id delegate; + BottomBarSegmentedControl* _structureContentSwitcher; #endif // IBOutlets @@ -81,16 +82,16 @@ IBOutlet SPTableData* tableDataInstance; IBOutlet id extendedTableInfoInstance; IBOutlet id databaseDataInstance; -#ifndef SP_REFACTOR +#ifndef SP_CODA IBOutlet id spHistoryControllerInstance; IBOutlet id exportControllerInstance; #endif - + IBOutlet id statusTableAccessoryView; IBOutlet id statusTableView; IBOutlet id statusTableCopyChecksum; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ SPUserManager *userManagerInstance; #endif SPServerSupport *serverSupport; @@ -111,32 +112,32 @@ IBOutlet id databaseRenameSheet; IBOutlet NSProgressIndicator* queryProgressBar; -#ifndef SP_REFACTOR +#ifndef SP_CODA IBOutlet NSBox *taskProgressLayer; IBOutlet id taskProgressIndicator; IBOutlet id taskDescriptionText; IBOutlet NSButton *taskCancelButton; - + IBOutlet id favoritesButton; #endif - + IBOutlet id databaseNameField; IBOutlet id databaseEncodingButton; IBOutlet id addDatabaseButton; -#ifndef SP_REFACTOR +#ifndef SP_CODA IBOutlet id databaseCopyNameField; IBOutlet NSButton *copyDatabaseDataButton; IBOutlet id copyDatabaseMessageField; IBOutlet id copyDatabaseButton; #endif - + IBOutlet id databaseRenameNameField; IBOutlet id renameDatabaseMessageField; IBOutlet id renameDatabaseButton; IBOutlet id chooseDatabaseButton; -#ifndef SP_REFACTOR +#ifndef SP_CODA IBOutlet id historyControl; IBOutlet NSTabView *tableTabView; @@ -155,7 +156,7 @@ IBOutlet NSWindow *createTableSyntaxWindow; IBOutlet NSWindow *connectionErrorDialog; -#ifndef SP_REFACTOR +#ifndef SP_CODA IBOutlet id saveConnectionAccessory; IBOutlet NSButton *saveConnectionIncludeData; IBOutlet NSButton *saveConnectionIncludeQuery; @@ -177,7 +178,7 @@ // Controllers SPConnectionController *connectionController; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ SPProcessListController *processListController; SPServerVariablesController *serverVariablesController; @@ -194,7 +195,7 @@ NSString *selectedDatabase; NSString *mySQLVersion; NSString *selectedDatabaseEncoding; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ NSUserDefaults *prefs; NSMutableArray *nibObjectsToRelease; NSUndoManager *undoManager; @@ -204,7 +205,7 @@ BOOL _supportsEncoding; BOOL _isConnected; NSInteger _isWorkingLevel; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ BOOL _mainNibLoaded; #endif BOOL databaseListIsSelectable; @@ -213,7 +214,7 @@ BOOL _workingTimeout; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSWindow *taskProgressWindow; BOOL taskDisplayIsIndeterminate; CGFloat taskProgressValue; @@ -224,7 +225,7 @@ BOOL taskCanBeCancelled; id taskCancellationCallbackObject; SEL taskCancellationCallbackSelector; - + NSToolbar *mainToolbar; NSToolbarItem *chooseDatabaseToolbarItem; @@ -236,7 +237,7 @@ NSString *queryEditorInitString; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ NSURL *spfFileURL; NSDictionary *spfSession; NSMutableDictionary *spfPreferences; @@ -247,7 +248,7 @@ NSString *keyChainID; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ NSThread *printThread; NSArray *statusValues; @@ -258,18 +259,18 @@ SPWindowController *parentWindowController; #endif NSWindow *parentWindow; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ NSTabViewItem *parentTabViewItem; #endif BOOL isProcessing; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ NSString *processID; BOOL windowTitleStatusViewIsVisible; #endif SPDatabaseStructure *databaseStructureRetrieval; } -#ifdef SP_REFACTOR /* ivars */ +#ifdef SP_CODA /* ivars */ @property (assign) SPDatabaseData* databaseDataInstance; @property (assign) SPTableData* tableDataInstance; @property (assign) SPCustomQuery* customQueryInstance; @@ -285,30 +286,30 @@ @property (assign) id databaseRenameSheet; #endif -#ifdef SP_REFACTOR /* ivars */ +#ifdef SP_CODA /* ivars */ @property (assign) id delegate; @property (readonly) NSMutableArray* allDatabases; @property (assign) NSProgressIndicator* queryProgressBar; @property (assign) NSWindow* databaseSheet; #endif -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ @property (readwrite, assign) SPWindowController *parentWindowController; @property (readwrite, assign) NSTabViewItem *parentTabViewItem; #endif @property (readwrite, assign) BOOL isProcessing; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ @property (readwrite, retain) NSString *processID; #endif @property (readonly) SPServerSupport *serverSupport; @property (readonly) SPDatabaseStructure *databaseStructureRetrieval; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ - (BOOL)isUntitled; #endif - (BOOL)couldCommitCurrentViewActions; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ - (void)initQueryEditorWithString:(NSString *)query; // Connection callback and methods @@ -319,18 +320,18 @@ // Database methods - (IBAction)setDatabases:(id)sender; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ - (IBAction)chooseDatabase:(id)sender; #endif - (void)selectDatabase:(NSString *)aDatabase item:(NSString *)anItem; - (IBAction)addDatabase:(id)sender; - (IBAction)removeDatabase:(id)sender; - (IBAction)refreshTables:(id)sender; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ - (IBAction)copyDatabase:(id)sender; #endif - (IBAction)renameDatabase:(id)sender; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ - (IBAction)showMySQLHelp:(id)sender; - (IBAction) makeTableListFilterHaveFocus:(id)sender; - (IBAction)showServerVariables:(id)sender; @@ -366,7 +367,7 @@ - (void)updateEncodingMenuWithSelectedEncoding:(NSNumber *)encodingTag; - (NSNumber *)encodingTagFromMySQLEncoding:(NSString *)mysqlEncoding; - (NSString *)mysqlEncodingFromEncodingTag:(NSNumber *)encodingTag; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ // Table methods - (IBAction)showCreateTableSyntax:(id)sender; @@ -385,7 +386,7 @@ - (IBAction)exportSelectedTablesAs:(id)sender; // Other methods -- (void)setQueryMode:(NSInteger)theQueryMode; +- (void) setQueryMode:(NSInteger)theQueryMode; - (IBAction)closeSheet:(id)sender; - (IBAction)closePanelSheet:(id)sender; - (void)doPerformQueryService:(NSString *)query; @@ -395,7 +396,7 @@ - (NSWindow *)getCreateTableSyntaxWindow; #endif - (void)refreshCurrentDatabase; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ - (void)saveConnectionPanelDidEnd:(NSSavePanel *)panel returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo; - (IBAction)validateSaveConnectionAccessory:(id)sender; - (BOOL)saveDocumentWithFilePath:(NSString *)fileName inBackground:(BOOL)saveInBackground onlyPreferences:(BOOL)saveOnlyPreferences contextInfo:(NSDictionary*)contextInfo; @@ -421,7 +422,7 @@ - (NSString *)user; - (NSString *)keyChainID; - (NSString *)connectionID; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ - (NSString *)tabTitleForTooltip; - (BOOL)isSaveInBundle; - (NSURL *)fileURL; @@ -431,7 +432,7 @@ - (NSArray *)allTableNames; - (SPTablesList *)tablesListInstance; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ // Notification center methods - (void)willPerformQuery:(NSNotification *)notification; - (void)hasPerformedQuery:(NSNotification *)notification; @@ -464,7 +465,7 @@ #endif - (BOOL)parentTabShouldClose; - (void)parentTabDidClose; -#ifndef SP_REFACTOR +#ifndef SP_CODA - (void)willResignActiveTabInWindow; - (void)didBecomeActiveTabInWindow; - (void)tabDidBecomeKey; @@ -476,7 +477,7 @@ - (void)setParentWindow:(NSWindow *)aWindow; - (NSWindow *)parentWindow; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ // Scripting - (void)handleSchemeCommand:(NSDictionary*)commandDict; - (void)registerActivity:(NSDictionary*)commandDict; @@ -486,13 +487,13 @@ - (NSDictionary*)shellVariables; // State saving and setting -- (NSDictionary *)stateIncludingDetails:(NSDictionary *)detailsToReturn; +- (NSDictionary *) stateIncludingDetails:(NSDictionary *)detailsToReturn; - (BOOL)setState:(NSDictionary *)stateDetails; - (BOOL)setStateFromConnectionFile:(NSString *)path; - (void)restoreSession; #endif -#ifdef SP_REFACTOR /* method decls */ +#ifdef SP_CODA /* method decls */ - (SPConnectionController*)createConnectionController; - (SPConnectionController*)connectionController; - (void)connect; diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 9c92a6f3..108fc40c 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -7,7 +7,7 @@ // Created by Lorenz Textor (lorenz@textor.ch) on May 1, 2002. // Copyright (c) 2002-2003 Lorenz Textor. All rights reserved. // Copyright (c) 2012 Sequel Pro Team. 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 @@ -45,7 +45,7 @@ enum { #import "SPTablesList.h" #import "SPTableStructure.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPFileHandle.h" #import "SPKeychain.h" #import "SPTableContent.h" @@ -59,17 +59,17 @@ enum { #endif #import "SPQueryController.h" #import "SPQueryDocumentsController.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPWindowController.h" #endif #import "SPNavigatorController.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPSQLParser.h" #import "SPTableData.h" #endif #import "SPDatabaseData.h" #import "SPDatabaseStructure.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPAppController.h" #import "SPWindowManagement.h" #import "SPExtendedTableInfo.h" @@ -89,17 +89,17 @@ enum { #import "SPCopyTable.h" #endif #import "SPServerSupport.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPTooltip.h" #endif #import "SPDatabaseViewController.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPBundleHTMLOutputController.h" #import "SPConnectionDelegate.h" #endif #import "SPThreadAdditions.h" -#ifdef SP_REFACTOR /* headers */ +#ifdef SP_CODA /* headers */ #import "SPAlertSheets.h" #import "NSNotificationCenterThreadingAdditions.h" #import "SPCustomQuery.h" @@ -109,7 +109,7 @@ enum { #import <SPMySQL/SPMySQL.h> // Constants -#ifndef SP_REFACTOR +#ifndef SP_CODA static NSString *SPCreateSyntx = @"SPCreateSyntax"; #endif static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; @@ -117,13 +117,13 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; @interface SPDatabaseDocument () - (void)_addDatabase; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ - (void)_copyDatabase; #endif - (void)_renameDatabase; - (void)_removeDatabase; - (void)_selectDatabaseAndItem:(NSDictionary *)selectionDetails; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ - (void)_processDatabaseChangedBundleTriggerActions; #endif @@ -131,18 +131,18 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; @implementation SPDatabaseDocument -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ @synthesize parentWindowController; @synthesize parentTabViewItem; #endif @synthesize isProcessing; @synthesize serverSupport; @synthesize databaseStructureRetrieval; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ @synthesize processID; #endif -#ifdef SP_REFACTOR /* ivars */ +#ifdef SP_CODA /* ivars */ @synthesize allDatabases; @synthesize delegate; @synthesize tableDataInstance; @@ -157,12 +157,13 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; @synthesize databaseRenameNameField; @synthesize renameDatabaseButton; @synthesize chooseDatabaseButton; +@synthesize structureContentSwitcher; #endif - (id)init { if ((self = [super init])) { -#ifndef SP_REFACTOR /* init ivars */ +#ifndef SP_CODA /* init ivars */ _mainNibLoaded = NO; #endif @@ -173,7 +174,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; databaseListIsSelectable = YES; _queryMode = SPInterfaceQueryMode; chooseDatabaseButton = nil; -#ifndef SP_REFACTOR /* init ivars */ +#ifndef SP_CODA /* init ivars */ chooseDatabaseToolbarItem = nil; #endif connectionController = nil; @@ -192,13 +193,13 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; mySQLVersion = nil; allDatabases = nil; allSystemDatabases = nil; -#ifndef SP_REFACTOR /* init ivars */ +#ifndef SP_CODA /* init ivars */ mainToolbar = nil; parentWindow = nil; #endif isProcessing = NO; -#ifndef SP_REFACTOR /* init ivars */ +#ifndef SP_CODA /* init ivars */ printWebView = [[WebView alloc] init]; [printWebView setFrameLoadDelegate:self]; @@ -207,7 +208,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; #endif queryEditorInitString = nil; -#ifndef SP_REFACTOR +#ifndef SP_CODA spfFileURL = nil; spfSession = nil; spfPreferences = [[NSMutableDictionary alloc] init]; @@ -216,7 +217,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; #endif titleAccessoryView = nil; -#ifndef SP_REFACTOR /* init ivars */ +#ifndef SP_CODA /* init ivars */ taskProgressWindow = nil; taskDisplayIsIndeterminate = YES; taskDisplayLastValue = 0; @@ -228,9 +229,9 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; taskCancellationCallbackObject = nil; taskCancellationCallbackSelector = NULL; #endif - + keyChainID = nil; -#ifndef SP_REFACTOR /* init ivars */ +#ifndef SP_CODA /* init ivars */ statusValues = nil; printThread = nil; windowTitleStatusViewIsVisible = NO; @@ -251,7 +252,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; return self; } -#ifdef SP_REFACTOR /* glue */ +#ifdef SP_CODA /* glue */ - (SPConnectionController*)createConnectionController { // Set up the connection controller @@ -278,7 +279,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; - (void)awakeFromNib { -#ifndef SP_REFACTOR +#ifndef SP_CODA if (_mainNibLoaded) return; _mainNibLoaded = YES; @@ -322,7 +323,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:@"NSApplicationWillTerminateNotification" object:nil]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Find the Database -> Database Encoding menu (it's not in our nib, so we can't use interface builder) selectEncodingMenu = [[[[[NSApp mainMenu] itemWithTag:SPMainMenuDatabase] submenu] itemWithTag:1] submenu]; @@ -331,7 +332,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; // Hide the activity list [self setActivityPaneHidden:[NSNumber numberWithInteger:1]]; - + // Load additional nibs, keeping track of the top-level objects to allow correct release NSArray *connectionDialogTopLevelObjects = nil; NSNib *nibLoader = [[NSNib alloc] initWithNibNamed:@"ConnectionErrorDialog" bundle:[NSBundle mainBundle]]; @@ -342,7 +343,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } [nibLoader release]; - // SP_REFACTOR can't use progress indicator because of BWToolkit dependency + // SP_CODA can't use progress indicator because of BWToolkit dependency NSArray *progressIndicatorLayerTopLevelObjects = nil; nibLoader = [[NSNib alloc] initWithNibNamed:@"ProgressIndicatorLayer" bundle:[NSBundle mainBundle]]; @@ -356,8 +357,8 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; // Retain the icon accessory view to allow it to be added and removed from windows [titleAccessoryView retain]; #endif - -#ifndef SP_REFACTOR + +#ifndef SP_CODA // Set up the progress indicator child window and layer - change indicator color and size [taskProgressIndicator setForeColor:[NSColor whiteColor]]; NSShadow *progressIndicatorShadow = [[NSShadow alloc] init]; @@ -377,7 +378,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; #endif } -#ifndef SP_REFACTOR /* password sheet and history navigation */ +#ifndef SP_CODA /* password sheet and history navigation */ /** * Set the return code for entering the encryption passowrd sheet */ @@ -432,7 +433,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; minor:[mySQLConnection serverMinorVersion] release:[mySQLConnection serverReleaseVersion]]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Set the fileURL and init the preferences (query favs, filters, and history) if available for that URL [self setFileURL:[[SPQueryController sharedQueryController] registerDocumentWithFileURL:[self fileURL] andContextInfo:spfPreferences]]; @@ -447,7 +448,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; if ([connectionController database] && ![[connectionController database] isEqualToString:@""]) { if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil; selectedDatabase = [[NSString alloc] initWithString:[connectionController database]]; -#ifndef SP_REFACTOR /* [spHistoryControllerInstance updateHistoryEntries] */ +#ifndef SP_CODA /* [spHistoryControllerInstance updateHistoryEntries] */ [spHistoryControllerInstance updateHistoryEntries]; #endif } @@ -468,9 +469,9 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; // Pass the support class to the data instance [databaseDataInstance setServerSupport:serverSupport]; -#ifdef SP_REFACTOR /* glue */ +#ifdef SP_CODA /* glue */ tablesListInstance = [[SPTablesList alloc] init]; - [tablesListInstance setDatabaseDocument:self]; + [tablesListInstance setDatabaseDocument:self]; [tablesListInstance awakeFromNib]; #endif @@ -478,7 +479,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; // is still UTF8 [tablesListInstance setConnection:mySQLConnection]; -#ifndef SP_REFACTOR /* set connection encoding from prefs */ +#ifndef SP_CODA /* set connection encoding from prefs */ // Set the connection encoding if necessary NSNumber *encodingType = [prefs objectForKey:SPDefaultEncoding]; @@ -487,7 +488,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } else { #endif [[self onMainThread] updateEncodingMenuWithSelectedEncoding:[self encodingTagFromMySQLEncoding:[mySQLConnection encoding]]]; -#ifndef SP_REFACTOR +#ifndef SP_CODA } #endif @@ -498,7 +499,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [tableTriggersInstance setConnection:mySQLConnection]; [customQueryInstance setConnection:mySQLConnection]; [tableDumpInstance setConnection:mySQLConnection]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [exportControllerInstance setConnection:mySQLConnection]; #endif [tableDataInstance setConnection:mySQLConnection]; @@ -507,7 +508,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; // Set the custom query editor's MySQL version [customQueryInstance setMySQLversion:mySQLVersion]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [self updateWindowTitle:self]; // Connected Growl notification @@ -589,7 +590,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; // otherwise set focus to Table List view [[tablesListInstance onMainThread] makeTableListFilterHaveFocus]; #endif -#ifdef SP_REFACTOR /* glue */ +#ifdef SP_CODA /* glue */ if ( delegate && [delegate respondsToSelector:@selector(databaseDocumentDidConnect:)] ) [delegate performSelector:@selector(databaseDocumentDidConnect:) withObject:self]; #endif @@ -600,7 +601,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; * * @return The document's connection */ -- (SPMySQLConnection *)getConnection +- (SPMySQLConnection *) getConnection { return mySQLConnection; } @@ -621,7 +622,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (IBAction)setDatabases:(id)sender; { -#ifndef SP_REFACTOR /* ui manipulation */ +#ifndef SP_CODA /* ui manipulation */ if (!chooseDatabaseButton) return; @@ -650,13 +651,13 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [databaseName isEqualToString:SPMySQLInformationSchemaDatabase] || [databaseName isEqualToString:SPMySQLPerformanceSchemaDatabase]) { [allSystemDatabases addObject:databaseName]; - } + } else { [allDatabases addObject:databaseName]; } } -#ifndef SP_REFACTOR /* ui manipulation */ +#ifndef SP_CODA /* ui manipulation */ // Add system databases for (NSString *db in allSystemDatabases) { @@ -678,7 +679,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; #endif } -#ifndef SP_REFACTOR /* chooseDatabase: */ +#ifndef SP_CODA /* chooseDatabase: */ /** * Selects the database choosen by the user, using a child task if necessary, @@ -691,7 +692,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; return; } - if ([chooseDatabaseButton indexOfSelectedItem] == 0) { + if ( [chooseDatabaseButton indexOfSelectedItem] == 0 ) { if ([self database]) { [chooseDatabaseButton selectItemWithTitle:[self database]]; } @@ -712,17 +713,17 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void)selectDatabase:(NSString *)database item:(NSString *)item { -#ifndef SP_REFACTOR /* update navigator controller */ +#ifndef SP_CODA /* update navigator controller */ // Do not update the navigator since nothing is changed [[SPNavigatorController sharedNavigatorController] setIgnoreUpdate:NO]; // If Navigator runs in syncMode let it follow the selection - if ([[SPNavigatorController sharedNavigatorController] syncMode]) { + if([[SPNavigatorController sharedNavigatorController] syncMode]) { NSMutableString *schemaPath = [NSMutableString string]; [schemaPath setString:[self connectionID]]; - if ([chooseDatabaseButton titleOfSelectedItem] && [[chooseDatabaseButton titleOfSelectedItem] length]) { + if([chooseDatabaseButton titleOfSelectedItem] && [[chooseDatabaseButton titleOfSelectedItem] length]) { [schemaPath appendString:SPUniqueSchemaDelimiter]; [schemaPath appendString:[chooseDatabaseButton titleOfSelectedItem]]; } @@ -795,7 +796,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } -#ifndef SP_REFACTOR /* operations on whole databases */ +#ifndef SP_CODA /* operations on whole databases */ /** * opens the copy database sheet and copies the databsae */ @@ -836,7 +837,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (IBAction)removeDatabase:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA // No database selected, bail if ([chooseDatabaseButton indexOfSelectedItem] == 0) return; #endif @@ -851,7 +852,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; NSArray *buttons = [alert buttons]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Change the alert's cancel button to have the key equivalent of return [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; @@ -874,7 +875,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [tablesListInstance updateTables:self]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Displays the database server variables sheet. */ @@ -936,8 +937,8 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void)sheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { -#ifndef SP_REFACTOR - if ([contextInfo isEqualToString:@"saveDocPrefSheetStatus"]) { +#ifndef SP_CODA + if([contextInfo isEqualToString:@"saveDocPrefSheetStatus"]) { saveDocPrefSheetStatus = returnCode; return; } @@ -954,7 +955,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; if (returnCode == NSAlertDefaultReturn) { [self _removeDatabase]; } -#ifdef SP_REFACTOR +#ifdef SP_CODA else { // Reset chooseDatabaseButton if ([[self database] length]) { @@ -962,7 +963,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } else { [chooseDatabaseButton selectItemAtIndex:0]; - } + } } #endif } @@ -981,10 +982,10 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } else { [chooseDatabaseButton selectItemAtIndex:0]; - } } } -#ifndef SP_REFACTOR + } +#ifndef SP_CODA else if ([contextInfo isEqualToString:@"copyDatabase"]) { if (returnCode == NSOKButton) { [self _copyDatabase]; @@ -995,7 +996,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; if (returnCode == NSOKButton) { [self _renameDatabase]; } -#ifdef SP_REFACTOR +#ifdef SP_CODA else { // Reset chooseDatabaseButton if ([[self database] length]) { @@ -1003,11 +1004,11 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } else { [chooseDatabaseButton selectItemAtIndex:0]; - } + } } #endif } -#ifndef SP_REFACTOR +#ifndef SP_CODA // Close error status sheet for OPTIMIZE, CHECK, REPAIR etc. else if ([contextInfo isEqualToString:@"statusError"]) { if (statusValues) [statusValues release], statusValues = nil; @@ -1015,7 +1016,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; #endif } -#ifndef SP_REFACTOR /* sheetDidEnd: */ +#ifndef SP_CODA /* sheetDidEnd: */ /** * Show Error sheet (can be called from inside of a endSheet selector) * via [self performSelector:@selector(showErrorSheetWithTitle:) withObject: afterDelay:] @@ -1050,14 +1051,14 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil; selectedDatabase = [[NSString alloc] initWithString:dbName]; [chooseDatabaseButton selectItemWithTitle:selectedDatabase]; -#ifndef SP_REFACTOR /* [self updateWindowTitle:self] */ +#ifndef SP_CODA /* [self updateWindowTitle:self] */ [self updateWindowTitle:self]; #endif } } else { if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil; [chooseDatabaseButton selectItemAtIndex:0]; -#ifndef SP_REFACTOR /* [self updateWindowTitle:self] */ +#ifndef SP_CODA /* [self updateWindowTitle:self] */ [self updateWindowTitle:self]; #endif } @@ -1067,7 +1068,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"SMySQLQueryHasBeenPerformed" object:self]; } -#ifndef SP_REFACTOR /* navigatorSchemaPathExistsForDatabase: */ +#ifndef SP_CODA /* navigatorSchemaPathExistsForDatabase: */ - (BOOL)navigatorSchemaPathExistsForDatabase:(NSString*)dbname { return [[SPNavigatorController sharedNavigatorController] schemaPathExistsForConnection:[self connectionID] andDatabase:dbname]; @@ -1084,7 +1085,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; return [[SPNavigatorController sharedNavigatorController] allSchemaKeysForConnection:[self connectionID]]; } -#ifndef SP_REFACTOR /* console and navigator methods */ +#ifndef SP_CODA /* console and navigator methods */ #pragma mark - #pragma mark Console methods @@ -1195,7 +1196,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; // Increment the task level _isWorkingLevel++; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Reset the progress indicator if necessary if (_isWorkingLevel == 1 || !taskDisplayIsIndeterminate) { taskDisplayIsIndeterminate = YES; @@ -1204,17 +1205,17 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; taskDisplayLastValue = 0; } #endif - + // If the working level just moved to start a task, set up the interface if (_isWorkingLevel == 1) { -#ifndef SP_REFACTOR +#ifndef SP_CODA [taskCancelButton setHidden:YES]; #endif - + // Set flags and prevent further UI interaction in this window databaseListIsSelectable = NO; [[NSNotificationCenter defaultCenter] postNotificationName:SPDocumentTaskStartNotification object:self]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [mainToolbar validateVisibleItems]; [chooseDatabaseButton setEnabled:NO]; @@ -1230,7 +1231,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void) fadeInTaskProgressWindow:(NSTimer *)theTimer { -#ifndef SP_REFACTOR +#ifndef SP_CODA double timeSinceFadeInStart = [[NSDate date] timeIntervalSinceDate:taskFadeInStartDate]; // Keep the window hidden for the first ~0.5 secs @@ -1260,7 +1261,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void) setTaskDescription:(NSString *)description { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSShadow *textShadow = [[NSShadow alloc] init]; [textShadow setShadowColor:[NSColor colorWithCalibratedWhite:0.0f alpha:0.75f]]; [textShadow setShadowOffset:NSMakeSize(1.0f, -1.0f)]; @@ -1287,7 +1288,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void) setTaskPercentage:(CGFloat)taskPercentage { -#ifndef SP_REFACTOR +#ifndef SP_CODA // If the task display is currently indeterminate, set it to determinate on the main thread. if (taskDisplayIsIndeterminate) { @@ -1323,7 +1324,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void) setTaskProgressToIndeterminateAfterDelay:(BOOL)afterDelay { -#ifndef SP_REFACTOR +#ifndef SP_CODA if (afterDelay) { [self performSelector:@selector(setTaskProgressToIndeterminateAfterDelay:) withObject:nil afterDelay:0.5]; return; @@ -1356,7 +1357,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; // If all tasks have ended, re-enable the interface if (!_isWorkingLevel) { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Cancel the draw timer if it exists if (taskDrawTimer) { [taskDrawTimer invalidate], [taskDrawTimer release], taskDrawTimer = nil; @@ -1369,11 +1370,11 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; taskDisplayIsIndeterminate = YES; [taskProgressIndicator setIndeterminate:YES]; #endif - + // Re-enable window interface databaseListIsSelectable = YES; [[NSNotificationCenter defaultCenter] postNotificationName:SPDocumentTaskEndNotification object:self]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [mainToolbar validateVisibleItems]; #endif [chooseDatabaseButton setEnabled:_isConnected]; @@ -1386,7 +1387,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void) enableTaskCancellationWithTitle:(NSString *)buttonTitle callbackObject:(id)callbackObject callbackFunction:(SEL)callbackFunction { -#ifndef SP_REFACTOR +#ifndef SP_CODA // If no task is active, return if (!_isWorkingLevel) return; @@ -1411,7 +1412,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void) disableTaskCancellation { -#ifndef SP_REFACTOR +#ifndef SP_CODA // If no task is active, return if (!_isWorkingLevel) return; @@ -1431,7 +1432,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (IBAction) cancelTask:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA if (!taskCanBeCancelled) return; [taskCancelButton setEnabled:NO]; @@ -1442,7 +1443,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [mySQLConnection setLastQueryWasCancelled:YES]; [[databaseStructureRetrieval connection] killQueryOnThreadID:[mySQLConnection mysqlConnectionThreadId]]; } else { - [mySQLConnection cancelCurrentQuery]; + [mySQLConnection cancelCurrentQuery]; } if (taskCancellationCallbackObject && taskCancellationCallbackSelector) { @@ -1473,7 +1474,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void) centerTaskWindow { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSPoint newBottomLeftPoint; NSRect mainWindowRect = [parentWindow frame]; NSRect taskWindowRect = [taskProgressWindow frame]; @@ -1491,7 +1492,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void) setTaskIndicatorShouldAnimate:(BOOL)shouldAnimate { -#ifndef SP_REFACTOR +#ifndef SP_CODA if (shouldAnimate) { [[taskProgressIndicator onMainThread] startAnimation:self]; } else { @@ -1648,7 +1649,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [selectedDatabaseEncoding release], selectedDatabaseEncoding = nil; // Fallback or older version? -> set encoding to mysql default encoding latin1 - if (!mysqlEncoding) { + if ( !mysqlEncoding ) { NSLog(@"Error: no character encoding found, mysql version is %@", [self mySQLVersion]); selectedDatabaseEncoding = [[NSString alloc] initWithString:@"latin1"]; @@ -1678,7 +1679,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; #pragma mark - #pragma mark Table Methods -#ifndef SP_REFACTOR /* whole table operations */ +#ifndef SP_CODA /* whole table operations */ /** * Copies if sender == self or displays or the CREATE TABLE syntax of the selected table(s) to the user . @@ -1941,7 +1942,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } // Process result - if ([selectedItems count] == 1) { + if([selectedItems count] == 1) { NSDictionary *lastresult = [resultStatuses lastObject]; message = ([[lastresult objectForKey:@"Msg_type"] isEqualToString:@"status"]) ? NSLocalizedString(@"Successfully analyzed table.",@"analyze table successfully passed message") : NSLocalizedString(@"Analyze table failed.", @"analyze table failed message"); @@ -2018,7 +2019,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } // Process result - if ([selectedItems count] == 1) { + if([selectedItems count] == 1) { NSDictionary *lastresult = [resultStatuses lastObject]; message = ([[lastresult objectForKey:@"Msg_type"] isEqualToString:@"status"]) ? NSLocalizedString(@"Successfully optimized table.",@"optimize table successfully passed message") : NSLocalizedString(@"Optimize table failed.", @"optimize table failed message"); @@ -2094,7 +2095,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } // Process result - if ([selectedItems count] == 1) { + if([selectedItems count] == 1) { NSDictionary *lastresult = [resultStatuses lastObject]; message = ([[lastresult objectForKey:@"Msg_type"] isEqualToString:@"status"]) ? NSLocalizedString(@"Successfully repaired table.",@"repair table successfully passed message") : NSLocalizedString(@"Repair table failed.", @"repair table failed message"); @@ -2104,7 +2105,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; message = NSLocalizedString(@"Successfully repaired all selected items.",@"successfully repaired all selected items message"); } - if (message) { + if(message) { [[NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Repair %@", @"REPAIR one or more tables - result title"), what] defaultButton:@"OK" alternateButton:nil @@ -2170,7 +2171,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } // Process result - if ([selectedItems count] == 1) { + if([selectedItems count] == 1) { NSDictionary *lastresult = [resultStatuses lastObject]; message = ([[lastresult objectForKey:@"Msg_type"] isEqualToString:@"status"]) ? NSLocalizedString(@"Successfully flushed table.",@"flush table successfully passed message") : NSLocalizedString(@"Flush table failed.", @"flush table failed message"); @@ -2180,7 +2181,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; message = NSLocalizedString(@"Successfully flushed all selected items.",@"successfully flushed all selected items message"); } - if (message) { + if(message) { [[NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Flush %@", @"FLUSH one or more tables - result title"), what] defaultButton:@"OK" alternateButton:nil @@ -2236,7 +2237,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; // Process result NSArray *resultStatuses = [theResult getAllRows]; - if ([selectedItems count] == 1) { + if([selectedItems count] == 1) { message = [[resultStatuses lastObject] objectForKey:@"Checksum"]; [[NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Checksum %@",@"checksum %@ message"), what] defaultButton:@"OK" @@ -2374,7 +2375,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [[sender window] orderOut:self]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Displays the user account manager. */ @@ -2477,7 +2478,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [mySQLConnection disconnect]; _isConnected = NO; -#ifndef SP_REFACTOR /* growl */ +#ifndef SP_CODA /* growl */ // Disconnected Growl notification [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Disconnected" description:[NSString stringWithFormat:NSLocalizedString(@"Disconnected from %@",@"description for disconnected growl notification"), [parentTabViewItem label]] @@ -2486,7 +2487,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; #endif } -#ifndef SP_REFACTOR /* observeValueForKeyPath: */ +#ifndef SP_CODA /* observeValueForKeyPath: */ /** * This method is called as part of Key Value Observing which is used to watch for prefernce changes which effect the interface. */ @@ -2514,7 +2515,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; - (BOOL)couldCommitCurrentViewActions { [parentWindow endEditingFor:nil]; -#ifndef SP_REFACTOR +#ifndef SP_CODA switch ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]]) { // Table structure view @@ -2528,7 +2529,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; default: break; } - + return YES; #else return [tableSourceInstance saveRowOnDeselect] && [tableContentInstance saveRowOnDeselect]; @@ -2604,7 +2605,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; /** * Returns the full window title which is mainly used for tab tooltips */ -#ifndef SP_REFACTOR +#ifndef SP_CODA - (NSString *)tabTitleForTooltip { @@ -2624,7 +2625,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; tabTitle = [NSMutableString string]; -#ifndef SP_REFACTOR /* Add the MySQL version to the window title */ +#ifndef SP_CODA /* Add the MySQL version to the window title */ // Add the MySQL version to the window title if enabled in prefs if ([prefs boolForKey:SPDisplayServerVersionInWindowTitle]) [tabTitle appendFormat:@"(MySQL %@)\n", [self mySQLVersion]]; #endif @@ -2725,7 +2726,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void)applicationWillTerminate:(NSNotification *)notification { -#ifndef SP_REFACTOR /* applicationWillTerminate: */ +#ifndef SP_CODA /* applicationWillTerminate: */ // Auto-save preferences to spf file based connection if([self fileURL] && [[[self fileURL] path] length] && ![self isUntitled]) @@ -2745,7 +2746,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; #pragma mark - #pragma mark Menu methods -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Saves SP session or if Custom Query tab is active the editor's content as SQL file * If sender == nil then the call came from [self writeSafelyToURL:ofType:forSaveOperation:error] @@ -3431,10 +3432,10 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [menuItem action] == @selector(closeTab:)); } -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([menuItem action] == @selector(openCurrentConnectionInNewWindow:)) { - if ([self isUntitled]) { + if([self isUntitled]) { [menuItem setTitle:NSLocalizedString(@"Open in New Window", @"menu item open in new window")]; return NO; } @@ -3509,7 +3510,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; return YES; } -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([menuItem action] == @selector(printDocument:)) { return (([self database] != nil && [[tablesListInstance valueForKeyPath:@"tablesListView"] numberOfSelectedRows] == 1) || // If Custom Query Tab is active the textView will handle printDocument by itself @@ -3535,7 +3536,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; return [[[tablesListInstance valueForKeyPath:@"tablesListView"] selectedRowIndexes] count]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([menuItem action] == @selector(addConnectionToFavorites:)) { return ![connectionController selectedFavorite]; } @@ -3597,7 +3598,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (IBAction)addConnectionToFavorites:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Obviously don't add if it already exists. We shouldn't really need this as the menu item validation // enables or disables the menu item based on the same method. Although to be safe do the check anyway // as we don't know what's calling this method. @@ -3613,7 +3614,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (BOOL)isCustomQuerySelected { -#ifndef SP_REFACTOR +#ifndef SP_CODA return [[self selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarCustomQuery]; #else return ([_structureContentSwitcher selectedSegment] == 2); @@ -3625,7 +3626,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void)savePanelDidEnd:(NSSavePanel *)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { -#ifndef SP_REFACTOR +#ifndef SP_CODA if (returnCode == NSOKButton) { if ([contextInfo isEqualToString:SPCreateSyntx]) { @@ -3657,7 +3658,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void) updateWindowTitle:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Ensure a call on the main thread if (![NSThread isMainThread]) return [[self onMainThread] updateWindowTitle:sender]; @@ -3736,7 +3737,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void)setStatusIconToImageWithName:(NSString *)imageName { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSString *imagePath = [[NSBundle mainBundle] pathForResource:imageName ofType:@"png"]; if (!imagePath) return; @@ -3747,7 +3748,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; - (void)setTitlebarStatus:(NSString *)status { -#ifndef SP_REFACTOR +#ifndef SP_CODA [self clearStatusIcon]; [titleStringView setStringValue:status]; #endif @@ -3758,7 +3759,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void)clearStatusIcon { -#ifndef SP_REFACTOR +#ifndef SP_CODA [titleImageView setImage:nil]; #endif } @@ -3769,7 +3770,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void)updateTitlebarStatusVisibilityForcingHide:(BOOL)forceHide { -#ifndef SP_REFACTOR +#ifndef SP_CODA BOOL newIsVisible = !forceHide; if (newIsVisible && [parentWindow styleMask] & NSFullScreenWindowMask) newIsVisible = NO; if (newIsVisible && [parentWindowController selectedTableDocument] != self) newIsVisible = NO; @@ -3796,14 +3797,14 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; #pragma mark - #pragma mark Toolbar Methods -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * set up the standard toolbar */ - (void)setupToolbar { - // create a new toolbar instance, and attach it to our document window + // create a new toolbar instance, and attach it to our document window mainToolbar = [[NSToolbar alloc] initWithIdentifier:@"TableWindowToolbar"]; // set up toolbar properties @@ -4066,7 +4067,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; - (void)makeKeyDocument { [[[self parentWindow] onMainThread] makeKeyAndOrderFront:self]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [[[[self parentTabViewItem] onMainThread] tabView] selectTabViewItemWithIdentifier:self]; #endif } @@ -4087,7 +4088,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; // edits in progress in various views. if ( ![tablesListInstance selectionShouldChangeInTableView:nil] ) return NO; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Auto-save spf file based connection and return if the save was not successful if([self fileURL] && [[[self fileURL] path] length] && ![self isUntitled]) { BOOL isSaved = [self saveDocumentWithFilePath:nil inBackground:YES onlyPreferences:YES contextInfo:nil]; @@ -4125,14 +4126,14 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void)parentTabDidClose { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Cancel autocompletion trigger if([prefs boolForKey:SPCustomQueryAutoComplete]) #endif [NSObject cancelPreviousPerformRequestsWithTarget:[customQueryInstance valueForKeyPath:@"textView"] selector:@selector(doAutoCompletion) object:nil]; -#ifndef SP_REFACTOR +#ifndef SP_CODA if([prefs boolForKey:SPCustomQueryUpdateAutoHelp]) #endif [NSObject cancelPreviousPerformRequestsWithTarget:[customQueryInstance valueForKeyPath:@"textView"] @@ -4146,7 +4147,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } else { [connectionController cancelConnection:self]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([[[SPQueryController sharedQueryController] window] isVisible]) [self toggleConsole:self]; [createTableSyntaxWindow orderOut:nil]; #endif @@ -4155,7 +4156,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Invoked when the parent tab is currently the active tab in the * window, but is being switched away from, to allow cleaning up @@ -4234,7 +4235,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void)setParentWindow:(NSWindow *)aWindow { -#ifndef SP_REFACTOR +#ifndef SP_CODA // If the window is being set for the first time - connection controller is visible - update focus if (!parentWindow && !mySQLConnection) { [aWindow makeFirstResponder:(NSResponder *)[connectionController favoritesOutlineView]]; @@ -4255,7 +4256,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; return parentWindow; } -#ifndef SP_REFACTOR +#ifndef SP_CODA #pragma mark - #pragma mark NSDocument compatibility @@ -4278,14 +4279,14 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; /** * Retrieve the NSURL for the .spf file for this connection instance (if any) */ -#ifndef SP_REFACTOR +#ifndef SP_CODA - (NSURL *)fileURL { return [[spfFileURL copy] autorelease]; } #endif -#ifndef SP_REFACTOR /* writeSafelyToURL: */ +#ifndef SP_CODA /* writeSafelyToURL: */ /** * Invoked if user chose "Save" from 'Do you want save changes you made...' sheet * which is called automatically if [self isDocumentEdited] == YES and user wanted to close an Untitled doc. @@ -4935,7 +4936,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void)connectionControllerInitiatingConnection:(id)controller { -#ifndef SP_REFACTOR /* ui manipulation */ +#ifndef SP_CODA /* ui manipulation */ // Update the window title to indicate that we are trying to establish a connection [parentTabViewItem setLabel:NSLocalizedString(@"Connecting…", @"window title string indicating that sp is connecting")]; @@ -4950,19 +4951,19 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void)connectionControllerConnectAttemptFailed:(id)controller { -#ifdef SP_REFACTOR /* glue */ +#ifdef SP_CODA /* glue */ if ( delegate && [delegate respondsToSelector:@selector(databaseDocumentConnectionFailed:)] ) [delegate performSelector:@selector(databaseDocumentConnectionFailed:) withObject:self]; #endif -#ifndef SP_REFACTOR /* updateWindowTitle: */ +#ifndef SP_CODA /* updateWindowTitle: */ // Reset the window title [self updateWindowTitle:self]; #endif } -#ifdef SP_REFACTOR +#ifdef SP_CODA - (SPConnectionController*)connectionController { @@ -4977,7 +4978,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; #endif -#ifndef SP_REFACTOR /* scheme scripting methods */ +#ifndef SP_CODA /* scheme scripting methods */ #pragma mark - #pragma mark Scheme scripting methods @@ -5386,7 +5387,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; NSUInteger i, j; NSArray *theRow; NSMutableString *result = [NSMutableString string]; - if (writeAsCsv) { + if(writeAsCsv) { for ( i = 0 ; i < [theResult numberOfRows] ; i++ ) { [result setString:@""]; theRow = [theResult getRowAsArray]; @@ -5612,7 +5613,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; if (object == databaseNameField) { [addDatabaseButton setEnabled:([[databaseNameField stringValue] length] > 0 && ![allDatabases containsObject: [databaseNameField stringValue]])]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA else if (object == databaseCopyNameField) { [copyDatabaseButton setEnabled:([[databaseCopyNameField stringValue] length] > 0 && ![allDatabases containsObject: [databaseCopyNameField stringValue]])]; } @@ -5620,7 +5621,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; else if (object == databaseRenameNameField) { [renameDatabaseButton setEnabled:([[databaseRenameNameField stringValue] length] > 0 && ![allDatabases containsObject: [databaseRenameNameField stringValue]])]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA else if (object == saveConnectionEncryptString) { [saveConnectionEncryptString setStringValue:[saveConnectionEncryptString stringValue]]; } @@ -5629,7 +5630,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; #pragma mark - #pragma mark General sheet delegate methods -#ifndef SP_REFACTOR /* window:willPositionSheet:usingRect: */ +#ifndef SP_CODA /* window:willPositionSheet:usingRect: */ - (NSRect)window:(NSWindow *)window willPositionSheet:(NSWindow *)sheet usingRect:(NSRect)rect { @@ -5657,7 +5658,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; #pragma mark - #pragma mark SplitView delegate methods -#ifndef SP_REFACTOR /* SplitView delegate methods */ +#ifndef SP_CODA /* SplitView delegate methods */ - (void)splitViewDidResizeSubviews:(NSNotification *)notification { @@ -5784,7 +5785,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; #pragma mark - #pragma mark Private API -#ifndef SP_REFACTOR /* whole database operations */ +#ifndef SP_CODA /* whole database operations */ - (void)_copyDatabase { @@ -5842,8 +5843,8 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } [dbActionRename release]; - -#ifdef SP_REFACTOR + +#ifdef SP_CODA if (delegate && [delegate respondsToSelector:@selector(refreshDatabasePopup)]) { [delegate performSelector:@selector(refreshDatabasePopup) withObject:nil]; } @@ -5907,10 +5908,10 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [tablesListInstance setConnection:mySQLConnection]; [tableDumpInstance setConnection:mySQLConnection]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [self updateWindowTitle:self]; #endif -#ifdef SP_REFACTOR /* glue */ +#ifdef SP_CODA /* glue */ if ( delegate && [delegate respondsToSelector:@selector(refreshDatabasePopup)] ) [delegate performSelector:@selector(refreshDatabasePopup) withObject:nil]; @@ -5960,10 +5961,10 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [tablesListInstance setConnection:mySQLConnection]; [tableDumpInstance setConnection:mySQLConnection]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [self updateWindowTitle:self]; #endif -#ifdef SP_REFACTOR /* glue */ +#ifdef SP_CODA /* glue */ if ( delegate && [delegate respondsToSelector:@selector(refreshDatabasePopup)] ) [delegate performSelector:@selector(refreshDatabasePopup) withObject:nil]; @@ -5985,7 +5986,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; { NSAutoreleasePool *taskPool = [[NSAutoreleasePool alloc] init]; NSString *targetDatabaseName = [selectionDetails objectForKey:@"database"]; -#ifndef SP_REFACTOR /* update history controller */ +#ifndef SP_CODA /* update history controller */ NSString *targetItemName = [selectionDetails objectForKey:@"item"]; // Save existing scroll position and details, and ensure no duplicate entries are created as table list changes @@ -6000,10 +6001,10 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; if (![targetDatabaseName isEqualToString:selectedDatabase]) { // Attempt to select the specified database, and abort on failure -#ifndef SP_REFACTOR /* patch */ +#ifndef SP_CODA /* patch */ if ([chooseDatabaseButton indexOfItemWithTitle:targetDatabaseName] == NSNotFound || ![mySQLConnection selectDatabase:targetDatabaseName]) #else - if (![mySQLConnection selectDatabase:targetDatabaseName]) + if ( ![mySQLConnection selectDatabase:targetDatabaseName] ) #endif { // End the task first to ensure the database dropdown can be reselected @@ -6021,17 +6022,17 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; return; } -#ifndef SP_REFACTOR /* chooseDatabaseButton selectItemWithTitle: */ +#ifndef SP_CODA /* chooseDatabaseButton selectItemWithTitle: */ [[chooseDatabaseButton onMainThread] selectItemWithTitle:targetDatabaseName]; #endif if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil; -#ifndef SP_REFACTOR /* patch */ +#ifndef SP_CODA /* patch */ selectedDatabase = [[NSString alloc] initWithString:[chooseDatabaseButton titleOfSelectedItem]]; #else selectedDatabase = [[NSString alloc] initWithString:targetDatabaseName]; #endif -#ifndef SP_REFACTOR /* update database encoding */ +#ifndef SP_CODA /* update database encoding */ // Update the stored database encoding, used for views, "default" table encodings, and to allow // or disallow use of the "View using encoding" menu @@ -6042,7 +6043,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [tablesListInstance setConnection:mySQLConnection]; [tableDumpInstance setConnection:mySQLConnection]; -#ifndef SP_REFACTOR /* update history controller and ui manip */ +#ifndef SP_CODA /* update history controller and ui manip */ // Update the window title [self updateWindowTitle:self]; @@ -6054,7 +6055,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; #endif } -#ifndef SP_REFACTOR /* update selected table in SPTablesList */ +#ifndef SP_CODA /* update selected table in SPTablesList */ BOOL focusOnFilter = YES; if (targetItemName) focusOnFilter = NO; @@ -6062,24 +6063,24 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; // If a the table has changed, update the selection if (![targetItemName isEqualToString:[self table]] && targetItemName) { focusOnFilter = ![tablesListInstance selectItemWithName:targetItemName]; - } + } // Ensure the window focus is on the table list or the filter as appropriate - [[tablesListInstance onMainThread] setTableListSelectability:YES]; + [[tablesListInstance onMainThread] setTableListSelectability:YES]; if (focusOnFilter) { [[tablesListInstance onMainThread] makeTableListFilterHaveFocus]; } else { [[tablesListInstance onMainThread] makeTableListHaveFocus]; } - [[tablesListInstance onMainThread] setTableListSelectability:NO]; + [[tablesListInstance onMainThread] setTableListSelectability:NO]; #endif [self endTask]; -#ifndef SP_REFACTOR /* triggered commands */ +#ifndef SP_CODA /* triggered commands */ [self _processDatabaseChangedBundleTriggerActions]; #endif -#ifdef SP_REFACTOR /* glue */ +#ifdef SP_CODA /* glue */ if (delegate && [delegate respondsToSelector:@selector(databaseDidChange:)]) { [delegate performSelectorOnMainThread:@selector(databaseDidChange:) withObject:self waitUntilDone:NO]; } @@ -6088,7 +6089,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [taskPool drain]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA - (void)_processDatabaseChangedBundleTriggerActions { NSArray *triggeredCommands = [[NSApp delegate] bundleCommandsForTrigger:SPBundleTriggerActionDatabaseChanged]; @@ -6100,7 +6101,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [aMenuItem setTag:0]; [aMenuItem setToolTip:[data objectAtIndex:0]]; - + // For HTML output check if corresponding window already exists BOOL stopTrigger = NO; @@ -6110,32 +6111,32 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; for (id win in [NSApp windows]) { - if ([[[[win delegate] class] description] isEqualToString:@"SPBundleHTMLOutputController"]) { - if ([[[win delegate] windowUUID] isEqualToString:uuid]) { + if([[[[win delegate] class] description] isEqualToString:@"SPBundleHTMLOutputController"]) { + if([[[win delegate] windowUUID] isEqualToString:uuid]) { correspondingWindowFound = YES; break; } } } - if (!correspondingWindowFound) stopTrigger = YES; + if(!correspondingWindowFound) stopTrigger = YES; } - if (!stopTrigger) { - if ([[data objectAtIndex:1] isEqualToString:SPBundleScopeGeneral]) { + if(!stopTrigger) { + if([[data objectAtIndex:1] isEqualToString:SPBundleScopeGeneral]) { [[[NSApp delegate] onMainThread] executeBundleItemForApp:aMenuItem]; } - else if ([[data objectAtIndex:1] isEqualToString:SPBundleScopeDataTable]) { + 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]) { + } + else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeInputField]) { if ([[[NSApp mainWindow] firstResponder] isKindOfClass:[NSTextView class]]) { [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForInputField:aMenuItem]; - } } } } + } } #endif @@ -6143,7 +6144,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; - (void)dealloc { -#ifndef SP_REFACTOR /* Unregister observers */ +#ifndef SP_CODA /* Unregister observers */ // Unregister observers [prefs removeObserver:self forKeyPath:SPDisplayTableViewVerticalGridlines]; [prefs removeObserver:tableSourceInstance forKeyPath:SPDisplayTableViewVerticalGridlines]; @@ -6170,7 +6171,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [[NSNotificationCenter defaultCenter] removeObserver:self]; [NSObject cancelPreviousPerformRequestsWithTarget:self]; -#ifndef SP_REFACTOR /* release nib objects */ +#ifndef SP_CODA /* release nib objects */ for (id retainedObject in nibObjectsToRelease) [retainedObject release]; [nibObjectsToRelease release]; @@ -6183,50 +6184,50 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [allDatabases release]; [allSystemDatabases release]; -#ifndef SP_REFACTOR /* dealloc ivars */ +#ifndef SP_CODA /* dealloc ivars */ [undoManager release]; [printWebView release]; #endif [selectedDatabaseEncoding release]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [taskProgressWindow close]; #endif if (selectedTableName) [selectedTableName release]; if (connectionController) [connectionController release]; -#ifndef SP_REFACTOR /* dealloc ivars */ +#ifndef SP_CODA /* dealloc ivars */ if (processListController) [processListController release]; if (serverVariablesController) [serverVariablesController release]; #endif if (mySQLConnection) [mySQLConnection release], mySQLConnection = nil; if (selectedDatabase) [selectedDatabase release]; if (mySQLVersion) [mySQLVersion release]; -#ifndef SP_REFACTOR +#ifndef SP_CODA if (taskDrawTimer) [taskDrawTimer invalidate], [taskDrawTimer release]; if (taskFadeInStartDate) [taskFadeInStartDate release]; #endif if (queryEditorInitString) [queryEditorInitString release]; -#ifndef SP_REFACTOR +#ifndef SP_CODA if (spfFileURL) [spfFileURL release]; if (spfPreferences) [spfPreferences release]; if (spfSession) [spfSession release]; if (spfDocData) [spfDocData release]; #endif if (keyChainID) [keyChainID release]; -#ifndef SP_REFACTOR +#ifndef SP_CODA if (mainToolbar) [mainToolbar release]; #endif if (titleAccessoryView) [titleAccessoryView release]; -#ifndef SP_REFACTOR +#ifndef SP_CODA if (taskProgressWindow) [taskProgressWindow release]; #endif if (serverSupport) [serverSupport release]; -#ifndef SP_REFACTOR /* dealloc ivars */ +#ifndef SP_CODA /* dealloc ivars */ if (processID) [processID release]; if (runningActivitiesArray) [runningActivitiesArray release]; #endif -#ifdef SP_REFACTOR +#ifdef SP_CODA if (tablesListInstance) [tablesListInstance release]; if (customQueryInstance) [customQueryInstance release]; #endif diff --git a/Source/SPDatabaseViewController.h b/Source/SPDatabaseViewController.h index 8bfb5ae3..00017a39 100644 --- a/Source/SPDatabaseViewController.h +++ b/Source/SPDatabaseViewController.h @@ -41,7 +41,7 @@ - (BOOL)contentLoaded; - (BOOL)statusLoaded; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ // Tab view control - (IBAction)viewStructure:(id)sender; - (IBAction)viewContent:(id)sender; @@ -57,7 +57,7 @@ // Table control - (void)loadTable:(NSString *)aTable ofType:(SPTableType)aTableType; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ - (NSView *)databaseView; #endif diff --git a/Source/SPDatabaseViewController.m b/Source/SPDatabaseViewController.m index 3fbeada0..fff47726 100644 --- a/Source/SPDatabaseViewController.m +++ b/Source/SPDatabaseViewController.m @@ -30,7 +30,7 @@ // // More info at <http://code.google.com/p/sequel-pro/> -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPAppController.h" #import "SPBundleHTMLOutputController.h" #endif @@ -42,7 +42,7 @@ #import "SPTablesList.h" #import "SPTableTriggers.h" #import "SPThreadAdditions.h" -#ifdef SP_REFACTOR /* headers */ +#ifdef SP_CODA /* headers */ #import "SPTableStructure.h" #import "SPTableStructureLoading.h" #endif @@ -61,7 +61,7 @@ #pragma mark - #pragma mark Getters -#ifndef SP_REFACTOR /* getters */ +#ifndef SP_CODA /* getters */ /** * Returns the master database view, containing the tables list and views for * table setup and contents. @@ -112,7 +112,7 @@ return statusLoaded; } -#ifndef SP_REFACTOR /* toolbar ibactions */ +#ifndef SP_CODA /* toolbar ibactions */ #pragma mark - #pragma mark Tab view control and delegate methods @@ -225,7 +225,7 @@ { BOOL reloadRequired = reload; -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == SPTableViewStructure) { reloadRequired = NO; } @@ -246,7 +246,7 @@ - (void)setContentRequiresReload:(BOOL)reload { if (reload && selectedTableName -#ifndef SP_REFACTOR /* check which tab is selected */ +#ifndef SP_CODA /* check which tab is selected */ && [tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == SPTableViewContent #endif ) { @@ -264,7 +264,7 @@ - (void)setStatusRequiresReload:(BOOL)reload { if (reload && selectedTableName -#ifndef SP_REFACTOR /* check which tab is selected */ +#ifndef SP_CODA /* check which tab is selected */ && [tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == SPTableViewStatus #endif ) { @@ -275,7 +275,7 @@ } } -#ifndef SP_REFACTOR /* !!! respond to tab change */ +#ifndef SP_CODA /* !!! respond to tab change */ /** * Triggers a task to update the newly selected tab view, ensuring * the data is fully loaded and up-to-date. @@ -319,7 +319,7 @@ [[tablesListInstance onMainThread] setSelectionState:nil]; [tableSourceInstance loadTable:nil]; [tableContentInstance loadTable:nil]; -#ifndef SP_REFACTOR /* [extendedTableInfoInstance loadTable:] */ +#ifndef SP_CODA /* [extendedTableInfoInstance loadTable:] */ [[extendedTableInfoInstance onMainThread] loadTable:nil]; [[tableTriggersInstance onMainThread] resetInterface]; #endif @@ -328,7 +328,7 @@ statusLoaded = NO; triggersLoaded = NO; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Update the window title [self updateWindowTitle:self]; @@ -409,7 +409,7 @@ contentLoaded = YES; } break; -#ifndef SP_REFACTOR /* case SPTableViewStatus: case SPTableViewTriggers: */ +#ifndef SP_CODA /* case SPTableViewStatus: case SPTableViewTriggers: */ case SPTableViewStatus: if (!statusLoaded) { [[extendedTableInfoInstance onMainThread] loadTable:selectedTableName]; @@ -438,7 +438,7 @@ NSAutoreleasePool *loadPool = [[NSAutoreleasePool alloc] init]; NSString *tableEncoding = nil; -#ifndef SP_REFACTOR /* Update the window title */ +#ifndef SP_CODA /* Update the window title */ // Update the window title [self updateWindowTitle:self]; #endif @@ -482,9 +482,9 @@ if (changeEncoding) [mySQLConnection restoreStoredEncoding]; // Notify listeners of the table change now that the state is fully set up. - [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:SPTableChangedNotification object:self]; + [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:SPTableChangedNotification object:self]; -#ifndef SP_REFACTOR /* [spHistoryControllerInstance restoreViewStates] */ +#ifndef SP_CODA /* [spHistoryControllerInstance restoreViewStates] */ // Restore view states as appropriate [spHistoryControllerInstance restoreViewStates]; @@ -493,7 +493,7 @@ // Load the currently selected view if looking at a table or view if (tableEncoding && (selectedTableType == SPTableTypeView || selectedTableType == SPTableTypeTable)) { -#ifndef SP_REFACTOR /* load everything */ +#ifndef SP_CODA /* load everything */ NSInteger selectedTabViewIndex = [tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]]; switch (selectedTabViewIndex) { @@ -501,13 +501,13 @@ #endif [tableSourceInstance loadTable:selectedTableName]; structureLoaded = YES; -#ifndef SP_REFACTOR /* load everything */ +#ifndef SP_CODA /* load everything */ break; case SPTableViewContent: #endif [tableContentInstance loadTable:selectedTableName]; contentLoaded = YES; -#ifndef SP_REFACTOR /* load everything */ +#ifndef SP_CODA /* load everything */ break; case SPTableViewStatus: [[extendedTableInfoInstance onMainThread] loadTable:selectedTableName]; @@ -533,7 +533,7 @@ // action will be performed if not necessary [tableDataInstance updateAccurateNumberOfRowsForCurrentTableForcingUpdate:NO]; -#ifndef SP_REFACTOR /* show Create Table syntax */ +#ifndef SP_CODA /* show Create Table syntax */ // Update the "Show Create Syntax" window if it's already opened // according to the selected table/view/proc/func if ([[[self onMainThread] getCreateTableSyntaxWindow] isVisible]) { @@ -546,7 +546,7 @@ // Empty the loading pool and exit the thread [self endTask]; -#ifndef SP_REFACTOR /* triggered commands */ +#ifndef SP_CODA /* triggered commands */ NSArray *triggeredCommands = [[NSApp delegate] bundleCommandsForTrigger:SPBundleTriggerActionTableChanged]; for(NSString* cmdPath in triggeredCommands) diff --git a/Source/SPEditSheetTextView.m b/Source/SPEditSheetTextView.m index 8548271f..c605c850 100644 --- a/Source/SPEditSheetTextView.m +++ b/Source/SPEditSheetTextView.m @@ -68,7 +68,7 @@ - (IBAction)paste:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Try to create an undo group if([[self delegate] respondsToSelector:@selector(setWasCutPaste)]) [[self delegate] setWasCutPaste]; @@ -78,7 +78,7 @@ - (IBAction)cut:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Try to create an undo group if([[self delegate] respondsToSelector:@selector(setWasCutPaste)]) [[self delegate] setWasCutPaste]; @@ -145,7 +145,7 @@ } } -#ifndef SP_REFACTOR +#ifndef SP_CODA // Allow undo grouping if user typed a ' ' (for word level undo) // or a RETURN but not for each char due to writing speed if([charactersIgnMod isEqualToString:@" "] @@ -155,7 +155,7 @@ [[self delegate] setDoGroupDueToChars]; } #endif - + [super keyDown: theEvent]; } @@ -199,12 +199,12 @@ // Check size and NSFileType NSDictionary *attr = [[NSFileManager defaultManager] attributesOfItemAtPath:filepath error:nil]; - if (attr) + if(attr) { NSNumber *filesize = [attr objectForKey:NSFileSize]; NSString *filetype = [attr objectForKey:NSFileType]; - if (filetype == NSFileTypeRegular && filesize) + if(filetype == NSFileTypeRegular && filesize) { // Ask for confirmation if file content is larger than 1MB if([filesize unsignedLongValue] > 1000000) diff --git a/Source/SPFieldEditorController.h b/Source/SPFieldEditorController.h index a920c9b0..a1cf0cee 100644 --- a/Source/SPFieldEditorController.h +++ b/Source/SPFieldEditorController.h @@ -165,7 +165,7 @@ NSUserDefaults *prefs; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSDictionary *qlTypes; #endif diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m index be9dd145..87d2025b 100644 --- a/Source/SPFieldEditorController.m +++ b/Source/SPFieldEditorController.m @@ -31,7 +31,7 @@ // More info at <http://code.google.com/p/sequel-pro/> #import "SPFieldEditorController.h" -#ifndef SP_REFACTOR +#ifndef SP_CODA #import "QLPreviewPanel.h" #endif #import "RegexKitLite.h" @@ -51,7 +51,7 @@ @end -#ifdef SP_REFACTOR +#ifdef SP_CODA /* Suppress deprecation warning for beginSheetForDirectory: until Sequel Pro team can migrate */ #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif @@ -66,7 +66,7 @@ */ - (id)init { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ((self = [super initWithWindowNibName:@"FieldEditorSheet"])) #else if ((self = [super initWithWindowNibName:@"SQLFieldEditorSheet"])) @@ -110,7 +110,7 @@ [menuItem setEnabled:NO]; [menu addItem:menuItem]; [menuItem release]; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSUInteger tag = 2; // Load default QL types @@ -168,7 +168,7 @@ { [NSObject cancelPreviousPerformRequestsWithTarget:self]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // On Mac OSX 10.6 QuickLook runs non-modal thus order out the panel // if still visible if ([[NSClassFromString(@"QLPreviewPanel") sharedPreviewPanel] isVisible]) { @@ -177,7 +177,7 @@ #endif if ( sheetEditData ) [sheetEditData release]; -#ifndef SP_REFACTOR +#ifndef SP_CODA if ( qlTypes ) [qlTypes release]; #endif if ( tmpFileName ) [tmpFileName release]; @@ -268,15 +268,15 @@ usedSheet = editSheet; // If required, use monospaced fonts -#ifndef SP_REFACTOR +#ifndef SP_CODA if (![prefs objectForKey:SPFieldEditorSheetFont]) { #endif [editTextView setFont: -#ifndef SP_REFACTOR +#ifndef SP_CODA ([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : #endif [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; -#ifndef SP_REFACTOR +#ifndef SP_CODA } else { [editTextView setFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:@"FieldEditorSheetFont"]]]; @@ -284,7 +284,7 @@ #endif [editTextView setContinuousSpellCheckingEnabled: -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs boolForKey:SPBlobTextEditorSpellCheckingEnabled] #else NO @@ -449,7 +449,7 @@ } - if (stringValue) [stringValue release], stringValue = nil; + if(stringValue) [stringValue release], stringValue = nil; editSheetWillBeInitialized = NO; @@ -510,7 +510,7 @@ [hexTextView setHidden:YES]; [hexTextScrollView setHidden:YES]; [usedSheet makeFirstResponder:editTextView]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [[NSApp mainWindow] makeFirstResponder:editTextView]; #endif break; @@ -582,7 +582,7 @@ - (void)sheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Remember spell cheecker status [prefs setBool:[editTextView isContinuousSpellCheckingEnabled] forKey:SPBlobTextEditorSpellCheckingEnabled]; #endif @@ -641,7 +641,7 @@ if(callerInstance) { id returnData = ( editSheetReturnCode && _isEditable ) ? (_isGeometry) ? [editTextView string] : sheetEditData : nil; -#ifdef SP_REFACTOR /* patch */ +#ifdef SP_CODA /* patch */ if ( [callerInstance isKindOfClass:[SPCustomQuery class]] ) [(SPCustomQuery*)callerInstance processFieldEditorResult:returnData contextInfo:contextInfo]; else if ( [callerInstance isKindOfClass:[SPTableContent class]] ) @@ -737,9 +737,9 @@ if ( [editSheetSegmentControl selectedSegment] == 0 || editImage == nil ) { [[editTextView string] writeToURL:fileURL - atomically:YES - encoding:encoding - error:NULL]; + atomically:YES + encoding:encoding + error:NULL]; } else if (editImage != nil){ @@ -753,9 +753,9 @@ // Write other field types' representations to the file via the current encoding else { [[sheetEditData description] writeToURL:fileURL - atomically:YES - encoding:encoding - error:NULL]; + atomically:YES + encoding:encoding + error:NULL]; } [editSheetProgressBar stopAnimation:self]; @@ -788,7 +788,7 @@ */ - (IBAction)quickLookFormatButton:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA if(qlTypes != nil && [[qlTypes objectForKey:@"QuickLookTypes"] count] > (NSUInteger)[sender tag] - 2) { NSDictionary *type = [[qlTypes objectForKey:@"QuickLookTypes"] objectAtIndex:[sender tag] - 2]; [self invokeQuickLookOfType:[type objectForKey:@"Extension"] treatAsText:([[type objectForKey:@"treatAsText"] integerValue])]; @@ -854,7 +854,7 @@ */ - (void)invokeQuickLookOfType:(NSString *)type treatAsText:(BOOL)isText { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Load QL via private framework (SDK 10.5) if([[NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/QuickLookUI.framework"] load]) { @@ -940,7 +940,7 @@ */ - (void)beginPreviewPanelControl:(id)panel { -#ifndef SP_REFACTOR +#ifndef SP_CODA // This document is now responsible of the preview panel [panel setDelegate:self]; @@ -1347,7 +1347,7 @@ // Length checking while using the Input Manager (eg for Japanese) if ([textView hasMarkedText] && (maxTextLength > 0) && (r.location < maxTextLength)) { - + // User tries to insert a new char but max text length was already reached - return NO if (!r.length && ([[textView textStorage] length] >= maxTextLength)) { [SPTooltip showWithObject:[NSString stringWithFormat:NSLocalizedString(@"Maximum text length is set to %llu.", @"Maximum text length is set to %llu."), maxTextLength]]; @@ -1385,7 +1385,7 @@ textLength--; } } - + // If it's too long, disallow the change but try // to insert a text chunk partially to maxTextLength. if ((NSUInteger)newLength > maxTextLength) { @@ -1409,7 +1409,7 @@ return NO; } - + maxTextLength = originalMaxTextLength; // Otherwise, allow it diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index ec2cf6a0..db7df98e 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -100,7 +100,7 @@ static NSString *SPTableViewSqlColumnID = @"sql"; tablesListInstance = [theDelegate valueForKeyPath:@"tablesListInstance"]; databaseDataInstance = [tablesListInstance valueForKeyPath:@"databaseDataInstance"]; -#ifndef SP_REFACTOR /* init ivars */ +#ifndef SP_CODA /* init ivars */ if(![prefs objectForKey:SPLastImportIntoNewTableType]) [prefs setObject:@"Default" forKey:SPLastImportIntoNewTableType]; if(![prefs objectForKey:SPLastImportIntoNewTableEncoding]) @@ -393,7 +393,7 @@ static NSString *SPTableViewSqlColumnID = @"sql"; { // Only save selection if the user selected 'OK' if ([sender tag]) { -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs setObject:[newTableInfoEnginePopup titleOfSelectedItem] forKey:SPLastImportIntoNewTableType]; [prefs setObject:[newTableInfoEncodingPopup titleOfSelectedItem] forKey:SPLastImportIntoNewTableEncoding]; #endif @@ -453,7 +453,7 @@ static NSString *SPTableViewSqlColumnID = @"sql"; NSInteger columnIndex = 0; NSInteger numberOfColumns = [fieldMappingTableColumnNames count]; NSMutableArray *columnDetails = [NSMutableArray array]; - for (columnIndex = 0; columnIndex < numberOfColumns; columnIndex++) { + for(columnIndex = 0; columnIndex < numberOfColumns; columnIndex++) { // Skip fields which aren't marked as imported if ([fieldMappingOperatorArray objectAtIndex:columnIndex] != doImport) { @@ -465,7 +465,7 @@ static NSString *SPTableViewSqlColumnID = @"sql"; [createString appendString:[columnDetails componentsJoinedByString:@", \n"]]; [createString appendString:@")"]; -#ifndef SP_REFACTOR +#ifndef SP_CODA if(![[prefs objectForKey:SPLastImportIntoNewTableType] isEqualToString:@"Default"]) [createString appendFormat:@" ENGINE=%@", [prefs objectForKey:SPLastImportIntoNewTableType]]; if(![[prefs objectForKey:SPLastImportIntoNewTableEncoding] isEqualToString:@"Default"]) { @@ -741,7 +741,7 @@ static NSString *SPTableViewSqlColumnID = @"sql"; } [fieldMapperTableView reloadData]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Remember last field alignment if not "custom order" if([[alignByPopup selectedItem] tag] != 3) [prefs setInteger:[[alignByPopup selectedItem] tag] forKey:SPCSVFieldImportMappingAlignment]; @@ -1049,7 +1049,7 @@ static NSString *SPTableViewSqlColumnID = @"sql"; [newTableInfoEnginePopup addItemWithTitle:[engine objectForKey:@"Engine"]]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA [newTableInfoEnginePopup selectItemWithTitle:[prefs objectForKey:SPLastImportIntoNewTableType]]; #endif @@ -1082,7 +1082,7 @@ static NSString *SPTableViewSqlColumnID = @"sql"; [newTableInfoEncodingPopup insertItemWithTitle:utf8MenuItemTitle atIndex:2]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA [newTableInfoEncodingPopup selectItemWithTitle:[prefs objectForKey:SPLastImportIntoNewTableEncoding]]; #endif } @@ -1111,7 +1111,7 @@ static NSString *SPTableViewSqlColumnID = @"sql"; while([insertPullDownButton numberOfItems] > (([[self selectedImportMethod] isEqualToString:@"UPDATE"]) ? 6 : 5)) [insertPullDownButton removeItemAtIndex:[insertPullDownButton numberOfItems]-1]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Add recent global value menu if([prefs objectForKey:SPGlobalValueHistory] && [[prefs objectForKey:SPGlobalValueHistory] isKindOfClass:[NSArray class]] && [[prefs objectForKey:SPGlobalValueHistory] count]) for(id item in [prefs objectForKey:SPGlobalValueHistory]) @@ -1199,7 +1199,7 @@ static NSString *SPTableViewSqlColumnID = @"sql"; [globalValuesSheet makeFirstResponder:globalValuesTableView]; // Replace the current map pair with the last selected global value - if ([replaceAfterSavingCheckBox state] == NSOnState && [globalValuesTableView numberOfSelectedRows] == 1) { + if([replaceAfterSavingCheckBox state] == NSOnState && [globalValuesTableView numberOfSelectedRows] == 1) { [fieldMappingArray replaceObjectAtIndex:[fieldMapperTableView selectedRow] withObject:[NSNumber numberWithInteger:[globalValuesTableView selectedRow]+numberOfImportColumns]]; @@ -1334,7 +1334,7 @@ static NSString *SPTableViewSqlColumnID = @"sql"; - (void)resizeWindowByHeightDelta:(NSInteger)delta { -#ifndef SP_REFACTOR /* resizeWindowByHeightDelta: */ +#ifndef SP_CODA /* resizeWindowByHeightDelta: */ NSUInteger tableMask = [fieldMapperTableScrollView autoresizingMask]; NSUInteger headerSwitchMask = [importFieldNamesHeaderSwitch autoresizingMask]; NSUInteger alignPopupMask = [alignByPopup autoresizingMask]; @@ -1561,7 +1561,7 @@ static NSString *SPTableViewSqlColumnID = @"sql"; NSInteger alignment = 0; -#ifndef SP_REFACTOR +#ifndef SP_CODA if([prefs integerForKey:SPCSVFieldImportMappingAlignment] && [prefs integerForKey:SPCSVFieldImportMappingAlignment] >= 0 && [prefs integerForKey:SPCSVFieldImportMappingAlignment] < 4) { @@ -1670,7 +1670,7 @@ static NSString *SPTableViewSqlColumnID = @"sql"; - (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex { -#ifndef SP_REFACTOR +#ifndef SP_CODA [aCell setFont:([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; #endif } @@ -1970,7 +1970,7 @@ static NSString *SPTableViewSqlColumnID = @"sql"; // Store anObject as recent global value if it's new NSMutableArray *recents = [NSMutableArray array]; -#ifndef SP_REFACTOR +#ifndef SP_CODA if([prefs objectForKey:SPGlobalValueHistory] && [[prefs objectForKey:SPGlobalValueHistory] isKindOfClass:[NSArray class]] && [[prefs objectForKey:SPGlobalValueHistory] count]) [recents setArray:[prefs objectForKey:SPGlobalValueHistory]]; #endif @@ -1979,7 +1979,7 @@ static NSString *SPTableViewSqlColumnID = @"sql"; [recents insertObject:anObject atIndex:0]; while([recents count] > 20) [recents removeObjectAtIndex:[recents count]-1]; -#ifndef SP_REFACTOR +#ifndef SP_CODA if([recents count]) [prefs setObject:recents forKey:SPGlobalValueHistory]; #endif diff --git a/Source/SPIndexesController.h b/Source/SPIndexesController.h index 2338f8a6..1c67a673 100644 --- a/Source/SPIndexesController.h +++ b/Source/SPIndexesController.h @@ -38,7 +38,7 @@ @class SPTableView; @interface SPIndexesController : NSWindowController -#ifdef SP_REFACTOR +#ifdef SP_CODA <NSTableViewDelegate, NSTableViewDataSource> #endif { @@ -64,7 +64,7 @@ IBOutlet NSButton *addIndexedColumnButton; IBOutlet NSButton *removeIndexedColumnButton; IBOutlet NSButton *confirmAddIndexButton; -#ifndef SP_REFACTOR +#ifndef SP_CODA IBOutlet NSBox *anchoredButtonBar; // Advanced options view @@ -82,13 +82,13 @@ NSMutableArray *fields, *indexes, *indexedFields; NSArray *supportsLength, *requiresLength; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ NSUserDefaults *prefs; #endif SPMySQLConnection *connection; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ BOOL showAdvancedView; NSInteger heightOffset; @@ -97,7 +97,7 @@ #endif } -#ifdef SP_REFACTOR +#ifdef SP_CODA @property (assign) SPTableView* indexesTableView; @property (assign) SPTableStructure* tableStructure; @property (assign) NSButton* addIndexButton; diff --git a/Source/SPIndexesController.m b/Source/SPIndexesController.m index bd226560..1ee45d52 100644 --- a/Source/SPIndexesController.m +++ b/Source/SPIndexesController.m @@ -69,7 +69,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; @synthesize table; @synthesize connection; -#ifdef SP_REFACTOR +#ifdef SP_CODA @synthesize indexesTableView; @synthesize tableStructure; @synthesize addIndexButton; @@ -80,7 +80,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; - (id)init { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSString* nibName = @"IndexesView"; #else NSString* nibName = @"SQLIndexes"; @@ -94,7 +94,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; indexes = [[NSMutableArray alloc] init]; indexedFields = [[NSMutableArray alloc] init]; -#ifndef SP_REFACTOR /* init ivars */ +#ifndef SP_CODA /* init ivars */ prefs = [NSUserDefaults standardUserDefaults]; showAdvancedView = NO; @@ -124,7 +124,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; if (_mainNibLoaded) return; _mainNibLoaded = YES; -#ifndef SP_REFACTOR /* patch */ +#ifndef SP_CODA /* patch */ // Set the index tables view's vertical gridlines if required [indexesTableView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; @@ -147,7 +147,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; [[fieldColumn dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } -#ifndef SP_REFACTOR /* patch */ +#ifndef SP_CODA /* patch */ [prefs addObserver:self forKeyPath:SPDisplayTableViewVerticalGridlines options:NSKeyValueObservingOptionNew context:NULL]; #endif } @@ -165,7 +165,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; // Check whether a save of the current field row is required. if (![tableStructure saveRowOnDeselect]) return; - + isMyISAMTale = [[[tableData statusValues] objectForKey:@"Engine"] isEqualToString:@"MyISAM"]; // Reset visibility of the primary key item @@ -233,7 +233,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; [addIndexedColumnButton setEnabled:([indexedFields count] < [fields count])]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // MyISAM and InnoDB tables only support BTREE storage types so disable the storage type popup button // as it's the default anyway. [indexStorageTypePopUpButton setEnabled:(!(isMyISAMTale || [[[tableData statusValues] objectForKey:@"Engine"] isEqualToString:@"InnoDB"]))]; @@ -316,7 +316,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; if (indexType == SPPrimaryKeyMenuTag) { [indexNameTextField setEnabled:NO]; [indexNameTextField setStringValue:@"PRIMARY"]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [indexStorageTypePopUpButton setEnabled:NO]; #endif } @@ -327,7 +327,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; [indexNameTextField setStringValue:@""]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA NSString *engine = [[tableData statusValues] objectForKey:@"Engine"]; // Specifiying an index storage type (i.e. HASH or BTREE) is not permitted with SPATIAL indexes @@ -344,7 +344,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; */ - (IBAction)closeSheet:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Close the advanced options view if it's open [indexAdvancedOptionsView setHidden:YES]; [indexAdvancedOptionsViewButton setState:NSOffState]; @@ -359,7 +359,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; [NSApp endSheet:[sender window] returnCode:[sender tag]]; [[sender window] orderOut:self]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Clear the index key block size field [indexKeyBlockSizeTextField setStringValue:@""]; #endif @@ -389,7 +389,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; [self _reloadIndexedColumnsTableData]; // Select new added row - [indexedColumnsTableView selectRowIndexes:[NSIndexSet indexSetWithIndex:[indexedFields count] - 1] byExtendingSelection:NO]; + [indexedColumnsTableView selectRowIndexes:[NSIndexSet indexSetWithIndex:[indexedFields count]-1] byExtendingSelection:NO]; [addIndexedColumnButton setEnabled:([indexedFields count] < [fields count])]; } @@ -411,7 +411,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; */ - (IBAction)toggleAdvancedIndexOptionsView:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA showAdvancedView = (!showAdvancedView); [indexAdvancedOptionsViewButton setState:showAdvancedView]; @@ -580,7 +580,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; [indexes setArray:tableIndexes]; } -#ifdef SP_REFACTOR +#ifdef SP_CODA - (void)setDatabaseDocument:(SPDatabaseDocument*)db { dbDocument = db; @@ -646,7 +646,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; break; } -#ifndef SP_REFACTOR +#ifndef SP_CODA // If there is a key block size set it means the database version supports it if ([[indexKeyBlockSizeTextField stringValue] length]) { [indexDetails setObject:[NSNumber numberWithInteger:[indexKeyBlockSizeTextField integerValue]] forKey:SPNewIndexKeyBlockSize]; @@ -802,11 +802,11 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; if ([field objectForKey:@"Size"] && [(NSString *)[field objectForKey:@"Size"] length]) { sizeRequiredFieldAndNotYetSet--; - } } } + } -#ifndef SP_REFACTOR +#ifndef SP_CODA // Only toggle the sizes column if the advanced view is hidden and at least one field requires a size if (!showAdvancedView) [indexSizeTableColumn setHidden:!sizeRequired]; #endif @@ -1010,14 +1010,14 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; NSUInteger popUpMask = [indexTypePopUpButton autoresizingMask]; NSUInteger nameFieldMask = [indexNameTextField autoresizingMask]; NSUInteger scrollMask = [indexedColumnsScrollView autoresizingMask]; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSUInteger buttonMask = [indexAdvancedOptionsViewButton autoresizingMask]; NSUInteger textFieldMask = [indexAdvancedOptionsViewLabelButton autoresizingMask]; NSUInteger advancedViewMask = [indexAdvancedOptionsView autoresizingMask]; #endif NSUInteger typeLabelMask = [indexTypeLabel autoresizingMask]; NSUInteger nameLabelMask = [indexNameLabel autoresizingMask]; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSUInteger buttonBarMask = [(NSView*)anchoredButtonBar autoresizingMask]; NSRect frame = [[self window] frame]; @@ -1033,14 +1033,14 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; [indexTypePopUpButton setAutoresizingMask:NSViewNotSizable | NSViewMinYMargin]; [indexNameTextField setAutoresizingMask:NSViewNotSizable | NSViewMinYMargin]; [indexedColumnsScrollView setAutoresizingMask:NSViewNotSizable | NSViewMinYMargin]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [indexAdvancedOptionsViewButton setAutoresizingMask:NSViewNotSizable | NSViewMinYMargin]; [indexAdvancedOptionsViewLabelButton setAutoresizingMask:NSViewNotSizable | NSViewMinYMargin]; [indexAdvancedOptionsView setAutoresizingMask:NSViewNotSizable | NSViewMinYMargin]; #endif [indexTypeLabel setAutoresizingMask:NSViewNotSizable | NSViewMinYMargin]; [indexNameLabel setAutoresizingMask:NSViewNotSizable | NSViewMinYMargin]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [(NSView*)anchoredButtonBar setAutoresizingMask:NSViewNotSizable | NSViewMinYMargin]; NSInteger newMinHeight = (windowMinHeigth - heightOffset + delta < windowMinHeigth) ? windowMinHeigth : windowMinHeigth - heightOffset + delta; @@ -1048,7 +1048,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; [[self window] setMinSize:NSMakeSize(windowMinWidth, newMinHeight)]; #endif -#ifndef SP_REFACTOR +#ifndef SP_CODA frame.origin.y += heightOffset; frame.size.height -= heightOffset; @@ -1063,14 +1063,14 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; [indexTypePopUpButton setAutoresizingMask:popUpMask]; [indexNameTextField setAutoresizingMask:nameFieldMask]; [indexedColumnsScrollView setAutoresizingMask:scrollMask]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [indexAdvancedOptionsViewButton setAutoresizingMask:buttonMask]; [indexAdvancedOptionsViewLabelButton setAutoresizingMask:textFieldMask]; [indexAdvancedOptionsView setAutoresizingMask:advancedViewMask]; #endif [indexTypeLabel setAutoresizingMask:typeLabelMask]; [indexNameLabel setAutoresizingMask:nameLabelMask]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [(NSView*)anchoredButtonBar setAutoresizingMask:buttonBarMask]; #endif } @@ -1088,7 +1088,7 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; if (indexedFields) [indexedFields release], indexedFields = nil; -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs removeObserver:self forKeyPath:SPDisplayTableViewVerticalGridlines]; #endif diff --git a/Source/SPNarrowDownCompletion.h b/Source/SPNarrowDownCompletion.h index 073844a1..f6e74ab9 100644 --- a/Source/SPNarrowDownCompletion.h +++ b/Source/SPNarrowDownCompletion.h @@ -6,7 +6,7 @@ // // This class is based on TextMate's TMDIncrementalPopUp implementation // (Dialog plugin) written by Joachim Mårtensson, Allan Odgaard, and Hans-Jörg Bibiko. -// +// // See license: http://svn.textmate.org/trunk/LICENSE // // Permission is hereby granted, free of charge, to any person @@ -79,7 +79,7 @@ NSMutableCharacterSet* textualInputCharacters; SPDatabaseStructure *databaseStructureRetrieval; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSUserDefaults *prefs; #endif } diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m index c808f220..626168b5 100644 --- a/Source/SPNarrowDownCompletion.m +++ b/Source/SPNarrowDownCompletion.m @@ -6,7 +6,7 @@ // // This class is based on TextMate's TMDIncrementalPopUp implementation // (Dialog plugin) written by Joachim Mårtensson, Allan Odgaard, and Hans-Jörg Bibiko. -// +// // See license: http://svn.textmate.org/trunk/LICENSE // // Permission is hereby granted, free of charge, to any person @@ -132,11 +132,11 @@ staticPrefix = nil; suggestions = nil; autocompletePlaceholderWasInserted = NO; -#ifndef SP_REFACTOR +#ifndef SP_CODA prefs = [NSUserDefaults standardUserDefaults]; #endif -#ifndef SP_REFACTOR +#ifndef SP_CODA tableFont = [NSUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] dataForKey:SPCustomQueryEditorFont]]; #else tableFont = [NSFont userFixedPitchFontOfSize:10.0]; @@ -159,7 +159,7 @@ - (void)dealloc { [NSObject cancelPreviousPerformRequestsWithTarget:self]; - if (stateTimer != nil) { + if(stateTimer != nil) { [stateTimer invalidate]; [stateTimer release]; stateTimer = nil; @@ -1083,7 +1083,7 @@ if(backtickMode && !triggerMode) [theView performSelector:@selector(moveRight:)]; // If it's a function or procedure append () and if a argument list can be retieved insert them as snippets -#ifndef SP_REFACTOR +#ifndef SP_CODA else if([prefs boolForKey:SPCustomQueryFunctionCompletionInsertsArguments] && ([[[filtered objectAtIndex:[theTableView selectedRow]] objectForKey:@"image"] hasPrefix:@"func"] || [[[filtered objectAtIndex:[theTableView selectedRow]] objectForKey:@"image"] hasPrefix:@"proc"]) && ![aString hasSuffix:@")"]) { NSString *functionArgumentSnippet = [NSString stringWithFormat:@"(%@)", [[SPQueryController sharedQueryController] argumentSnippetForFunction:aString]]; [theView insertAsSnippet:functionArgumentSnippet atRange:[theView selectedRange]]; diff --git a/Source/SPNavigatorController.h b/Source/SPNavigatorController.h index b6588c5a..155f7e4d 100644 --- a/Source/SPNavigatorController.h +++ b/Source/SPNavigatorController.h @@ -34,7 +34,7 @@ @interface SPNavigatorController : NSWindowController { -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ IBOutlet SPNavigatorOutlineView *outlineSchema2; IBOutlet id navigatorWindow; IBOutlet id infoTable; @@ -53,7 +53,7 @@ NSMutableArray *updatingConnections; NSMutableDictionary *expandStatus2; NSMutableDictionary *cachedSortedKeys; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ NSString *selectedKey2; NSRect selectionViewPort2; BOOL ignoreUpdate; @@ -74,7 +74,7 @@ + (SPNavigatorController *)sharedNavigatorController; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ - (IBAction)outlineViewAction:(id)sender; - (IBAction)reloadAllStructures:(id)sender; - (IBAction)filterTree:(id)sender; @@ -91,7 +91,7 @@ - (NSArray *)allSchemaKeysForConnection:(NSString*)connectionID; - (NSArray *)getUniqueDbIdentifierFor:(NSString*)term andConnection:(NSString*)connectionID ignoreFields:(BOOL)ignoreFields; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ - (BOOL)isUpdatingConnection:(NSString*)connectionID; - (BOOL)isUpdating; diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m index 9977773c..0e041cd4 100644 --- a/Source/SPNavigatorController.m +++ b/Source/SPNavigatorController.m @@ -32,7 +32,7 @@ #import "SPNavigatorController.h" #import "SPSplitView.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "RegexKitLite.h" #import "SPNavigatorOutlineView.h" #import "ImageAndTextCell.h" @@ -53,7 +53,7 @@ static SPNavigatorController *sharedNavigatorController = nil; @implementation SPNavigatorController -#ifndef SP_REFACTOR /* unused sort func */ +#ifndef SP_CODA /* unused sort func */ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* context) { return (NSComparisonResult)objc_msgSend(s1, @selector(localizedCompare:), s2); @@ -94,7 +94,7 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte cachedSortedKeys = [[NSMutableDictionary alloc] init]; infoArray = [[NSMutableArray alloc] init]; updatingConnections = [[NSMutableArray alloc] init]; -#ifndef SP_REFACTOR +#ifndef SP_CODA selectedKey2 = @""; ignoreUpdate = NO; isFiltered = NO; @@ -118,7 +118,7 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte if(updatingConnections) [updatingConnections release]; if(expandStatus2) [expandStatus2 release]; if(cachedSortedKeys) [cachedSortedKeys release]; -#ifndef SP_REFACTOR /* dealloc ivars */ +#ifndef SP_CODA /* dealloc ivars */ [connectionIcon release]; [databaseIcon release]; [tableIcon release]; @@ -144,7 +144,7 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte - (oneway void)release { } -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Set the window's auto save name and initialise display */ @@ -436,7 +436,7 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte if (doc && [doc isKindOfClass:[SPDatabaseDocument class]]) { SPMySQLConnection *theConnection = [doc getConnection]; - if (!theConnection || ![theConnection isConnected]) return; + if(!theConnection || ![theConnection isConnected]) return; NSString *connectionID = [doc connectionID]; NSString *connectionName = [doc connectionID]; @@ -572,7 +572,7 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte return [NSArray arrayWithObjects:[NSNumber numberWithInt:0], @"", nil]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA - (BOOL)isUpdatingConnection:(NSString*)connectionID { @@ -593,9 +593,9 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte // Reset everything for current active doc connection SPDatabaseDocument *doc = [[NSApp delegate] frontDocument]; - if (!doc) return; + if(!doc) return; NSString *connectionID = [doc connectionID]; - if (!connectionID || [connectionID length] < 2) return; + if(!connectionID || [connectionID length] < 2) return; [searchField setStringValue:@""]; [schemaDataFiltered removeAllObjects]; diff --git a/Source/SPQueryConsoleDataSource.m b/Source/SPQueryConsoleDataSource.m index 92e4fdf2..cc447c7f 100644 --- a/Source/SPQueryConsoleDataSource.m +++ b/Source/SPQueryConsoleDataSource.m @@ -42,7 +42,7 @@ static NSUInteger SPMessageTruncateCharacterLength = 256; */ - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView { -#ifndef SP_REFACTOR +#ifndef SP_CODA return [messagesVisibleSet count]; #else return 0; @@ -54,7 +54,7 @@ static NSUInteger SPMessageTruncateCharacterLength = 256; */ - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSString *returnValue = nil; id object = [[messagesVisibleSet objectAtIndex:row] valueForKey:[tableColumn identifier]]; diff --git a/Source/SPQueryController.h b/Source/SPQueryController.h index 31e1d38e..85997a3f 100644 --- a/Source/SPQueryController.h +++ b/Source/SPQueryController.h @@ -30,7 +30,7 @@ // // More info at <http://code.google.com/p/sequel-pro/> -#ifndef SP_REFACTOR /* constants */ +#ifndef SP_CODA /* constants */ extern NSString *SPQueryConsoleWindowAutoSaveName; extern NSString *SPTableViewDateColumnID; extern NSString *SPTableViewConnectionColumnID; @@ -38,7 +38,7 @@ extern NSString *SPTableViewConnectionColumnID; @interface SPQueryController : NSWindowController { -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ IBOutlet NSView *saveLogView; IBOutlet NSTableView *consoleTableView; IBOutlet NSSearchField *consoleSearchField; @@ -67,7 +67,7 @@ extern NSString *SPTableViewConnectionColumnID; NSArray *completionFunctionList; NSDictionary *functionArgumentSnippets; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ NSUserDefaults *prefs; NSDateFormatter *dateFormatter; @@ -75,7 +75,7 @@ extern NSString *SPTableViewConnectionColumnID; #endif } -#ifndef SP_REFACTOR +#ifndef SP_CODA @property (readwrite, retain) NSFont *consoleFont; #endif diff --git a/Source/SPQueryController.m b/Source/SPQueryController.m index 166d89df..f4586cf3 100644 --- a/Source/SPQueryController.m +++ b/Source/SPQueryController.m @@ -37,7 +37,7 @@ #import "pthread.h" -#ifndef SP_REFACTOR +#ifndef SP_CODA NSString *SPQueryConsoleWindowAutoSaveName = @"QueryConsole"; NSString *SPTableViewDateColumnID = @"messageDate"; NSString *SPTableViewConnectionColumnID = @"messageConnection"; @@ -56,7 +56,7 @@ static SPQueryController *sharedQueryController = nil; @implementation SPQueryController -#ifndef SP_REFACTOR +#ifndef SP_CODA @synthesize consoleFont; #endif @@ -86,7 +86,7 @@ static SPQueryController *sharedQueryController = nil; - (id)init { if ((self = [super initWithWindowNibName:@"Console"])) { -#ifndef SP_REFACTOR +#ifndef SP_CODA messagesFullSet = [[NSMutableArray alloc] init]; messagesFilteredSet = [[NSMutableArray alloc] init]; @@ -110,12 +110,12 @@ static SPQueryController *sharedQueryController = nil; completionFunctionList = nil; functionArgumentSnippets = nil; -#ifndef SP_REFACTOR +#ifndef SP_CODA pthread_mutex_init(&consoleLock, NULL); #endif NSError *error = [self loadCompletionLists]; - + if (error) { NSLog(@"Error loading completion tokens data: %@", [error localizedDescription]); } @@ -146,7 +146,7 @@ static SPQueryController *sharedQueryController = nil; */ - (void)copy:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSResponder *firstResponder = [[self window] firstResponder]; if ((firstResponder == consoleTableView) && ([consoleTableView numberOfSelectedRows] > 0)) { @@ -155,7 +155,7 @@ static SPQueryController *sharedQueryController = nil; NSIndexSet *rows = [consoleTableView selectedRowIndexes]; NSUInteger i = [rows firstIndex]; - + BOOL includeTimestamps = ![[consoleTableView tableColumnWithIdentifier:SPTableViewDateColumnID] isHidden]; BOOL includeConnections = ![[consoleTableView tableColumnWithIdentifier:SPTableViewConnectionColumnID] isHidden]; @@ -165,19 +165,19 @@ static SPQueryController *sharedQueryController = nil; { if (i < [messagesVisibleSet count]) { SPConsoleMessage *message = NSArrayObjectAtIndex(messagesVisibleSet, i); - + if (includeTimestamps || includeConnections) [string appendString:@"/* "]; if (includeTimestamps) { [string appendString:[dateFormatter stringFromDate:[message messageDate]]]; [string appendString:@" "]; } - + if (includeConnections) { [string appendString:[message messageConnection]]; [string appendString:@" "]; } - + if (includeTimestamps || includeConnections) [string appendString:@"*/ "]; [string appendFormat:@"%@\n", [message message]]; @@ -200,7 +200,7 @@ static SPQueryController *sharedQueryController = nil; */ - (IBAction)clearConsole:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA [messagesFullSet removeAllObjects]; [messagesFilteredSet removeAllObjects]; @@ -213,7 +213,7 @@ static SPQueryController *sharedQueryController = nil; */ - (IBAction)saveConsoleAs:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSSavePanel *panel = [NSSavePanel savePanel]; [panel setAllowedFileTypes:[NSArray arrayWithObject:SPFileExtensionSQL]]; @@ -233,7 +233,7 @@ static SPQueryController *sharedQueryController = nil; */ - (IBAction)toggleShowTimeStamps:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA [[consoleTableView tableColumnWithIdentifier:SPTableViewDateColumnID] setHidden:([sender state])]; #endif } @@ -243,7 +243,7 @@ static SPQueryController *sharedQueryController = nil; */ - (IBAction)toggleShowConnections:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA [[consoleTableView tableColumnWithIdentifier:SPTableViewConnectionColumnID] setHidden:([sender state])]; #endif } @@ -253,7 +253,7 @@ static SPQueryController *sharedQueryController = nil; */ - (IBAction)toggleShowSelectShowStatements:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Store the state of the toggle for later quick reference showSelectStatementsAreDisabled = [sender state]; @@ -266,7 +266,7 @@ static SPQueryController *sharedQueryController = nil; */ - (IBAction)toggleShowHelpStatements:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Store the state of the toggle for later quick reference showHelpStatementsAreDisabled = [sender state]; @@ -279,7 +279,7 @@ static SPQueryController *sharedQueryController = nil; */ - (void)showMessageInConsole:(NSString *)message connection:(NSString *)connection { -#ifndef SP_REFACTOR +#ifndef SP_CODA [self _addMessageToConsole:message connection:connection isError:NO]; #endif } @@ -289,7 +289,7 @@ static SPQueryController *sharedQueryController = nil; */ - (void)showErrorInConsole:(NSString *)error connection:(NSString *)connection { -#ifndef SP_REFACTOR +#ifndef SP_CODA [self _addMessageToConsole:error connection:connection isError:YES]; #endif } @@ -299,7 +299,7 @@ static SPQueryController *sharedQueryController = nil; */ - (NSUInteger)consoleMessageCount { -#ifndef SP_REFACTOR +#ifndef SP_CODA return [messagesFullSet count]; #else return 0; @@ -311,7 +311,7 @@ static SPQueryController *sharedQueryController = nil; */ - (void)savePanelDidEnd:(NSSavePanel *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { -#ifndef SP_REFACTOR +#ifndef SP_CODA if (returnCode == NSOKButton) { [[self _getConsoleStringWithTimeStamps:[includeTimeStampsButton state] connections:[includeConnectionButton state]] writeToFile:[[sheet URL] path] atomically:YES encoding:NSUTF8StringEncoding error:NULL]; } @@ -326,7 +326,7 @@ static SPQueryController *sharedQueryController = nil; */ - (void)controlTextDidChange:(NSNotification *)notification { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([[notification object] isEqualTo:consoleSearchField]) { // Store the state of the text filter and the current filter string for later quick reference @@ -344,7 +344,7 @@ static SPQueryController *sharedQueryController = nil; */ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Show/hide logging disabled label if ([keyPath isEqualToString:SPConsoleEnableLogging]) { [loggingDisabledTextField setStringValue:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? @"" : NSLocalizedString(@"Query logging is currently disabled", @"query logging currently disabled label")]; @@ -373,7 +373,7 @@ static SPQueryController *sharedQueryController = nil; */ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([menuItem action] == @selector(copy:)) { return ([consoleTableView numberOfSelectedRows] > 0); } @@ -389,7 +389,7 @@ static SPQueryController *sharedQueryController = nil; - (BOOL)allowConsoleUpdate { -#ifndef SP_REFACTOR +#ifndef SP_CODA return allowConsoleUpdate; #else return NO; @@ -398,7 +398,7 @@ static SPQueryController *sharedQueryController = nil; - (void)setAllowConsoleUpdate:(BOOL)allowUpdate { -#ifndef SP_REFACTOR +#ifndef SP_CODA allowConsoleUpdate = allowUpdate; if (allowUpdate && [[self window] isVisible]) [self updateEntries]; @@ -410,13 +410,13 @@ static SPQueryController *sharedQueryController = nil; */ - (void)updateEntries { -#ifndef SP_REFACTOR +#ifndef SP_CODA [consoleTableView reloadData]; [consoleTableView scrollRowToVisible:([messagesVisibleSet count] - 1)]; #endif } -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Return the AutoSaveName of the Query Console. */ @@ -435,64 +435,64 @@ static SPQueryController *sharedQueryController = nil; */ - (void)_updateFilterState { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Display start progress spinner [progressIndicator setHidden:NO]; [progressIndicator startAnimation:self]; - + // Don't allow clearing the console while filtering its content [saveConsoleButton setEnabled:NO]; [clearConsoleButton setEnabled:NO]; - + [messagesFilteredSet removeAllObjects]; - + // If filtering is disabled and all show/selects are shown, empty the filtered // result set and set the full set to visible. if (!filterIsActive && !showSelectStatementsAreDisabled && !showHelpStatementsAreDisabled) { messagesVisibleSet = messagesFullSet; - + [consoleTableView reloadData]; [consoleTableView scrollRowToVisible:([messagesVisibleSet count] - 1)]; - + [saveConsoleButton setEnabled:YES]; [clearConsoleButton setEnabled:YES]; - + [saveConsoleButton setTitle:NSLocalizedString(@"Save As...", @"save as button title")]; - + // Hide progress spinner [progressIndicator setHidden:YES]; [progressIndicator stopAnimation:self]; return; } - + // Cache frequently used selector, avoiding dynamic binding overhead IMP messageMatchesFilters = [self methodForSelector:@selector(_messageMatchesCurrentFilters:)]; - + // Loop through all the messages in the full set to determine which should be // added to the filtered set. for (SPConsoleMessage *message in messagesFullSet) { - + // Add a reference to the message to the filtered set if filters are active and the // current message matches them if ((messageMatchesFilters)(self, @selector(_messageMatchesCurrentFilters:), [message message])) { [messagesFilteredSet addObject:message]; } } - + // Ensure that the filtered set is marked as the currently visible set. messagesVisibleSet = messagesFilteredSet; - + [consoleTableView reloadData]; [consoleTableView scrollRowToVisible:([messagesVisibleSet count] - 1)]; - + if ([messagesVisibleSet count] > 0) { [saveConsoleButton setEnabled:YES]; [clearConsoleButton setEnabled:YES]; } - + [saveConsoleButton setTitle:NSLocalizedString(@"Save View As...", @"save view as button title")]; - + // Hide progress spinner [progressIndicator setHidden:YES]; [progressIndicator stopAnimation:self]; @@ -506,13 +506,13 @@ static SPQueryController *sharedQueryController = nil; - (BOOL)_messageMatchesCurrentFilters:(NSString *)message { BOOL messageMatchesCurrentFilters = YES; - -#ifndef SP_REFACTOR + +#ifndef SP_CODA // Check whether to hide the message based on the current filter text, if any if (filterIsActive && [message rangeOfString:activeFilterString options:NSCaseInsensitiveSearch].location == NSNotFound) { messageMatchesCurrentFilters = NO; } - + // If hiding SELECTs and SHOWs is toggled to on, check whether the message is a SELECT or SHOW if (messageMatchesCurrentFilters && showSelectStatementsAreDisabled && @@ -520,13 +520,13 @@ static SPQueryController *sharedQueryController = nil; { messageMatchesCurrentFilters = NO; } - + // If hiding HELP is toggled to on, check whether the message is a HELP if (messageMatchesCurrentFilters && showHelpStatementsAreDisabled && ([[message uppercaseString] hasPrefix:@"HELP"])) { messageMatchesCurrentFilters = NO; } #endif - + return messageMatchesCurrentFilters; } @@ -537,8 +537,8 @@ static SPQueryController *sharedQueryController = nil; - (NSString *)_getConsoleStringWithTimeStamps:(BOOL)timeStamps connections:(BOOL)connections { NSMutableString *consoleString = [NSMutableString string]; - -#ifndef SP_REFACTOR + +#ifndef SP_CODA NSArray *messageCopy = [messagesVisibleSet copy]; for (SPConsoleMessage *message in messagesVisibleSet) @@ -546,28 +546,28 @@ static SPQueryController *sharedQueryController = nil; // As we are going to save the messages as an SQL file we need to comment // the timestamps and connections if included. if (timeStamps || connections) [consoleString appendString:@"/* "]; - + // If the timestamp column is not hidden we need to include them in the copy if (timeStamps) { [consoleString appendString:[dateFormatter stringFromDate:[message messageDate]]]; [consoleString appendString:@" "]; } - + // If the connection column is not hidden we need to include them in the copy if (connections) { [consoleString appendString:[message messageConnection]]; [consoleString appendString:@" "]; } - + // Close the comment if (timeStamps || connections) [consoleString appendString:@"*/ "]; - + [consoleString appendFormat:@"%@\n", [message message]]; } [messageCopy release]; #endif - + return consoleString; } @@ -576,20 +576,20 @@ static SPQueryController *sharedQueryController = nil; */ - (void)_addMessageToConsole:(NSString *)message connection:(NSString *)connection isError:(BOOL)error { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSString *messageTemp = [[message stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] stringByReplacingOccurrencesOfString:@"\n" withString:@" "]; - + // Only append a semi-colon (;) if the supplied message is not an error if (!error) messageTemp = [messageTemp stringByAppendingString:@";"]; - + SPConsoleMessage *consoleMessage = [SPConsoleMessage consoleMessageWithMessage:messageTemp date:[NSDate date] connection:connection]; - + [consoleMessage setIsError:error]; - + pthread_mutex_lock(&consoleLock); [messagesFullSet addObject:consoleMessage]; - + // If filtering is active, determine whether to add a reference to the filtered set if ((showSelectStatementsAreDisabled || showHelpStatementsAreDisabled || filterIsActive) && [self _messageMatchesCurrentFilters:[consoleMessage message]]) @@ -598,7 +598,7 @@ static SPQueryController *sharedQueryController = nil; [saveConsoleButton setEnabled:YES]; [clearConsoleButton setEnabled:YES]; } - + // Reload the table and scroll to the new message if it's visible (for speed) if (allowConsoleUpdate && [[self window] isVisible]) { [consoleTableView noteNumberOfRowsChanged]; @@ -614,12 +614,12 @@ static SPQueryController *sharedQueryController = nil; - (void)dealloc { -#ifndef SP_REFACTOR +#ifndef SP_CODA messagesVisibleSet = nil; #endif [NSObject cancelPreviousPerformRequestsWithTarget:self]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [dateFormatter release], dateFormatter = nil; [messagesFullSet release], messagesFullSet = nil; @@ -635,7 +635,7 @@ static SPQueryController *sharedQueryController = nil; if (completionFunctionList) [completionFunctionList release], completionFunctionList = nil; if (functionArgumentSnippets) [functionArgumentSnippets release], functionArgumentSnippets = nil; -#ifndef SP_REFACTOR +#ifndef SP_CODA pthread_mutex_destroy(&consoleLock); #endif diff --git a/Source/SPQueryControllerInitializer.m b/Source/SPQueryControllerInitializer.m index f3a3f70e..12952ef0 100644 --- a/Source/SPQueryControllerInitializer.m +++ b/Source/SPQueryControllerInitializer.m @@ -51,7 +51,7 @@ static NSString *SPCompletionTokensSnippetsKey = @"function_argument_snippets"; */ - (void)awakeFromNib { -#ifndef SP_REFACTOR /* init ivars */ +#ifndef SP_CODA /* init ivars */ prefs = [NSUserDefaults standardUserDefaults]; [self setWindowFrameAutosaveName:SPQueryConsoleWindowAutoSaveName]; diff --git a/Source/SPQueryDocumentsController.m b/Source/SPQueryDocumentsController.m index d1a21209..3557c75f 100644 --- a/Source/SPQueryDocumentsController.m +++ b/Source/SPQueryDocumentsController.m @@ -36,7 +36,7 @@ - (NSURL *)registerDocumentWithFileURL:(NSURL *)fileURL andContextInfo:(NSMutableDictionary *)contextInfo { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Register a new untiled document and return its URL if (fileURL == nil) { NSURL *new = [NSURL URLWithString:[[NSString stringWithFormat:NSLocalizedString(@"Untitled %ld",@"Title of a new Sequel Pro Document"), (unsigned long)untitledDocumentCounter] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; @@ -120,7 +120,7 @@ - (void)removeRegisteredDocumentWithFileURL:(NSURL *)fileURL { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Check for multiple instance of the same document. // Remove it if only one instance was registerd. NSArray *allDocs = [[NSApp delegate] orderedDocuments]; @@ -154,7 +154,7 @@ - (void)replaceContentFilterByArray:(NSArray *)contentFilterArray ofType:(NSString *)filterType forFileURL:(NSURL *)fileURL { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([contentFilterContainer objectForKey:[fileURL absoluteString]]) { NSMutableDictionary *c = [[NSMutableDictionary alloc] init]; [c setDictionary:[contentFilterContainer objectForKey:[fileURL absoluteString]]]; @@ -167,7 +167,7 @@ - (void)replaceFavoritesByArray:(NSArray *)favoritesArray forFileURL:(NSURL *)fileURL { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([favoritesContainer objectForKey:[fileURL absoluteString]]) { [favoritesContainer setObject:favoritesArray forKey:[fileURL absoluteString]]; } @@ -183,21 +183,21 @@ */ - (void)removeFavoriteAtIndex:(NSUInteger)index forFileURL:(NSURL *)fileURL { -#ifndef SP_REFACTOR +#ifndef SP_CODA [[favoritesContainer objectForKey:[fileURL absoluteString]] removeObjectAtIndex:index]; #endif } - (void)insertFavorite:(NSDictionary *)favorite atIndex:(NSUInteger)index forFileURL:(NSURL *)fileURL { -#ifndef SP_REFACTOR +#ifndef SP_CODA [[favoritesContainer objectForKey:[fileURL absoluteString]] insertObject:favorite atIndex:index]; #endif } - (void)replaceHistoryByArray:(NSArray *)historyArray forFileURL:(NSURL *)fileURL { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([historyContainer objectForKey:[fileURL absoluteString]]) { [historyContainer setObject:historyArray forKey:[fileURL absoluteString]]; } @@ -219,7 +219,7 @@ - (void)addFavorite:(NSDictionary *)favorite forFileURL:(NSURL *)fileURL { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([favoritesContainer objectForKey:[fileURL absoluteString]]) { [[favoritesContainer objectForKey:[fileURL absoluteString]] addObject:favorite]; } @@ -228,7 +228,7 @@ - (void)addHistory:(NSString *)history forFileURL:(NSURL *)fileURL { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSUInteger maxHistoryItems = [[prefs objectForKey:SPCustomQueryMaxHistoryItems] integerValue]; // Save each history item due to its document source @@ -271,7 +271,7 @@ - (NSMutableArray *)favoritesForFileURL:(NSURL *)fileURL { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([favoritesContainer objectForKey:[fileURL absoluteString]]) { return [favoritesContainer objectForKey:[fileURL absoluteString]]; } @@ -282,7 +282,7 @@ - (NSMutableArray *)historyForFileURL:(NSURL *)fileURL { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([historyContainer objectForKey:[fileURL absoluteString]]) { return [historyContainer objectForKey:[fileURL absoluteString]]; } @@ -293,7 +293,7 @@ - (NSArray *)historyMenuItemsForFileURL:(NSURL *)fileURL { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([historyContainer objectForKey:[fileURL absoluteString]]) { NSMutableArray *returnArray = [NSMutableArray arrayWithCapacity:[[historyContainer objectForKey:[fileURL absoluteString]] count]]; NSMenuItem *historyMenuItem; @@ -323,7 +323,7 @@ */ - (NSUInteger)numberOfHistoryItemsForFileURL:(NSURL *)fileURL { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([historyContainer objectForKey:[fileURL absoluteString]]) { return [[historyContainer objectForKey:[fileURL absoluteString]] count]; } @@ -344,7 +344,7 @@ */ - (NSMutableDictionary *)contentFilterForFileURL:(NSURL *)fileURL { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([contentFilterContainer objectForKey:[fileURL absoluteString]]) { return [contentFilterContainer objectForKey:[fileURL absoluteString]]; } @@ -366,7 +366,7 @@ } } -#ifndef SP_REFACTOR +#ifndef SP_CODA if (includeGlobals && [prefs objectForKey:SPQueryFavorites]) { for (id fav in [prefs objectForKey:SPQueryFavorites]) diff --git a/Source/SPQueryFavoriteManager.h b/Source/SPQueryFavoriteManager.h index cb5c4dd5..f6e611ed 100644 --- a/Source/SPQueryFavoriteManager.h +++ b/Source/SPQueryFavoriteManager.h @@ -42,9 +42,9 @@ @interface SPQueryFavoriteManager : NSWindowController <NSOpenSavePanelDelegate> { -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ NSUserDefaults *prefs; - + NSURL *delegatesFileURL; #endif SPDatabaseDocument *tableDocumentInstance; @@ -65,7 +65,7 @@ - (id)initWithDelegate:(id)managerDelegate; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Accessors - (NSMutableArray *)queryFavoritesForFileURL:(NSURL *)fileURL; diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m index c645ce47..79839316 100644 --- a/Source/SPQueryFavoriteManager.m +++ b/Source/SPQueryFavoriteManager.m @@ -61,7 +61,7 @@ { if ((self = [super initWithWindowNibName:@"QueryFavoriteManager"])) { -#ifndef SP_REFACTOR +#ifndef SP_CODA prefs = [NSUserDefaults standardUserDefaults]; #endif @@ -73,7 +73,7 @@ return nil; } tableDocumentInstance = [managerDelegate valueForKeyPath:@"tableDocumentInstance"]; -#ifndef SP_REFACTOR +#ifndef SP_CODA delegatesFileURL = [tableDocumentInstance fileURL]; #endif } @@ -86,7 +86,7 @@ */ - (void)awakeFromNib { -#ifndef SP_REFACTOR +#ifndef SP_CODA [favorites addObject:[NSDictionary dictionaryWithObjectsAndKeys: @"Global", @"name", @"", @"headerOfFileURL", @@ -142,7 +142,7 @@ * Returns the query favorites array for fileURL. * fileURL == nil → global favorites */ -#ifndef SP_REFACTOR +#ifndef SP_CODA - (NSMutableArray *)queryFavoritesForFileURL:(NSURL *)fileURL { NSMutableArray *favs = [NSMutableArray array]; @@ -195,7 +195,7 @@ */ - (IBAction)addQueryFavorite:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSMutableDictionary *favorite; NSUInteger insertIndex; @@ -208,12 +208,12 @@ // Add a new favorite else favorite = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"New Favorite", @"", nil] forKeys:[NSArray arrayWithObjects:@"name", @"query", nil]]; - + // If a favourite is currently selected, add the new favourite next to it if ([favoritesTableView numberOfSelectedRows] > 0) { insertIndex = [[favoritesTableView selectedRowIndexes] lastIndex]+1; [favorites insertObject:favorite atIndex:insertIndex]; - } + } // If the DatabaseDocument is an on-disk document, add the favourite to the bottom of it else if (![tableDocumentInstance isUntitled]) { @@ -304,7 +304,7 @@ */ - (IBAction)saveFavoriteToFile:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSSavePanel *panel = [NSSavePanel savePanel]; [panel setAllowedFileTypes:[NSArray arrayWithObject:SPFileExtensionSQL]]; @@ -324,7 +324,7 @@ - (IBAction)exportFavorites:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSSavePanel *panel = [NSSavePanel savePanel]; [panel setAllowedFileTypes:[NSArray arrayWithObject:SPFileExtensionDefault]]; @@ -340,7 +340,7 @@ - (IBAction)importFavoritesByAdding:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSOpenPanel *panel = [NSOpenPanel openPanel]; [panel setCanSelectHiddenExtension:YES]; [panel setDelegate:self]; @@ -440,7 +440,7 @@ */ - (IBAction)closeQueryManagerSheet:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA // First check for ESC if pressed while inline editing if(![sender tag] && isTableCellEditing) { @@ -479,7 +479,7 @@ } -#ifndef SP_REFACTOR +#ifndef SP_CODA - (IBAction)showHelp:(id)sender { [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:NSLocalizedString(@"http://www.sequelpro.com/docs/Query_Favorites", @"Localized help page for query favourites - do not localize if no translated webpage is available")]]; @@ -809,7 +809,7 @@ */ - (void)importPanelDidEnd:(NSOpenPanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { -#ifndef SP_REFACTOR +#ifndef SP_CODA if (returnCode == NSOKButton) { @@ -877,7 +877,7 @@ */ - (void)savePanelDidEnd:(NSSavePanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { -#ifndef SP_REFACTOR +#ifndef SP_CODA if([contextInfo isEqualToString:@"saveQuery"]) { if (returnCode == NSOKButton) { diff --git a/Source/SPTableContent.h b/Source/SPTableContent.h index fcc106b2..eb3aa881 100644 --- a/Source/SPTableContent.h +++ b/Source/SPTableContent.h @@ -7,7 +7,7 @@ // Created by Lorenz Textor (lorenz@textor.ch) on May 1, 2002. // Copyright (c) 2002-2003 Lorenz Textor. All rights reserved. // Copyright (c) 2012 Sequel Pro Team. 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 @@ -47,7 +47,7 @@ @class SPTableStructure; @class SPTableList; @class SPContentFilterManager; -#ifndef SP_REFACTOR +#ifndef SP_CODA @class SPSplitView; #endif @@ -58,7 +58,7 @@ IBOutlet SPTableData* tableDataInstance; IBOutlet id tableSourceInstance; -#ifndef SP_REFACTOR +#ifndef SP_CODA IBOutlet SPTableInfo *tableInfoInstance; IBOutlet SPHistoryController *spHistoryControllerInstance; #endif @@ -72,7 +72,7 @@ IBOutlet id duplicateButton; IBOutlet id removeButton; IBOutlet id reloadButton; -#ifndef SP_REFACTOR +#ifndef SP_CODA IBOutlet NSButton *multipleLineEditingButton; IBOutlet id countText; IBOutlet id limitRowsField; @@ -84,17 +84,17 @@ IBOutlet id betweenTextField; IBOutlet NSButton *paginationPreviousButton; -#ifndef SP_REFACTOR +#ifndef SP_CODA IBOutlet NSButton *paginationButton; IBOutlet NSButton *paginationGoButton; #endif IBOutlet NSButton *paginationNextButton; -#ifndef SP_REFACTOR +#ifndef SP_CODA IBOutlet NSView *contentViewPane; IBOutlet NSView *paginationView; #endif IBOutlet NSTextField *paginationPageField; -#ifndef SP_REFACTOR +#ifndef SP_CODA IBOutlet NSStepper *paginationPageStepper; IBOutlet SPCopyTable *filterTableView; @@ -109,14 +109,14 @@ IBOutlet NSButton *filterTableLiveSearchCheckbox; IBOutlet NSButton *filterTableSearchAllFields; IBOutlet NSPanel *filterTableSetDefaultOperatorSheet; - IBOutlet NSComboBox *filterTableSetDefaultOperatorValue; + IBOutlet NSComboBox* filterTableSetDefaultOperatorValue; #endif SPMySQLConnection *mySQLConnection; BOOL _mainNibLoaded; BOOL isWorking; pthread_mutex_t tableValuesLock; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSMutableArray *nibObjectsToRelease; #endif @@ -137,7 +137,7 @@ SPContentFilterManager *contentFilterManager; NSUInteger contentPage; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSMutableDictionary *filterTableData; BOOL filterTableNegate; BOOL filterTableDistinct; @@ -156,7 +156,7 @@ NSRect selectionViewportToRestore; NSString *filterFieldToRestore, *filterComparisonToRestore, *filterValueToRestore, *firstBetweenValueToRestore, *secondBetweenValueToRestore; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSInteger paginationViewHeight; #endif @@ -178,7 +178,7 @@ NSRange fieldEditorSelectedRange; } -#ifdef SP_REFACTOR /* glue */ +#ifdef SP_CODA /* glue */ @property (assign) id filterButton; @property (assign) id fieldField; @property (assign) id compareField; @@ -204,32 +204,32 @@ - (NSRange)fieldEditorSelectedRange; // Table loading methods and information -- (void)loadTable:(NSString *)aTable; +- (void) loadTable:(NSString *)aTable; - (void)setTableDetails:(NSDictionary *)tableDetails; -- (void)clearTableValues; -- (void)loadTableValues; -- (NSString *)tableFilterString; -- (void)updateCountText; -- (void)initTableLoadTimer; -- (void)clearTableLoadTimer; -- (void)tableLoadUpdate:(NSTimer *)theTimer; +- (void) clearTableValues; +- (void) loadTableValues; +- (NSString *) tableFilterString; +- (void) updateCountText; +- (void) initTableLoadTimer; +- (void) clearTableLoadTimer; +- (void) tableLoadUpdate:(NSTimer *)theTimer; // Table interface actions -- (IBAction)reloadTable:(id)sender; -- (void)reloadTableTask; -- (IBAction)filterTable:(id)sender; +- (IBAction) reloadTable:(id)sender; +- (void) reloadTableTask; +- (IBAction) filterTable:(id)sender; - (void)filterTableTask; -- (IBAction)toggleFilterField:(id)sender; -- (NSString *)usedQuery; -- (void)setUsedQuery:(NSString *)query; +- (IBAction) toggleFilterField:(id)sender; +- (NSString *) usedQuery; +- (void) setUsedQuery:(NSString *)query; // Pagination -- (IBAction)navigatePaginationFromButton:(id)sender; -#ifndef SP_REFACTOR +- (IBAction) navigatePaginationFromButton:(id)sender; +#ifndef SP_CODA - (IBAction)togglePagination:(NSButton *)sender; #endif -- (void)setPaginationViewVisibility:(BOOL)makeVisible; -- (void)updatePaginationState; +- (void) setPaginationViewVisibility:(BOOL)makeVisible; +- (void) updatePaginationState; // Edit methods - (IBAction)addRow:(id)sender; @@ -252,8 +252,8 @@ - (NSArray *)currentDataResultWithNULLs:(BOOL)includeNULLs hideBLOBs:(BOOL)hide; // Task interaction -- (void)startDocumentTaskForTab:(NSNotification *)aNotification; -- (void)endDocumentTaskForTab:(NSNotification *)aNotification; +- (void) startDocumentTaskForTab:(NSNotification *)aNotification; +- (void) endDocumentTaskForTab:(NSNotification *)aNotification; // Additional methods - (void)setConnection:(SPMySQLConnection *)theConnection; @@ -277,23 +277,23 @@ - (void)saveViewCellValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSUInteger)rowIndex; // Retrieving and setting table state -- (NSString *)sortColumnName; -- (BOOL)sortColumnIsAscending; -- (NSUInteger)pageNumber; +- (NSString *) sortColumnName; +- (BOOL) sortColumnIsAscending; +- (NSUInteger) pageNumber; - (NSDictionary *)selectionDetailsAllowingIndexSelection:(BOOL)allowIndexFallback; -- (NSRect)viewport; -- (CGFloat)tablesListWidth; -- (NSDictionary *)filterSettings; +- (NSRect) viewport; +- (CGFloat) tablesListWidth; +- (NSDictionary *) filterSettings; - (NSArray *)dataColumnDefinitions; -- (void)setSortColumnNameToRestore:(NSString *)theSortColumnName isAscending:(BOOL)isAscending; -- (void)setPageToRestore:(NSUInteger)thePage; +- (void) setSortColumnNameToRestore:(NSString *)theSortColumnName isAscending:(BOOL)isAscending; +- (void) setPageToRestore:(NSUInteger)thePage; - (void)setSelectionToRestore:(NSDictionary *)theSelection; -- (void)setViewportToRestore:(NSRect)theViewport; -- (void)setFiltersToRestore:(NSDictionary *)filterSettings; -- (void)storeCurrentDetailsForRestoration; -- (void)clearDetailsToRestore; -- (void)setFilterTableData:(NSData*)arcData; -- (NSData*)filterTableData; +- (void) setViewportToRestore:(NSRect)theViewport; +- (void) setFiltersToRestore:(NSDictionary *)filterSettings; +- (void) storeCurrentDetailsForRestoration; +- (void) clearDetailsToRestore; +- (void) setFilterTableData:(NSData*)arcData; +- (NSData*) filterTableData; - (NSString *)escapeFilterArgument:(NSString *)argument againstClause:(NSString *)clause; - (void)openContentFilterManager; diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index a587c945..986cffb8 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -44,7 +44,7 @@ #import "SPQueryController.h" #import "SPQueryDocumentsController.h" #import "SPTextAndLinkCell.h" -#ifndef SP_REFACTOR +#ifndef SP_CODA #import "QLPreviewPanel.h" #import "SPSplitView.h" #endif @@ -58,7 +58,7 @@ #import "SPGeometryDataView.h" #import "SPTextView.h" #import "SPDatabaseViewController.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPAppController.h" #import "SPBundleHTMLOutputController.h" #endif @@ -68,7 +68,7 @@ #import <pthread.h> #import <SPMySQL/SPMySQL.h> -#ifndef SP_REFACTOR +#ifndef SP_CODA static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOperator"; #endif @@ -80,7 +80,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper @implementation SPTableContent -#ifdef SP_REFACTOR +#ifdef SP_CODA @synthesize addButton; @synthesize argumentField; @synthesize betweenTextField; @@ -111,21 +111,21 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper isWorking = NO; pthread_mutex_init(&tableValuesLock, NULL); -#ifndef SP_REFACTOR +#ifndef SP_CODA nibObjectsToRelease = [[NSMutableArray alloc] init]; #endif - tableValues = [[SPDataStorage alloc] init]; - dataColumns = [[NSMutableArray alloc] init]; - oldRow = [[NSMutableArray alloc] init]; -#ifndef SP_REFACTOR - filterTableData = [[NSMutableDictionary alloc] initWithCapacity:1]; + tableValues = [[SPDataStorage alloc] init]; + dataColumns = [[NSMutableArray alloc] init]; + oldRow = [[NSMutableArray alloc] init]; +#ifndef SP_CODA + filterTableData = [[NSMutableDictionary alloc] initWithCapacity:1]; #endif tableRowsCount = 0; previousTableRowsCount = 0; -#ifndef SP_REFACTOR +#ifndef SP_CODA filterTableNegate = NO; filterTableDistinct = NO; filterTableIsSwapped = NO; @@ -207,11 +207,11 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper if (_mainNibLoaded) return; _mainNibLoaded = YES; -#ifndef SP_REFACTOR /* ui manipulation */ +#ifndef SP_CODA /* ui manipulation */ // Set the table content view's vertical gridlines if required [tableContentView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; [filterTableView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; - + // Set the double-click action in blank areas of the table to create new rows [tableContentView setEmptyDoubleClickAction:@selector(addRow:)]; @@ -244,13 +244,13 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [tableContentView setFieldEditorSelectedRange:NSMakeRange(0,0)]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Init Filter Table GUI [filterTableDistinctCheckbox setState:(filterTableDistinct) ? NSOnState : NSOffState]; [filterTableNegateCheckbox setState:(filterTableNegate) ? NSOnState : NSOffState]; [filterTableLiveSearchCheckbox setState:NSOffState]; #endif -#ifndef SP_REFACTOR /* patch */ +#ifndef SP_CODA /* patch */ filterTableDefaultOperator = [[self escapeFilterTableDefaultOperator:[prefs objectForKey:SPFilterTableDefaultOperator]] retain]; #else // filterTableDefaultOperator = [[self escapeFilterTableDefaultOperator:nil] retain]; @@ -345,18 +345,18 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper { NSString *newTableName; NSInteger i, sortColumnNumberToRestore = NSNotFound; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSNumber *colWidth; #endif NSArray *columnNames; NSDictionary *columnDefinition; NSMutableDictionary *preservedColumnWidths = nil; NSTableColumn *theCol; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSTableColumn *filterCol; #endif BOOL enableInteraction = -#ifndef SP_REFACTOR /* checking toolbar state */ +#ifndef SP_CODA /* checking toolbar state */ ![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableContent] || #endif ![tableDocumentInstance isWorking]; @@ -371,7 +371,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper newTableName = [tableDetails objectForKey:@"name"]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA // Ensure the pagination view hides itself if visible, after a tiny delay for smoothness [self performSelector:@selector(setPaginationViewVisibility:) withObject:nil afterDelay:0.1]; #endif @@ -386,7 +386,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // reload the data in-place to maintain table state if possible. if ([selectedTable isEqualToString:newTableName]) { previousTableRowsCount = tableRowsCount; - + // Store the column widths for later restoration preservedColumnWidths = [NSMutableDictionary dictionaryWithCapacity:[[tableContentView tableColumns] count]]; for (NSTableColumn *eachColumn in [tableContentView tableColumns]) { @@ -427,7 +427,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [tableContentView reloadData]; isFiltered = NO; isLimited = NO; -#ifndef SP_REFACTOR +#ifndef SP_CODA [countText setStringValue:@""]; #endif @@ -458,7 +458,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // Disable pagination [paginationPreviousButton setEnabled:NO]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [paginationButton setEnabled:NO]; [paginationButton setTitle:@""]; #endif @@ -472,7 +472,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // Clear restoration settings [self clearDetailsToRestore]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Clear filter table while ([[filterTableView tableColumns] count]) { [filterTableView removeTableColumn:NSArrayObjectAtIndex([filterTableView tableColumns], 0)]; @@ -491,7 +491,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper while ([[tableContentView tableColumns] count]) { [tableContentView removeTableColumn:NSArrayObjectAtIndex([tableContentView tableColumns], 0)]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA // Remove existing columns from the filter table [filterTableView abortEditing]; while ([[filterTableView tableColumns] count]) { @@ -529,7 +529,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper } NSString *nullValue = [prefs objectForKey:SPNullValue]; -#ifndef SP_REFACTOR /* get font from prefs */ +#ifndef SP_CODA /* get font from prefs */ NSFont *tableFont = [NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPGlobalResultTableFont]]; [tableContentView setRowHeight:2.0f+NSSizeToCGSize([[NSString stringWithString:@"{ǞṶḹÜ∑zgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; #else @@ -559,7 +559,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [theCol setEditable:YES]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Set up column for filterTable filterCol = [[NSTableColumn alloc] initWithIdentifier:[columnDefinition objectForKey:@"datacolumnindex"]]; [[filterCol headerCell] setStringValue:[columnDefinition objectForKey:@"name"]]; @@ -630,7 +630,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // Assign the data cell [theCol setDataCell:dataCell]; -#ifndef SP_REFACTOR /* prefs access */ +#ifndef SP_CODA /* prefs access */ // Set the width of this column to saved value if exists colWidth = [[[[prefs objectForKey:SPTableColumnWidths] objectForKey:[NSString stringWithFormat:@"%@@%@", [tableDocumentInstance database], [tableDocumentInstance host]]] objectForKey:[tablesListInstance tableName]] objectForKey:[columnDefinition objectForKey:@"name"]]; if ( colWidth ) { @@ -647,7 +647,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [theCol release]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA [filterTableView setDelegate:self]; [filterTableView setDataSource:self]; [filterTableView reloadData]; @@ -728,7 +728,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper if (!previousTableRowsCount) { [self clearTableValues]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA [filterTableView reloadData]; #endif @@ -769,7 +769,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper SPMySQLFastStreamingResult *streamingResult; NSInteger rowsToLoad = [[tableDataInstance statusValueForKey:@"Rows"] integerValue]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [countText setStringValue:NSLocalizedString(@"Loading table data...", @"Loading table data string")]; #endif @@ -778,7 +778,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // Start construction of the query string queryString = [NSMutableString stringWithFormat:@"SELECT %@%@ FROM %@", -#ifndef SP_REFACTOR +#ifndef SP_CODA (activeFilter == 1 && [self tableFilterString] && filterTableDistinct) ? @"DISTINCT " : #endif @"", @@ -958,7 +958,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; if ([mySQLConnection queryErrored] && ![mySQLConnection lastQueryWasCancelled]) { -#ifndef SP_REFACTOR +#ifndef SP_CODA if(activeFilter == 0) { #endif if(filterString) @@ -968,7 +968,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"The table data couldn't be loaded.\n\nMySQL said: %@", @"message of panel when loading of table failed"), [mySQLConnection lastErrorMessage]]); } -#ifndef SP_REFACTOR +#ifndef SP_CODA // Filter task came from filter table else if(activeFilter == 1){ [filterTableWindow setTitle:[NSString stringWithFormat:@"%@ – %@", NSLocalizedString(@"Filter", @"filter label"), NSLocalizedString(@"WHERE clause not valid", @"WHERE clause not valid")]]; @@ -977,7 +977,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper #endif else { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Trigger a full reload if required if (fullTableReloadRequired) [self reloadTable:self]; [[filterTableWindow onMainThread] setTitle:NSLocalizedString(@"Filter", @"filter label")]; @@ -1003,13 +1003,13 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [[self onMainThread] initTableLoadTimer]; NSAutoreleasePool *dataLoadingPool; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSProgressIndicator *dataLoadingIndicator = [tableDocumentInstance valueForKey:@"queryProgressBar"]; #else NSProgressIndicator *dataLoadingIndicator = [tableDocumentInstance queryProgressBar]; #endif BOOL prefsLoadBlobsAsNeeded = -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs boolForKey:SPLoadBlobsAsNeeded] #else NO @@ -1090,7 +1090,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper - (NSString *)tableFilterString { -#ifndef SP_REFACTOR +#ifndef SP_CODA // If filter command was passed by sequelpro url scheme if(activeFilter == 2) { if(schemeFilter) @@ -1349,7 +1349,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [countString appendFormat:NSLocalizedString(@"%@ %@ selected", @"text showing how many rows are selected"), [numberFormatter stringFromNumber:[NSNumber numberWithInteger:[tableContentView numberOfSelectedRows]]], rowString]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA [[countText onMainThread] setStringValue:countString]; #endif } @@ -1487,7 +1487,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper - (IBAction)filterTable:(id)sender { BOOL senderIsPaginationButton = (sender == paginationPreviousButton || sender == paginationNextButton -#ifndef SP_REFACTOR +#ifndef SP_CODA || sender == paginationGoButton #endif ); @@ -1497,7 +1497,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // (Keycode 51 is backspace, 117 is delete.) BOOL deleteTriggeringFilter = ([sender isKindOfClass:[NSSearchField class]] && [[[sender window] currentEvent] type] == NSKeyDown && ([[[sender window] currentEvent] keyCode] == 51 || [[[sender window] currentEvent] keyCode] == 117)); -#ifndef SP_REFACTOR +#ifndef SP_CODA // If the filter table is being used - the advanced filter - switch type if(sender == filterTableFilterButton) { @@ -1505,7 +1505,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper } // If a string was supplied, use a custom query from that URL scheme - else if ([sender isKindOfClass:[NSString class]] && [(NSString *)sender length]) { + else if([sender isKindOfClass:[NSString class]] && [(NSString *)sender length]) { if(schemeFilter) [schemeFilter release], schemeFilter = nil; schemeFilter = [sender retain]; activeFilter = 2; @@ -1534,7 +1534,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [sender becomeFirstResponder]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA [self setPaginationViewVisibility:FALSE]; #endif @@ -1571,7 +1571,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper { NSAutoreleasePool *filterPool = [[NSAutoreleasePool alloc] init]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Update history [spHistoryControllerInstance updateHistoryEntries]; #endif @@ -1658,7 +1658,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper - (void)sortTableTaskWithColumn:(NSTableColumn *)tableColumn { NSAutoreleasePool *sortPool = [[NSAutoreleasePool alloc] init]; - + // Check whether a save of the current row is required. if (![[self onMainThread] saveRowOnDeselect]) { @@ -1667,7 +1667,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [sortPool drain]; return; } - + // Sets column order as tri-state descending, ascending, no sort, descending, ascending etc. order if the same // header is clicked several times if (sortCol && [[tableColumn identifier] integerValue] == [sortCol integerValue]) { @@ -1756,7 +1756,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper * When the Pagination button is pressed, show or hide the pagination * layer depending on the current state. */ -#ifndef SP_REFACTOR +#ifndef SP_CODA - (IBAction) togglePagination:(NSButton *)sender { if ([sender state] == NSOnState) [self setPaginationViewVisibility:YES]; @@ -1769,7 +1769,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper */ - (void) setPaginationViewVisibility:(BOOL)makeVisible { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSRect paginationViewFrame = [paginationView frame]; if (makeVisible) { @@ -1824,7 +1824,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper else [paginationNextButton setEnabled:NO]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // As long as a table is selected (which it will be if this is called), enable pagination detail button [paginationButton setEnabled:enabledMode]; #endif @@ -1832,7 +1832,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // Set the values and maximums for the text field and associated pager [paginationPageField setStringValue:[numberFormatter stringFromNumber:[NSNumber numberWithUnsignedInteger:contentPage]]]; [[paginationPageField formatter] setMaximum:[NSNumber numberWithUnsignedInteger:maxPage]]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [paginationPageStepper setIntegerValue:contentPage]; [paginationPageStepper setMaxValue:maxPage]; #endif @@ -1962,7 +1962,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper isEditingRow = YES; isEditingNewRow = YES; currentlyEditingRow = [tableContentView selectedRow]; -#ifndef SP_REFACTOR +#ifndef SP_CODA if ( [multipleLineEditingButton state] == NSOffState ) #endif [tableContentView editColumn:0 row:[tableContentView numberOfRows]-1 withEvent:nil select:YES]; @@ -1978,7 +1978,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper NSDictionary *row; NSArray *dbDataRow = nil; NSUInteger i; - + // Check whether a save of the current row is required. if (![self saveRowOnDeselect]) return; @@ -1988,11 +1988,11 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil, NSLocalizedString(@"You can only copy single rows.", @"message of panel when trying to copy multiple rows")); return; } - + // Row contents tempRow = [tableValues rowContentsAtIndex:[tableContentView selectedRow]]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // If we don't show blobs, read data for this duplicate column from db if ([prefs boolForKey:SPLoadBlobsAsNeeded]) { @@ -2011,7 +2011,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper queryResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SHOW COLUMNS FROM %@", [selectedTable backtickQuotedString]]]; [queryResult setReturnDataAsStrings:YES]; - + for (i = 0; i < [queryResult numberOfRows]; i++) { row = [queryResult getRowAsDictionary]; @@ -2020,7 +2020,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [tempRow replaceObjectAtIndex:i withObject:[NSNull null]]; } else if ([tableDataInstance columnIsBlobOrText:[row objectForKey:@"Field"]] && -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs boolForKey:SPLoadBlobsAsNeeded] #else NO @@ -2042,11 +2042,11 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper isEditingNewRow = YES; currentlyEditingRow = [tableContentView selectedRow]; -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([multipleLineEditingButton state]) { #endif [tableContentView editColumn:0 row:[tableContentView selectedRow] withEvent:nil select:YES]; -#ifndef SP_REFACTOR +#ifndef SP_CODA } #endif } @@ -2071,7 +2071,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper NSArray *buttons = [alert buttons]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Change the alert's cancel button to have the key equivalent of return [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; @@ -2093,7 +2093,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // If table has PRIMARY KEY ask for resetting the auto increment after deletion if given if(![[tableDataInstance statusValueForKey:@"Auto_increment"] isNSNull]) { [alert setShowsSuppressionButton:YES]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [[alert suppressionButton] setState:([prefs boolForKey:SPResetAutoIncrementAfterDeletionOfAllRows]) ? NSOnState : NSOffState]; #endif [[[alert suppressionButton] cell] setControlSize:NSSmallControlSize]; @@ -2126,7 +2126,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper NSInteger i, errors; BOOL consoleUpdateStatus; BOOL reloadAfterRemovingRow = -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs boolForKey:SPReloadAfterRemovingRow] #else NO @@ -2152,11 +2152,11 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // Reset auto increment if suppression button was ticked if([[alert suppressionButton] state] == NSOnState) { [tableSourceInstance setAutoIncrementTo:@"1"]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs setBool:YES forKey:SPResetAutoIncrementAfterDeletionOfAllRows]; #endif } else { -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs setBool:NO forKey:SPResetAutoIncrementAfterDeletionOfAllRows]; #endif } @@ -2408,7 +2408,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper } [tableContentView deselectAll:self]; - } + } } } @@ -2507,7 +2507,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper NSImage *image = [v thumbnailImage]; NSString *imageStr = @""; - if (image) { + if(image) { NSString *maxSizeValue = @"WIDTH"; NSInteger imageWidth = [image size].width; NSInteger imageHeight = [image size].height; @@ -2545,7 +2545,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [tempRow addObject:hide ? @"<BLOB>" : [o stringRepresentationUsingEncoding:[mySQLConnection stringEncoding]]]; } - if (image) [image release]; + if(image) [image release]; } } @@ -2602,7 +2602,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper return; } -#ifndef SP_REFACTOR +#ifndef SP_CODA // Save existing scroll position and details and mark that state is being modified [spHistoryControllerInstance updateHistoryEntries]; [spHistoryControllerInstance setModifyingState:YES]; @@ -2637,7 +2637,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper } } -#ifndef SP_REFACTOR +#ifndef SP_CODA // End state and ensure a new history entry [spHistoryControllerInstance setModifyingState:NO]; [spHistoryControllerInstance updateHistoryEntries]; @@ -2646,7 +2646,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // End the task [tableDocumentInstance endTask]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // If the same table is the target, trigger a filter task on the main thread if (tableFilterRequired) [self performSelectorOnMainThread:@selector(filterTable:) withObject:self waitUntilDone:NO]; @@ -2741,7 +2741,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper } } -#ifndef SP_REFACTOR /* content filters */ +#ifndef SP_CODA /* content filters */ // Load global user-defined content filters if([prefs objectForKey:SPContentFilters] && [contentFilters objectForKey:compareType] @@ -2790,7 +2790,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper i++; } -#ifndef SP_REFACTOR +#ifndef SP_CODA [menu addItem:[NSMenuItem separatorItem]]; NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Edit Filters…", @"edit filter") action:NULL keyEquivalent:@""]; [item setToolTip:NSLocalizedString(@"Edit user-defined Filters…", @"edit user-defined filter")]; @@ -2819,7 +2819,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [compareField selectItemWithTag:lastSelectedContentFilterIndex]; // init query favorites controller -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs synchronize]; #endif if(contentFilterManager) [contentFilterManager release]; @@ -2951,7 +2951,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // If no rows have been changed, show error if appropriate. if ( ![mySQLConnection rowsAffectedByLastQuery] && ![mySQLConnection queryErrored] ) { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ( [prefs boolForKey:SPShowNoAffectedRowsError] ) { SPBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil, NSLocalizedString(@"The row was not written to the MySQL database. You probably haven't changed anything.\nReload the table to be sure that the row exists and use a primary key for your table.\n(This error can be turned off in the preferences.)", @"message of panel when no rows have been affected after writing to the db")); @@ -2981,13 +2981,13 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // New row created successfully if ( isEditingNewRow ) { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ( [prefs boolForKey:SPReloadAfterAddingRow] ) { // Save any edits which have been started but not saved to the underlying table/data structures // yet - but not if currently undoing/redoing, as this can cause a processing loop if (![[[[tableContentView window] firstResponder] undoManager] isUndoing] && ![[[[tableContentView window] firstResponder] undoManager] isRedoing]) { - [[tableDocumentInstance parentWindow] endEditingFor:nil]; + [[tableDocumentInstance parentWindow] endEditingFor:nil]; } previousTableRowsCount = tableRowsCount; @@ -3001,7 +3001,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [tableValues replaceObjectInRow:currentlyEditingRow column:i withObject:[[NSNumber numberWithUnsignedLongLong:[mySQLConnection lastInsertID]] description]]; } } -#ifndef SP_REFACTOR +#ifndef SP_CODA } #endif isEditingNewRow = NO; @@ -3010,13 +3010,13 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper } else { // Reload table if set to - otherwise no action required. -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([prefs boolForKey:SPReloadAfterEditingRow]) { // Save any edits which have been started but not saved to the underlying table/data structures // yet - but not if currently undoing/redoing, as this can cause a processing loop if (![[[[tableContentView window] firstResponder] undoManager] isUndoing] && ![[[[tableContentView window] firstResponder] undoManager] isRedoing]) { - [[tableDocumentInstance parentWindow] endEditingFor:nil]; + [[tableDocumentInstance parentWindow] endEditingFor:nil]; } previousTableRowsCount = tableRowsCount; @@ -3052,7 +3052,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper } else { - // Discard changes selected + // Discard changes selected [self cancelRowEditing]; } @@ -3172,7 +3172,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // When the option to not show blob or text options is set, we have a problem - we don't have // the right values to use in the WHERE statement. Throw an error if this is the case. -#ifndef SP_REFACTOR +#ifndef SP_CODA if ( [prefs boolForKey:SPLoadBlobsAsNeeded] && [self tableContainsBlobOrTextColumns] ) { SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil, NSLocalizedString(@"You can't hide blob and text fields when working with tables without index.", @"message of panel when trying to edit tables without index and with hidden blob/text fields")); @@ -3253,7 +3253,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper */ - (NSString *)fieldListForQuery { -#ifndef SP_REFACTOR +#ifndef SP_CODA if (([prefs boolForKey:SPLoadBlobsAsNeeded]) && [dataColumns count]) { NSMutableArray *fields = [NSMutableArray arrayWithCapacity:[dataColumns count]]; @@ -3366,7 +3366,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper */ - (void)sheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { -#ifndef SP_REFACTOR +#ifndef SP_CODA [sheet orderOut:self]; if([contextInfo isEqualToString:SPTableFilterSetDefaultOperator]) { @@ -3543,7 +3543,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // This shouldn't happen – for safety reasons if ( ![mySQLConnection rowsAffectedByLastQuery] ) { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ( [prefs boolForKey:SPShowNoAffectedRowsError] ) { SPBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil, NSLocalizedString(@"The row was not written to the MySQL database. You probably haven't changed anything.\nReload the table to be sure that the row exists and use a primary key for your table.\n(This error can be turned off in the preferences.)", @"message of panel when no rows have been affected after writing to the db")); @@ -3596,14 +3596,14 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper */ - (IBAction)tableFilterClear:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA [filterTableView abortEditing]; - if (filterTableData && [filterTableData count]) { + if(filterTableData && [filterTableData count]) { // Clear filter data - for (NSNumber *col in [filterTableData allKeys]) + for(NSNumber *col in [filterTableData allKeys]) { [[filterTableData objectForKey:col] setObject:[NSMutableArray arrayWithObjects:@"", @"", @"", @"", @"", @"", @"", @"", @"", @"", nil] forKey:SPTableContentFilterKey]; } @@ -3623,7 +3623,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper */ - (IBAction)showFilterTable:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA [filterTableWindow makeKeyAndOrderFront:nil]; [filterTableWhereClause setContinuousSpellCheckingEnabled:NO]; [filterTableWhereClause setAutoindent:NO]; @@ -3644,7 +3644,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper */ - (IBAction)toggleNegateClause:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA filterTableNegate = !filterTableNegate; if (filterTableNegate) { @@ -3667,7 +3667,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper */ - (IBAction)toggleDistinctSelect:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA filterTableDistinct = !filterTableDistinct; [filterTableDistinctCheckbox setState:(filterTableDistinct) ? NSOnState : NSOffState]; @@ -3685,17 +3685,17 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper */ - (IBAction)setDefaultOperator:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA [filterTableWindow makeFirstResponder:filterTableView]; // Load history - if ([prefs objectForKey:SPFilterTableDefaultOperatorLastItems]) { + if([prefs objectForKey:SPFilterTableDefaultOperatorLastItems]) { NSMutableArray *lastItems = [NSMutableArray array]; [lastItems addObject:@"LIKE '%@%'"]; - for (NSString* item in [prefs objectForKey:SPFilterTableDefaultOperatorLastItems]) + for(NSString* item in [prefs objectForKey:SPFilterTableDefaultOperatorLastItems]) { [lastItems addObject:item]; } @@ -3722,7 +3722,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper { [self updateFilterTableClause:sender]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // If live search is set perform filtering if ([filterTableLiveSearchCheckbox state] == NSOnState) { [self filterTable:filterTableFilterButton]; @@ -3754,7 +3754,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper /** * Provide a getter for the table's sort column name */ -- (NSString *)sortColumnName +- (NSString *) sortColumnName { if (!sortCol || !dataColumns) return nil; @@ -3764,7 +3764,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper /** * Provide a getter for the table current sort order */ -- (BOOL)sortColumnIsAscending +- (BOOL) sortColumnIsAscending { return !isDesc; } @@ -3791,7 +3791,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper primaryKeyFieldIndexes[i] = [[tableDataInstance columnNames] indexOfObject:[primaryKeyFieldNames objectAtIndex:i]]; if (primaryKeyFieldIndexes[i] == NSNotFound) { problemColumns = YES; -#ifndef SP_REFACTOR +#ifndef SP_CODA } else { if ([prefs boolForKey:SPLoadBlobsAsNeeded]) { if ([tableDataInstance columnIsBlobOrText:[primaryKeyFieldNames objectAtIndex:i]]) { @@ -4016,7 +4016,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper - (void) setFilterTableData:(NSData*)arcData { -#ifndef SP_REFACTOR +#ifndef SP_CODA if(!arcData) return; NSDictionary *filterData = [NSUnarchiver unarchiveObjectWithData:arcData]; [filterTableData removeAllObjects]; @@ -4028,7 +4028,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper - (NSData*) filterTableData { -#ifndef SP_REFACTOR +#ifndef SP_CODA if(![filterTableWindow isVisible]) return nil; [filterTableView deselectAll:nil]; @@ -4060,7 +4060,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper maxNumRowsIsEstimate = NO; [tableDataInstance setStatusValue:[NSString stringWithFormat:@"%ld", (long)maxNumRows] forKey:@"Rows"]; [tableDataInstance setStatusValue:@"y" forKey:@"RowsCountAccurate"]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [[tableInfoInstance onMainThread] tableChanged:nil]; [[[tableDocumentInstance valueForKey:@"extendedTableInfoInstance"] onMainThread] loadTable:selectedTable]; #endif @@ -4073,16 +4073,16 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // If the state is now accurate, use it if ([[tableDataInstance statusValueForKey:@"RowsCountAccurate"] boolValue]) { - maxNumRows = [[tableDataInstance statusValueForKey:@"Rows"] integerValue]; - maxNumRowsIsEstimate = NO; - checkStatusCount = YES; + maxNumRows = [[tableDataInstance statusValueForKey:@"Rows"] integerValue]; + maxNumRowsIsEstimate = NO; + checkStatusCount = YES; // Otherwise, use the estimate count - } else { - maxNumRows = [[tableDataInstance statusValueForKey:@"Rows"] integerValue]; - maxNumRowsIsEstimate = YES; - checkStatusCount = YES; - } + } else { + maxNumRows = [[tableDataInstance statusValueForKey:@"Rows"] integerValue]; + maxNumRowsIsEstimate = YES; + checkStatusCount = YES; + } } // Check whether the estimated count requires updating, ie if the retrieved count exceeds it @@ -4110,7 +4110,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper } [tableDataInstance setStatusValue:[NSString stringWithFormat:@"%ld", (long)maxNumRows] forKey:@"Rows"]; [tableDataInstance setStatusValue:maxNumRowsIsEstimate?@"n":@"y" forKey:@"RowsCountAccurate"]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [[tableInfoInstance onMainThread] tableChanged:nil]; #endif } @@ -4128,7 +4128,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [tableContentView setDelegate:nil]; for (NSDictionary *columnDefinition in dataColumns) { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Skip columns with saved widths if ([[[[prefs objectForKey:SPTableColumnWidths] objectForKey:[NSString stringWithFormat:@"%@@%@", [tableDocumentInstance database], [tableDocumentInstance host]]] objectForKey:[tablesListInstance tableName]] objectForKey:[columnDefinition objectForKey:@"name"]]) continue; #endif @@ -4151,7 +4151,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper { isWorking = YES; -#ifndef SP_REFACTOR /* Only proceed if this view is selected */ +#ifndef SP_CODA /* Only proceed if this view is selected */ // Only proceed if this view is selected. if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableContent]) return; @@ -4165,7 +4165,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper tableRowsSelectable = NO; [paginationPreviousButton setEnabled:NO]; [paginationNextButton setEnabled:NO]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [paginationButton setEnabled:NO]; #endif } @@ -4177,7 +4177,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper { isWorking = NO; -#ifndef SP_REFACTOR /* Only proceed if this view is selected */ +#ifndef SP_CODA /* Only proceed if this view is selected */ // Only proceed if this view is selected. if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableContent]) return; @@ -4208,16 +4208,16 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper */ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { -#ifndef SP_REFACTOR /* observe pref changes */ +#ifndef SP_CODA /* observe pref changes */ // Display table veiew vertical gridlines preference changed if ([keyPath isEqualToString:SPDisplayTableViewVerticalGridlines]) { - [tableContentView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; + [tableContentView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; [filterTableView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; } // Table font preference changed else if ([keyPath isEqualToString:SPGlobalResultTableFont]) { NSFont *tableFont = [NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]; - [tableContentView setRowHeight:2.0f + NSSizeToCGSize([[NSString stringWithString:@"{ǞṶḹÜ∑zgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; + [tableContentView setRowHeight:2.0f+NSSizeToCGSize([[NSString stringWithString:@"{ǞṶḹÜ∑zgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; [tableContentView setFont:tableFont]; [tableContentView reloadData]; } @@ -4283,7 +4283,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper pthread_mutex_destroy(&tableValuesLock); [dataColumns release]; [oldRow release]; -#ifndef SP_REFACTOR +#ifndef SP_CODA for (id retainedObject in nibObjectsToRelease) [retainedObject release]; [nibObjectsToRelease release]; diff --git a/Source/SPTableContentDataSource.m b/Source/SPTableContentDataSource.m index 21743464..0f84950d 100644 --- a/Source/SPTableContentDataSource.m +++ b/Source/SPTableContentDataSource.m @@ -46,7 +46,7 @@ - (NSInteger)numberOfRowsInTableView:(SPCopyTable *)tableView { -#ifndef SP_REFACTOR +#ifndef SP_CODA if (tableView == filterTableView) { return filterTableIsSwapped ? [filterTableData count] : [[[filterTableData objectForKey:@"0"] objectForKey:SPTableContentFilterKey] count]; } @@ -61,7 +61,7 @@ - (id)tableView:(SPCopyTable *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex { -#ifndef SP_REFACTOR +#ifndef SP_CODA if (tableView == filterTableView) { if (filterTableIsSwapped) @@ -122,7 +122,7 @@ - (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex { -#ifndef SP_REFACTOR +#ifndef SP_CODA if(tableView == filterTableView) { if (filterTableIsSwapped) { [[[filterTableData objectForKey:[NSNumber numberWithInteger:rowIndex]] objectForKey:SPTableContentFilterKey] replaceObjectAtIndex:([[tableColumn identifier] integerValue] - 1) withObject:(NSString *)object]; diff --git a/Source/SPTableContentDelegate.m b/Source/SPTableContentDelegate.m index 69a8f953..182386fb 100644 --- a/Source/SPTableContentDelegate.m +++ b/Source/SPTableContentDelegate.m @@ -32,7 +32,7 @@ #import "SPTableContentDelegate.h" #import "SPTableContentFilter.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPAppController.h" #endif #import "SPDatabaseDocument.h" @@ -40,7 +40,7 @@ #import "SPGeometryDataView.h" #import "SPTooltip.h" #import "SPTablesList.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPBundleHTMLOutputController.h" #endif #import "SPCopyTable.h" @@ -118,7 +118,7 @@ [self updateCountText]; -#ifndef SP_REFACTOR /* triggered commands */ +#ifndef SP_CODA /* triggered commands */ NSArray *triggeredCommands = [[NSApp delegate] bundleCommandsForTrigger:SPBundleTriggerActionTableRowChanged]; for (NSString *cmdPath in triggeredCommands) @@ -184,14 +184,14 @@ NSString *table = [tablesListInstance tableName]; // Get tableColumnWidths object -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([prefs objectForKey:SPTableColumnWidths] != nil ) { tableColumnWidths = [NSMutableDictionary dictionaryWithDictionary:[prefs objectForKey:SPTableColumnWidths]]; } else { #endif tableColumnWidths = [NSMutableDictionary dictionary]; -#ifndef SP_REFACTOR +#ifndef SP_CODA } #endif @@ -215,7 +215,7 @@ [[[tableColumnWidths objectForKey:database] objectForKey:table] setObject:[NSNumber numberWithDouble:[(NSTableColumn *)[[notification userInfo] objectForKey:@"NSTableColumn"] width]] forKey:[[[[notification userInfo] objectForKey:@"NSTableColumn"] headerCell] stringValue]]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs setObject:tableColumnWidths forKey:SPTableColumnWidths]; #endif } @@ -228,7 +228,7 @@ { if ([tableDocumentInstance isWorking]) return NO; -#ifndef SP_REFACTOR +#ifndef SP_CODA if (tableView == filterTableView) { return (filterTableIsSwapped && [[tableColumn identifier] integerValue] == 0) ? NO : YES; } @@ -385,7 +385,7 @@ */ - (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)rowIndex { -#ifndef SP_REFACTOR +#ifndef SP_CODA if (tableView == filterTableView) { return YES; } @@ -405,7 +405,7 @@ // Get the column width NSUInteger targetWidth = [tableContentView autodetectWidthForColumnDefinition:columnDefinition maxRows:500]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Clear any saved widths for the column NSString *dbKey = [NSString stringWithFormat:@"%@@%@", [tableDocumentInstance database], [tableDocumentInstance host]]; NSString *tableKey = [tablesListInstance tableName]; @@ -446,7 +446,7 @@ */ - (void)tableView:(SPCopyTable *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex { -#ifndef SP_REFACTOR +#ifndef SP_CODA if (tableView == filterTableView) { if (filterTableIsSwapped && [[tableColumn identifier] integerValue] == 0) { [cell setDrawsBackground:YES]; @@ -509,7 +509,7 @@ } } -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Show the table cell content as tooltip * @@ -599,7 +599,7 @@ } #endif -#ifndef SP_REFACTOR /* SplitView delegate methods */ +#ifndef SP_CODA /* SplitView delegate methods */ #pragma mark - #pragma mark SplitView delegate methods @@ -662,7 +662,7 @@ - (void)controlTextDidChange:(NSNotification *)notification { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([notification object] == filterTableView) { NSString *string = [[[[notification userInfo] objectForKey:@"NSFieldEditor"] textStorage] string]; @@ -758,13 +758,13 @@ */ - (BOOL)control:(NSControl<NSControlTextEditingDelegate> *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Check firstly if SPCopyTable can handle command if ([control control:control textView:textView doCommandBySelector:(SEL)command]) #else if ([control control:control textView:textView doCommandBySelector:command]) #endif - return YES; + return YES; // Trap the escape key if ([[control window] methodForSelector:command] == [[control window] methodForSelector:@selector(cancelOperation:)]) { diff --git a/Source/SPTableContentFilter.m b/Source/SPTableContentFilter.m index b3d032de..b8e1d72e 100644 --- a/Source/SPTableContentFilter.m +++ b/Source/SPTableContentFilter.m @@ -34,7 +34,7 @@ @implementation SPTableContent (SPTableContentFilter) -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Escape passed operator for usage as filterTableDefaultOperator. diff --git a/Source/SPTableData.h b/Source/SPTableData.h index 0806bd8b..f0ada4f2 100644 --- a/Source/SPTableData.h +++ b/Source/SPTableData.h @@ -85,7 +85,7 @@ - (NSDictionary *) parseFieldDefinitionStringParts:(NSArray *)definitionParts; - (NSArray *) primaryKeyColumnNames; -#ifdef SP_REFACTOR /* glue */ +#ifdef SP_CODA /* glue */ - (void)setTableDocumentInstance:(SPDatabaseDocument*)doc; - (void)setTableListInstance:(SPTablesList*)list; #endif diff --git a/Source/SPTableData.m b/Source/SPTableData.m index 04aaaed6..0de1e651 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -51,7 +51,7 @@ @synthesize tableHasAutoIncrementField; -- (id)init +- (id) init { if ((self = [super init])) { columns = [[NSMutableArray alloc] init]; @@ -78,7 +78,7 @@ * * @param theConnection The used connection for the SPDatabaseDocument */ -- (void)setConnection:(SPMySQLConnection *)theConnection +- (void) setConnection:(SPMySQLConnection *)theConnection { mySQLConnection = theConnection; [mySQLConnection retain]; @@ -87,7 +87,7 @@ /** * Retrieve the encoding for the current table, using or refreshing the cache as appropriate. */ -- (NSString *)tableEncoding +- (NSString *) tableEncoding { // If processing is already in action, wait for it to complete [self _loopWhileWorking]; @@ -479,7 +479,7 @@ [mySQLConnection storeEncodingForRestoration]; [mySQLConnection setEncoding:@"utf8"]; } - + // In cases where this method is called directly instead of via -updateInformationForCurrentTable // (for example, from the exporters) clear the list of constraints to prevent the previous call's table // constraints being included in the table information (issue 1206). @@ -727,11 +727,11 @@ [primaryKeyFields addObject:primaryFieldName]; for (NSMutableDictionary *theTableColumn in tableColumns) { if ([[theTableColumn objectForKey:@"name"] isEqualToString:primaryFieldName]) { - [theTableColumn setObject:[NSNumber numberWithInteger:1] forKey:@"isprimarykey"]; - break; - } + [theTableColumn setObject:[NSNumber numberWithInteger:1] forKey:@"isprimarykey"]; + break; } - } + } + } [tableData setObject:primaryKeyFields forKey:@"primarykeyfield"]; } } @@ -745,9 +745,9 @@ NSString *uniqueFieldName = [[SPSQLParser stringWithString:quotedUniqueKey] unquotedString]; for (NSMutableDictionary *theTableColumn in tableColumns) { if ([[theTableColumn objectForKey:@"name"] isEqualToString:uniqueFieldName]) { - [theTableColumn setObject:[NSNumber numberWithInteger:1] forKey:@"unique"]; - break; - } + [theTableColumn setObject:[NSNumber numberWithInteger:1] forKey:@"unique"]; + break; + } } } } @@ -1118,7 +1118,7 @@ SPRowCountQueryUsageLevels rowCountLevel = SPRowCountFetchAlways; NSInteger rowCountCheapBoundary = 5242880; -#ifndef SP_REFACTOR +#ifndef SP_CODA rowCountLevel = [[[NSUserDefaults standardUserDefaults] objectForKey:SPTableRowCountQueryLevel] integerValue]; rowCountCheapBoundary = [[[NSUserDefaults standardUserDefaults] objectForKey:SPTableRowCountCheapSizeBoundary] integerValue]; #endif @@ -1407,7 +1407,7 @@ pthread_mutex_unlock(&dataProcessingLock); } -#ifdef SP_REFACTOR /* glue */ +#ifdef SP_CODA /* glue */ - (void)setTableDocumentInstance:(SPDatabaseDocument *)doc { @@ -1421,4 +1421,4 @@ #endif -@end +@end
\ No newline at end of file diff --git a/Source/SPTableStructure.h b/Source/SPTableStructure.h index 2b2a2014..c749c822 100644 --- a/Source/SPTableStructure.h +++ b/Source/SPTableStructure.h @@ -42,21 +42,21 @@ @class SPMySQLResult; @interface SPTableStructure : NSObject -#ifdef SP_REFACTOR +#ifdef SP_CODA <NSTableViewDelegate, NSTableViewDataSource, NSComboBoxCellDataSource> #endif { IBOutlet SPTablesList* tablesListInstance; IBOutlet SPTableData* tableDataInstance; IBOutlet SPDatabaseDocument* tableDocumentInstance; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ IBOutlet id tableInfoInstance; IBOutlet id extendedTableInfoInstance; #endif IBOutlet SPIndexesController* indexesController; IBOutlet SPDatabaseData* databaseDataInstance; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ IBOutlet id keySheet; IBOutlet id resetAutoIncrementSheet; IBOutlet id resetAutoIncrementValue; @@ -67,7 +67,7 @@ IBOutlet id duplicateFieldButton; IBOutlet id removeFieldButton; IBOutlet id reloadFieldsButton; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ IBOutlet id chooseKeyButton; IBOutlet id structureGrabber; IBOutlet id editTableButton; @@ -76,7 +76,7 @@ IBOutlet id refreshIndexesButton; #endif IBOutlet SPTableView* indexesTableView; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ IBOutlet NSSplitView *tablesIndexesSplitView; IBOutlet NSButton *indexesShowButton; @@ -103,7 +103,7 @@ BOOL isEditingRow, isEditingNewRow, isSavingRow, alertSheetOpened; } -#ifdef SP_REFACTOR +#ifdef SP_CODA @property (assign) SPIndexesController* indexesController; @property (assign) id indexesTableView; @property (assign) id addFieldButton; @@ -112,7 +112,7 @@ @property (assign) id reloadFieldsButton; #endif -#ifdef SP_REFACTOR /* method decls */ +#ifdef SP_CODA /* method decls */ - (void)setDatabaseDocument:(SPDatabaseDocument*)doc; - (void)setTableListInstance:(SPTablesList*)list; - (void)setTableDataInstance:(SPTableData*)data; diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m index 994d4944..dd64fa21 100644 --- a/Source/SPTableStructure.m +++ b/Source/SPTableStructure.m @@ -57,7 +57,7 @@ @implementation SPTableStructure -#ifdef SP_REFACTOR +#ifdef SP_CODA @synthesize indexesController; @synthesize indexesTableView; @synthesize addFieldButton; @@ -95,7 +95,7 @@ - (void)awakeFromNib { -#ifndef SP_REFACTOR /* ui manipulation */ +#ifndef SP_CODA /* ui manipulation */ // Set the structure and index view's vertical gridlines if required [tableSourceView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; [indexesTableView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; @@ -104,7 +104,7 @@ // Set the double-click action in blank areas of the table to create new rows [tableSourceView setEmptyDoubleClickAction:@selector(addField:)]; -#ifndef SP_REFACTOR /* set font from prefs */ +#ifndef SP_CODA /* set font from prefs */ // Set the strutcture and index view's font [tableSourceView setFont:([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; [indexesTableView setFont:([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; @@ -183,17 +183,17 @@ name:SPDocumentTaskEndNotification object:tableDocumentInstance]; -#ifndef SP_REFACTOR /* add prefs observer */ +#ifndef SP_CODA /* add prefs observer */ [prefs addObserver:indexesController forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL]; #endif -#ifndef SP_REFACTOR +#ifndef SP_CODA // Init the view column submenu according to saved hidden status; // menu items are identified by their tag number which represents the initial column index for (NSMenuItem *item in [viewColumnsMenu itemArray]) [item setState:NSOnState]; // Set all items to NSOnState #endif -#ifndef SP_REFACTOR /* patch */ +#ifndef SP_CODA /* patch */ for (NSTableColumn *col in [tableSourceView tableColumns]) { if ([col isHidden]) { @@ -244,7 +244,7 @@ NSInteger insertIndex = ([tableSourceView numberOfSelectedRows] == 0 ? [tableSourceView numberOfRows] : [tableSourceView selectedRow] + 1); -#ifndef SP_REFACTOR /* prefs access */ +#ifndef SP_CODA /* prefs access */ [tableFields insertObject:[NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"", @"INT", @"", @"0", @"0", @"0", ([prefs boolForKey:SPNewFieldsAllowNulls]) ? @"1" : @"0", @"", [prefs stringForKey:SPNullValue], @"None", @"", [NSNumber numberWithInt:0], [NSNumber numberWithInt:0], nil] forKeys:[NSArray arrayWithObjects:@"name", @"type", @"length", @"unsigned", @"zerofill", @"binary", @"null", @"Key", @"default", @"Extra", @"comment", @"encoding", @"collation", nil]] @@ -319,26 +319,26 @@ NSString *columnIdentifierName = nil; - switch ([sender tag]) { + switch([sender tag]) { case 7: - columnIdentifierName = @"Key"; + columnIdentifierName = @"Key"; break; case 10: - columnIdentifierName = @"encoding"; + columnIdentifierName = @"encoding"; break; case 11: - columnIdentifierName = @"collation"; + columnIdentifierName = @"collation"; break; case 12: - columnIdentifierName = @"comment"; + columnIdentifierName = @"comment"; break; default: return; } - for (NSTableColumn *col in [tableSourceView tableColumns]) { + for(NSTableColumn *col in [tableSourceView tableColumns]) { - if ([[col identifier] isEqualToString:columnIdentifierName]) { + if([[col identifier] isEqualToString:columnIdentifierName]) { [col setHidden:([sender state] == NSOffState) ? NO : YES]; [(NSMenuItem *)sender setState:![sender state]]; break; @@ -440,7 +440,7 @@ NSArray *buttons = [alert buttons]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Change the alert's cancel button to have the key equivalent of return [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; @@ -458,7 +458,7 @@ */ - (IBAction)resetAutoIncrement:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([sender tag] == 1) { [resetAutoIncrementLine setHidden:YES]; @@ -486,7 +486,7 @@ */ - (void)resetAutoincrementSheetDidEnd:(NSWindow *)theSheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Order out current sheet to suppress overlapping of sheets [theSheet orderOut:nil]; @@ -549,7 +549,7 @@ - (IBAction)unhideIndexesView:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA [tablesIndexesSplitView setPosition:[tablesIndexesSplitView frame].size.height-130 ofDividerAtIndex:0]; #endif } @@ -584,7 +584,7 @@ if (valueAsString == nil || ![valueAsString length]) { // reload data and bail [tableDataInstance resetAllData]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [extendedTableInfoInstance loadTable:selTable]; [tableInfoInstance tableChanged:nil]; #endif @@ -610,12 +610,12 @@ [tableDataInstance resetStatusData]; if([[tableDocumentInstance valueForKeyPath:@"tableTabView"] indexOfTabViewItem:[[tableDocumentInstance valueForKeyPath:@"tableTabView"] selectedTabViewItem]] == 3) { [tableDataInstance resetAllData]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [extendedTableInfoInstance loadTable:selTable]; #endif } -#ifndef SP_REFACTOR +#ifndef SP_CODA [tableInfoInstance tableChanged:nil]; #endif } @@ -682,7 +682,7 @@ isSavingRow = YES; // Save any edits which have been made but not saved to the table yet. -#ifndef SP_REFACTOR /* patch */ +#ifndef SP_CODA /* patch */ [[tableDocumentInstance parentWindow] endEditingFor:nil]; #else [[tableSourceView window] endEditingFor:nil]; @@ -961,7 +961,7 @@ [addFieldButton setEnabled:NO]; [duplicateFieldButton setEnabled:NO]; [removeFieldButton setEnabled:NO]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [addIndexButton setEnabled:NO]; [removeIndexButton setEnabled:NO]; [editTableButton setEnabled:NO]; @@ -989,7 +989,7 @@ } } -#ifdef SP_REFACTOR /* glue */ +#ifdef SP_CODA /* glue */ - (void)setDatabaseDocument:(SPDatabaseDocument*)doc { @@ -1076,7 +1076,7 @@ */ - (void)sheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Order out current sheet to suppress overlapping of sheets if ([sheet respondsToSelector:@selector(orderOut:)]) @@ -1144,7 +1144,7 @@ */ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { -#ifndef SP_REFACTOR /* observe prefs change */ +#ifndef SP_CODA /* observe prefs change */ // Display table veiew vertical gridlines preference changed if ([keyPath isEqualToString:SPDisplayTableViewVerticalGridlines]) { [tableSourceView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; @@ -1304,7 +1304,7 @@ */ - (void)startDocumentTaskForTab:(NSNotification *)aNotification { -#ifndef SP_REFACTOR /* check toolbar mode */ +#ifndef SP_CODA /* check toolbar mode */ // Only proceed if this view is selected. if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableStructure]) return; #endif @@ -1314,12 +1314,12 @@ [removeFieldButton setEnabled:NO]; [duplicateFieldButton setEnabled:NO]; [reloadFieldsButton setEnabled:NO]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [editTableButton setEnabled:NO]; #endif [indexesTableView setEnabled:NO]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [addIndexButton setEnabled:NO]; [removeIndexButton setEnabled:NO]; [refreshIndexesButton setEnabled:NO]; @@ -1331,7 +1331,7 @@ */ - (void)endDocumentTaskForTab:(NSNotification *)aNotification { -#ifndef SP_REFACTOR /* check toolbar mode */ +#ifndef SP_CODA /* check toolbar mode */ // Only re-enable elements if the current tab is the structure view if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableStructure]) return; #endif @@ -1348,14 +1348,14 @@ } [reloadFieldsButton setEnabled:YES]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [editTableButton setEnabled:YES]; #endif [indexesTableView setEnabled:YES]; [indexesTableView displayIfNeeded]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [addIndexButton setEnabled:editingEnabled]; [removeIndexButton setEnabled:(editingEnabled && ([indexesTableView numberOfSelectedRows] > 0))]; [refreshIndexesButton setEnabled:YES]; @@ -1436,7 +1436,7 @@ - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs removeObserver:indexesController forKeyPath:SPUseMonospacedFonts]; #endif diff --git a/Source/SPTableStructureDelegate.m b/Source/SPTableStructureDelegate.m index f6a2b454..cd276f37 100644 --- a/Source/SPTableStructureDelegate.m +++ b/Source/SPTableStructureDelegate.m @@ -135,16 +135,16 @@ NSMutableDictionary *currentRow = [tableFields objectAtIndex:rowIndex]; // Reset collation if encoding was changed - if ([[aTableColumn identifier] isEqualToString:@"encoding"]) { - if ([[currentRow objectForKey:@"encoding"] integerValue] != [anObject integerValue]) { + if([[aTableColumn identifier] isEqualToString:@"encoding"]) { + if([[currentRow objectForKey:@"encoding"] integerValue] != [anObject integerValue]) { [currentRow setObject:[NSNumber numberWithInteger:0] forKey:@"collation"]; [tableSourceView reloadData]; } } // Reset collation if BINARY was set to 1 since BINARY sets collation to *_bin - else if ([[aTableColumn identifier] isEqualToString:@"binary"]) { - if ([[currentRow objectForKey:@"binary"] integerValue] != [anObject integerValue]) { - if ([anObject integerValue] == 1) { + else if([[aTableColumn identifier] isEqualToString:@"binary"]) { + if([[currentRow objectForKey:@"binary"] integerValue] != [anObject integerValue]) { + if([anObject integerValue] == 1) { [currentRow setObject:[NSNumber numberWithInteger:0] forKey:@"collation"]; } @@ -152,17 +152,17 @@ } } // Set null field to "do not allow NULL" for auto_increment Extra and reset Extra suggestion list - else if ([[aTableColumn identifier] isEqualToString:@"Extra"]) { - if (![[currentRow objectForKey:@"Extra"] isEqualToString:anObject]) { + else if([[aTableColumn identifier] isEqualToString:@"Extra"]) { + if(![[currentRow objectForKey:@"Extra"] isEqualToString:anObject]) { isCurrentExtraAutoIncrement = [[[anObject stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString] isEqualToString:@"AUTO_INCREMENT"]; - if (isCurrentExtraAutoIncrement) { + if(isCurrentExtraAutoIncrement) { [currentRow setObject:[NSNumber numberWithInteger:0] forKey:@"null"]; // Asks the user to add an index to query if AUTO_INCREMENT is set and field isn't indexed if ((![currentRow objectForKey:@"Key"] || [[currentRow objectForKey:@"Key"] isEqualToString:@""])) { -#ifndef SP_REFACTOR +#ifndef SP_CODA [chooseKeyButton selectItemWithTag:SPPrimaryKeyMenuTag]; [NSApp beginSheet:keySheet @@ -190,10 +190,10 @@ // Reset default to "" if field doesn't allow NULL and current default is set to NULL else if ([[aTableColumn identifier] isEqualToString:@"null"]) { if ([[currentRow objectForKey:@"null"] integerValue] != [anObject integerValue]) { - if ([anObject integerValue] == 0) { + if([anObject integerValue] == 0) { if ([[currentRow objectForKey:@"default"] isEqualToString:[prefs objectForKey:SPNullValue]]) { [currentRow setObject:@"" forKey:@"default"]; - } + } } [tableSourceView reloadData]; @@ -253,8 +253,8 @@ return YES; } - return NO; -} + return NO; + } /** * Determine whether to allow a drag and drop operation on this table - for the purposes of drag reordering, @@ -470,15 +470,15 @@ column = [tableSourceView editedColumn]; // Trap the tab key, selecting the next item in the line - if ([textView methodForSelector:command] == [textView methodForSelector:@selector(insertTab:)] && [tableSourceView numberOfColumns] - 1 == column) + if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(insertTab:)] && [tableSourceView numberOfColumns] - 1 == column) { //save current line [[control window] makeFirstResponder:control]; - if ([self addRowToDB] && [textView methodForSelector:command] == [textView methodForSelector:@selector(insertTab:)]) { - if (row < ([tableSourceView numberOfRows] - 1)) { - [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:row + 1] byExtendingSelection:NO]; - [tableSourceView editColumn:0 row:row + 1 withEvent:nil select:YES]; + if ( [self addRowToDB] && [textView methodForSelector:command] == [textView methodForSelector:@selector(insertTab:)] ) { + if ( row < ([tableSourceView numberOfRows] - 1) ) { + [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:row+1] byExtendingSelection:NO]; + [tableSourceView editColumn:0 row:row+1 withEvent:nil select:YES]; } else { [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO]; @@ -489,18 +489,18 @@ return YES; } // Trap shift-tab key - else if ([textView methodForSelector:command] == [textView methodForSelector:@selector(insertBacktab:)] && column < 1) + else if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(insertBacktab:)] && column < 1) { - if ([self addRowToDB] && [textView methodForSelector:command] == [textView methodForSelector:@selector(insertBacktab:)]) { + if ( [self addRowToDB] && [textView methodForSelector:command] == [textView methodForSelector:@selector(insertBacktab:)] ) { [[control window] makeFirstResponder:control]; - if (row > 0) { - [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:row - 1] byExtendingSelection:NO]; - [tableSourceView editColumn:([tableFields count] - 1) row:row - 1 withEvent:nil select:YES]; + if ( row > 0) { + [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:row-1] byExtendingSelection:NO]; + [tableSourceView editColumn:([tableFields count]-1) row:row-1 withEvent:nil select:YES]; } else { - [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:([tableFields count] - 1)] byExtendingSelection:NO]; - [tableSourceView editColumn:([tableFields count] - 1) row:([tableSourceView numberOfRows] - 1) withEvent:nil select:YES]; + [tableSourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:([tableFields count]-1)] byExtendingSelection:NO]; + [tableSourceView editColumn:([tableFields count]-1) row:([tableSourceView numberOfRows]-1) withEvent:nil select:YES]; } } @@ -599,7 +599,7 @@ #pragma mark - #pragma mark Split view delegate methods -#ifndef SP_REFACTOR /* Split view delegate methods */ +#ifndef SP_CODA /* Split view delegate methods */ - (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview { @@ -665,4 +665,4 @@ return @""; } -@end +@end
\ No newline at end of file diff --git a/Source/SPTableStructureLoading.m b/Source/SPTableStructureLoading.m index 4d7bb4dd..89a731a8 100644 --- a/Source/SPTableStructureLoading.m +++ b/Source/SPTableStructureLoading.m @@ -290,7 +290,7 @@ target:[tableDocumentInstance databaseStructureRetrieval] selector:@selector(queryDbStructureWithUserInfo:) object:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]]; - + [self loadTable:selectedTable]; } @@ -305,7 +305,7 @@ NSMutableDictionary *newDefaultValues; BOOL enableInteraction = -#ifndef SP_REFACTOR /* patch */ +#ifndef SP_CODA /* patch */ ![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableStructure] || #endif ![tableDocumentInstance isWorking]; @@ -324,7 +324,7 @@ [addFieldButton setEnabled:NO]; [duplicateFieldButton setEnabled:NO]; [removeFieldButton setEnabled:NO]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [addIndexButton setEnabled:NO]; [removeIndexButton setEnabled:NO]; [editTableButton setEnabled:NO]; @@ -358,7 +358,7 @@ defaultValues = [[NSDictionary dictionaryWithDictionary:newDefaultValues] retain]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Enable the edit table button [editTableButton setEnabled:enableInteraction]; #endif @@ -367,7 +367,7 @@ BOOL editingEnabled = ([tablesListInstance tableType] == SPTableTypeTable) && enableInteraction; [addFieldButton setEnabled:editingEnabled]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [addIndexButton setEnabled:editingEnabled]; #endif @@ -376,4 +376,4 @@ [tableSourceView reloadData]; } -@end +@end
\ No newline at end of file diff --git a/Source/SPTableView.m b/Source/SPTableView.m index 61c63c75..a93bc655 100644 --- a/Source/SPTableView.m +++ b/Source/SPTableView.m @@ -54,7 +54,7 @@ @synthesize tabEditingDisabled; -- (id)init +- (id) init { if ((self = [super init])) { emptyDoubleClickAction = NULL; @@ -63,13 +63,13 @@ return self; } -- (void)awakeFromNib +- (void) awakeFromNib { [super setDoubleAction:@selector(_doubleClickAction)]; if ([NSTableView instancesRespondToSelector:@selector(awakeFromNib)]) { [super awakeFromNib]; - } +} } #pragma mark - @@ -98,7 +98,7 @@ */ - (NSMenu *)menuForEvent:(NSEvent *)event { -#ifndef SP_REFACTOR /* menuForEvent: */ +#ifndef SP_CODA /* menuForEvent: */ // Try to retrieve a reference to the table document (assuming this is frontmost tab) SPDatabaseDocument *parentTableDocument = nil; @@ -257,7 +257,7 @@ emptyDoubleClickAction = aSelector; } -#ifdef SP_REFACTOR +#ifdef SP_CODA - (void)delete:(id)sender { diff --git a/Source/SPTablesList.h b/Source/SPTablesList.h index 81ee3bbb..a8ba3b50 100644 --- a/Source/SPTablesList.h +++ b/Source/SPTablesList.h @@ -40,23 +40,23 @@ @class SPTableContent; @class SPSplitView; -#ifdef SP_REFACTOR +#ifdef SP_CODA @class SQLSidebarViewController; #endif @interface SPTablesList : NSObject <NSTextFieldDelegate, NSTableViewDelegate> { - IBOutlet SPDatabaseDocument *tableDocumentInstance; - IBOutlet SPTableStructure *tableSourceInstance; - IBOutlet SPTableContent *tableContentInstance; -#ifndef SP_REFACTOR /* ivars */ + IBOutlet SPDatabaseDocument* tableDocumentInstance; + IBOutlet SPTableStructure* tableSourceInstance; + IBOutlet SPTableContent* tableContentInstance; +#ifndef SP_CODA /* ivars */ IBOutlet id customQueryInstance; IBOutlet id tableDumpInstance; IBOutlet id tableDataInstance; IBOutlet id extendedTableInfoInstance; #endif IBOutlet SPDatabaseData* databaseDataInstance; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ IBOutlet id tableInfoInstance; IBOutlet id tableTriggersInstance; IBOutlet SPHistoryController *spHistoryControllerInstance; @@ -64,7 +64,7 @@ IBOutlet id copyTableSheet; #endif IBOutlet SPTableView *tablesListView; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ IBOutlet id copyTableButton; IBOutlet id copyTableNameField; IBOutlet id copyTableMessageField; @@ -75,15 +75,15 @@ IBOutlet id tableEncodingButton; IBOutlet id tableTypeButton; IBOutlet id toolbarAddButton; -#ifdef SP_REFACTOR +#ifdef SP_CODA id toolbarDeleteButton; #endif -#ifndef SP_REFACTOR +#ifndef SP_CODA IBOutlet id toolbarActionsButton; #endif IBOutlet id toolbarReloadButton; IBOutlet id addTableButton; -#ifndef SP_REFACTOR +#ifndef SP_CODA IBOutlet id truncateTableButton; IBOutlet SPSplitView *tableListSplitView; IBOutlet SPSplitView *tableListFilterSplitView; @@ -104,7 +104,7 @@ SPMySQLConnection *mySQLConnection; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ // Table list context menu items IBOutlet NSMenuItem *removeTableContextMenuItem; IBOutlet NSMenuItem *duplicateTableContextMenuItem; @@ -129,11 +129,11 @@ BOOL tableListContainsViews; BOOL alertSheetOpened; -#ifndef SP_REFACTOR /* ivars */ +#ifndef SP_CODA /* ivars */ NSFont *smallSystemFont; #endif -#ifdef SP_REFACTOR +#ifdef SP_CODA SQLSidebarViewController* sidebarViewController; #endif } @@ -144,7 +144,7 @@ - (IBAction)closeSheet:(id)sender; - (IBAction)removeTable:(id)sender; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ - (IBAction)copyTable:(id)sender; - (IBAction)renameTable:(id)sender; - (IBAction)truncateTable:(id)sender; @@ -156,7 +156,7 @@ - (void)setConnection:(SPMySQLConnection *)theConnection; - (void)setSelectionState:(NSDictionary *)selectionDetails; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ - (void)selectTableAtIndex:(NSNumber *)row; - (void)makeTableListFilterHaveFocus; - (void)makeTableListHaveFocus; @@ -181,13 +181,13 @@ // Setters - (BOOL)selectItemWithName:(NSString *)theName; -#ifndef SP_REFACTOR /* method decls */ +#ifndef SP_CODA /* method decls */ - (BOOL)selectItemsWithNames:(NSArray *)theNames; // Table list filter interaction -- (void)showFilter; -- (void)hideFilter; -- (void)clearFilter; +- (void) showFilter; +- (void) hideFilter; +- (void) clearFilter; #endif - (IBAction) updateFilter:(id)sender; @@ -198,7 +198,7 @@ - (BOOL)isTableNameValid:(NSString *)tableName forType:(SPTableType)tableType; - (BOOL)isTableNameValid:(NSString *)tableName forType:(SPTableType)tableType ignoringSelectedTable:(BOOL)ignoreSelectedTable; -#ifdef SP_REFACTOR /* method decls */ +#ifdef SP_CODA /* method decls */ @property (assign) SPTableStructure* tableSourceInstance; @property (assign) SPTableContent* tableContentInstance; @property (assign) id toolbarAddButton; diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index 3fd71139..e3a28fce 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -36,11 +36,11 @@ #import "SPTableStructure.h" #import "SPDatabaseViewController.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPTableContent.h" #endif #import "SPTableData.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPTableInfo.h" #import "SPDataImport.h" #import "SPTableView.h" @@ -49,19 +49,19 @@ #endif #import "SPDatabaseData.h" #import "SPAlertSheets.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPNavigatorController.h" #import "SPHistoryController.h" #endif #import "SPServerSupport.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPWindowController.h" #import "SPAppController.h" #import "SPSplitView.h" #endif #import "SPThreadAdditions.h" -#ifdef SP_REFACTOR +#ifdef SP_CODA #import "SQLSidebarViewController.h" #endif @@ -71,19 +71,19 @@ static NSString *SPAddRow = @"SPAddRow"; static NSString *SPAddNewTable = @"SPAddNewTable"; static NSString *SPRemoveTable = @"SPRemoveTable"; -#ifndef SP_REFACTOR +#ifndef SP_CODA static NSString *SPTruncateTable = @"SPTruncateTable"; static NSString *SPDuplicateTable = @"SPDuplicateTable"; #endif @interface SPTablesList () -#ifndef SP_REFACTOR +#ifndef SP_CODA - (void)_removeTable; - (void)_truncateTable; #endif - (void)_addTable; -#ifndef SP_REFACTOR +#ifndef SP_CODA - (void)_copyTable; #endif - (void)_renameTableOfType:(SPTableType)tableType from:(NSString *)oldTableName to:(NSString *)newTableName; @@ -92,7 +92,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; @implementation SPTablesList -#ifdef SP_REFACTOR +#ifdef SP_CODA @synthesize sidebarViewController; @synthesize databaseDataInstance; @synthesize toolbarAddButton; @@ -123,7 +123,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; tableListContainsViews = NO; selectedTableType = SPTableTypeNone; selectedTableName = nil; -#ifndef SP_REFACTOR +#ifndef SP_CODA [tables addObject:NSLocalizedString(@"TABLES", @"header for table list")]; smallSystemFont = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; @@ -135,7 +135,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; - (void)awakeFromNib { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Configure the table information pane [tableListSplitView setCollapsibleSubviewIndex:1]; @@ -144,7 +144,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; if ([[[NSUserDefaults standardUserDefaults] objectForKey:SPTableInformationPanelCollapsed] boolValue]) { [tableListSplitView setCollapsibleSubviewCollapsed:YES animate:NO]; } - + // Configure the table list filter, starting it collapsed [tableListFilterSplitView setCollapsibleSubviewIndex:0]; [tableListFilterSplitView setCollapsibleSubviewCollapsed:YES animate:NO]; @@ -163,7 +163,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; name:SPDocumentTaskEndNotification object:tableDocumentInstance]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [tablesListView registerForDraggedTypes:[NSArray arrayWithObjects:SPNavigatorTableDataPasteboardDragType, nil]]; #endif } @@ -183,7 +183,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; BOOL changeEncoding = ![[mySQLConnection encoding] isEqualToString:@"utf8"]; if (selectedTableName) previousSelectedTable = [[NSString alloc] initWithString:selectedTableName]; -#ifndef SP_REFACTOR /* table list filtering */ +#ifndef SP_CODA /* table list filtering */ if (isTableListFiltered) { previousFilterString = [[NSString alloc] initWithString:[listFilterField stringValue]]; if (filteredTables) [filteredTables release]; @@ -196,7 +196,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; tableListContainsViews = NO; #endif tableListIsSelectable = YES; -#ifndef SP_REFACTOR +#ifndef SP_CODA [[tablesListView onMainThread] deselectAll:self]; tableListIsSelectable = previousTableListIsSelectable; #endif @@ -246,7 +246,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; // Reorder the tables in alphabetical order [tables sortArrayUsingSelector:@selector(localizedCompare:) withPairedMutableArrays:tableTypes, nil]; -#ifndef SP_REFACTOR /* table procedures and functions */ +#ifndef SP_CODA /* table procedures and functions */ /* Grab the procedures and functions * * Using information_schema gives us more info (for information window perhaps?) but breaks @@ -265,18 +265,18 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [tables addObject:NSLocalizedString(@"PROCS & FUNCS",@"header for procs & funcs list")]; [tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeNone]]; - for (NSArray *eachRow in theResult) { - [tables addObject:NSArrayObjectAtIndex(eachRow, 3)]; - if ([NSArrayObjectAtIndex(eachRow, 4) isEqualToString:@"PROCEDURE"]) { - [tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeProc]]; - } else { - [tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeFunc]]; + for (NSArray *eachRow in theResult) { + [tables addObject:NSArrayObjectAtIndex(eachRow, 3)]; + if ([NSArrayObjectAtIndex(eachRow, 4) isEqualToString:@"PROCEDURE"]) { + [tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeProc]]; + } else { + [tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeFunc]]; + } } } } - } #endif - + // Restore encoding if appropriate if (changeEncoding) [mySQLConnection restoreStoredEncoding]; @@ -284,7 +284,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA // Add the table headers even if no tables were found if (tableListContainsViews) { [tables insertObject:NSLocalizedString(@"TABLES & VIEWS",@"header for table & views list") atIndex:0]; @@ -296,7 +296,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [tableTypes insertObject:[NSNumber numberWithInteger:SPTableTypeNone] atIndex:0]; #endif -#ifndef SP_REFACTOR /* ui manipulation */ +#ifndef SP_CODA /* ui manipulation */ [[tablesListView onMainThread] reloadData]; #else [sidebarViewController setTableNames:[self allTableNames] selectedTableName:selectedTableName]; @@ -311,7 +311,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; if ( ![sender isKindOfClass:[SPTableData class]] && previousSelectedTable != nil && [tables indexOfObject:previousSelectedTable] < [tables count]) { NSInteger itemToReselect = [tables indexOfObject:previousSelectedTable]; tableListIsSelectable = YES; -#ifndef SP_REFACTOR /* ui manipulation */ +#ifndef SP_CODA /* ui manipulation */ [[tablesListView onMainThread] selectRowIndexes:[NSIndexSet indexSetWithIndex:itemToReselect] byExtendingSelection:NO]; #endif tableListIsSelectable = previousTableListIsSelectable; @@ -325,7 +325,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; selectedTableType = SPTableTypeNone; } -#ifndef SP_REFACTOR /* table list filtering */ +#ifndef SP_CODA /* table list filtering */ // Determine whether or not to preserve the existing filter, and whether to // show or hide the list filter based on the number of tables if ([tables count] > 20) { @@ -450,7 +450,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; NSArray *buttons = [alert buttons]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Change the alert's cancel button to have the key equivalent of return [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; @@ -518,7 +518,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [alert beginSheetModalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:SPRemoveTable]; } -#ifndef SP_REFACTOR /* whole table operations */ +#ifndef SP_CODA /* whole table operations */ /** * Copies a table/view/proc/func, if desired with content */ @@ -682,7 +682,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [self performSelector:@selector(_removeTable) withObject:nil afterDelay:0.0]; } } -#ifndef SP_REFACTOR +#ifndef SP_CODA else if ([contextInfo isEqualToString:SPTruncateTable]) { if (returnCode == NSAlertDefaultReturn) { [self _truncateTable]; @@ -695,7 +695,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [self _addTable]; } } -#ifndef SP_REFACTOR +#ifndef SP_CODA else if ([contextInfo isEqualToString:SPDuplicateTable]) { if (returnCode == NSOKButton) { [self _copyTable]; @@ -727,7 +727,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; if (object == tableNameField) { [addTableButton setEnabled:[self isTableNameValid:[tableNameField stringValue] forType: SPTableTypeTable]]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA else if (object == copyTableNameField) { [copyTableButton setEnabled:[self isTableNameValid:[copyTableNameField stringValue] forType:[self tableType]]]; @@ -750,7 +750,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; if (object == tableNameField) { [addTableButton performClick:object]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA else if (object == copyTableNameField) { [copyTableButton performClick:object]; } @@ -770,14 +770,14 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; { // First handle empty or multiple selections if (!selectionDetails || ![selectionDetails objectForKey:@"name"]) { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSIndexSet *indexes = [tablesListView selectedRowIndexes]; #endif // Update the selected table name and type if (selectedTableName) [selectedTableName release]; selectedTableName = nil; -#ifndef SP_REFACTOR /* ui manipulation */ +#ifndef SP_CODA /* ui manipulation */ // Set gear menu items Remove/Duplicate table/view according to the table types // if at least one item is selected @@ -801,31 +801,31 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; switch (lastType) { case SPTableTypeTable: - [removeTableMenuItem setTitle:NSLocalizedString(@"Delete Tables", @"delete tables menu title")]; - [truncateTableButton setTitle:NSLocalizedString(@"Truncate Tables", @"truncate tables menu item")]; - [removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Tables", @"delete tables menu title")]; - [truncateTableContextMenuItem setTitle:NSLocalizedString(@"Truncate Tables", @"truncate tables menu item")]; - [truncateTableButton setHidden:NO]; - [truncateTableContextMenuItem setHidden:NO]; - break; + [removeTableMenuItem setTitle:NSLocalizedString(@"Delete Tables", @"delete tables menu title")]; + [truncateTableButton setTitle:NSLocalizedString(@"Truncate Tables", @"truncate tables menu item")]; + [removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Tables", @"delete tables menu title")]; + [truncateTableContextMenuItem setTitle:NSLocalizedString(@"Truncate Tables", @"truncate tables menu item")]; + [truncateTableButton setHidden:NO]; + [truncateTableContextMenuItem setHidden:NO]; + break; case SPTableTypeView: - [removeTableMenuItem setTitle:NSLocalizedString(@"Delete Views", @"delete views menu title")]; - [removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Views", @"delete views menu title")]; - [truncateTableButton setHidden:YES]; - [truncateTableContextMenuItem setHidden:YES]; - break; + [removeTableMenuItem setTitle:NSLocalizedString(@"Delete Views", @"delete views menu title")]; + [removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Views", @"delete views menu title")]; + [truncateTableButton setHidden:YES]; + [truncateTableContextMenuItem setHidden:YES]; + break; case SPTableTypeProc: - [removeTableMenuItem setTitle:NSLocalizedString(@"Delete Procedures", @"delete procedures menu title")]; - [removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Procedures", @"delete procedures menu title")]; - [truncateTableButton setHidden:YES]; - [truncateTableContextMenuItem setHidden:YES]; - break; + [removeTableMenuItem setTitle:NSLocalizedString(@"Delete Procedures", @"delete procedures menu title")]; + [removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Procedures", @"delete procedures menu title")]; + [truncateTableButton setHidden:YES]; + [truncateTableContextMenuItem setHidden:YES]; + break; case SPTableTypeFunc: - [removeTableMenuItem setTitle:NSLocalizedString(@"Delete Functions", @"delete functions menu title")]; - [removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Functions", @"delete functions menu title")]; - [truncateTableButton setHidden:YES]; - [truncateTableContextMenuItem setHidden:YES]; - break; + [removeTableMenuItem setTitle:NSLocalizedString(@"Delete Functions", @"delete functions menu title")]; + [removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Functions", @"delete functions menu title")]; + [truncateTableButton setHidden:YES]; + [truncateTableContextMenuItem setHidden:YES]; + break; } } else { @@ -863,7 +863,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; // Get main menu "Table"'s submenu NSMenu *tableSubMenu = [[[NSApp mainMenu] itemWithTag:SPMainMenuTable] submenu]; - + [[tableSubMenu itemAtIndex:4] setTitle:NSLocalizedString(@"Copy Create Syntaxes", @"copy create syntaxes menu item")]; [[tableSubMenu itemAtIndex:5] setTitle:NSLocalizedString(@"Show Create Syntaxes...", @"show create syntaxes menu item")]; @@ -898,7 +898,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; selectedTableName = [[NSString alloc] initWithString:selectedItemName]; selectedTableType = selectedItemType; -#ifndef SP_REFACTOR /* ui manipulation */ +#ifndef SP_CODA /* ui manipulation */ // Remove the "current selection" item for filtered lists if appropriate if (isTableListFiltered && [tablesListView selectedRow] < (NSInteger)[filteredTables count] - 2 && [filteredTables count] > 2 && [[filteredTableTypes objectAtIndex:[filteredTableTypes count]-2] integerValue] == SPTableTypeNone @@ -1153,7 +1153,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; /** * Returns the currently selected table type, or -1 if no table or multiple tables are selected */ -- (SPTableType)tableType +- (SPTableType) tableType { return selectedTableType; } @@ -1290,7 +1290,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; // If no match found, return failure if (itemIndex == NSNotFound) return NO; -#ifndef SP_REFACTOR /* table list filtering */ +#ifndef SP_CODA /* table list filtering */ if (!isTableListFiltered) { [tablesListView selectRowIndexes:[NSIndexSet indexSetWithIndex:itemIndex] byExtendingSelection:NO]; } else { @@ -1308,7 +1308,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [self updateFilter:self]; [tableDocumentInstance loadTable:selectedTableName ofType:selectedTableType]; -#ifndef SP_REFACTOR /* table list filtering */ +#ifndef SP_CODA /* table list filtering */ } } @@ -1318,7 +1318,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; return YES; } -#ifndef SP_REFACTOR /* tableView datasource/delegate */ +#ifndef SP_CODA /* tableView datasource/delegate */ /** * Try to select items using the provided names in theNames; returns YES if at least @@ -1425,7 +1425,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; return isValid; } -#ifndef SP_REFACTOR +#ifndef SP_CODA #pragma mark - #pragma mark Datasource methods @@ -1512,7 +1512,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; SPBeginAlertSheet( NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil, [myException reason]); } -#ifndef SP_REFACTOR +#ifndef SP_CODA // Set window title to reflect the new table name [tableDocumentInstance updateWindowTitle:self]; #endif @@ -1521,7 +1521,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [NSThread detachNewThreadWithName:@"SPNavigatorController database structure querier" target:[tableDocumentInstance databaseStructureRetrieval] selector:@selector(queryDbStructureWithUserInfo:) object:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA #pragma mark - #pragma mark TableView delegate methods @@ -1569,7 +1569,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; return [tableDocumentInstance couldCommitCurrentViewActions]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Loads a table in content or source view (if tab selected) */ @@ -1615,7 +1615,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; selectedTableType = newType; [tableDocumentInstance loadTable:selectedTableName ofType:selectedTableType]; - if ([[SPNavigatorController sharedNavigatorController] syncMode]) { + if([[SPNavigatorController sharedNavigatorController] syncMode]) { NSMutableString *schemaPath = [NSMutableString string]; [schemaPath setString:[tableDocumentInstance connectionID]]; @@ -1774,7 +1774,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; { return selectedRows == 1 && [[self tableName] length]; } - + if (action == @selector(removeTable:) || action == @selector(truncateTable:)) { @@ -1851,7 +1851,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; if (selectedTableName) [selectedTableName release], selectedTableName = nil; } -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([[listFilterField stringValue] length]) { if (isTableListFiltered) { [filteredTables release]; @@ -1874,7 +1874,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; if (substringRange.location == NSNotFound) continue; } -#ifndef SP_REFACTOR +#ifndef SP_CODA // Add a title if necessary if ((tableType == SPTableTypeTable || tableType == SPTableTypeView) && lastTableType == NSNotFound) { @@ -1919,13 +1919,13 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [filteredTables release]; #endif filteredTables = tables; -#ifndef SP_REFACTOR +#ifndef SP_CODA [filteredTableTypes release]; filteredTableTypes = tableTypes; } #endif -#ifndef SP_REFACTOR +#ifndef SP_CODA // Reselect correct row and reload the table view display if ([tablesListView numberOfRows] < (NSInteger)[filteredTables count]) [tablesListView noteNumberOfRowsChanged]; if (selectedTableName) [tablesListView selectRowIndexes:[NSIndexSet indexSetWithIndex:[filteredTables indexOfObject:selectedTableName]] byExtendingSelection:NO]; @@ -1940,7 +1940,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; - (void) selectTableAtIndex:(NSNumber *)row { NSUInteger rowIndex = [row unsignedIntegerValue]; -#ifndef SP_REFACTOR +#ifndef SP_CODA if (rowIndex == NSNotFound || rowIndex > [filteredTables count] || [[filteredTableTypes objectAtIndex:rowIndex] integerValue] == SPTableTypeNone) return; #else @@ -1957,11 +1957,11 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; /** * Disable all table list interactive elements during an ongoing task. */ -- (void)startDocumentTaskForTab:(NSNotification *)aNotification +- (void) startDocumentTaskForTab:(NSNotification *)aNotification { tableListIsSelectable = NO; [toolbarAddButton setEnabled:NO]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [toolbarActionsButton setEnabled:NO]; #endif [toolbarReloadButton setEnabled:NO]; @@ -1970,11 +1970,11 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; /** * Enable all table list interactive elements after an ongoing task. */ -- (void)endDocumentTaskForTab:(NSNotification *)aNotification +- (void) endDocumentTaskForTab:(NSNotification *)aNotification { tableListIsSelectable = YES; [toolbarAddButton setEnabled:YES]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [toolbarActionsButton setEnabled:YES]; #endif [toolbarReloadButton setEnabled:YES]; @@ -1983,12 +1983,12 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; /** * Set the table list to selectable or not during the task process. */ -- (void)setTableListSelectability:(BOOL)isSelectable +- (void) setTableListSelectability:(BOOL)isSelectable { tableListIsSelectable = isSelectable; } -#ifndef SP_REFACTOR +#ifndef SP_CODA #pragma mark - #pragma mark SplitView Delegate Methods @@ -2030,11 +2030,11 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; #pragma mark - #pragma mark Other -#ifdef SP_REFACTOR /* glue */ +#ifdef SP_CODA /* glue */ - (void)setDatabaseDocument:(SPDatabaseDocument*)val { tableDocumentInstance = val; -} + } #endif #pragma mark - @@ -2125,11 +2125,11 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [tablesListView deselectAll:self]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // set window title [tableDocumentInstance updateWindowTitle:self]; #endif -#ifdef SP_REFACTOR +#ifdef SP_CODA [sidebarViewController setTableNames:filteredTables selectedTableName:nil]; #endif @@ -2137,7 +2137,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [NSThread detachNewThreadWithName:@"SPNavigatorController database structure querier" target:[tableDocumentInstance databaseStructureRetrieval] selector:@selector(queryDbStructureWithUserInfo:) object:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]]; } -#ifndef SP_REFACTOR /* operations performed on whole tables */ +#ifndef SP_CODA /* operations performed on whole tables */ /** * Trucates the selected table(s). @@ -2271,11 +2271,11 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; // Select the newly created table and switch to the table structure view for easier setup [tableDocumentInstance loadTable:selectedTableName ofType:selectedTableType]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [tableDocumentInstance viewStructure:self]; #endif -#ifdef SP_REFACTOR +#ifdef SP_CODA [sidebarViewController setTableNames:[self allTableNames] selectedTableName:selectedTableName]; #endif @@ -2293,7 +2293,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, @selector(sheetDidEnd:returnCode:contextInfo:), SPAddRow, [NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to add the new table '%@'.\n\nMySQL said: %@", @"error adding new table informative message"), tableName, [mySQLConnection lastErrorMessage]]); - + if (changeEncoding) [mySQLConnection restoreStoredEncoding]; [[tablesListView onMainThread] reloadData]; @@ -2301,12 +2301,12 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; // Clear table name [[tableNameField onMainThread] setStringValue:@""]; - + [tableDocumentInstance endTask]; [tableAdditionPool release]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Copies the currently selected object (table, view, procedure, function, etc.). */ @@ -2393,9 +2393,9 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; // get the create syntax SPMySQLResult *theResult; - if (selectedTableType == SPTableTypeProc) + if(selectedTableType == SPTableTypeProc) theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SHOW CREATE PROCEDURE %@", [selectedTableName backtickQuotedString]]]; - else if ([self tableType] == SPTableTypeFunc) + else if([self tableType] == SPTableTypeFunc) theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SHOW CREATE FUNCTION %@", [selectedTableName backtickQuotedString]]]; else return; @@ -2593,7 +2593,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [tables release]; [tableTypes release]; -#ifndef SP_REFACTOR +#ifndef SP_CODA if (isTableListFiltered && filteredTables) [filteredTables release]; if (isTableListFiltered && filteredTableTypes) [filteredTableTypes release]; #endif diff --git a/Source/SPTextView.h b/Source/SPTextView.h index d596395d..0e61e09d 100644 --- a/Source/SPTextView.h +++ b/Source/SPTextView.h @@ -51,7 +51,7 @@ BOOL autoindentIgnoresEnter; BOOL autouppercaseKeywordsEnabled; BOOL delBackwardsWasPressed; -#ifndef SP_REFACTOR +#ifndef SP_CODA BOOL autohelpEnabled; #endif NoodleLineNumberView *lineNumberView; @@ -59,14 +59,14 @@ BOOL startListeningToBoundChanges; BOOL textBufferSizeIncreased; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSString *showMySQLHelpFor; #endif IBOutlet NSScrollView *scrollView; SPNarrowDownCompletion *completionPopup; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSUserDefaults *prefs; #endif @@ -116,14 +116,14 @@ @property(assign) BOOL completionIsOpen; @property(assign) BOOL completionWasReinvokedAutomatically; -#ifdef SP_REFACTOR +#ifdef SP_CODA @property (assign) SPDatabaseDocument *tableDocumentInstance; @property (assign) SPTablesList *tablesListInstance; @property (assign) SPCustomQuery *customQueryInstance; @property (assign) SPMySQLConnection *mySQLConnection; #endif -#ifndef SP_REFACTOR +#ifndef SP_CODA - (IBAction)showMySQLHelpForCurrentWord:(id)sender; #endif @@ -142,14 +142,14 @@ - (BOOL) autopair; - (void) setAutouppercaseKeywords:(BOOL)enableAutouppercaseKeywords; - (BOOL) autouppercaseKeywords; -#ifndef SP_REFACTOR +#ifndef SP_CODA - (void) setAutohelp:(BOOL)enableAutohelp; - (BOOL) autohelp; #endif - (void) setTabStops; - (void) selectLineNumber:(NSUInteger)lineNumber ignoreLeadingNewLines:(BOOL)ignLeadingNewLines; - (NSUInteger) getLineNumberForCharacterIndex:(NSUInteger)anIndex; -#ifndef SP_REFACTOR +#ifndef SP_CODA - (void) autoHelp; #endif - (void) doSyntaxHighlighting; diff --git a/Source/SPTextView.m b/Source/SPTextView.m index f659a3cd..76a80774 100644 --- a/Source/SPTextView.m +++ b/Source/SPTextView.m @@ -41,11 +41,11 @@ #import "SPNavigatorController.h" #import "SPAlertSheets.h" #import "RegexKitLite.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPBundleHTMLOutputController.h" #endif #import "SPDatabaseViewController.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPAppController.h" #endif #import "SPDatabaseStructure.h" @@ -86,7 +86,7 @@ @interface SPTextView (Private_API) NSInteger _alphabeticSort(id string1, id string2, void *reverse); -#ifndef SP_REFACTOR +#ifndef SP_CODA - (void)_setTextSelectionColor:(NSColor *)newSelectionColor onBackgroundColor:(NSColor *)aBackgroundColor; #endif - (void)_positionCompletionPopup:(SPNarrowDownCompletion *)aPopup relativeToTextAtLocation:(NSUInteger)aLocation; @@ -118,7 +118,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS @synthesize completionIsOpen; @synthesize completionWasReinvokedAutomatically; -#ifdef SP_REFACTOR +#ifdef SP_CODA @synthesize tableDocumentInstance; @synthesize tablesListInstance; @synthesize customQueryInstance; @@ -127,7 +127,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS - (void) awakeFromNib { -#ifndef SP_REFACTOR /* init ivars */ +#ifndef SP_CODA /* init ivars */ prefs = [[NSUserDefaults standardUserDefaults] retain]; [self setFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorFont]]]; #endif @@ -140,7 +140,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS autopairEnabled = YES; autoindentIgnoresEnter = NO; autouppercaseKeywordsEnabled = NO; -#ifndef SP_REFACTOR +#ifndef SP_CODA autohelpEnabled = NO; #endif delBackwardsWasPressed = NO; @@ -160,18 +160,18 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS [scrollView setRulersVisible:YES]; [self setAllowsDocumentBackgroundColorChange:YES]; [self setContinuousSpellCheckingEnabled:NO]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [self setAutoindent:[prefs boolForKey:SPCustomQueryAutoIndent]]; #else [self setAutoindent:YES]; #endif [self setAutoindentIgnoresEnter:YES]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [self setAutopair:[prefs boolForKey:SPCustomQueryAutoPairCharacters]]; [self setAutohelp:[prefs boolForKey:SPCustomQueryUpdateAutoHelp]]; [self setAutouppercaseKeywords:[prefs boolForKey:SPCustomQueryAutoUppercaseKeywords]]; #else - [self setAutopair:YES]; + [self setAutopair:YES]; //[self setAutouppercaseKeywords:YES]; // #18925 #endif [self setCompletionWasReinvokedAutomatically:NO]; @@ -186,7 +186,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS [scrollView setPostsBoundsChangedNotifications:YES]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(boundsDidChangeNotification:) name:NSViewBoundsDidChangeNotification object:[scrollView contentView]]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [self setQueryHiliteColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorHighlightQueryColor]]]; NSColor *backgroundColor = [NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorBackgroundColor]]; [self setQueryEditorBackgroundColor:backgroundColor]; @@ -249,7 +249,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS */ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([keyPath isEqualToString:SPCustomQueryEditorBackgroundColor]) { NSColor *backgroundColor = [NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]; [self setQueryEditorBackgroundColor:backgroundColor]; @@ -320,7 +320,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS { NSMutableArray *possibleCompletions = [[NSMutableArray alloc] initWithCapacity:32]; -#ifndef SP_REFACTOR +#ifndef SP_CODA if(currentWord == nil) currentWord = [NSString stringWithString:@""]; #else if(currentWord == nil) currentWord = @""; @@ -591,7 +591,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS if(completionIsOpen || !self || ![self delegate]) return; // Cancel autocompletion trigger -#ifndef SP_REFACTOR +#ifndef SP_CODA if([prefs boolForKey:SPCustomQueryAutoComplete]) #endif [NSObject cancelPreviousPerformRequestsWithTarget:self @@ -635,7 +635,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS { // Cancel autocompletion trigger -#ifndef SP_REFACTOR +#ifndef SP_CODA if([prefs boolForKey:SPCustomQueryAutoComplete]) #endif [NSObject cancelPreviousPerformRequestsWithTarget:self @@ -830,7 +830,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS } // Cancel autocompletion trigger again if user typed something in while parsing -#ifndef SP_REFACTOR +#ifndef SP_CODA if([prefs boolForKey:SPCustomQueryAutoComplete]) #endif [NSObject cancelPreviousPerformRequestsWithTarget:self @@ -1075,7 +1075,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.01]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Search for the current selection or current word in the MySQL Help */ @@ -1108,7 +1108,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS [self setSelectedRange:innerSelectionRange]; // If autopair is enabled mark last autopair character as autopair-linked -#ifndef SP_REFACTOR +#ifndef SP_CODA if([prefs boolForKey:SPCustomQueryAutoPairCharacters]) #endif [[self textStorage] addAttribute:kAPlinked value:kAPval range:NSMakeRange(NSMaxRange(innerSelectionRange), 1)]; @@ -1192,7 +1192,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS if (selectedRange.location == NSNotFound || ![self isEditable]) return NO; NSString *indentString = @"\t"; -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([prefs boolForKey:SPCustomQuerySoftIndent]) { NSUInteger numberOfSpaces = [prefs integerForKey:SPCustomQuerySoftIndentWidth]; if(numberOfSpaces < 1) numberOfSpaces = 1; @@ -1283,7 +1283,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS // Check for soft indention NSUInteger indentStringLength = 1; -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([prefs boolForKey:SPCustomQuerySoftIndent]) { NSUInteger numberOfSpaces = [prefs integerForKey:SPCustomQuerySoftIndentWidth]; if(numberOfSpaces < 1) numberOfSpaces = 1; @@ -1298,7 +1298,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS } else { #endif replaceRange = NSMakeRange(currentLineRange.location, indentStringLength); -#ifndef SP_REFACTOR +#ifndef SP_CODA } #endif @@ -1323,7 +1323,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS // Check for soft or hard indention NSString *indentString = @"\t"; NSUInteger indentStringLength = 1; -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([prefs boolForKey:SPCustomQuerySoftIndent]) { indentStringLength = [prefs integerForKey:SPCustomQuerySoftIndentWidth]; if(indentStringLength < 1) indentStringLength = 1; @@ -1388,7 +1388,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS { // Cancel auto-completion timer -#ifndef SP_REFACTOR +#ifndef SP_CODA if([prefs boolForKey:SPCustomQueryAutoComplete]) #endif [NSObject cancelPreviousPerformRequestsWithTarget:self @@ -1789,7 +1789,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS if (tablesListInstance && [tablesListInstance selectedDatabase]) currentDb = [tablesListInstance selectedDatabase]; -#ifndef SP_REFACTOR +#ifndef SP_CODA while([theHintString isMatchedByRegex:@"(?<!\\\\)\\$SP_SELECTED_TABLES"]) { r = [theHintString rangeOfRegex:@"(?<!\\\\)\\$SP_SELECTED_TABLES"]; if(r.length) { @@ -1830,7 +1830,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS [theHintString replaceOccurrencesOfRegex:@"\\\\(\\$\\(|\\}|\\$SP_)" withString:@"$1"]; [theHintString flushCachedRegexData]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // If inside the snippet hint $(…) is defined run … as BASH command // and replace $(…) by the return string of that command. Please note // only one $(…) statement is allowed within one ${…} snippet environment. @@ -1960,7 +1960,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS // If autopair is enabled check whether snip begins with ( and ends with ), if so mark ) as pair-linked if ( -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs boolForKey:SPCustomQueryAutoPairCharacters] && #else #endif @@ -2083,7 +2083,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS { // Cancel autoHelp timer -#ifndef SP_REFACTOR +#ifndef SP_CODA if([prefs boolForKey:SPCustomQueryUpdateAutoHelp]) [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(autoHelp) @@ -2091,7 +2091,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS #endif // Cancel auto-completion timer -#ifndef SP_REFACTOR +#ifndef SP_CODA if([prefs boolForKey:SPCustomQueryAutoComplete]) #endif [NSObject cancelPreviousPerformRequestsWithTarget:self @@ -2100,7 +2100,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS [super mouseDown:theEvent]; -#ifndef SP_REFACTOR +#ifndef SP_CODA // Start autoHelp timer if([prefs boolForKey:SPCustomQueryUpdateAutoHelp]) [self performSelector:@selector(autoHelp) withObject:nil afterDelay:[[prefs valueForKey:SPCustomQueryAutoHelpDelay] doubleValue]]; @@ -2112,7 +2112,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS */ - (void) keyDown:(NSEvent *)theEvent { -#ifndef SP_REFACTOR +#ifndef SP_CODA if([prefs boolForKey:SPCustomQueryUpdateAutoHelp]) {// restart autoHelp timer [NSObject cancelPreviousPerformRequestsWithTarget:self @@ -2124,7 +2124,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS #endif // Cancel auto-completion timer -#ifndef SP_REFACTOR +#ifndef SP_CODA if([prefs boolForKey:SPCustomQueryAutoComplete]) #endif [NSObject cancelPreviousPerformRequestsWithTarget:self @@ -2154,7 +2154,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS [self setCompletionWasReinvokedAutomatically:NO]; completionWasRefreshed = NO; // Cancel autocompletion trigger -#ifndef SP_REFACTOR +#ifndef SP_CODA if([prefs boolForKey:SPCustomQueryAutoComplete]) #endif [NSObject cancelPreviousPerformRequestsWithTarget:self @@ -2176,7 +2176,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS // Check for {SHIFT}TAB to try to insert query favorite via TAB trigger if SPTextView belongs to SPCustomQuery // and TAB as soft indention if ([theEvent keyCode] == 48 && [self isEditable] && [[self delegate] isKindOfClass:[SPCustomQuery class]]){ -#ifndef SP_REFACTOR +#ifndef SP_CODA NSRange targetRange = [self getRangeForCurrentWord]; NSString *tabTrigger = [[self string] substringWithRange:targetRange]; #endif @@ -2222,7 +2222,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS } -#ifndef SP_REFACTOR +#ifndef SP_CODA // Check if tab trigger is defined; if so insert it, otherwise pass through event if(snippetControlCounter < 0 && [tabTrigger length] && [tableDocumentInstance fileURL]) { NSArray *snippets = [[SPQueryController sharedQueryController] queryFavoritesForFileURL:[tableDocumentInstance fileURL] andTabTrigger:tabTrigger includeGlobals:YES]; @@ -2240,7 +2240,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS #endif } -#ifndef SP_REFACTOR +#ifndef SP_CODA // Note: switch(insertedCharacter) {} does not work instead use charactersIgnoringModifiers if([charactersIgnMod isEqualToString:@"h"]) // ^H show MySQL Help if(curFlags==(NSControlKeyMask)) @@ -2269,7 +2269,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS if([charactersIgnMod isEqualToString:@"0"]) { // reset font to default BOOL editableStatus = [self isEditable]; [self setEditable:YES]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [self setFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorFont]]]; #endif [self setEditable:editableStatus]; @@ -2278,7 +2278,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS } // Only process for character autopairing if autopairing is enabled and a single character is being added. -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([prefs boolForKey:SPCustomQueryAutoPairCharacters] && characters && [characters length] == 1) { #else if (characters && [characters length] == 1) { @@ -2417,7 +2417,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS } // Let Xcode 3 match braces correctly... -#ifndef SP_REFACTOR +#ifndef SP_CODA } #else } @@ -2493,7 +2493,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS } // Remove soft indent if active and left from caret are only white spaces -#ifndef SP_REFACTOR +#ifndef SP_CODA else if ([prefs boolForKey:SPCustomQuerySoftIndent] && [self isCaretAtIndentPositionIgnoreLineStart:NO]) #else else if ([self isCaretAtIndentPositionIgnoreLineStart:NO]) @@ -2519,7 +2519,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS // Handle newlines, adding any indentation found on the current line to the new line - ignoring the enter key if appropriate if (aSelector == @selector(insertNewline:) -#ifndef SP_REFACTOR +#ifndef SP_CODA && [prefs boolForKey:SPCustomQueryAutoIndent] #endif && (!autoindentIgnoresEnter || [[NSApp currentEvent] keyCode] != 0x4C)) @@ -2559,7 +2559,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS } // Remove soft indent if active and left from caret are only white spaces -#ifndef SP_REFACTOR +#ifndef SP_CODA if (aSelector == @selector(deleteForward:) && ![self selectedRange].length && [prefs boolForKey:SPCustomQuerySoftIndent] @@ -2623,7 +2623,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS return autopairEnabled; } -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Set whether MySQL Help should be automatically invoked while typing. */ @@ -2665,7 +2665,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS - (void)autoHelp { -#ifndef SP_REFACTOR +#ifndef SP_CODA if(![prefs boolForKey:SPCustomQueryUpdateAutoHelp] || ![[self string] length]) return; #else if(![[self string] length]) return; @@ -2897,7 +2897,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS - (void) setTabStops { -#ifndef SP_REFACTOR +#ifndef SP_CODA NSFont *tvFont = [self font]; #else NSFont* tvFont = [NSFont userFixedPitchFontOfSize:10.0]; @@ -2910,14 +2910,14 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS BOOL oldEditableStatus = [self isEditable]; [self setEditable:YES]; -#ifndef SP_REFACTOR +#ifndef SP_CODA NSInteger tabStopWidth = [prefs integerForKey:SPCustomQueryEditorTabStopWidth]; #else NSInteger tabStopWidth = 4; #endif if(tabStopWidth < 1) tabStopWidth = 1; -#ifndef SP_REFACTOR +#ifndef SP_CODA float tabWidth = NSSizeToCGSize([[NSString stringWithString:@" "] sizeWithAttributes:[NSDictionary dictionaryWithObject:tvFont forKey:NSFontAttributeName]]).width; #else float tabWidth = NSSizeToCGSize([@" " sizeWithAttributes:[NSDictionary dictionaryWithObject:tvFont forKey:NSFontAttributeName]]).width; @@ -3084,7 +3084,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS */ - (NSMenu *)menuForEvent:(NSEvent *)event { -#ifndef SP_REFACTOR +#ifndef SP_CODA // Set title of the menu item if([self selectedRange].length) showMySQLHelpFor = NSLocalizedString(@"MySQL Help for Selection", @"MySQL Help for Selection"); @@ -3099,7 +3099,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS // if it doesn't yet exist NSMenu *menu = [[self class] defaultMenu]; -#ifndef SP_REFACTOR +#ifndef SP_CODA if ([[[self class] defaultMenu] itemWithTag:SP_CQ_SEARCH_IN_MYSQL_HELP_MENU_ITEM_TAG] == nil) { [menu insertItem:[NSMenuItem separatorItem] atIndex:3]; @@ -3138,7 +3138,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS [[menu itemAtIndex:6] setHidden:YES]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA [[NSApp delegate] reloadBundles:self]; // Remove 'Bundles' sub menu and separator @@ -3300,7 +3300,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS if (textStore!=[self textStorage]) return; // Cancel autocompletion trigger -#ifndef SP_REFACTOR +#ifndef SP_CODA if([prefs boolForKey:SPCustomQueryAutoComplete]) #endif [NSObject cancelPreviousPerformRequestsWithTarget:self @@ -3316,14 +3316,14 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS NSInteger editedMask = [textStore editedMask]; // Start autohelp only if the user really changed the text (not e.g. for setting a background color) -#ifndef SP_REFACTOR +#ifndef SP_CODA if([prefs boolForKey:SPCustomQueryUpdateAutoHelp] && editedMask != 1) { [self performSelector:@selector(autoHelp) withObject:nil afterDelay:[[prefs valueForKey:SPCustomQueryAutoHelpDelay] doubleValue]]; } #endif // Start autocompletion if enabled -#ifndef SP_REFACTOR +#ifndef SP_CODA if([[NSApp keyWindow] firstResponder] == self && [prefs boolForKey:SPCustomQueryAutoComplete] && !completionIsOpen && editedMask != 1 && [textStore changeInLength] == 1) [self performSelector:@selector(doAutoCompletion) withObject:nil afterDelay:[[prefs valueForKey:SPCustomQueryAutoCompleteDelay] doubleValue]]; #else @@ -3651,7 +3651,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS - (void)changeFont:(id)sender { -#ifndef SP_REFACTOR +#ifndef SP_CODA if (prefs && [self font] != nil) { [prefs setObject:[NSArchiver archivedDataWithRootObject:[self font]] forKey:SPCustomQueryEditorFont]; NSFont *nf = [[NSFontPanel sharedFontPanel] panelConvertFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorFont]]]; @@ -3675,7 +3675,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS // Remove observers [[NSNotificationCenter defaultCenter] removeObserver:self]; -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs removeObserver:self forKeyPath:SPCustomQueryEditorSelectionColor]; [prefs removeObserver:self forKeyPath:SPCustomQueryEditorCaretColor]; [prefs removeObserver:self forKeyPath:SPCustomQueryEditorFont]; @@ -3694,7 +3694,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS #endif if (completionIsOpen) [completionPopup close], completionIsOpen = NO; -#ifndef SP_REFACTOR +#ifndef SP_CODA [prefs release]; #endif [lineNumberView release]; @@ -3725,7 +3725,7 @@ NSInteger _alphabeticSort(id string1, id string2, void *reverse) return [string1 localizedCaseInsensitiveCompare:string2]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA /** * Take a supplied text selection colour, and if it contains an alpha component, * pre-multiply it by the background colour before setting it to avoid drawing problems. diff --git a/Source/SPTextViewAdditions.h b/Source/SPTextViewAdditions.h index fbdc13fd..23ee4b91 100644 --- a/Source/SPTextViewAdditions.h +++ b/Source/SPTextViewAdditions.h @@ -50,7 +50,7 @@ - (IBAction)moveSelectionLineUp:(id)sender; - (IBAction)moveSelectionLineDown:(id)sender; -#ifndef SP_REFACTOR +#ifndef SP_CODA - (IBAction)executeBundleItemForInputField:(id)sender; #endif diff --git a/Source/SPTextViewAdditions.m b/Source/SPTextViewAdditions.m index de3b955b..8e93d2e6 100644 --- a/Source/SPTextViewAdditions.m +++ b/Source/SPTextViewAdditions.m @@ -32,11 +32,11 @@ #import "SPAlertSheets.h" #import "SPTooltip.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPBundleHTMLOutputController.h" #endif #import "SPCustomQuery.h" -#ifndef SP_REFACTOR /* headers */ +#ifndef SP_CODA /* headers */ #import "SPAppController.h" #import "SPWindowManagement.h" #endif @@ -507,7 +507,7 @@ [self setEditable:editableStatus]; } -#ifndef SP_REFACTOR +#ifndef SP_CODA - (IBAction)executeBundleItemForInputField:(id)sender { @@ -662,13 +662,13 @@ } NSString *output = [SPBundleCommandRunner runBashCommand:cmd withEnvironment:env - atCurrentDirectoryPath:nil - callerInstance:[(SPAppController*)[NSApp delegate] frontDocument] - contextInfo:[NSDictionary dictionaryWithObjectsAndKeys: - ([cmdData objectForKey:SPBundleFileNameKey])?:@"-", @"name", - NSLocalizedString(@"Input Field", @"input field menu item label"), @"scope", + atCurrentDirectoryPath:nil + callerInstance:[(SPAppController*)[NSApp delegate] frontDocument] + contextInfo:[NSDictionary dictionaryWithObjectsAndKeys: + ([cmdData objectForKey:SPBundleFileNameKey])?:@"-", @"name", + NSLocalizedString(@"Input Field", @"input field menu item label"), @"scope", uuid, SPBundleFileInternalexecutionUUID, nil] - error:&err]; + error:&err]; [[NSFileManager defaultManager] removeItemAtPath:bundleInputFilePath error:nil]; |