From 0576c2fcca6ddfa04c9a7c6a3d76f3e51cf88919 Mon Sep 17 00:00:00 2001 From: sqlprodev Date: Tue, 27 Mar 2012 21:02:15 +0000 Subject: tweaks to compile on Xcode 4 / 10.6 SDK for SP_REFACTOR --- Source/SPConnectionController.m | 33 +++++++++++++++++++--- Source/SPConnectionDelegate.h | 4 +++ Source/SPContentFilterManager.m | 8 ++++++ Source/SPCopyTable.m | 34 +++++++++++++++++++++++ Source/SPCustomQuery.m | 13 +++++++-- Source/SPDatabaseData.m | 4 +++ Source/SPDatabaseDocument.h | 3 +- Source/SPDatabaseDocument.m | 34 +++++++++++++++++++++-- Source/SPDatabaseInfo.m | 4 +++ Source/SPDatabaseRename.m | 4 +++ Source/SPDatabaseStructure.m | 4 +++ Source/SPDatabaseViewController.m | 4 ++- Source/SPFieldEditorController.m | 26 ++++++++++++------ Source/SPFieldMapperController.m | 4 +++ Source/SPIndexesController.m | 4 +++ Source/SPQueryController.m | 2 ++ Source/SPQueryFavoriteManager.m | 14 +++++++--- Source/SPSSHTunnel.h | 5 ++++ Source/SPSSHTunnel.m | 4 +++ Source/SPTableContent.m | 11 ++++++-- Source/SPTableCopy.m | 4 +++ Source/SPTableData.m | 4 +++ Source/SPTableStructure.m | 9 ++++++ Source/SPTableStructureDelegate.m | 4 +++ Source/SPTableView.m | 28 +++++++++++++++++++ Source/SPTablesList.h | 6 +++- Source/SPTablesList.m | 58 ++++++++++++++++++++++++++++----------- Source/SPTextView.h | 1 + Source/SPTextView.m | 5 ++++ 29 files changed, 295 insertions(+), 43 deletions(-) (limited to 'Source') diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index acec49de..43dc8004 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -25,7 +25,11 @@ #import "SPConnectionController.h" #import "SPDatabaseDocument.h" +#ifndef SP_REFACTOR #import "SPMySQL.h" +#else +#import +#endif #ifndef SP_REFACTOR /* headers */ #import "SPAppController.h" @@ -525,7 +529,14 @@ // Only display the connection error message if there is a window visible and the connection attempt // wasn't cancelled even though it failed. if ([[tableDocument parentWindow] isVisible] && (!mySQLConnectionCancelled)) { +#ifdef SP_REFACTOR + if ( errorDetail ) + NSLog(@"%@", errorDetail); + + SPBeginAlertSheet(theTitle, NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocument parentWindow], self, @selector(connectionFailureSheetDidEnd:returnCode:contextInfo:), @"connect", theErrorMessage); +#else SPBeginAlertSheet(theTitle, NSLocalizedString(@"OK", @"OK button"), (errorDetail) ? NSLocalizedString(@"Show Detail", @"Show detail button") : nil, (isSSHTunnelBindError) ? NSLocalizedString(@"Use Standard Connection", @"use standard connection button") : nil, [tableDocument parentWindow], self, @selector(connectionFailureSheetDidEnd:returnCode:contextInfo:), @"connect", theErrorMessage); +#endif } } @@ -605,14 +616,13 @@ { #ifndef SP_REFACTOR /* favorites */ [favoritesTable deselectAll:self]; -#endif + NSString *directoryPath = nil; NSString *filePath = nil; NSArray *permittedFileTypes = nil; keySelectionPanel = [NSOpenPanel openPanel]; [keySelectionPanel setShowsHiddenFiles:[prefs boolForKey:SPHiddenKeyFileVisibilityKey]]; -#ifndef SP_REFACTOR /* !!! ssh keys */ // Switch details by sender. // First, SSH keys: if (sender == sshSSHKeyButton) { @@ -659,7 +669,6 @@ permittedFileTypes = [NSArray arrayWithObjects:@"pem", @"cert", @"crt", @"", nil]; [keySelectionPanel setAccessoryView:sslCACertLocationHelp]; } -#endif [keySelectionPanel beginSheetForDirectory:directoryPath file:filePath @@ -668,6 +677,7 @@ modalDelegate:self didEndSelector:@selector(chooseKeyLocationSheetDidEnd:returnCode:contextInfo:) contextInfo:sender]; +#endif } /** @@ -879,14 +889,23 @@ { if ([self type] != SPSocketConnection && [[self host] isEqualToString:@"localhost"]) { SPBeginAlertSheet(NSLocalizedString(@"You have entered 'localhost' for a non-socket connection", @"title of error when using 'localhost' for a network connection"), +#ifndef SP_REFACTOR NSLocalizedString(@"Use 127.0.0.1", @"Use 127.0.0.1 button"), // Main button NSLocalizedString(@"Connect via socket", @"Connect via socket button"), // Alternate button +#else + NSLocalizedString(@"OK", @"OK"), // Main button + nil, // Alternate button +#endif nil, // Other button [tableDocument parentWindow], // Window to attach to self, // Modal delegate @selector(localhostErrorSheetDidEnd:returnCode:contextInfo:), // Did end selector nil, // Contextual info for selectors +#ifndef SP_REFACTOR NSLocalizedString(@"To MySQL, 'localhost' is a special host and means that a socket connection should be used.\n\nDid you mean to use a socket connection, or to connect to the local machine via a port? If you meant to connect via a port, '127.0.0.1' should be used instead of 'localhost'.", @"message of error when using 'localhost' for a network connection")); +#else + NSLocalizedString(@"In MySQL, \"localhost\" is a special host and implies that a socket connection should be used.\n\nTo make a socket connection to a local server, choose \"MySQL Socket\" from the \"Connect to\" pop-up.\n\nTo connect via port instead, please change the \"MySQL Server\" field from \"localhost\" to \"127.0.0.1\".", @"message of error when using 'localhost' for a network connection")); +#endif return NO; } @@ -898,12 +917,14 @@ */ - (void)localhostErrorSheetDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { +#ifndef SP_REFACTOR if (returnCode == NSAlertAlternateReturn) { [self setType:SPSocketConnection]; [self setHost:@""]; } else { [self setHost:@"127.0.0.1"]; } +#endif } #ifndef SP_REFACTOR @@ -1280,6 +1301,7 @@ [favoritesNode release]; } +#endif /** * Restores the connection interface to its original state. @@ -1296,6 +1318,7 @@ [tableDocument setIsProcessing:NO]; // Reset the UI +#ifndef SP_REFACTOR [addToFavoritesButton setHidden:NO]; [addToFavoritesButton display]; [helpButton setHidden:NO]; @@ -1311,13 +1334,15 @@ // Re-enable favorites table view [favoritesTable setEnabled:YES]; [favoritesTable display]; +#endif mySQLConnectionCancelled = NO; // Revert the connect button back to its original selector +#ifndef SP_REFACTOR [connectButton setAction:@selector(initiateConnection:)]; -} #endif +} /** * Called on the main thread once the MySQL connection is established on the background thread. Either the diff --git a/Source/SPConnectionDelegate.h b/Source/SPConnectionDelegate.h index 04bee877..f06bbc08 100644 --- a/Source/SPConnectionDelegate.h +++ b/Source/SPConnectionDelegate.h @@ -25,7 +25,11 @@ #import "SPDatabaseDocument.h" +#ifndef SP_REFACTOR #import "SPMySQLConnectionDelegate.h" +#else +#import +#endif @interface SPDatabaseDocument (SPConnectionDelegate) diff --git a/Source/SPContentFilterManager.m b/Source/SPContentFilterManager.m index 7c6213b2..e5eec285 100644 --- a/Source/SPContentFilterManager.m +++ b/Source/SPContentFilterManager.m @@ -307,6 +307,7 @@ */ - (IBAction)exportContentFilter:(id)sender { +#ifndef SP_REFACTOR NSSavePanel *panel = [NSSavePanel savePanel]; [panel setAllowedFileTypes:[NSArray arrayWithObject:SPFileExtensionDefault]]; @@ -317,6 +318,7 @@ [panel setCanCreateDirectories:YES]; [panel beginSheetForDirectory:nil file:nil modalForWindow:[self window] modalDelegate:self didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:@"exportFilter"]; +#endif } /** @@ -324,6 +326,7 @@ */ - (IBAction)importContentFilterByAdding:(id)sender { +#ifndef SP_REFACTOR NSOpenPanel *panel = [NSOpenPanel openPanel]; [panel setCanSelectHiddenExtension:YES]; [panel setDelegate:self]; @@ -338,6 +341,7 @@ modalDelegate:self didEndSelector:@selector(importPanelDidEnd:returnCode:contextInfo:) contextInfo:NULL]; +#endif } /** @@ -828,6 +832,7 @@ */ - (void)importPanelDidEnd:(NSOpenPanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { +#ifndef SP_REFACTOR if (returnCode == NSOKButton) { NSString *filename = [[panel filenames] objectAtIndex:0]; @@ -885,6 +890,7 @@ } } } +#endif } @@ -894,6 +900,7 @@ - (void)savePanelDidEnd:(NSSavePanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { +#ifndef SP_REFACTOR if([contextInfo isEqualToString:@"exportFilter"]) { if (returnCode == NSOKButton) { @@ -941,6 +948,7 @@ } } +#endif } @end diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m index 79fc89e6..637c3913 100644 --- a/Source/SPCopyTable.m +++ b/Source/SPCopyTable.m @@ -36,7 +36,11 @@ #import "SPBundleEditorController.h" #import "SPAppController.h" #import "SPTablesList.h" +#ifndef SP_REFACTOR #import "SPMySQL.h" +#else +#import +#endif NSInteger SPEditMenuCopy = 2001; NSInteger SPEditMenuCopyWithColumns = 2002; @@ -112,6 +116,15 @@ static const NSInteger kBlobAsImageFile = 4; #endif } +#ifdef SP_REFACTOR + +- (void)delete:(id)sender +{ + [tableInstance removeRow:self]; +} + +#endif + /** * Get selected rows a string of newline separated lines of tab separated fields * the value in each field is from the objects description method @@ -978,6 +991,16 @@ static const NSInteger kBlobAsImageFile = 4; if (menuItemTag == SPEditCopyAsSQL) { return (columnDefinitions != nil && [self numberOfSelectedRows] > 0); } +#endif +#ifdef SP_REFACTOR + if ( [anItem action] == @selector(selectAll:) ) + return YES; + + if ( [anItem action] == @selector(delete:) ) + { + if ( [self numberOfSelectedRows] > 0 ) + return YES; + } #endif return NO; } @@ -1158,7 +1181,18 @@ static const NSInteger kBlobAsImageFile = 4; { // Retrieve the column definition +#if SP_REFACTOR + NSDictionary *columnDefinition; + + if ( [[self delegate] isKindOfClass:[SPTableContent class]] ) + columnDefinition = [[(SPTableContent*)[self delegate] dataColumnDefinitions] objectAtIndex:colIndex]; + + else if ( [[self delegate] isKindOfClass:[SPCustomQuery class]] ) + columnDefinition = [[(SPCustomQuery*)[self delegate] dataColumnDefinitions] objectAtIndex:colIndex]; +#else NSDictionary *columnDefinition = [[[self delegate] dataColumnDefinitions] objectAtIndex:colIndex]; +#endif + NSString *columnType = [columnDefinition objectForKey:@"typegrouping"]; // Return YES if the multiple line editing button is enabled - triggers sheet editing on all cells. diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index 8b9d9a74..b7f105eb 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -25,9 +25,11 @@ #import "SPCustomQuery.h" #import "SPSQLParser.h" -#import "SPMySQL.h" #ifndef SP_REFACTOR /* headers */ +#import "SPMySQL.h" #import "SPGrowlController.h" +#else +#import #endif #import "SPDataCellFormatter.h" #import "SPDatabaseDocument.h" @@ -861,7 +863,9 @@ ]; } } +#ifndef SP_REFACTOR [[affectedRowsText onMainThread] setStringValue:statusString]; +#endif // Restore automatic query retries [mySQLConnection setRetryQueriesOnConnectionFailure:YES]; @@ -1292,9 +1296,11 @@ // If errors occur, display them if ( [mySQLConnection lastQueryWasCancelled] || ([errorsString length] && !queryIsTableSorter)) { +#ifndef SP_REFACTOR // set the error text [errorText setString:[errorsString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; [[errorTextScrollView verticalScroller] setFloatValue:1.0f]; +#endif // try to select the line x of the first error if error message with ID 1064 contains "at line x" // by capturing the last number of the error string @@ -1368,6 +1374,9 @@ [queryInfoButton setState:NSOffState]; [self toggleQueryInfoPaneCollapse:queryInfoButton]; } +#else + if ( [errorsString length] > 0 ) + NSRunAlertPanel(LOCAL(@"Query Error"), @"%@", LOCAL(@"OK"), nil, nil, errorsString); #endif } @@ -1530,11 +1539,11 @@ [autouppercaseKeywordsMenuItem setState:(YES?NSOnState:NSOffState)]; #endif +#ifndef SP_REFACTOR if ( [[SPQueryController sharedQueryController] historyForFileURL:[tableDocumentInstance fileURL]] ) [self performSelectorOnMainThread:@selector(historyItemsHaveBeenUpdated:) withObject:self waitUntilDone:YES]; // Populate query favorites -#ifndef SP_REFACTOR [self queryFavoritesHaveBeenUpdated:nil]; #endif diff --git a/Source/SPDatabaseData.m b/Source/SPDatabaseData.m index 2317902e..1ff4afa6 100644 --- a/Source/SPDatabaseData.m +++ b/Source/SPDatabaseData.m @@ -26,7 +26,11 @@ #import "SPDatabaseData.h" #import "SPServerSupport.h" #import "SPDatabaseCharacterSets.h" +#ifndef SP_REFACTOR #import "SPMySQL.h" +#else +#import +#endif @interface SPDatabaseData (PrivateAPI) diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h index 1c6fe296..8e239344 100644 --- a/Source/SPDatabaseDocument.h +++ b/Source/SPDatabaseDocument.h @@ -247,6 +247,7 @@ SPDatabaseData, SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPS @property (assign) id databaseNameField; @property (assign) id databaseEncodingButton; @property (assign) id addDatabaseButton; +@property (assign) id chooseDatabaseButton; @property (assign) id databaseRenameNameField; @property (assign) id renameDatabaseButton; @@ -293,8 +294,8 @@ SPDatabaseData, SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPS - (void)selectDatabase:(NSString *)aDatabase item:(NSString *)anItem; - (IBAction)addDatabase:(id)sender; - (IBAction)removeDatabase:(id)sender; -#ifndef SP_REFACTOR /* method decls */ - (IBAction)refreshTables:(id)sender; +#ifndef SP_REFACTOR /* method decls */ - (IBAction)copyDatabase:(id)sender; #endif - (IBAction)renameDatabase:(id)sender; diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 529b05f5..a9365b52 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -35,7 +35,11 @@ enum { #import "SPDatabaseDocument.h" #import "SPConnectionController.h" +#ifndef SP_REFACTOR #import "SPMySQL.h" +#else +#import +#endif #import "SPTablesList.h" #import "SPTableStructure.h" @@ -90,7 +94,7 @@ enum { #ifdef SP_REFACTOR /* headers */ #import "SPAlertSheets.h" -#import "NSNotificationAdditions.h" +#import "NSNotificationCenterThreadingAdditions.h" #import "SPCustomQuery.h" #import "SPDatabaseRename.h" #endif @@ -139,6 +143,7 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; @synthesize databaseRenameSheet; @synthesize databaseRenameNameField; @synthesize renameDatabaseButton; +@synthesize chooseDatabaseButton; #endif - (id)init @@ -815,17 +820,21 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; NSArray *buttons = [alert buttons]; +#ifndef SP_REFACTOR // Change the alert's cancel button to have the key equivalent of return [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; [[buttons objectAtIndex:1] setKeyEquivalent:@"\r"]; +#else + [[buttons objectAtIndex:1] setKeyEquivalent:@"\e"]; // Esc = Cancel + [[buttons objectAtIndex:0] setKeyEquivalent:@"\r"]; // Return = OK +#endif [alert setAlertStyle:NSCriticalAlertStyle]; [alert beginSheetModalForWindow:parentWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"removeDatabase"]; } -#ifndef SP_REFACTOR /** * Refreshes the tables list by calling SPTablesList's updateTables. */ @@ -834,6 +843,7 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; [tablesListInstance updateTables:self]; } +#ifndef SP_REFACTOR /** * Displays the database server variables sheet. */ @@ -913,6 +923,15 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; if (returnCode == NSAlertDefaultReturn) { [self _removeDatabase]; } +#ifdef SP_REFACTOR + else { + // reset chooseDatabaseButton + if([[self database] length]) + [chooseDatabaseButton selectItemWithTitle:[self database]]; + else + [chooseDatabaseButton selectItemAtIndex:0]; + } +#endif } // Add a new database else if ([contextInfo isEqualToString:@"addDatabase"]) { @@ -941,6 +960,15 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; if (returnCode == NSOKButton) { [self _renameDatabase]; } +#ifdef SP_REFACTOR + else { + // reset chooseDatabaseButton + if([[self database] length]) + [chooseDatabaseButton selectItemWithTitle:[self database]]; + else + [chooseDatabaseButton selectItemAtIndex:0]; + } +#endif } #ifndef SP_REFACTOR // Close error status sheet for OPTIMIZE, CHECK, REPAIR etc. @@ -5911,7 +5939,7 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax"; if ([chooseDatabaseButton indexOfItemWithTitle:targetDatabaseName] == NSNotFound || ![mySQLConnection selectDatabase:targetDatabaseName]) #else - if ( ![mySQLConnection selectDB:targetDatabaseName] ) + if ( ![mySQLConnection selectDatabase:targetDatabaseName] ) #endif { diff --git a/Source/SPDatabaseInfo.m b/Source/SPDatabaseInfo.m index fc487718..71dd489c 100644 --- a/Source/SPDatabaseInfo.m +++ b/Source/SPDatabaseInfo.m @@ -24,7 +24,11 @@ #import "SPDBActionCommons.h" #import "SPDatabaseInfo.h" +#ifndef SP_REFACTOR #import "SPMySQL.h" +#else +#import +#endif @implementation SPDatabaseInfo diff --git a/Source/SPDatabaseRename.m b/Source/SPDatabaseRename.m index 1877e955..23ed2593 100644 --- a/Source/SPDatabaseRename.m +++ b/Source/SPDatabaseRename.m @@ -26,7 +26,11 @@ #import "SPDatabaseRename.h" #import "SPTableCopy.h" #import "SPDatabaseInfo.h" +#ifndef SP_REFACTOR #import "SPMySQL.h" +#else +#import +#endif @implementation SPDatabaseRename diff --git a/Source/SPDatabaseStructure.m b/Source/SPDatabaseStructure.m index 3579e269..f6174ab8 100644 --- a/Source/SPDatabaseStructure.m +++ b/Source/SPDatabaseStructure.m @@ -28,7 +28,11 @@ #import "SPConnectionDelegate.h" #import "SPTablesList.h" #import "RegexKitLite.h" +#ifndef SP_REFACTOR #import "SPMySQL.h" +#else +#import +#endif #import @interface SPDatabaseStructure (Private_API) diff --git a/Source/SPDatabaseViewController.m b/Source/SPDatabaseViewController.m index 7fb6b794..4c1c6cac 100644 --- a/Source/SPDatabaseViewController.m +++ b/Source/SPDatabaseViewController.m @@ -32,9 +32,11 @@ #import "SPTableData.h" #import "SPTablesList.h" #import "SPTableTriggers.h" -#import "SPMySQL.h" #ifdef SP_REFACTOR /* headers */ +#import #import "SPTableStructure.h" +#else +#import "SPMySQL.h" #endif @interface SPDatabaseDocument (SPDatabaseViewControllerPrivateAPI) diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m index 549c994e..d994e35b 100644 --- a/Source/SPFieldEditorController.m +++ b/Source/SPFieldEditorController.m @@ -35,7 +35,11 @@ #include #import "SPCustomQuery.h" #import "SPTableContent.h" +#ifndef SP_REFACTOR #import "SPMySQLGeometryData.h" +#else +#import +#endif @interface SPFieldEditorController (SPFieldEditorControllerDelegate) @@ -43,6 +47,10 @@ @end +#ifdef SP_REFACTOR +/* Suppress deprecation warning for beginSheetForDirectory: until Sequel Pro team can migrate */ +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif @implementation SPFieldEditorController @@ -1135,7 +1143,7 @@ NSUInteger bitValue = 0x1; for(i=0; i0; i--) { - [[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i]] setState:[[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i-1]] state]]; + [(NSButton*)[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i]] setState:[(NSButton*)[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i-1]] state]]; } [[self valueForKeyPath:@"bitSheetBitButton0"] setState:NSOffState]; break; case 4: // shift right for(i=0; i0; i--) { - [[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i]] setState:[[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i-1]] state]]; + [(NSButton*)[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i]] setState:[(NSButton*)[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i-1]] state]]; } [[self valueForKeyPath:@"bitSheetBitButton0"] setState:aBit]; break; case 6: // rotate right - aBit = [[self valueForKeyPath:@"bitSheetBitButton0"] state]; + aBit = [(NSButton*)[self valueForKeyPath:@"bitSheetBitButton0"] state]; for(i=0; i 64) ? 64 : maxTextLength); - if([sender state] == NSOnState) { + if([(NSButton*)sender state] == NSOnState) { for(i=0; i +#endif #define SP_NUMBER_OF_RECORDS_STRING NSLocalizedString(@"%ld of %@%lu records", @"Label showing the index of the selected CSV row") diff --git a/Source/SPIndexesController.m b/Source/SPIndexesController.m index f4f03d28..20f22dd0 100644 --- a/Source/SPIndexesController.m +++ b/Source/SPIndexesController.m @@ -28,7 +28,11 @@ #import "SPServerSupport.h" #import "SPTableContent.h" #import "SPTableData.h" +#ifndef SP_REFACTOR #import "SPMySQL.h" +#else +#import +#endif #import "SPDatabaseDocument.h" #import "SPTablesList.h" #import "SPTableView.h" diff --git a/Source/SPQueryController.m b/Source/SPQueryController.m index 6c425bc7..8a2a5902 100644 --- a/Source/SPQueryController.m +++ b/Source/SPQueryController.m @@ -403,6 +403,7 @@ static SPQueryController *sharedQueryController = nil; #endif } +#ifndef SP_REFACTOR /** * Return the AutoSaveName of the Query Console. */ @@ -410,6 +411,7 @@ static SPQueryController *sharedQueryController = nil; { return SPQueryConsoleWindowAutoSaveName; } +#endif /** * Updates the filtered result set based on any filter string and whether or not diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m index 1b5ce3dc..da4e56c5 100644 --- a/Source/SPQueryFavoriteManager.m +++ b/Source/SPQueryFavoriteManager.m @@ -285,6 +285,7 @@ */ - (IBAction)saveFavoriteToFile:(id)sender { +#ifndef SP_REFACTOR NSSavePanel *panel = [NSSavePanel savePanel]; [panel setAllowedFileTypes:[NSArray arrayWithObject:SPFileExtensionSQL]]; @@ -294,17 +295,17 @@ [panel setCanSelectHiddenExtension:YES]; [panel setCanCreateDirectories:YES]; -#ifndef SP_REFACTOR [panel setAccessoryView:[SPEncodingPopupAccessory encodingAccessory:[prefs integerForKey:SPLastSQLFileEncoding] includeDefaultEntry:NO encodingPopUp:&encodingPopUp]]; -#endif [encodingPopUp setEnabled:YES]; [panel beginSheetForDirectory:nil file:[favoriteNameTextField stringValue] modalForWindow:[self window] modalDelegate:self didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:@"saveQuery"]; +#endif } - (IBAction)exportFavorites:(id)sender { +#ifndef SP_REFACTOR NSSavePanel *panel = [NSSavePanel savePanel]; [panel setAllowedFileTypes:[NSArray arrayWithObject:SPFileExtensionDefault]]; @@ -315,10 +316,12 @@ [panel setCanCreateDirectories:YES]; [panel beginSheetForDirectory:nil file:nil modalForWindow:[self window] modalDelegate:self didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:@"exportFavorites"]; +#endif } - (IBAction)importFavoritesByAdding:(id)sender { +#ifndef SP_REFACTOR NSOpenPanel *panel = [NSOpenPanel openPanel]; [panel setCanSelectHiddenExtension:YES]; [panel setDelegate:self]; @@ -333,6 +336,7 @@ modalDelegate:self didEndSelector:@selector(importPanelDidEnd:returnCode:contextInfo:) contextInfo:NULL]; +#endif } - (IBAction)importFavoritesByReplacing:(id)sender @@ -740,6 +744,7 @@ */ - (void)importPanelDidEnd:(NSOpenPanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { +#ifndef SP_REFACTOR if (returnCode == NSOKButton) { @@ -798,6 +803,7 @@ } } } +#endif } @@ -806,15 +812,14 @@ */ - (void)savePanelDidEnd:(NSSavePanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { +#ifndef SP_REFACTOR if([contextInfo isEqualToString:@"saveQuery"]) { if (returnCode == NSOKButton) { NSError *error = nil; -#ifndef SP_REFACTOR [prefs setInteger:[[encodingPopUp selectedItem] tag] forKey:SPLastSQLFileEncoding]; [prefs synchronize]; -#endif [[favoriteQueryTextView string] writeToURL:[panel URL] atomically:YES encoding:[[encodingPopUp selectedItem] tag] error:&error]; @@ -866,6 +871,7 @@ } } +#endif } - (void)_initWithNoSelection diff --git a/Source/SPSSHTunnel.h b/Source/SPSSHTunnel.h index 231a41a6..64edd3a2 100644 --- a/Source/SPSSHTunnel.h +++ b/Source/SPSSHTunnel.h @@ -23,8 +23,13 @@ // // More info at +#ifndef SP_REFACTOR #import "SPMySQLConnectionProxy.h" #import "SPMySQLConstants.h" +#else +#import +#import +#endif @interface SPSSHTunnel : NSObject { diff --git a/Source/SPSSHTunnel.m b/Source/SPSSHTunnel.m index 1d4870b2..2820d1fd 100644 --- a/Source/SPSSHTunnel.m +++ b/Source/SPSSHTunnel.m @@ -27,7 +27,11 @@ #import "RegexKitLite.h" #import "SPKeychain.h" #import "SPAlertSheets.h" +#ifndef SP_REFACTOR #import "SPMySQL.h" +#else +#import +#endif #import diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 87056e20..23bac322 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -37,9 +37,11 @@ #import "SPQueryController.h" #import "SPQueryDocumentsController.h" #import "SPTextAndLinkCell.h" -#import "SPMySQL.h" #ifndef SP_REFACTOR +#import "SPMySQL.h" #import "QLPreviewPanel.h" +#else +#import #endif #import "SPFieldEditorController.h" #import "SPTooltip.h" @@ -2009,10 +2011,15 @@ NSArray *buttons = [alert buttons]; +#ifndef SP_REFACTOR // Change the alert's cancel button to have the key equivalent of return [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; [[buttons objectAtIndex:1] setKeyEquivalent:@"\r"]; +#else + [[buttons objectAtIndex:0] setKeyEquivalent:@"\r"]; + [[buttons objectAtIndex:1] setKeyEquivalent:@"\e"]; +#endif [alert setShowsSuppressionButton:NO]; [[alert suppressionButton] setState:NSOffState]; @@ -2684,7 +2691,6 @@ { [[contentFilters objectForKey:compareType] addObjectsFromArray:[[prefs objectForKey:SPContentFilters] objectForKey:compareType]]; } -#endif // Load doc-based user-defined content filters if([[SPQueryController sharedQueryController] contentFilterForFileURL:[tableDocumentInstance fileURL]]) { @@ -2692,6 +2698,7 @@ if([filters objectForKey:compareType]) [[contentFilters objectForKey:compareType] addObjectsFromArray:[filters objectForKey:compareType]]; } +#endif // Rebuild operator popup menu NSUInteger i = 0; diff --git a/Source/SPTableCopy.m b/Source/SPTableCopy.m index 539b83af..5efc91c0 100644 --- a/Source/SPTableCopy.m +++ b/Source/SPTableCopy.m @@ -24,7 +24,11 @@ #import "SPDBActionCommons.h" #import "SPTableCopy.h" +#ifndef SP_REFACTOR #import "SPMySQL.h" +#else +#import +#endif @implementation SPTableCopy diff --git a/Source/SPTableData.m b/Source/SPTableData.m index b2626057..ac40d94e 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -30,7 +30,11 @@ #import "SPAlertSheets.h" #import "RegexKitLite.h" #import "SPServerSupport.h" +#ifndef SP_REFACTOR #import "SPMySQL.h" +#else +#import +#endif #include @interface SPTableData (PrivateAPI) diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m index c6f20ded..6fbc6aac 100644 --- a/Source/SPTableStructure.m +++ b/Source/SPTableStructure.m @@ -36,7 +36,11 @@ #import "SPIndexesController.h" #import "RegexKitLite.h" #import "SPTableFieldValidation.h" +#ifndef SP_REFACTOR #import "SPMySQL.h" +#else +#import +#endif @interface SPTableStructure (PrivateAPI) @@ -699,10 +703,15 @@ NSArray *buttons = [alert buttons]; +#ifndef SP_REFACTOR // Change the alert's cancel button to have the key equivalent of return [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; [[buttons objectAtIndex:1] setKeyEquivalent:@"\r"]; +#else + [[buttons objectAtIndex:0] setKeyEquivalent:@"\r"]; + [[buttons objectAtIndex:1] setKeyEquivalent:@"\e"]; +#endif [alert beginSheetModalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self didEndSelector:@selector(removeFieldSheetDidEnd:returnCode:contextInfo:) contextInfo:(hasForeignKey) ? @"removeFieldAndForeignKey" : @"removeField"]; } diff --git a/Source/SPTableStructureDelegate.m b/Source/SPTableStructureDelegate.m index d0bbbf75..b77c70f4 100644 --- a/Source/SPTableStructureDelegate.m +++ b/Source/SPTableStructureDelegate.m @@ -30,7 +30,11 @@ #import "SPTableData.h" #import "SPTableView.h" #import "SPTableFieldValidation.h" +#ifndef SP_REFACTOR #import "SPMySQL.h" +#else +#import +#endif @implementation SPTableStructure (SPTableStructureDelegate) diff --git a/Source/SPTableView.m b/Source/SPTableView.m index e135e16b..3fced944 100644 --- a/Source/SPTableView.m +++ b/Source/SPTableView.m @@ -241,6 +241,34 @@ emptyDoubleClickAction = aSelector; } +#ifdef SP_REFACTOR + +- (void)delete:(id)sender +{ + if ( [[self delegate] respondsToSelector:@selector(removeField:)] ) + { + [[self delegate] performSelector:@selector(removeField:) withObject:self]; + } + else if ( [[self delegate] respondsToSelector:@selector(removeIndex:)] ) + { + [[self delegate] performSelector:@selector(removeIndex:) withObject:self]; + } +} + + +- (BOOL)validateMenuItem:(NSMenuItem *)menuItem +{ + if ( [menuItem action] == @selector(delete:) ) + { + if ( [self numberOfSelectedRows] == 0 ) + return NO; + } + + return YES; +} + +#endif + @end diff --git a/Source/SPTablesList.h b/Source/SPTablesList.h index 6da4f6cc..4f406890 100644 --- a/Source/SPTablesList.h +++ b/Source/SPTablesList.h @@ -156,9 +156,11 @@ #ifndef SP_REFACTOR /* method decls */ - (void)selectTableAtIndex:(NSNumber *)row; - (void)makeTableListFilterHaveFocus; +#endif // Getters - (NSArray *)selectedTableNames; +#ifndef SP_REFACTOR /* method decls */ - (NSArray *)selectedTableItems; - (NSArray *)selectedTableTypes; #endif @@ -199,16 +201,18 @@ @property (assign) SPTableContent* tableContentInstance; @property (assign) id toolbarAddButton; @property (assign) id toolbarDeleteButton; +@property (assign) id toolbarReloadButton; @property (assign) id tableSheet; @property (assign) id tableNameField; @property (assign) id tableEncodingButton; @property (assign) id tableTypeButton; @property (assign) id databaseDataInstance; @property (assign) id addTableButton; -@property (assign) NSTableView* tablesListView; +@property (assign) SPTableView* tablesListView; @property (assign) SQLSidebarViewController* sidebarViewController; - (BOOL)selectionShouldChangeInTableView:(NSTableView *)aTableView; - (void)setDatabaseDocument:(SPDatabaseDocument*)val; +- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex; #endif @end diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index 0283eb98..8e2e8316 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -27,7 +27,11 @@ #import "SPDatabaseDocument.h" #import "SPTableStructure.h" #import "SPDatabaseViewController.h" +#ifndef SP_REFACTOR #import "SPMySQL.h" +#else +#import +#endif #ifndef SP_REFACTOR /* headers */ #import "SPTableContent.h" @@ -74,8 +78,8 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; - (void)_addTable; #ifndef SP_REFACTOR - (void)_copyTable; -- (void)_renameTableOfType:(SPTableType)tableType from:(NSString *)oldTableName to:(NSString *)newTableName; #endif +- (void)_renameTableOfType:(SPTableType)tableType from:(NSString *)oldTableName to:(NSString *)newTableName; @end @@ -86,6 +90,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; @synthesize databaseDataInstance; @synthesize toolbarAddButton; @synthesize toolbarDeleteButton; +@synthesize toolbarReloadButton; @synthesize tableSourceInstance; @synthesize tableContentInstance; @synthesize tableSheet; @@ -273,6 +278,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; } +#ifndef SP_REFACTOR // Add the table headers even if no tables were found if (tableListContainsViews) { [tables insertObject:NSLocalizedString(@"TABLES & VIEWS",@"header for table & views list") atIndex:0]; @@ -282,9 +288,14 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; } [tableTypes insertObject:[NSNumber numberWithInteger:SPTableTypeNone] atIndex:0]; +#endif #ifndef SP_REFACTOR /* ui manipulation */ [[tablesListView onMainThread] reloadData]; +#else + [sidebarViewController setTableNames:[self allTableNames] selectedTableName:selectedTableName]; + [sidebarViewController tableViewSelectionDidChange:nil]; + #endif // if the previous selected table still exists, select it @@ -432,10 +443,15 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; NSArray *buttons = [alert buttons]; +#ifndef SP_REFACTOR // Change the alert's cancel button to have the key equivalent of return [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; [[buttons objectAtIndex:1] setKeyEquivalent:@"\r"]; +#else + [[buttons objectAtIndex:0] setKeyEquivalent:@"\r"]; // Return = OK + [[buttons objectAtIndex:1] setKeyEquivalent:@"\e"]; // Esc = Cancel +#endif NSIndexSet *indexes = [tablesListView selectedRowIndexes]; @@ -777,7 +793,9 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; { // First handle empty or multiple selections if (!selectionDetails || ![selectionDetails objectForKey:@"name"]) { +#ifndef SP_REFACTOR NSIndexSet *indexes = [tablesListView selectedRowIndexes]; +#endif // Update the selected table name and type if (selectedTableName) [selectedTableName release]; selectedTableName = nil; @@ -1099,7 +1117,6 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; #endif } -#ifndef SP_REFACTOR /* getters */ #pragma mark - #pragma mark Getter methods @@ -1120,6 +1137,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; return selTables; } +#ifndef SP_REFACTOR /* getters */ - (NSArray *)selectedTableItems { NSIndexSet *indexes = [tablesListView selectedRowIndexes]; @@ -1461,7 +1479,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; { return ![tableDocumentInstance isWorking]; } - +#endif /** * Renames a table (in tables-array and mysql-db). @@ -1516,13 +1534,16 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; SPBeginAlertSheet( NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil, [myException reason]); } +#ifndef SP_REFACTOR // Set window title to reflect the new table name [tableDocumentInstance updateWindowTitle:self]; +#endif // Query the structure of all databases in the background (mainly for completion) [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:[tableDocumentInstance databaseStructureRetrieval] withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]]; } +#ifndef SP_REFACTOR #pragma mark - #pragma mark TableView delegate methods @@ -1862,6 +1883,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; if (substringRange.location == NSNotFound) continue; } +#ifndef SP_REFACTOR // Add a title if necessary if ((tableType == SPTableTypeTable || tableType == SPTableTypeView) && lastTableType == NSNotFound) { @@ -1877,6 +1899,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [filteredTables addObject:NSLocalizedString(@"PROCS & FUNCS",@"header for procs & funcs list")]; [filteredTableTypes addObject:[NSNumber numberWithInteger:SPTableTypeNone]]; } +#endif lastTableType = tableType; // Add the item @@ -1910,18 +1933,12 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; } #endif -#ifdef SP_REFACTOR - [sidebarViewController setTableNames:[self allTableNames]]; -#endif - +#ifndef SP_REFACTOR // 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] -#ifdef SP_REFACTOR - - 1 -#endif - ] byExtendingSelection:NO]; + if (selectedTableName) [tablesListView selectRowIndexes:[NSIndexSet indexSetWithIndex:[filteredTables indexOfObject:selectedTableName]] byExtendingSelection:NO]; [tablesListView reloadData]; +#endif } /** @@ -2008,8 +2025,8 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; tableListContainsViews = NO; selectedTableType = SPTableTypeNone; selectedTableName = nil; +#ifndef SP_REFACTOR [tables addObject:NSLocalizedString(@"TABLES",@"header for table list")]; -#ifndef SP_REFACTOR /* font */ smallSystemFont = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; #endif } @@ -2091,7 +2108,6 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; } #endif -#ifndef SP_REFACTOR /* operations performed on whole tables */ /** * Removes the selected object (table, view, procedure, function, etc.) from the database and tableView. @@ -2178,15 +2194,21 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [tablesListView deselectAll:self]; +#ifndef SP_REFACTOR // set window title [tableDocumentInstance updateWindowTitle:self]; - +#endif +#ifdef SP_REFACTOR + [sidebarViewController setTableNames:filteredTables selectedTableName:nil]; +#endif // Query the structure of all databases in the background (mainly for completion) [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:[tableDocumentInstance databaseStructureRetrieval] withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]]; } +#ifndef SP_REFACTOR /* operations performed on whole tables */ + /** * Trucates the selected table(s). */ @@ -2318,6 +2340,10 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [tableDocumentInstance viewStructure:self]; #endif +#ifdef SP_REFACTOR + [sidebarViewController setTableNames:[self allTableNames] selectedTableName:selectedTableName]; +#endif + // Query the structure of all databases in the background (mainly for completion) [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:[tableDocumentInstance databaseStructureRetrieval] withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]]; @@ -2527,6 +2553,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; } } } +#endif /** * Renames a table, view, procedure or function. Also handles only changes in case! @@ -2616,6 +2643,5 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [NSException raise:@"Object of unknown type" format:NSLocalizedString(@"An error occured while renaming. '%@' is of an unknown type.", @"rename error - don't know what type the renamed thing is"), oldTableName]; } -#endif @end diff --git a/Source/SPTextView.h b/Source/SPTextView.h index ac4391d8..3f70edde 100644 --- a/Source/SPTextView.h +++ b/Source/SPTextView.h @@ -114,6 +114,7 @@ @property (assign) SPDatabaseDocument *tableDocumentInstance; @property (assign) SPTablesList *tablesListInstance; @property (assign) SPCustomQuery *customQueryInstance; +@property (assign) SPMySQLConnection *mySQLConnection; #endif #ifndef SP_REFACTOR diff --git a/Source/SPTextView.m b/Source/SPTextView.m index c4b600f8..2b2e5e04 100644 --- a/Source/SPTextView.m +++ b/Source/SPTextView.m @@ -36,7 +36,11 @@ #import "SPBundleHTMLOutputController.h" #import "SPDatabaseViewController.h" #import "SPAppController.h" +#ifndef SP_REFACTOR #import "SPMySQL.h" +#else +#import +#endif #import "SPDatabaseStructure.h" #pragma mark - @@ -109,6 +113,7 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS @synthesize tableDocumentInstance; @synthesize tablesListInstance; @synthesize customQueryInstance; +@synthesize mySQLConnection; #endif /** -- cgit v1.2.3