aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPConnectionController.h18
-rw-r--r--Source/SPConnectionController.m54
-rw-r--r--Source/SPConnectionHandler.m24
-rw-r--r--Source/SPCustomQuery.h1
-rw-r--r--Source/SPCustomQuery.m1
-rw-r--r--Source/SPDatabaseDocument.h16
-rw-r--r--Source/SPDatabaseDocument.m78
-rw-r--r--Source/SPDatabaseViewController.m5
-rw-r--r--Source/SPEditSheetTextView.m6
-rw-r--r--Source/SPTextView.m2
10 files changed, 185 insertions, 20 deletions
diff --git a/Source/SPConnectionController.h b/Source/SPConnectionController.h
index 2fcede2f..dccbf9a6 100644
--- a/Source/SPConnectionController.h
+++ b/Source/SPConnectionController.h
@@ -26,9 +26,6 @@
#import "SPConnectionControllerDelegateProtocol.h"
#import <SPMySQL/SPMySQLConnectionDelegate.h>
-#ifndef SP_REFACTOR /* headers */
-#endif
-
@class SPDatabaseDocument,
SPFavoritesController,
SPSSHTunnel,
@@ -64,17 +61,15 @@
SPKeychain *keychain;
NSView *databaseConnectionSuperview;
NSSplitView *databaseConnectionView;
- NSOpenPanel *keySelectionPanel;
#endif
+ NSOpenPanel *keySelectionPanel;
NSUserDefaults *prefs;
-#ifndef SP_REFACTOR /* ivars */
BOOL cancellingConnection;
BOOL isConnecting;
// Standard details
NSInteger previousType;
-#endif
NSInteger type;
NSString *name;
NSString *host;
@@ -103,7 +98,6 @@
NSString *connectionKeychainID;
NSString *connectionKeychainItemName;
-#ifndef SP_REFACTOR /* ivars */
NSString *connectionKeychainItemAccount;
NSString *connectionSSHKeychainItemName;
NSString *connectionSSHKeychainItemAccount;
@@ -114,7 +108,9 @@
IBOutlet NSSplitView *connectionSplitView;
IBOutlet NSScrollView *connectionDetailsScrollView;
IBOutlet NSTextField *connectionInstructionsTextField;
+#ifndef SP_REFACTOR
IBOutlet BWAnchoredButtonBar *connectionSplitViewButtonBar;
+#endif
IBOutlet SPFavoritesOutlineView *favoritesOutlineView;
IBOutlet NSWindow *errorDetailWindow;
@@ -161,7 +157,6 @@
BOOL isEditing;
BOOL reverseFavoritesSort;
-#endif
BOOL initComplete;
BOOL mySQLConnectionCancelled;
BOOL favoriteNameFieldWasTouched;
@@ -199,21 +194,22 @@
@property (readwrite, assign) NSInteger sshKeyLocationEnabled;
@property (readwrite, retain) NSString *sshKeyLocation;
@property (readwrite, retain) NSString *sshPort;
-#ifndef SP_REFACTOR /* ivars */
-
@property (readwrite, retain) NSString *connectionKeychainItemName;
@property (readwrite, retain) NSString *connectionKeychainItemAccount;
@property (readwrite, retain) NSString *connectionSSHKeychainItemName;
@property (readwrite, retain) NSString *connectionSSHKeychainItemAccount;
+
+#ifdef SP_REFACTOR
+@property (readwrite, assign) SPDatabaseDocument *dbDocument;
#endif
@property (readonly, assign) BOOL isConnecting;
// Connection processes
- (IBAction)initiateConnection:(id)sender;
-#ifndef SP_REFACTOR /* method decls */
- (IBAction)cancelMySQLConnection:(id)sender;
+#ifndef SP_REFACTOR
// Interface interaction
- (IBAction)nodeDoubleClicked:(id)sender;
- (IBAction)chooseKeyLocation:(id)sender;
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index 023ec2b6..2c4412ef 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -25,10 +25,13 @@
#import "SPConnectionController.h"
#import "SPDatabaseDocument.h"
+
+#ifndef SP_REFACTOR /* headers */
#import "SPAppController.h"
#import "SPPreferenceController.h"
#import "ImageAndTextCell.h"
#import "RegexKitLite.h"
+#endif
#import "SPAlertSheets.h"
#import "SPKeychain.h"
#import "SPSSHTunnel.h"
@@ -58,6 +61,7 @@ static NSString *SPExportFavoritesFilename = @"SequelProFavorites.plist";
@interface SPConnectionController ()
- (BOOL)_checkHost;
+#ifndef SP_REFACTOR
- (void)_sortFavorites;
- (void)_sortTreeNode:(SPTreeNode *)node usingKey:(NSString *)key;
- (void)_favoriteTypeDidChange;
@@ -75,6 +79,7 @@ static NSString *SPExportFavoritesFilename = @"SequelProFavorites.plist";
- (void)_updateFavoritePasswordsFromField:(NSControl *)control;
static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, void *key);
+#endif
@end
@@ -103,6 +108,10 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
@synthesize sshKeyLocation;
@synthesize sshPort;
+#ifdef SP_REFACTOR
+@synthesize dbDocument;
+#endif
+
@synthesize connectionKeychainItemName;
@synthesize connectionKeychainItemAccount;
@synthesize connectionSSHKeychainItemName;
@@ -192,6 +201,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
isConnecting = YES;
cancellingConnection = NO;
+#ifndef SP_REFACTOR
// Disable the favorites outline view to prevent further connections attempts
[favoritesOutlineView setEnabled:NO];
@@ -200,6 +210,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
[connectButton setEnabled:NO];
[progressIndicator startAnimation:self];
[progressIndicatorText setHidden:NO];
+#endif
// Start the current tab's progress indicator
[dbDocument setIsProcessing:YES];
@@ -207,6 +218,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
if (connectionKeychainItemName) {
if ([[keychain getPasswordForName:connectionKeychainItemName account:connectionKeychainItemAccount] isEqualToString:[self password]]) {
[self setPassword:[[NSString string] stringByPaddingToLength:[[self password] length] withString:@"sp" startingAtIndex:0]];
@@ -231,6 +243,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
[connectionSSHKeychainItemAccount release], connectionSSHKeychainItemAccount = nil;
}
}
+#endif
// Inform the delegate that we are starting the connection process
if (delegate && [delegate respondsToSelector:@selector(connectionControllerInitiatingConnection:)]) {
@@ -260,12 +273,14 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
*/
- (IBAction)cancelMySQLConnection:(id)sender
{
+#ifndef SP_REFACTOR
[connectButton setEnabled:NO];
[progressIndicatorText setStringValue:NSLocalizedString(@"Cancelling...", @"cancelling task status message")];
[progressIndicatorText display];
mySQLConnectionCancelled = YES;
+#endif
}
#pragma mark -
@@ -276,6 +291,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
*/
- (IBAction)nodeDoubleClicked:(id)sender
{
+#ifndef SP_REFACTOR
SPTreeNode *node = [self selectedFavoriteNode];
if (node) {
@@ -288,6 +304,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
[favoritesOutlineView editColumn:0 row:[favoritesOutlineView selectedRow] withEvent:nil select:YES];
}
}
+#endif
}
/**
@@ -434,6 +451,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
*/
- (void)sortFavorites:(id)sender
{
+#ifndef SP_REFACTOR
SPFavoritesSortItem previousSortItem = currentSortItem;
currentSortItem = (SPFavoritesSortItem)[[sender menu] indexOfItem:sender];
@@ -445,6 +463,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
if (previousSortItem > SPFavoritesSortUnsorted) [[[sender menu] itemAtIndex:previousSortItem] setState:NSOffState];
[[[sender menu] itemAtIndex:currentSortItem] setState:NSOnState];
+#endif
}
/**
@@ -452,6 +471,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
*/
- (void)reverseSortFavorites:(NSMenuItem *)sender
{
+#ifndef SP_REFACTOR
reverseFavoritesSort = (![sender state]);
[prefs setBool:reverseFavoritesSort forKey:SPFavoritesSortedInReverse];
@@ -460,6 +480,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
[self _sortFavorites];
[(NSMenuItem *)sender setState:reverseFavoritesSort];
+#endif
}
/**
@@ -467,6 +488,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
*/
- (void)updateFavoriteSelection:(id)sender
{
+#ifndef SP_REFACTOR
// Clear the keychain referral items as appropriate
if (connectionKeychainID) [connectionKeychainID release], connectionKeychainID = nil;
@@ -551,11 +573,13 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
// Set first responder to password field if it is empty
[self performSelector:@selector(_updateFavoriteFirstResponder) withObject:nil afterDelay:0.0];
+#endif
}
/**
* Returns the selected favorite data dictionary or nil if nothing is selected.
*/
+#ifndef SP_REFACTOR
- (NSMutableDictionary *)selectedFavorite
{
SPTreeNode *node = [self selectedFavoriteNode];
@@ -989,6 +1013,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
}
}
}
+#endif
/**
* Called after closing the SSH/SSL key selection sheet.
@@ -1041,6 +1066,8 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
/**
* Called when the user dismisses either the import of export favorites panels.
*/
+#ifndef SP_REFACTOR
+
- (void)importExportFavoritesSheetDidEnd:(NSOpenPanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo
{
if (returnCode == NSOKButton) {
@@ -1061,6 +1088,8 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
}
}
+#endif
+
/**
* Alert sheet callback method - invoked when the error sheet is closed.
*/
@@ -1069,11 +1098,15 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
if (returnCode == NSAlertAlternateReturn) {
[self setType:SPSocketConnection];
[self setHost:@""];
+#ifndef SP_REFACTOR
[self _updateFavoritePasswordsFromField:standardSQLHostField];
+#endif
}
else {
[self setHost:@"127.0.0.1"];
+#ifndef SP_REFACTOR
[self _updateFavoritePasswordsFromField:standardSQLHostField];
+#endif
}
}
@@ -1104,6 +1137,8 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
/**
* Sorts the connection favorites based on the selected criteria.
*/
+
+#ifndef SP_REFACTOR
- (void)_sortFavorites
{
NSString *sortKey = SPFavoriteNameKey;
@@ -1131,6 +1166,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
[[NSNotificationCenter defaultCenter] postNotificationName:SPConnectionFavoritesChangedNotification object:self];
}
+#endif
/**
* Sorts the supplied tree node using the supplied sort key.
@@ -1211,6 +1247,9 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
/**
* Updates the favorite's host when the type changes.
*/
+
+#ifndef SP_REFACTOR
+
- (void)_favoriteTypeDidChange
{
NSDictionary *favorite = [self selectedFavorite];
@@ -1273,6 +1312,8 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
}
}
+#endif
+
/**
* Restores the connection interface to its original state.
*/
@@ -1310,6 +1351,8 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
[connectButton setAction:@selector(initiateConnection:)];
}
+#ifndef SP_REFACTOR
+
/**
* Selected the supplied node in the favorites outline view.
*
@@ -1409,6 +1452,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
return favoriteNode;
}
+#endif
/**
* Strips any invalid characters form the supplied string. Invalid is defined as any characters that should
@@ -1421,6 +1465,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
return [result stringByReplacingOccurrencesOfString:@"\n" withString:@""];
}
+#ifndef SP_REFACTOR
/**
* Check all fields used in the keychain names against the old values for that
* favorite, and update the keychain names to match if necessary.
@@ -1519,6 +1564,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
currentFavorite = [[[[self selectedFavoriteNode] representedObject] nodeFavorite] copy];
}
}
+#endif
#pragma mark -
@@ -1528,6 +1574,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
[NSObject cancelPreviousPerformRequestsWithTarget:self];
// Unregister observers
+#ifndef SP_REFACTOR
[self removeObserver:self forKeyPath:SPFavoriteTypeKey];
[self removeObserver:self forKeyPath:SPFavoriteNameKey];
[self removeObserver:self forKeyPath:SPFavoriteHostKey];
@@ -1547,11 +1594,16 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
[self removeObserver:self forKeyPath:SPFavoriteSSLCertificateFileLocationKey];
[self removeObserver:self forKeyPath:SPFavoriteSSLCACertFileLocationEnabledKey];
[self removeObserver:self forKeyPath:SPFavoriteSSLCACertFileLocationKey];
+#endif
+#ifndef SP_REFACTOR
[keychain release];
+#endif
[prefs release];
+#ifndef SP_REFACTOR
[folderImage release], folderImage = nil;
+#endif
for (id retainedObject in nibObjectsToRelease) [retainedObject release];
@@ -1569,7 +1621,9 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
if (connectionSSHKeychainItemName) [connectionSSHKeychainItemName release];
if (connectionSSHKeychainItemAccount) [connectionSSHKeychainItemAccount release];
+#ifndef SP_REFACTOR
if (currentFavorite) [currentFavorite release], currentFavorite = nil;
+#endif
[super dealloc];
}
diff --git a/Source/SPConnectionHandler.m b/Source/SPConnectionHandler.m
index fdc3d35e..77e3550f 100644
--- a/Source/SPConnectionHandler.m
+++ b/Source/SPConnectionHandler.m
@@ -50,6 +50,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1";
*/
- (void)initiateMySQLConnection
{
+#ifndef SP_REFACTOR
[progressIndicatorText setStringValue:(sshTunnel) ? NSLocalizedString(@"MySQL connecting...", @"MySQL connecting very short status message") : NSLocalizedString(@"Connecting...", @"Generic connecting very short status message")];
[progressIndicatorText display];
@@ -57,6 +58,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1";
[connectButton setAction:@selector(cancelMySQLConnection:)];
[connectButton setEnabled:YES];
[connectButton display];
+#endif
[NSThread detachNewThreadSelector:@selector(initiateMySQLConnectionInBackground) toTarget:self withObject:nil];
}
@@ -273,18 +275,22 @@ static NSString *SPLocalhostAddress = @"127.0.0.1";
return;
}
+#ifndef SP_REFACTOR
[progressIndicatorText setStringValue:NSLocalizedString(@"Connected", @"connection established message")];
[progressIndicatorText display];
+#endif
// Stop the current tab's progress indicator
[dbDocument setIsProcessing:NO];
// Successful connection!
+#ifndef SP_REFACTOR
[connectButton setEnabled:NO];
[connectButton display];
[progressIndicator stopAnimation:self];
[progressIndicatorText setHidden:YES];
[addToFavoritesButton setHidden:NO];
+#endif
// If SSL was enabled, check it was established correctly
if (useSSL && ([self type] == SPTCPIPConnection || [self type] == SPSocketConnection)) {
@@ -292,13 +298,17 @@ 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
[dbDocument setStatusIconToImageWithName:@"titlebarlock"];
+#endif
}
}
+#ifndef SP_REFACTOR
// Re-enable favorites table view
[favoritesOutlineView setEnabled:YES];
[(NSView *)favoritesOutlineView display];
+#endif
// Release the tunnel if set - will now be retained by the connection
if (sshTunnel) [sshTunnel release], sshTunnel = nil;
@@ -326,19 +336,25 @@ static NSString *SPLocalhostAddress = @"127.0.0.1";
}
if (newState == SPMySQLProxyIdle) {
+#ifndef SP_REFACTOR
[dbDocument setTitlebarStatus:NSLocalizedString(@"SSH Disconnected", @"SSH disconnected titlebar marker")];
+#endif
[self failConnectionWithTitle:NSLocalizedString(@"SSH connection failed!", @"SSH connection failed title") errorMessage:[theTunnel lastError] detail:[sshTunnel debugMessages] rawErrorText:[theTunnel lastError]];
[self _restoreConnectionInterface];
}
else if (newState == SPMySQLProxyConnected) {
+#ifndef SP_REFACTOR
[dbDocument setTitlebarStatus:NSLocalizedString(@"SSH Connected", @"SSH connected titlebar marker")];
+#endif
[self initiateMySQLConnection];
}
else {
+#ifndef SP_REFACTOR
[dbDocument setTitlebarStatus:NSLocalizedString(@"SSH Connecting…", @"SSH connecting titlebar marker")];
+#endif
}
}
@@ -363,6 +379,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1";
*/
- (void)addConnectionToDocument
{
+#ifndef SP_REFACTOR
// Hide the connection view and restore the main view
[connectionView removeFromSuperviewWithoutNeedingDisplay];
[databaseConnectionView setHidden:NO];
@@ -371,6 +388,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1";
NSArray *toolbarItems = [[[dbDocument parentWindow] toolbar] items];
for (NSUInteger i = 0; i < [toolbarItems count]; i++) [[toolbarItems objectAtIndex:i] setEnabled:YES];
+#endif
if (connectionKeychainID) [dbDocument setKeychainID:connectionKeychainID];
@@ -387,6 +405,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1";
{
BOOL isSSHTunnelBindError = NO;
+#ifndef SP_REFACTOR
// Clean up the interface
[progressIndicator stopAnimation:self];
[progressIndicator display];
@@ -396,6 +415,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1";
[addToFavoritesButton display];
[connectButton setEnabled:YES];
[dbDocument clearStatusIcon];
+#endif
// Release as appropriate
if (sshTunnel) {
@@ -427,6 +447,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1";
*/
- (void)connectionFailureSheetDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
+#ifndef SP_REFACTOR
// Restore the passwords from keychain for editing if appropriate
if (connectionKeychainItemName) {
[self setPassword:[keychain getPasswordForName:connectionKeychainItemName account:connectionKeychainItemAccount]];
@@ -435,6 +456,7 @@ static NSString *SPLocalhostAddress = @"127.0.0.1";
if (connectionSSHKeychainItemName) {
[self setSshPassword:[keychain getPasswordForName:connectionSSHKeychainItemName account:connectionSSHKeychainItemAccount]];
}
+#endif
if (returnCode == NSAlertAlternateReturn) {
[errorDetailText setFont:[NSFont userFontOfSize:12]];
@@ -456,8 +478,10 @@ static NSString *SPLocalhostAddress = @"127.0.0.1";
[self setHost:SPLocalhostAddress];
[self _updateFavoritePasswordsFromField:standardSQLHostField];
+#ifndef SP_REFACTOR
// Change to standard TCP/IP connection view
[self resizeTabViewToConnectionType:SPTCPIPConnection animating:YES];
+#endif
// Initiate the connection after a half second delay to give the connection view a chance to resize
[self performSelector:@selector(initiateConnection:) withObject:self afterDelay:0.5];
diff --git a/Source/SPCustomQuery.h b/Source/SPCustomQuery.h
index 10d3b6eb..3a5fb4c7 100644
--- a/Source/SPCustomQuery.h
+++ b/Source/SPCustomQuery.h
@@ -189,6 +189,7 @@
@property (assign) SPTextView *textView;
@property (assign) SPCopyTable *customQueryView;
@property (assign) NSButton* runAllButton;
+@property (assign) id affectedRowsText;
#endif
@property(assign) BOOL textViewWasChanged;
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m
index 9cd81fe9..403882f2 100644
--- a/Source/SPCustomQuery.m
+++ b/Source/SPCustomQuery.m
@@ -72,6 +72,7 @@
@synthesize runAllButton;
@synthesize tableDocumentInstance;
@synthesize tablesListInstance;
+@synthesize affectedRowsText;
#endif
@synthesize textViewWasChanged;
diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h
index 9c7111ad..12f00863 100644
--- a/Source/SPDatabaseDocument.h
+++ b/Source/SPDatabaseDocument.h
@@ -37,12 +37,16 @@ SPDatabaseData, SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPS
#import "SPConnectionControllerDelegateProtocol.h"
+#ifdef SP_REFACTOR /* patch */
+#import <SPMySQL/SPMySQLConnectionDelegate.h>
+#endif
+
/**
* The SPDatabaseDocument class controls the primary database view window.
*/
@interface SPDatabaseDocument : NSObject <SPConnectionControllerDelegateProtocol
#ifdef SP_REFACTOR /* patch */
- , NSTextFieldDelegate
+ , SPMySQLConnectionDelegate, NSTextFieldDelegate
#endif
>
{
@@ -89,27 +93,32 @@ SPDatabaseData, SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPS
IBOutlet id databaseRenameSheet;
IBOutlet NSProgressIndicator* queryProgressBar;
+#ifndef SP_REFACTOR
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
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
IBOutlet id historyControl;
IBOutlet NSTabView *tableTabView;
@@ -120,6 +129,7 @@ SPDatabaseData, SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPS
IBOutlet id sidebarGrabber;
IBOutlet NSPopUpButton *encodingPopUp;
+#endif
IBOutlet NSTextView *customQueryTextView;
@@ -130,6 +140,7 @@ SPDatabaseData, SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPS
IBOutlet NSWindow *createTableSyntaxWindow;
IBOutlet NSWindow *connectionErrorDialog;
+#ifndef SP_REFACTOR
IBOutlet id saveConnectionAccessory;
IBOutlet NSButton *saveConnectionIncludeData;
IBOutlet NSButton *saveConnectionIncludeQuery;
@@ -144,6 +155,7 @@ SPDatabaseData, SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPS
IBOutlet id inputTextWindowMessage;
IBOutlet id inputTextWindowSecureTextField;
NSInteger passwordSheetReturnCode;
+#endif
// Master connection
SPMySQLConnection *mySQLConnection;
@@ -186,6 +198,7 @@ SPDatabaseData, SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPS
BOOL _workingTimeout;
+#ifndef SP_REFACTOR
NSWindow *taskProgressWindow;
BOOL taskDisplayIsIndeterminate;
CGFloat taskProgressValue;
@@ -200,7 +213,6 @@ SPDatabaseData, SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPS
NSToolbar *mainToolbar;
NSToolbarItem *chooseDatabaseToolbarItem;
-#ifndef SP_REFACTOR /* ivars */
WebView *printWebView;
#endif
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index 4d9c76bf..e5cc23b8 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -162,7 +162,9 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
databaseListIsSelectable = YES;
_queryMode = SPInterfaceQueryMode;
chooseDatabaseButton = nil;
+#ifndef SP_REFACTOR /* init ivars */
chooseDatabaseToolbarItem = nil;
+#endif
connectionController = nil;
selectedTableName = nil;
@@ -201,6 +203,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
runningActivitiesArray = [[NSMutableArray alloc] init];
titleAccessoryView = nil;
+#ifndef SP_REFACTOR /* init ivars */
taskProgressWindow = nil;
taskDisplayIsIndeterminate = YES;
taskDisplayLastValue = 0;
@@ -211,6 +214,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
taskCanBeCancelled = NO;
taskCancellationCallbackObject = nil;
taskCancellationCallbackSelector = NULL;
+#endif
keyChainID = nil;
#ifndef SP_REFACTOR /* init ivars */
@@ -321,6 +325,9 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
[nibObjectsToRelease addObjectsFromArray:connectionDialogTopLevelObjects];
}
[nibLoader release];
+
+ // SP_REFACTOR can't use progress indicator because of BWToolkit dependency
+
NSArray *progressIndicatorLayerTopLevelObjects = nil;
nibLoader = [[NSNib alloc] initWithNibNamed:@"ProgressIndicatorLayer" bundle:[NSBundle mainBundle]];
if (![nibLoader instantiateNibWithOwner:self topLevelObjects:&progressIndicatorLayerTopLevelObjects]) {
@@ -332,7 +339,9 @@ 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
// Set up the progress indicator child window and layer - change indicator color and size
[taskProgressIndicator setForeColor:[NSColor whiteColor]];
NSShadow *progressIndicatorShadow = [[NSShadow alloc] init];
@@ -1170,6 +1179,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
// Increment the task level
_isWorkingLevel++;
+#ifndef SP_REFACTOR
// Reset the progress indicator if necessary
if (_isWorkingLevel == 1 || !taskDisplayIsIndeterminate) {
taskDisplayIsIndeterminate = YES;
@@ -1177,20 +1187,25 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
[taskProgressIndicator startAnimation:self];
taskDisplayLastValue = 0;
}
+#endif
// If the working level just moved to start a task, set up the interface
if (_isWorkingLevel == 1) {
+#ifndef SP_REFACTOR
[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
[mainToolbar validateVisibleItems];
[chooseDatabaseButton setEnabled:NO];
// Schedule appearance of the task window in the near future, using a frame timer.
taskFadeInStartDate = [[NSDate alloc] init];
taskDrawTimer = [[NSTimer scheduledTimerWithTimeInterval:1.0 / 30.0 target:self selector:@selector(fadeInTaskProgressWindow:) userInfo:nil repeats:YES] retain];
+#endif
}
}
@@ -1199,6 +1214,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
*/
- (void) fadeInTaskProgressWindow:(NSTimer *)theTimer
{
+#ifndef SP_REFACTOR
double timeSinceFadeInStart = [[NSDate date] timeIntervalSinceDate:taskFadeInStartDate];
// Keep the window hidden for the first ~0.5 secs
@@ -1219,6 +1235,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
[taskDrawTimer invalidate], [taskDrawTimer release], taskDrawTimer = nil;
[taskFadeInStartDate release], taskFadeInStartDate = nil;
}
+#endif
}
@@ -1227,6 +1244,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
*/
- (void) setTaskDescription:(NSString *)description
{
+#ifndef SP_REFACTOR
NSShadow *textShadow = [[NSShadow alloc] init];
[textShadow setShadowColor:[NSColor colorWithCalibratedWhite:0.0f alpha:0.75f]];
[textShadow setShadowOffset:NSMakeSize(1.0f, -1.0f)];
@@ -1243,6 +1261,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
[string release];
[attributes release];
[textShadow release];
+#endif
}
/**
@@ -1252,6 +1271,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
*/
- (void) setTaskPercentage:(CGFloat)taskPercentage
{
+#ifndef SP_REFACTOR
// If the task display is currently indeterminate, set it to determinate on the main thread.
if (taskDisplayIsIndeterminate) {
@@ -1275,6 +1295,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
}
taskDisplayLastValue = taskProgressValue;
}
+#endif
}
/**
@@ -1286,6 +1307,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
*/
- (void) setTaskProgressToIndeterminateAfterDelay:(BOOL)afterDelay
{
+#ifndef SP_REFACTOR
if (afterDelay) {
[self performSelector:@selector(setTaskProgressToIndeterminateAfterDelay:) withObject:nil afterDelay:0.5];
return;
@@ -1297,6 +1319,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
[taskProgressIndicator setIndeterminate:YES];
[taskProgressIndicator startAnimation:self];
taskDisplayLastValue = 0;
+#endif
}
/**
@@ -1304,6 +1327,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
*/
- (void) endTask
{
+
// Ensure a call on the main thread
if (![NSThread isMainThread]) return [[self onMainThread] endTask];
@@ -1316,6 +1340,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
// If all tasks have ended, re-enable the interface
if (!_isWorkingLevel) {
+#ifndef SP_REFACTOR
// Cancel the draw timer if it exists
if (taskDrawTimer) {
[taskDrawTimer invalidate], [taskDrawTimer release], taskDrawTimer = nil;
@@ -1327,11 +1352,14 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
[taskProgressWindow setAlphaValue:0.0f];
taskDisplayIsIndeterminate = YES;
[taskProgressIndicator setIndeterminate:YES];
+#endif
// Re-enable window interface
databaseListIsSelectable = YES;
[[NSNotificationCenter defaultCenter] postNotificationName:SPDocumentTaskEndNotification object:self];
+#ifndef SP_REFACTOR
[mainToolbar validateVisibleItems];
+#endif
[chooseDatabaseButton setEnabled:_isConnected];
}
}
@@ -1342,6 +1370,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
*/
- (void) enableTaskCancellationWithTitle:(NSString *)buttonTitle callbackObject:(id)callbackObject callbackFunction:(SEL)callbackFunction
{
+#ifndef SP_REFACTOR
// If no task is active, return
if (!_isWorkingLevel) return;
@@ -1358,6 +1387,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
[taskCancelButton setTitle:buttonTitle];
[taskCancelButton setEnabled:YES];
[taskCancelButton setHidden:NO];
+#endif
}
/**
@@ -1365,6 +1395,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
*/
- (void) disableTaskCancellation
{
+#ifndef SP_REFACTOR
// If no task is active, return
if (!_isWorkingLevel) return;
@@ -1376,6 +1407,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
taskCancellationCallbackObject = nil;
taskCancellationCallbackSelector = NULL;
[taskCancelButton setHidden:YES];
+#endif
}
/**
@@ -1383,6 +1415,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
*/
- (IBAction) cancelTask:(id)sender
{
+#ifndef SP_REFACTOR
if (!taskCanBeCancelled) return;
[taskCancelButton setEnabled:NO];
@@ -1399,6 +1432,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
if (taskCancellationCallbackObject && taskCancellationCallbackSelector) {
[taskCancellationCallbackObject performSelector:taskCancellationCallbackSelector];
}
+#endif
}
/**
@@ -1423,6 +1457,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
*/
- (void) centerTaskWindow
{
+#ifndef SP_REFACTOR
NSPoint newBottomLeftPoint;
NSRect mainWindowRect = [parentWindow frame];
NSRect taskWindowRect = [taskProgressWindow frame];
@@ -1431,6 +1466,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
newBottomLeftPoint.y = roundf(mainWindowRect.origin.y + mainWindowRect.size.height/2 - taskWindowRect.size.height/2);
[taskProgressWindow setFrameOrigin:newBottomLeftPoint];
+#endif
}
/**
@@ -1439,11 +1475,13 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
*/
- (void) setTaskIndicatorShouldAnimate:(BOOL)shouldAnimate
{
+#ifndef SP_REFACTOR
if (shouldAnimate) {
[[taskProgressIndicator onMainThread] startAnimation:self];
} else {
[[taskProgressIndicator onMainThread] stopAnimation:self];
}
+#endif
}
#pragma mark -
@@ -2448,6 +2486,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
- (BOOL)couldCommitCurrentViewActions
{
[parentWindow endEditingFor:nil];
+#ifndef SP_REFACTOR
switch ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]]) {
// Table structure view
@@ -2463,6 +2502,9 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
}
return YES;
+#else
+ return [tableSourceInstance saveRowOnDeselect] && [tableContentInstance saveRowOnDeselect];
+#endif
}
#pragma mark -
@@ -4025,8 +4067,8 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
else [connectionController cancelConnection];
#ifndef SP_REFACTOR
if ([[[SPQueryController sharedQueryController] window] isVisible]) [self toggleConsole:self];
-#endif
[createTableSyntaxWindow orderOut:nil];
+#endif
[[NSNotificationCenter defaultCenter] removeObserver:self];
[self setParentWindow:nil];
@@ -4111,13 +4153,13 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
*/
- (void)setParentWindow:(NSWindow *)aWindow
{
+#ifndef SP_REFACTOR
// If the window is being set for the first time - connection controller is visible - update focus
if (!parentWindow && !mySQLConnection) {
-#ifndef SP_REFACTOR
[aWindow makeFirstResponder:(NSResponder *)[connectionController favoritesOutlineView]];
-#endif
[connectionController updateFavoriteSelection:self];
}
+#endif
parentWindow = aWindow;
SPSSHTunnel *currentTunnel = [connectionController valueForKeyPath:@"sshTunnel"];
@@ -4830,6 +4872,11 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
*/
- (void)connectionControllerConnectAttemptFailed:(id)controller
{
+#ifdef SP_REFACTOR /* glue */
+ if ( delegate && [delegate respondsToSelector:@selector(databaseDocumentConnectionFailed:)] )
+ [delegate performSelector:@selector(databaseDocumentConnectionFailed:) withObject:self];
+#endif
+
#ifndef SP_REFACTOR /* updateWindowTitle: */
// Reset the window title
[self updateWindowTitle:self];
@@ -4837,6 +4884,15 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
}
+#ifdef SP_REFACTOR
+- (void)databaseDocumentConnectionFailed:(id)sender
+{
+ if ( delegate && [delegate respondsToSelector:@selector(databaseDocumentConnectionFailed:)] )
+ [delegate performSelector:@selector(databaseDocumentConnectionFailed:) withObject:self];
+}
+#endif
+
+
#ifndef SP_REFACTOR /* scheme scripting methods */
#pragma mark -
@@ -5472,16 +5528,19 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
if (object == databaseNameField) {
[addDatabaseButton setEnabled:([[databaseNameField stringValue] length] > 0 && ![allDatabases containsObject: [databaseNameField stringValue]])];
}
+#ifndef SP_REFACTOR
else if (object == databaseCopyNameField) {
[copyDatabaseButton setEnabled:([[databaseCopyNameField stringValue] length] > 0 && ![allDatabases containsObject: [databaseCopyNameField stringValue]])];
}
+#endif
else if (object == databaseRenameNameField) {
[renameDatabaseButton setEnabled:([[databaseRenameNameField stringValue] length] > 0 && ![allDatabases containsObject: [databaseRenameNameField stringValue]])];
}
+#ifndef SP_REFACTOR
else if (object == saveConnectionEncryptString) {
[saveConnectionEncryptString setStringValue:[saveConnectionEncryptString stringValue]];
}
-
+#endif
}
#pragma mark -
@@ -5689,7 +5748,9 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
[printWebView release];
#endif
[selectedDatabaseEncoding release];
+#ifndef SP_REFACTOR
[taskProgressWindow close];
+#endif
if (selectedTableName) [selectedTableName release];
if (connectionController) [connectionController release];
@@ -5700,17 +5761,23 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
if (mySQLConnection) [mySQLConnection release];
if (selectedDatabase) [selectedDatabase release];
if (mySQLVersion) [mySQLVersion release];
+#ifndef SP_REFACTOR
if (taskDrawTimer) [taskDrawTimer invalidate], [taskDrawTimer release];
if (taskFadeInStartDate) [taskFadeInStartDate release];
+#endif
if (queryEditorInitString) [queryEditorInitString release];
if (spfFileURL) [spfFileURL release];
if (spfPreferences) [spfPreferences release];
if (spfSession) [spfSession release];
if (spfDocData) [spfDocData release];
if (keyChainID) [keyChainID release];
+#ifndef SP_REFACTOR
if (mainToolbar) [mainToolbar release];
+#endif
if (titleAccessoryView) [titleAccessoryView release];
+#ifndef SP_REFACTOR
if (taskProgressWindow) [taskProgressWindow release];
+#endif
if (serverSupport) [serverSupport release];
#ifndef SP_REFACTOR /* dealloc ivars */
if (processID) [processID release];
@@ -5903,10 +5970,9 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
[tablesListInstance setConnection:mySQLConnection];
[tableDumpInstance setConnection:mySQLConnection];
-#ifndef SP_REFACTOR /* ui */
+#ifndef SP_REFACTOR
[self updateWindowTitle:self];
#endif
-
#ifdef SP_REFACTOR /* glue */
if ( delegate && [delegate respondsToSelector:@selector(refreshDatabasePopup)] )
[delegate performSelector:@selector(refreshDatabasePopup) withObject:nil];
diff --git a/Source/SPDatabaseViewController.m b/Source/SPDatabaseViewController.m
index 485a3cfa..962ebedb 100644
--- a/Source/SPDatabaseViewController.m
+++ b/Source/SPDatabaseViewController.m
@@ -37,6 +37,7 @@
#import <SPMySQL/SPMySQL.h>
#ifdef SP_REFACTOR /* headers */
#import "SPTableStructure.h"
+#import "SPTableStructureLoading.h"
#endif
@interface SPDatabaseDocument (SPDatabaseViewControllerPrivateAPI)
@@ -220,7 +221,11 @@
*/
- (void)setStructureRequiresReload:(BOOL)reload
{
+#ifndef SP_REFACTOR
if (reload && selectedTableName && [tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == SPTableViewStructure) {
+#else
+ if (reload && selectedTableName ) {
+#endif
[tableSourceInstance loadTable:selectedTableName];
} else {
structureLoaded = !reload;
diff --git a/Source/SPEditSheetTextView.m b/Source/SPEditSheetTextView.m
index a5d110a6..89c6f19a 100644
--- a/Source/SPEditSheetTextView.m
+++ b/Source/SPEditSheetTextView.m
@@ -60,17 +60,21 @@
- (IBAction)paste:(id)sender
{
+#ifndef SP_REFACTOR
// Try to create an undo group
if([[self delegate] respondsToSelector:@selector(setWasCutPaste)])
[[self delegate] setWasCutPaste];
+#endif
[super paste:sender];
}
- (IBAction)cut:(id)sender
{
+#ifndef SP_REFACTOR
// Try to create an undo group
if([[self delegate] respondsToSelector:@selector(setWasCutPaste)])
[[self delegate] setWasCutPaste];
+#endif
[super cut:sender];
}
@@ -133,6 +137,7 @@
}
}
+#ifndef SP_REFACTOR
// 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:@" "]
@@ -141,6 +146,7 @@
) {
[[self delegate] setDoGroupDueToChars];
}
+#endif
[super keyDown: theEvent];
diff --git a/Source/SPTextView.m b/Source/SPTextView.m
index ac9bf3a2..b670e8d3 100644
--- a/Source/SPTextView.m
+++ b/Source/SPTextView.m
@@ -173,7 +173,7 @@ NSInteger _alphabeticSort(id string1, id string2, void *reverse)
[self setAutouppercaseKeywords:[prefs boolForKey:SPCustomQueryAutoUppercaseKeywords]];
#else
[self setAutopair:YES];
- [self setAutouppercaseKeywords:YES];
+ //[self setAutouppercaseKeywords:YES]; // #18925
#endif
[self setCompletionWasReinvokedAutomatically:NO];