aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/ImageAndTextCell.m8
-rw-r--r--Source/SPAboutController.m7
-rw-r--r--Source/SPAlertSheets.m4
-rw-r--r--Source/SPAppController.h2
-rw-r--r--Source/SPAppleScriptSupport.m17
-rw-r--r--Source/SPBundleEditorController.h13
-rw-r--r--Source/SPBundleEditorController.m159
-rw-r--r--Source/SPBundleHTMLOutputController.h6
-rw-r--r--Source/SPCSVExporter.m66
-rw-r--r--Source/SPConnectionController.h2
-rw-r--r--Source/SPConnectionController.m2
-rw-r--r--Source/SPConnectionControllerDelegate.m4
-rw-r--r--Source/SPConnectionDelegate.m2
-rw-r--r--Source/SPConstants.m10
-rw-r--r--Source/SPContentFilterManager.h5
-rw-r--r--Source/SPCopyTable.h13
-rw-r--r--Source/SPCopyTable.m133
-rw-r--r--Source/SPCustomQuery.m64
-rw-r--r--Source/SPDataCellFormatter.h4
-rw-r--r--Source/SPDataImport.m69
-rw-r--r--Source/SPDatabaseCopy.m14
-rw-r--r--Source/SPDatabaseDocument.m10
-rw-r--r--Source/SPDatabaseViewController.m1
-rw-r--r--Source/SPExportController.m6
-rw-r--r--Source/SPExportFile.m5
-rw-r--r--Source/SPExportFileNameTokenObject.h8
-rw-r--r--Source/SPExportFileNameTokenObject.m2
-rw-r--r--Source/SPExportFileUtilities.m44
-rw-r--r--Source/SPExportInitializer.m5
-rw-r--r--Source/SPFieldEditorController.h7
-rw-r--r--Source/SPFieldMapperController.m14
-rw-r--r--Source/SPGeneralPreferencePane.h5
-rw-r--r--Source/SPGeneralPreferencePane.m131
-rw-r--r--Source/SPNotLoaded.m25
-rw-r--r--Source/SPPreferencesUpgrade.m4
-rw-r--r--Source/SPPrintController.m29
-rw-r--r--Source/SPProcessListController.m2
-rw-r--r--Source/SPQueryController.h4
-rw-r--r--Source/SPQueryFavoriteManager.h5
-rw-r--r--Source/SPQueryFavoriteManager.m2
-rw-r--r--Source/SPSQLExporter.h6
-rw-r--r--Source/SPSQLExporter.m9
-rw-r--r--Source/SPSSHTunnel.m13
-rw-r--r--Source/SPTableCopy.h15
-rw-r--r--Source/SPTableCopy.m46
-rw-r--r--Source/SPTableFieldValidation.m2
-rw-r--r--Source/SPTableInfo.m6
-rw-r--r--Source/SPTableStructureDelegate.m2
-rw-r--r--Source/SPTableTriggers.m3
-rw-r--r--Source/SPTextView.m22
-rw-r--r--Source/SPUserMO.m34
-rw-r--r--Source/SPUserManager.m6
-rw-r--r--Source/SPWindow.m1
53 files changed, 521 insertions, 557 deletions
diff --git a/Source/ImageAndTextCell.m b/Source/ImageAndTextCell.m
index e3c835f0..61c37564 100644
--- a/Source/ImageAndTextCell.m
+++ b/Source/ImageAndTextCell.m
@@ -167,12 +167,10 @@
- (NSSize)cellSize
{
NSSize cellSize = [super cellSize];
+
cellSize.width += (image ? [image size].width : 0) + ((1 - MIN(1,INDENT_AMOUNT)) * 3) + (INDENT_AMOUNT * _indentationLevel) + 2;
- // TODO : this has to be generalized yet
- if (image != nil)
- cellSize.height += 2;
- else
- cellSize.height += 8;
+ cellSize.height += image ? 2 : 8;
+
return cellSize;
}
diff --git a/Source/SPAboutController.m b/Source/SPAboutController.m
index 0e0e7a09..1e0c82c2 100644
--- a/Source/SPAboutController.m
+++ b/Source/SPAboutController.m
@@ -25,6 +25,9 @@
#import "SPAboutController.h"
+static NSString *SPCreditsFilename = @"Credits";
+static NSString *SPLicenseFilename = @"License";
+
@implementation SPAboutController
/**
@@ -52,10 +55,10 @@
[appBuildVersionTextField setStringValue:[NSString stringWithFormat:@"%@ %@", (isNightly) ? NSLocalizedString(@"Nightly Build", @"nightly build label") : NSLocalizedString(@"Build", @"build label") , [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]];
// Get the credits file contents
- NSAttributedString *credits = [[[NSAttributedString alloc] initWithPath:[[NSBundle mainBundle] pathForResource:@"Credits" ofType:@"rtf"] documentAttributes:nil] autorelease];
+ NSAttributedString *credits = [[[NSAttributedString alloc] initWithPath:[[NSBundle mainBundle] pathForResource:SPCreditsFilename ofType:@"rtf"] documentAttributes:nil] autorelease];
// Get the license file contents
- NSAttributedString *license = [[[NSAttributedString alloc] initWithPath:[[NSBundle mainBundle] pathForResource:@"License" ofType:@"rtf"] documentAttributes:nil] autorelease];
+ NSAttributedString *license = [[[NSAttributedString alloc] initWithPath:[[NSBundle mainBundle] pathForResource:SPLicenseFilename ofType:@"rtf"] documentAttributes:nil] autorelease];
// Set the credits
[[appCreditsTextView textStorage] appendAttributedString:credits];
diff --git a/Source/SPAlertSheets.m b/Source/SPAlertSheets.m
index b9ac1136..41b07e00 100644
--- a/Source/SPAlertSheets.m
+++ b/Source/SPAlertSheets.m
@@ -161,6 +161,6 @@ void SPBeginWaitingAlertSheet(
}
- [NSApp endModalSession:session];
- [NSApp endSheet:[alert window]];
+ [[NSApp onMainThread] endModalSession:session];
+ [[NSApp onMainThread] endSheet:[alert window]];
}
diff --git a/Source/SPAppController.h b/Source/SPAppController.h
index 87ae8e9e..b96b1d75 100644
--- a/Source/SPAppController.h
+++ b/Source/SPAppController.h
@@ -32,6 +32,7 @@
@interface SPAppController : NSObject <FRFeedbackReporterDelegate>
{
+
IBOutlet NSWindow* bundleEditorWindow;
BOOL isNewFavorite;
@@ -56,6 +57,7 @@
NSMutableArray *runningActivitiesArray;
NSString *lastBundleBlobFilesDirectory;
+
}
@property (readwrite, retain) NSString *lastBundleBlobFilesDirectory;
diff --git a/Source/SPAppleScriptSupport.m b/Source/SPAppleScriptSupport.m
index 90ab240e..337a14dc 100644
--- a/Source/SPAppleScriptSupport.m
+++ b/Source/SPAppleScriptSupport.m
@@ -31,23 +31,6 @@
@implementation SPAppController (SPAppleScriptSupport)
-//////////////// Examples to catch AS core events - maybe for further stuff
-// - (void)handleQuitEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
-// {
-// [NSApp terminate:self];
-// }
-// - (void)handleOpenEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
-// {
-// NSLog(@"OPEN ");
-// }
-//
-// - (void)applicationWillFinishLaunching:(NSNotification *)aNotification
-// {
-// NSAppleEventManager *aeManager = [NSAppleEventManager sharedAppleEventManager];
-// [aeManager setEventHandler:self andSelector:@selector(handleQuitEvent:withReplyEvent:) forEventClass:kCoreEventClass andEventID:kAEQuitApplication];
-// [aeManager setEventHandler:self andSelector:@selector(handleOpenEvent:withReplyEvent:) forEventClass:kCoreEventClass andEventID:kAEOpenApplication];
-// }
-
/**
* Is needed to interact with AppleScript for set/get internal SP variables
*/
diff --git a/Source/SPBundleEditorController.h b/Source/SPBundleEditorController.h
index 5ea1658f..7bcf84e2 100644
--- a/Source/SPBundleEditorController.h
+++ b/Source/SPBundleEditorController.h
@@ -42,9 +42,6 @@
IBOutlet NSTextField *fallbackLabelField;
IBOutlet NSTextField *withBlobLabelField;
IBOutlet NSTextField *commandLabelField;
- IBOutlet NSTextField *authorLabelField;
- IBOutlet NSTextField *contactLabelField;
- IBOutlet NSTextField *descriptionLabelField;
IBOutlet NSPopUpButton *inputPopupButton;
IBOutlet NSPopUpButton *inputFallbackPopupButton;
IBOutlet NSPopUpButton *outputPopupButton;
@@ -56,16 +53,17 @@
IBOutlet NSButton *saveButton;
IBOutlet NSButton *cancelButton;
IBOutlet NSButton *helpButton;
- IBOutlet NSButton *showHideMetaButton;
+ IBOutlet NSTextField *metaInfoSummary;
+ IBOutlet NSButton *displayMetaInfoButton;
IBOutlet NSMenuItem *duplicateMenuItem;
IBOutlet NSMenuItem *revealInFinderMenuItem;
IBOutlet SRRecorderControl *keyEquivalentField;
IBOutlet NSButton *disabledCheckbox;
IBOutlet NSScrollView *commandScrollView;
- IBOutlet NSScrollView *descriptionScrollView;
IBOutlet BWSplitView *splitView;
- IBOutlet id undeleteSheet;
+ IBOutlet NSWindow *undeleteSheet;
+ IBOutlet NSWindow *metaInfoSheet;
IBOutlet NSTableView *undeleteTableView;
IBOutlet NSTreeController *commandBundleTreeController;
@@ -128,10 +126,11 @@
- (IBAction)showHelp:(id)sender;
- (IBAction)saveAndCloseWindow:(id)sender;
- (IBAction)reloadBundles:(id)sender;
-- (IBAction)metaButtonChanged:(id)sender;
- (IBAction)performClose:(id)sender;
- (IBAction)undeleteDefaultBundles:(id)sender;
- (IBAction)closeUndeleteDefaultBundlesSheet:(id)sender;
+- (IBAction)displayBundleMetaInfo:(id)sender;
+- (IBAction)closeSheet:(id)sender;
- (BOOL)saveBundle:(NSDictionary*)bundle atPath:(NSString*)aPath;
- (BOOL)cancelRowEditing;
diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m
index 387bfcf1..8d4d1c65 100644
--- a/Source/SPBundleEditorController.m
+++ b/Source/SPBundleEditorController.m
@@ -40,17 +40,18 @@
#define SP_BUNDLEEDITOR_SPLITVIEW_AUTOSAVE_STRING @"SPBundleEditorSplitView"
-@interface SPBundleEditorController (PrivateAPI)
+@interface SPBundleEditorController ()
- (void)_updateBundleDataView;
+- (void)_updateBundleMetaSummary;
- (id)_currentSelectedObject;
- (id)_currentSelectedNode;
-- (void)_enableBundleDataInput:(BOOL)enabled;
-- (void)_enableMetaDataInput:(BOOL)enabled;
+- (void)_enableBundleDataInput:(BOOL)enabled bundleEnabled:(BOOL)bundleEnabled;
- (void)_initTree;
- (NSUInteger)_arrangedScopeIndexForScopeIndex:(NSUInteger)scopeIndex;
- (NSUInteger)_scopeIndexForArrangedScopeIndex:(NSUInteger)scopeIndex;
- (NSUInteger)_arrangedCategoryIndexForScopeIndex:(NSUInteger)scopeIndex andCategory:(NSString*)category;
+- (void)_metaSheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
@end
@@ -73,12 +74,10 @@
}
return self;
-
}
- (void)dealloc
{
-
[inputGeneralScopePopUpMenu release];
[inputInputFieldScopePopUpMenu release];
[inputDataTableScopePopUpMenu release];
@@ -106,14 +105,13 @@
[shellVariableSuggestions release];
[deletedDefaultBundles release];
- if(touchedBundleArray) [touchedBundleArray release], touchedBundleArray = nil;
- if(commandBundleTree) [commandBundleTree release], commandBundleTree = nil;
- if(sortDescriptor) [sortDescriptor release], sortDescriptor = nil;
- if(bundlePath) [bundlePath release], bundlePath = nil;
+ if (touchedBundleArray) [touchedBundleArray release], touchedBundleArray = nil;
+ if (commandBundleTree) [commandBundleTree release], commandBundleTree = nil;
+ if (sortDescriptor) [sortDescriptor release], sortDescriptor = nil;
+ if (bundlePath) [bundlePath release], bundlePath = nil;
if (esUndoManager) [esUndoManager release], esUndoManager = nil;
[super dealloc];
-
}
- (void)awakeFromNib
@@ -800,14 +798,6 @@
}
/**
- * Show/Hide meta data input fields
- */
-- (IBAction)metaButtonChanged:(id)sender
-{
- [self _enableMetaDataInput:([sender state] == NSOnState) ? YES : NO];
-}
-
-/**
* Read all installed bundles and order front the Bundle Editor
*/
- (IBAction)showWindow:(id)sender
@@ -841,7 +831,21 @@
[sender orderOut:nil];
else if ([sender respondsToSelector:@selector(window)])
[[sender window] orderOut:nil];
+}
+- (IBAction)displayBundleMetaInfo:(id)sender
+{
+ [NSApp beginSheet:metaInfoSheet
+ modalForWindow:[self window]
+ modalDelegate:self
+ didEndSelector:@selector(_metaSheetDidEnd:returnCode:contextInfo:)
+ contextInfo:nil];
+}
+
+- (IBAction)closeSheet:(id)sender
+{
+ [NSApp endSheet:[sender window] returnCode:[sender tag]];
+ [[sender window] orderOut:self];
}
/**
@@ -849,7 +853,6 @@
*/
- (IBAction)saveAndCloseWindow:(id)sender
{
-
// Commit all pending edits
if([commandBundleTreeController commitEditing]) {
@@ -1283,7 +1286,6 @@
*/
- (void)outlineViewSelectionDidChange:(NSNotification *)aNotification
{
-
if([aNotification object] != commandsOutlineView) return;
// Remember selected bundle name to reset the name if the user cancelled
@@ -1291,9 +1293,9 @@
if(oldBundleName) [oldBundleName release], oldBundleName = nil;
if(![[self _currentSelectedObject] objectForKey:kChildrenKey]) {
oldBundleName = [[[self _currentSelectedObject] objectForKey:kBundleNameKey] retain];
- [self _enableBundleDataInput:YES];
+ [self _enableBundleDataInput:YES bundleEnabled:![[[self _currentSelectedObject] objectForKey:@"disabled"] boolValue]];
} else {
- [self _enableBundleDataInput:NO];
+ [self _enableBundleDataInput:NO bundleEnabled:NO];
if(oldBundleName) [oldBundleName release], oldBundleName = nil;
}
@@ -1303,6 +1305,7 @@
[touchedBundleArray addObject:oldBundleName];
[self _updateBundleDataView];
+
[commandTextView setSelectedRange:NSMakeRange(0,0)];
}
@@ -1478,7 +1481,6 @@
[commandBundleTreeController rearrangeObjects];
[commandsOutlineView reloadData];
}
-
}
#pragma mark -
@@ -1489,17 +1491,17 @@
*/
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{
-
SEL action = [menuItem action];
- if ( (action == @selector(duplicateCommandBundle:))
- || (action == @selector(revealCommandBundleInFinder:))
- || (action == @selector(saveBundle:))
- || (action == @selector(removeCommandBundle:))
- )
+ if ((action == @selector(duplicateCommandBundle:)) ||
+ (action == @selector(revealCommandBundleInFinder:)) ||
+ (action == @selector(saveBundle:)) ||
+ (action == @selector(removeCommandBundle:)) ||
+ (action == @selector(displayBundleMetaInfo:)))
{
// Allow to record short-cuts used by the Bundle Editor
if([[NSApp mainWindow] firstResponder] == keyEquivalentField) return NO;
+
return ([[commandBundleTreeController selectedObjects] count] == 1 && ![[[commandBundleTreeController selectedObjects] objectAtIndex:0] objectForKey:kChildrenKey]);
}
@@ -1508,7 +1510,6 @@
}
return YES;
-
}
#pragma mark -
@@ -1675,18 +1676,8 @@
doGroupDueToChars = YES;
}
-@end
-
-#pragma mark -
-
-@implementation SPBundleEditorController (PrivateAPI)
-
- (void)_initTree
{
-
- [showHideMetaButton setState:NSOffState];
- [self _enableMetaDataInput:NO];
-
// Re-init commandBundleTree
[[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:kInputFieldScopeArrayIndex] setObject:[NSMutableArray array] forKey:kChildrenKey];
[[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:kDataTableScopeArrayIndex] setObject:[NSMutableArray array] forKey:kChildrenKey];
@@ -1814,7 +1805,7 @@
[commandsOutlineView expandItem:[commandsOutlineView itemAtRow:0] expandChildren:NO];
[self _updateBundleDataView];
- [self _enableBundleDataInput:NO];
+ [self _enableBundleDataInput:NO bundleEnabled:NO];
}
/**
@@ -1822,7 +1813,6 @@
*/
- (void)_updateBundleDataView
{
-
NSInteger anIndex;
if([commandsOutlineView selectedRow] < 0) return;
@@ -1963,6 +1953,9 @@
[fallbackLabelField setHidden:YES];
}
+ // Update the bundle summary text
+ [self _updateBundleMetaSummary];
+
// Validate add and remove bundle button in left bar
[removeButton setEnabled:([[commandBundleTreeController selectedObjects] count] == 1 && ![[[commandBundleTreeController selectedObjects] objectAtIndex:0] objectForKey:kChildrenKey])];
[addButton setEnabled:([[commandBundleTreeController selectionIndexPath] length] > 1)];
@@ -1970,6 +1963,29 @@
}
/**
+ * Update the bundle meta summary text
+ */
+- (void)_updateBundleMetaSummary
+{
+ NSDictionary *currentDict = [self _currentSelectedObject];
+ if (!currentDict) {
+ [metaInfoSummary setStringValue:@""];
+ return;
+ }
+
+ NSMutableString *metaString = [[[NSMutableString alloc] init] autorelease];
+ if ([currentDict objectForKey:@"author"]) {
+ [metaString appendFormat:@"(%@) ", [currentDict objectForKey:@"author"]];
+ } else if ([currentDict objectForKey:@"contact"]) {
+ [metaString appendFormat:@"(%@) ", [currentDict objectForKey:@"contact"]];
+ }
+
+ if ([currentDict objectForKey:@"description"]) [metaString appendString:[currentDict objectForKey:@"description"]];
+
+ [metaInfoSummary setStringValue:metaString];
+}
+
+/**
* Return the current selected object as NSDictionary
*/
- (id)_currentSelectedObject
@@ -1990,7 +2006,6 @@
*/
- (NSUInteger)_arrangedScopeIndexForScopeIndex:(NSUInteger)scopeIndex
{
-
NSString *unsortedBundleName = [[[commandBundleTree objectForKey:kChildrenKey] objectAtIndex:scopeIndex] objectForKey:kBundleNameKey];
if(!unsortedBundleName || ![unsortedBundleName length]) return scopeIndex;
@@ -2005,7 +2020,6 @@
}
return k;
-
}
/**
@@ -2013,7 +2027,6 @@
*/
- (NSUInteger)_scopeIndexForArrangedScopeIndex:(NSUInteger)scopeIndex
{
-
NSString *bName = [[[[[[[commandBundleTreeController arrangedObjects] childNodes] objectAtIndex:0] childNodes] objectAtIndex:scopeIndex] representedObject] objectForKey:kBundleNameKey];
NSUInteger k = 0;
for(id i in [commandBundleTree objectForKey:kChildrenKey]) {
@@ -2027,40 +2040,29 @@
/**
* Enable / disable data input
*/
-- (void)_enableBundleDataInput:(BOOL)enabled
-{
- [nameTextField setEnabled:enabled];
- [inputPopupButton setEnabled:enabled];
- [inputFallbackPopupButton setEnabled:enabled];
- [scopePopupButton setEnabled:enabled];
- [commandTextView setEditable:enabled];
- [outputPopupButton setEnabled:enabled];
- [triggerPopupButton setEnabled:enabled];
- [disabledCheckbox setEnabled:enabled];
- [keyEquivalentField setEnabled:enabled];
- [categoryTextField setEnabled:enabled];
- [tooltipTextField setEnabled:enabled];
+- (void)_enableBundleDataInput:(BOOL)enabled bundleEnabled:(BOOL)bundleEnabled
+{
+
+ // Most of the interface requires both a bundle selected and enabled
+ BOOL enableInterface = enabled && bundleEnabled;
+ [nameTextField setEnabled:enableInterface];
+ [inputPopupButton setEnabled:enableInterface];
+ [inputFallbackPopupButton setEnabled:enableInterface];
+ [scopePopupButton setEnabled:enableInterface];
+ [commandTextView setEditable:enableInterface];
+ [outputPopupButton setEnabled:enableInterface];
+ [triggerPopupButton setEnabled:enableInterface];
+ [keyEquivalentField setEnabled:enableInterface];
+ [categoryTextField setEnabled:enableInterface];
+ [tooltipTextField setEnabled:enableInterface];
+
+ // Always leave the meta fields enabled, and the disabled checkbox.
[authorTextField setEnabled:enabled];
[contactTextField setEnabled:enabled];
[descriptionTextView setEditable:enabled];
-}
+ [displayMetaInfoButton setEnabled:enabled];
-/**
- * Enable / disable meta input
- */
-- (void)_enableMetaDataInput:(BOOL)enabled
-{
- [commandTextView setHidden:enabled];
- [disabledCheckbox setHidden:enabled];
- [commandLabelField setHidden:enabled];
- [commandScrollView setHidden:enabled];
- [authorLabelField setHidden:!enabled];
- [contactLabelField setHidden:!enabled];
- [descriptionLabelField setHidden:!enabled];
- [descriptionTextView setHidden:!enabled];
- [authorTextField setHidden:!enabled];
- [contactTextField setHidden:!enabled];
- [descriptionScrollView setHidden:!enabled];
+ [disabledCheckbox setEnabled:enabled];
}
/**
@@ -2117,5 +2119,12 @@
return returnIndex;
}
+- (void)_metaSheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
+{
+ [sheet makeFirstResponder:nil];
+
+ [self _updateBundleMetaSummary];
+}
+
@end
diff --git a/Source/SPBundleHTMLOutputController.h b/Source/SPBundleHTMLOutputController.h
index de67799c..01460a85 100644
--- a/Source/SPBundleHTMLOutputController.h
+++ b/Source/SPBundleHTMLOutputController.h
@@ -22,11 +22,10 @@
//
// More info at <http://code.google.com/p/sequel-pro/>
-#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
-@interface SPBundleHTMLOutputController : NSWindowController {
-
+@interface SPBundleHTMLOutputController : NSWindowController
+{
IBOutlet WebView *webView;
NSString *docTitle;
@@ -35,7 +34,6 @@
NSString *docUUID;
BOOL suppressExceptionAlerting;
WebPreferences *webPreferences;
-
}
@property(readwrite,retain) NSString *docTitle;
diff --git a/Source/SPCSVExporter.m b/Source/SPCSVExporter.m
index 7850e7ec..4bf6c651 100644
--- a/Source/SPCSVExporter.m
+++ b/Source/SPCSVExporter.m
@@ -118,7 +118,37 @@
[self setExportProcessIsRunning:YES];
lastProgressValue = 0;
-
+
+ // Before the streaming query is started, build an array of numeric columns if a table
+ // is being exported
+ if ([self csvTableName] && (![self csvDataArray])) {
+ NSDictionary *tableDetails = nil;
+
+ // Determine whether the supplied table is actually a table or a view via the CREATE TABLE command, and get the table details
+ SPMySQLResult *queryResult = [connection queryString:[NSString stringWithFormat:@"SHOW CREATE TABLE %@", [[self csvTableName] backtickQuotedString]]];
+ [queryResult setReturnDataAsStrings:YES];
+
+ if ([queryResult numberOfRows]) {
+ id object = [[queryResult getRowAsDictionary] objectForKey:@"Create View"];
+
+ tableDetails = [[NSDictionary alloc] initWithDictionary:(object) ? [[self csvTableData] informationForView:[self csvTableName]] : [[self csvTableData] informationForTable:[self csvTableName]]];
+ }
+
+ // Retrieve the table details via the data class, and use it to build an array containing column numeric status
+ for (NSDictionary *column in [tableDetails objectForKey:@"columns"])
+ {
+ NSString *tableColumnTypeGrouping = [column objectForKey:@"typegrouping"];
+
+ [tableColumnNumericStatus addObject:[NSNumber numberWithBool:
+ ([tableColumnTypeGrouping isEqualToString:@"bit"]
+ || [tableColumnTypeGrouping isEqualToString:@"integer"]
+ || [tableColumnTypeGrouping isEqualToString:@"float"])
+ ]];
+ }
+
+ [tableDetails release];
+ }
+
// Make a streaming request for the data if the data array isn't set
if ((![self csvDataArray]) && [self csvTableName]) {
totalRows = [[connection getFirstFieldFromQuery:[NSString stringWithFormat:@"SELECT COUNT(1) FROM %@", [[self csvTableName] backtickQuotedString]]] integerValue];
@@ -177,35 +207,7 @@
if ([self csvDataArray]) totalRows = [[self csvDataArray] count];
if (([self csvDataArray]) && (![self csvOutputFieldNames])) currentRowIndex++;
-
- if ([self csvTableName] && (![self csvDataArray])) {
-
- NSDictionary *tableDetails = nil;
-
- // Determine whether the supplied table is actually a table or a view via the CREATE TABLE command, and get the table details
- SPMySQLResult *queryResult = [connection queryString:[NSString stringWithFormat:@"SHOW CREATE TABLE %@", [[self csvTableName] backtickQuotedString]]];
-
- [queryResult setReturnDataAsStrings:YES];
-
- if ([queryResult numberOfRows]) {
- id object = [[queryResult getRowAsDictionary] objectForKey:@"Create View"];
-
- tableDetails = [[NSDictionary alloc] initWithDictionary:(object) ? [[self csvTableData] informationForView:[self csvTableName]] : [[self csvTableData] informationForTable:[self csvTableName]]];
- }
- // Retrieve the table details via the data class, and use it to build an array containing column numeric status
- for (NSDictionary *column in [tableDetails objectForKey:@"columns"])
- {
- NSString *tableColumnTypeGrouping = [column objectForKey:@"typegrouping"];
-
- [tableColumnNumericStatus addObject:[NSNumber numberWithBool:([tableColumnTypeGrouping isEqualToString:@"bit"] ||
- [tableColumnTypeGrouping isEqualToString:@"integer"] ||
- [tableColumnTypeGrouping isEqualToString:@"float"])]];
- }
-
- [tableDetails release];
- }
-
// Drop into the processing loop
NSAutoreleasePool *csvExportPool = [[NSAutoreleasePool alloc] init];
@@ -291,12 +293,8 @@
[csvCellString setString:[csvCell description]];
}
- // For NULL values supplied via an array add the unenclosed null string as set in preferences
- if ([csvCellString isEqualToString:[self csvNULLString]]) {
- [csvString appendString:[self csvNULLString]];
- }
// Add empty strings as a pair of enclosing characters.
- else if ([csvCellString length] == 0) {
+ if ([csvCellString length] == 0) {
[csvString appendString:[self csvEnclosingCharacterString]];
[csvString appendString:[self csvEnclosingCharacterString]];
}
diff --git a/Source/SPConnectionController.h b/Source/SPConnectionController.h
index d6599b55..eeb7f2d0 100644
--- a/Source/SPConnectionController.h
+++ b/Source/SPConnectionController.h
@@ -238,7 +238,7 @@
- (IBAction)addGroup:(id)sender;
- (IBAction)removeNode:(id)sender;
- (IBAction)duplicateFavorite:(id)sender;
-- (IBAction)renameFavorite:(id)sender;
+- (IBAction)renameNode:(id)sender;
- (IBAction)makeSelectedFavoriteDefault:(id)sender;
// Import/export favorites
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index af46f564..6b43f01a 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -863,7 +863,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
/**
* Switches the selected favorite/group to editing mode so it can be renamed.
*/
-- (IBAction)renameFavorite:(id)sender
+- (IBAction)renameNode:(id)sender
{
if ([favoritesOutlineView numberOfSelectedRows] == 1) {
[favoritesOutlineView editColumn:0 row:[favoritesOutlineView selectedRow] withEvent:nil select:YES];
diff --git a/Source/SPConnectionControllerDelegate.m b/Source/SPConnectionControllerDelegate.m
index e2557601..352836e3 100644
--- a/Source/SPConnectionControllerDelegate.m
+++ b/Source/SPConnectionControllerDelegate.m
@@ -283,10 +283,10 @@ static NSString *SPDatabaseImage = @"database-small";
{
id field = [notification object];
- [field setStringValue:[self _stripInvalidCharactersFromString:[field stringValue]]];
-
if (((field == standardNameField) || (field == socketNameField) || (field == sshNameField)) && [self selectedFavoriteNode]) {
+ [field setStringValue:[self _stripInvalidCharactersFromString:[field stringValue]]];
+
favoriteNameFieldWasTouched = YES;
BOOL nameFieldIsEmpty = [[field stringValue] isEqualToString:@""];
diff --git a/Source/SPConnectionDelegate.m b/Source/SPConnectionDelegate.m
index 74f1d407..0d41a3ac 100644
--- a/Source/SPConnectionDelegate.m
+++ b/Source/SPConnectionDelegate.m
@@ -71,7 +71,7 @@
{
// If no keychain item is available, return an empty password
- if (![connectionController connectionKeychainItemName]) return @"";
+ if (![connectionController connectionKeychainItemName]) return nil;
// Otherwise, pull the password from the keychain using the details from this connection
SPKeychain *keychain = [[SPKeychain alloc] init];
diff --git a/Source/SPConstants.m b/Source/SPConstants.m
index 4f41531c..79de29a8 100644
--- a/Source/SPConstants.m
+++ b/Source/SPConstants.m
@@ -65,7 +65,7 @@ NSString *SPDataSupportFolder = @"Data";
// General Prefpane
NSString *SPDefaultFavorite = @"DefaultFavorite";
NSString *SPSelectLastFavoriteUsed = @"SelectLastFavoriteUsed";
-NSString *SPLastFavoriteID = @"LastFavoriteID";
+NSString *SPLastFavoriteID = @"SPLastFavoriteID";
NSString *SPAutoConnectToDefault = @"AutoConnectToDefault";
NSString *SPDefaultViewMode = @"DefaultViewMode";
NSString *SPLastViewMode = @"LastViewMode";
@@ -108,9 +108,15 @@ NSString *SPConsoleEnableImportExportLogging = @"ConsoleEnableImportExportLo
NSString *SPConsoleEnableErrorLogging = @"ConsoleEnableErrorLogging";
// Network Prefpane
+#ifndef SP_REFACTOR
NSString *SPConnectionTimeoutValue = @"ConnectionTimeoutValue";
NSString *SPUseKeepAlive = @"UseKeepAlive";
NSString *SPKeepAliveInterval = @"KeepAliveInterval";
+#else
+NSString *SPConnectionTimeoutValue = @"SPConnectionTimeoutValue";
+NSString *SPUseKeepAlive = @"SPUseKeepAlive";
+NSString *SPKeepAliveInterval = @"SPKeepAliveInterval";
+#endif
// Editor Prefpane
NSString *SPCustomQueryEditorFont = @"CustomQueryEditorFont";
@@ -206,7 +212,7 @@ NSString *SPSelectionDetailTypePrimaryKeyed = @"SelectionDetailTypePrimaryK
// URLs
NSString *SPDonationsURL = @"http://www.sequelpro.com/donate/";
-NSString *SPMySQLSearchURL = @"http://search.mysql.com/search/query/search?q=%@&group=refman-%@";
+NSString *SPMySQLSearchURL = @"http://dev.mysql.com/doc/refman/%@/%@/%@.html";
NSString *SPDevURL = @"http://code.google.com/p/sequel-pro/";
// Toolbar constants
diff --git a/Source/SPContentFilterManager.h b/Source/SPContentFilterManager.h
index ec23afe6..dda8995c 100644
--- a/Source/SPContentFilterManager.h
+++ b/Source/SPContentFilterManager.h
@@ -31,10 +31,9 @@
@end
-#ifndef SP_REFACTOR /* ivars */
@interface SPContentFilterManager : NSWindowController
-#else
-@interface SPContentFilterManager : NSWindowController <NSOpenSavePanelDelegate>
+#ifdef SP_REFACTOR /* ivars */
+<NSOpenSavePanelDelegate>
#endif
{
#ifndef SP_REFACTOR /* ivars */
diff --git a/Source/SPCopyTable.h b/Source/SPCopyTable.h
index 6e9187f5..84db1e9d 100644
--- a/Source/SPCopyTable.h
+++ b/Source/SPCopyTable.h
@@ -24,11 +24,15 @@
#import "SPTableView.h"
+@class SPDataStorage;
+@class SPTableContent;
+
#define SP_MAX_CELL_WIDTH_MULTICOLUMN 200
#define SP_MAX_CELL_WIDTH 400
-@class SPDataStorage;
-@class SPTableContent;
+extern NSInteger SPEditMenuCopy;
+extern NSInteger SPEditMenuCopyWithColumns;
+extern NSInteger SPEditCopyAsSQL;
/*!
@class copyTable
@@ -50,7 +54,6 @@
NSRange fieldEditorSelectedRange;
NSString *tmpBlobFileDirectory;
-
}
@property(readwrite,assign) NSString *tmpBlobFileDirectory;
@@ -189,7 +192,3 @@
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command;
@end
-
-extern NSInteger MENU_EDIT_COPY;
-extern NSInteger MENU_EDIT_COPY_WITH_COLUMN;
-extern NSInteger MENU_EDIT_COPY_AS_SQL;
diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m
index 4460630c..ea0fe720 100644
--- a/Source/SPCopyTable.m
+++ b/Source/SPCopyTable.m
@@ -42,18 +42,17 @@
#import "SPTablesList.h"
#import <SPMySQL/SPMySQL.h>
-NSInteger MENU_EDIT_COPY = 2001;
-NSInteger MENU_EDIT_COPY_WITH_COLUMN = 2002;
-NSInteger MENU_EDIT_COPY_AS_SQL = 2003;
+NSInteger SPEditMenuCopy = 2001;
+NSInteger SPEditMenuCopyWithColumns = 2002;
+NSInteger SPEditCopyAsSQL = 2003;
-NSInteger kBlobExclude = 1;
-NSInteger kBlobInclude = 2;
-NSInteger kBlobAsFile = 3;
-NSInteger kBlobAsImageFile = 4;
+static const NSInteger kBlobExclude = 1;
+static const NSInteger kBlobInclude = 2;
+static const NSInteger kBlobAsFile = 3;
+static const NSInteger kBlobAsImageFile = 4;
@implementation SPCopyTable
-
/**
* Hold the selected range of the current table cell editor to be able to set this passed
* selection in the field editor's editTextView
@@ -64,25 +63,21 @@ NSInteger kBlobAsImageFile = 4;
/**
* Cell editing in SPCustomQuery or for views in SPTableContent
*/
-- (BOOL) isCellEditingMode
+- (BOOL)isCellEditingMode
{
-
return ([[self delegate] isKindOfClass:[SPCustomQuery class]]
|| ([[self delegate] isKindOfClass:[SPTableContent class]]
&& [(NSObject*)[self delegate] valueForKeyPath:@"tablesListInstance"]
&& [(SPTablesList*)([(NSObject*)[self delegate] valueForKeyPath:@"tablesListInstance"]) tableType] == SPTableTypeView));
-
}
/**
* Check if current edited cell represents a class other than a normal NSString
* like pop-up menus for enum or set
*/
-- (BOOL) isCellComplex
+- (BOOL)isCellComplex
{
-
return (![[self preparedCellAtColumn:[self editedColumn] row:[self editedRow]] isKindOfClass:[SPTextAndLinkCell class]]);
-
}
#pragma mark -
@@ -90,33 +85,29 @@ NSInteger kBlobAsImageFile = 4;
/**
* Handles the general Copy action of selected rows in the table according to sender
*/
-- (void) copy:(id)sender
+- (void)copy:(id)sender
{
#ifndef SP_REFACTOR /* copy table rows */
NSString *tmp = nil;
- if([sender tag] == MENU_EDIT_COPY_AS_SQL) {
+ if ([sender tag] == SPEditCopyAsSQL) {
tmp = [self rowsAsSqlInsertsOnlySelectedRows:YES];
- if ( nil != tmp )
- {
+
+ if (tmp != nil){
NSPasteboard *pb = [NSPasteboard generalPasteboard];
- [pb declareTypes:[NSArray arrayWithObjects: NSStringPboardType, nil]
- owner:nil];
+ [pb declareTypes:[NSArray arrayWithObjects: NSStringPboardType, nil] owner:nil];
[pb setString:tmp forType:NSStringPboardType];
}
- } else {
- tmp = [self rowsAsTabStringWithHeaders:([sender tag] == MENU_EDIT_COPY_WITH_COLUMN) onlySelectedRows:YES blobHandling:kBlobInclude];
- if ( nil != tmp )
- {
+ }
+ else {
+ tmp = [self rowsAsTabStringWithHeaders:([sender tag] == SPEditMenuCopyWithColumns) onlySelectedRows:YES blobHandling:kBlobInclude];
+
+ if (tmp != nil) {
NSPasteboard *pb = [NSPasteboard generalPasteboard];
- [pb declareTypes:[NSArray arrayWithObjects:
- NSTabularTextPboardType,
- NSStringPboardType,
- nil]
- owner:nil];
+ [pb declareTypes:[NSArray arrayWithObjects:NSTabularTextPboardType, NSStringPboardType, nil] owner:nil];
[pb setString:tmp forType:NSStringPboardType];
[pb setString:tmp forType:NSTabularTextPboardType];
@@ -139,7 +130,7 @@ NSInteger kBlobAsImageFile = 4;
* the value in each field is from the objects description method
*/
#ifndef SP_REFACTOR /* get rows as string */
-- (NSString *) rowsAsTabStringWithHeaders:(BOOL)withHeaders onlySelectedRows:(BOOL)onlySelected blobHandling:(NSInteger)withBlobHandling
+- (NSString *)rowsAsTabStringWithHeaders:(BOOL)withHeaders onlySelectedRows:(BOOL)onlySelected blobHandling:(NSInteger)withBlobHandling
{
if (onlySelected && [self numberOfSelectedRows] == 0) return nil;
@@ -277,7 +268,7 @@ NSInteger kBlobAsImageFile = 4;
* Get selected rows a string of newline separated lines of , separated fields wrapped into quotes
* the value in each field is from the objects description method
*/
-- (NSString *) rowsAsCsvStringWithHeaders:(BOOL)withHeaders onlySelectedRows:(BOOL)onlySelected blobHandling:(NSInteger)withBlobHandling
+- (NSString *)rowsAsCsvStringWithHeaders:(BOOL)withHeaders onlySelectedRows:(BOOL)onlySelected blobHandling:(NSInteger)withBlobHandling
{
if (onlySelected && [self numberOfSelectedRows] == 0) return nil;
@@ -417,21 +408,15 @@ NSInteger kBlobAsImageFile = 4;
* Return selected rows as SQL INSERT INTO `foo` VALUES (baz) string.
* If no selected table name is given `<table>` will be used instead.
*/
-- (NSString *) rowsAsSqlInsertsOnlySelectedRows:(BOOL)onlySelected
+- (NSString *)rowsAsSqlInsertsOnlySelectedRows:(BOOL)onlySelected
{
-
if (onlySelected && [self numberOfSelectedRows] == 0) return nil;
- NSIndexSet *selectedRows;
- if(onlySelected)
- selectedRows = [self selectedRowIndexes];
- else
- selectedRows = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [tableStorage count])];
+ NSIndexSet *selectedRows = (onlySelected) ? [self selectedRowIndexes] : [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [tableStorage count])];
- NSArray *columns = [self tableColumns];
- NSUInteger numColumns = [columns count];
-
- NSMutableString *value = [NSMutableString stringWithCapacity:10];
+ NSArray *columns = [self tableColumns];
+ NSUInteger numColumns = [columns count];
+ NSMutableString *value = [NSMutableString stringWithCapacity:10];
id cellData = nil;
@@ -443,14 +428,18 @@ NSInteger kBlobAsImageFile = 4;
// Create an array of table column names
NSMutableArray *tbHeader = [NSMutableArray arrayWithCapacity:numColumns];
- for (id enumObj in columns) {
+
+ for (id enumObj in columns)
+ {
[tbHeader addObject:[[enumObj headerCell] stringValue]];
}
// Create arrays of table column mappings and types for fast iteration
NSUInteger *columnMappings = malloc(numColumns * sizeof(NSUInteger));
NSUInteger *columnTypes = malloc(numColumns * sizeof(NSUInteger));
- for ( c = 0; c < numColumns; c++) {
+
+ for (c = 0; c < numColumns; c++)
+ {
columnMappings[c] = (NSUInteger)[[NSArrayObjectAtIndex(columns, c) identifier] integerValue];
NSString *t = [NSArrayObjectAtIndex(columnDefinitions, columnMappings[c]) objectForKey:@"typegrouping"];
@@ -479,12 +468,12 @@ NSInteger kBlobAsImageFile = 4;
NSUInteger rowIndex = [selectedRows firstIndex];
Class spTableContentClass = [SPTableContent class];
Class nsDataClass = [NSData class];
- while ( rowIndex != NSNotFound )
+
+ while (rowIndex != NSNotFound)
{
[value appendString:@"\t("];
cellData = nil;
rowCounter++;
-
NSMutableArray *rowValues = [[NSMutableArray alloc] initWithCapacity:numColumns];
for (c = 0; c < numColumns; c++)
@@ -516,10 +505,11 @@ NSInteger kBlobAsImageFile = 4;
[rowValues addObject:@"NULL"];
continue;
- } else if (cellData) {
+ }
+ else if (cellData) {
// Check column type and insert the data accordingly
- switch(columnTypes[c]) {
+ switch (columnTypes[c]) {
// Convert numeric types to unquoted strings
case 0:
@@ -550,13 +540,12 @@ NSInteger kBlobAsImageFile = 4;
}
// If nil is encountered, abort
- } else {
+ }
+ else {
NSBeep();
free(columnMappings);
free(columnTypes);
-
[rowValues release];
-
return nil;
}
}
@@ -566,7 +555,7 @@ NSInteger kBlobAsImageFile = 4;
[rowValues release];
// Close this VALUES group and set up the next one if appropriate
- if ( rowCounter != penultimateRowIndex ) {
+ if (rowCounter != penultimateRowIndex) {
// Add a new INSERT starter command every ~250k of data.
if ([value length] > 250000) {
@@ -575,23 +564,25 @@ NSInteger kBlobAsImageFile = 4;
[(selectedTable == nil) ? @"<table>" : selectedTable backtickQuotedString],
[tbHeader componentsJoinedAndBacktickQuoted]];
[value setString:@""];
- } else {
+ }
+ else {
[value appendString:@"),\n"];
}
- } else {
+ }
+ else {
[value appendString:@"),\n"];
[result appendString:value];
}
// Get the next selected row index
rowIndex = [selectedRows indexGreaterThanIndex:rowIndex];
-
}
// Remove the trailing ",\n" from the query string
- if ( [result length] > 3 )
+ if ([result length] > 3) {
[result deleteCharactersInRange:NSMakeRange([result length]-2, 2)];
+ }
[result appendString:@";\n"];
@@ -873,7 +864,6 @@ NSInteger kBlobAsImageFile = 4;
- (NSMenu *)menuForEvent:(NSEvent *)event
{
-
NSMenu *menu = [self menu];
#ifndef SP_REFACTOR /* menuForEvent: */
@@ -941,7 +931,6 @@ NSInteger kBlobAsImageFile = 4;
}
[bundleSubMenuItem release];
-
}
#endif
return menu;
@@ -950,8 +939,7 @@ NSInteger kBlobAsImageFile = 4;
- (void)selectTableRows:(NSArray*)rowIndices
{
-
- if(!rowIndices || ![rowIndices count]) return;
+ if (!rowIndices || ![rowIndices count]) return;
NSMutableIndexSet *selection = [NSMutableIndexSet indexSet];
#ifndef SP_REFACTOR
@@ -969,14 +957,13 @@ NSInteger kBlobAsImageFile = 4;
[self selectRowIndexes:selection byExtendingSelection:NO];
}
-
}
/**
* Only have the copy menu item enabled when row(s) are selected in
* supported tables.
*/
-- (BOOL) validateMenuItem:(NSMenuItem*)anItem
+- (BOOL)validateMenuItem:(NSMenuItem*)anItem
{
#ifndef SP_REFACTOR /* validateMenuItem: */
NSInteger menuItemTag = [anItem tag];
@@ -986,7 +973,7 @@ NSInteger kBlobAsImageFile = 4;
}
// Don't validate anything other than the copy commands
- if (menuItemTag != MENU_EDIT_COPY && menuItemTag != MENU_EDIT_COPY_WITH_COLUMN && menuItemTag != MENU_EDIT_COPY_AS_SQL) {
+ if (menuItemTag != SPEditMenuCopy && menuItemTag != SPEditMenuCopyWithColumns && menuItemTag != SPEditCopyAsSQL) {
return YES;
}
@@ -996,12 +983,12 @@ NSInteger kBlobAsImageFile = 4;
}
// Enable the Copy [with column names] commands if a row is selected
- if (menuItemTag == MENU_EDIT_COPY || menuItemTag == MENU_EDIT_COPY_WITH_COLUMN) {
+ if (menuItemTag == SPEditMenuCopy || menuItemTag == SPEditMenuCopyWithColumns) {
return ([self numberOfSelectedRows] > 0);
}
// Enable the Copy as SQL commands if rows are selected and column definitions are available
- if (menuItemTag == MENU_EDIT_COPY_AS_SQL) {
+ if (menuItemTag == SPEditCopyAsSQL) {
return (columnDefinitions != nil && [self numberOfSelectedRows] > 0);
}
#endif
@@ -1022,9 +1009,8 @@ NSInteger kBlobAsImageFile = 4;
* Trap the enter, escape, tab and arrow keys, overriding default behaviour and continuing/ending editing,
* only within the current row.
*/
-- (BOOL) control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command
+- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command
{
-
NSInteger row, column;
row = [self editedRow];
@@ -1152,9 +1138,8 @@ NSInteger kBlobAsImageFile = 4;
return NO;
}
-- (void) keyDown:(NSEvent *)theEvent
+- (void)keyDown:(NSEvent *)theEvent
{
-
// RETURN or ENTER invoke editing mode for selected row
// by calling tableView:shouldEditTableColumn: to validate
@@ -1511,28 +1496,26 @@ NSInteger kBlobAsImageFile = 4;
SPBeginAlertSheet(NSLocalizedString(@"BASH Error", @"bash error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [self window], self, nil, nil,
[NSString stringWithFormat:@"%@ “%@”:\n%@", NSLocalizedString(@"Error for", @"error for message"), [cmdData objectForKey:@"name"], errorMessage]);
}
-
}
if (cmdData) [cmdData release];
-
}
#endif
}
#pragma mark -
-- (void) awakeFromNib
+- (void)awakeFromNib
{
columnDefinitions = nil;
prefs = [[NSUserDefaults standardUserDefaults] retain];
- if ([NSTableView instancesRespondToSelector:@selector(awakeFromNib)])
+ if ([NSTableView instancesRespondToSelector:@selector(awakeFromNib)]) {
[super awakeFromNib];
-
+ }
}
-- (void) dealloc
+- (void)dealloc
{
if (columnDefinitions) [columnDefinitions release];
#ifndef SP_REFACTOR
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m
index f7f31088..8a2bc021 100644
--- a/Source/SPCustomQuery.m
+++ b/Source/SPCustomQuery.m
@@ -36,7 +36,9 @@
#import "SPFieldEditorController.h"
#import "SPTextAndLinkCell.h"
#import "SPTooltip.h"
+#ifndef SP_REFACTOR /* headers */
#import "SPQueryFavoriteManager.h"
+#endif
#import "SPQueryController.h"
#import "SPQueryDocumentsController.h"
#import "SPEncodingPopupAccessory.h"
@@ -269,7 +271,7 @@
// init query favorites controller
#ifndef SP_REFACTOR
[prefs synchronize];
-#endif
+
if(favoritesManager) [favoritesManager release];
favoritesManager = [[SPQueryFavoriteManager alloc] initWithDelegate:self];
@@ -279,6 +281,7 @@
modalDelegate:favoritesManager
didEndSelector:nil
contextInfo:nil];
+#endif
}
else if ([queryFavoritesButton indexOfSelectedItem] > 5) {
// Choose favorite
@@ -1484,22 +1487,28 @@
{
[tempRow addObject:[[tableColumn headerCell] stringValue]];
}
-
+
NSMutableArray *currentResult = [NSMutableArray array];
[currentResult addObject:[NSArray arrayWithArray:tempRow]];
- //add rows
- for ( i = 0 ; i < [self numberOfRowsInTableView:customQueryView] ; i++) {
+ // Add rows
+ for (i = 0; i < [self numberOfRowsInTableView:customQueryView]; i++)
+ {
[tempRow removeAllObjects];
+
NSEnumerator *enumerator = [[customQueryView tableColumns] objectEnumerator];
- while ( (tableColumn = [enumerator nextObject]) ) {
+
+ while ((tableColumn = [enumerator nextObject]))
+ {
id value = [self _resultDataItemAtRow:i columnIndex:[[tableColumn identifier] integerValue]];
[tempRow addObject:[self _convertResultDataValueToDisplayableRepresentation:value whilePreservingNULLs:includeNULLs truncateDataFields:truncate]];
}
+
[currentResult addObject:[NSArray arrayWithArray:tempRow]];
}
+
[tempRow release];
return currentResult;
@@ -1830,10 +1839,6 @@
[columnsInSpecifiedTable addObject:field];
}
- // Try to identify the field bijectively
- NSMutableString *fieldIDQueryStr = [NSMutableString string];
- [fieldIDQueryStr setString:@"WHERE ("];
-
// --- Build WHERE clause ---
dataRow = [resultData rowContentsAtIndex:rowIndex];
@@ -1858,30 +1863,26 @@
// Build up the argument
for (field in columnsToQuery) {
id aValue = [dataRow objectAtIndex:[[field objectForKey:@"datacolumnindex"] integerValue]];
-
if ([aValue isNSNull]) {
[argumentParts addObject:[NSString stringWithFormat:@"%@ IS NULL", [[field objectForKey:@"org_name"] backtickQuotedString]]];
- }
- else {
+ } else {
NSString *fieldTypeGrouping = [field objectForKey:@"typegrouping"];
-
+
// Skip blob-type fields if requested
if (!includeBlobs
- && ([fieldTypeGrouping isEqualToString:@"textdata"] ||
- [fieldTypeGrouping isEqualToString:@"blobdata"] ||
- [[field objectForKey:@"type"] isEqualToString:@"BINARY"] ||
- [[field objectForKey:@"type"] isEqualToString:@"VARBINARY"]))
+ && ([fieldTypeGrouping isEqualToString:@"textdata"]
+ || [fieldTypeGrouping isEqualToString:@"blobdata"]
+ || [[field objectForKey:@"type"] isEqualToString:@"BINARY"]
+ || [[field objectForKey:@"type"] isEqualToString:@"VARBINARY"]))
{
continue;
}
-
- if ([[field objectForKey:@"typegrouping"] isEqualToString:@"bit"]) {
+
+ // If the field is of type BIT then it needs a binary prefix
+ if ([fieldTypeGrouping isEqualToString:@"bit"]) {
[argumentParts addObject:[NSString stringWithFormat:@"%@=b'%@'", [[field objectForKey:@"org_name"] backtickQuotedString], [aValue description]]];
}
- else if ([[field objectForKey:@"typegrouping"] isEqualToString:@"integer"]) {
- [fieldIDQueryStr appendFormat:@"%@=%@ AND ", [[field objectForKey:@"org_name"] backtickQuotedString], [aValue description]];
- }
- else if ([[field objectForKey:@"typegrouping"] isEqualToString:@"geometry"]) {
+ else if ([fieldTypeGrouping isEqualToString:@"geometry"]) {
[argumentParts addObject:[NSString stringWithFormat:@"%@=%@", [[field objectForKey:@"org_name"] backtickQuotedString], [mySQLConnection escapeAndQuoteData:[aValue data]]]];
}
// BLOB/TEXT data
@@ -3054,15 +3055,16 @@
{
NSString *version = nil;
if([[mySQLversion stringByReplacingOccurrencesOfString:@"." withString:@""] integerValue] < 42)
- version = @"41";
+ version = @"4.1";
else
- version = [mySQLversion stringByReplacingOccurrencesOfString:@"." withString:@""];
+ version = [NSString stringWithString:mySQLversion];
+
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:
[[NSString stringWithFormat:
SPMySQLSearchURL,
- searchString,
version,
- NSLocalizedString(@"en", @"MySQL search language code - eg in http://search.mysql.com/search?q=select&site=refman-50&lr=lang_en")]
+ NSLocalizedString(@"en", @"MySQL search language code - eg in http://search.mysql.com/search?q=select&site=refman-50&lr=lang_en"),
+ searchString]
stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]];
}
@@ -3389,7 +3391,9 @@
initWithString:([favorite objectForKey:@"tabtrigger"] && [(NSString*)[favorite objectForKey:@"tabtrigger"] length]) ? [NSString stringWithFormat:@"%@\t%@⇥", [favorite objectForKey:@"name"], [favorite objectForKey:@"tabtrigger"]] : [favorite objectForKey:@"name"]
attributes:attributes] autorelease];
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""];
- [item setToolTip:[NSString stringWithString:[favorite objectForKey:@"query"]]];
+ if ([favorite objectForKey:@"query"]) {
+ [item setToolTip:[NSString stringWithString:[favorite objectForKey:@"query"]]];
+ }
[item setAttributedTitle:titleString];
[item setIndentationLevel:1];
[menu addItem:item];
@@ -3414,7 +3418,9 @@
initWithString:([favorite objectForKey:@"tabtrigger"] && [(NSString*)[favorite objectForKey:@"tabtrigger"] length]) ? [NSString stringWithFormat:@"%@\t%@⇥", [favorite objectForKey:@"name"], [favorite objectForKey:@"tabtrigger"]] : [favorite objectForKey:@"name"]
attributes:attributes] autorelease];
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""];
- [item setToolTip:[NSString stringWithString:[favorite objectForKey:@"query"]]];
+ if ([favorite objectForKey:@"query"]) {
+ [item setToolTip:[NSString stringWithString:[favorite objectForKey:@"query"]]];
+ }
[item setAttributedTitle:titleString];
[item setIndentationLevel:1];
[menu addItem:item];
diff --git a/Source/SPDataCellFormatter.h b/Source/SPDataCellFormatter.h
index c5d9cd99..a2710bf6 100644
--- a/Source/SPDataCellFormatter.h
+++ b/Source/SPDataCellFormatter.h
@@ -29,7 +29,7 @@
NSString *fieldType;
}
-@property(readwrite, assign) NSInteger textLimit;
-@property(readwrite, retain) NSString* fieldType;
+@property (readwrite, assign) NSInteger textLimit;
+@property (readwrite, retain) NSString* fieldType;
@end
diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m
index 6d8f701d..89c5b86e 100644
--- a/Source/SPDataImport.m
+++ b/Source/SPDataImport.m
@@ -45,10 +45,10 @@
#define SP_FILE_READ_ERROR_STRING NSLocalizedString(@"File read error", @"File read error title (Import Dialog)")
-@interface SPDataImport (PrivateAPI)
+@interface SPDataImport ()
-- (void) _importBackgroundProcess:(NSString *)filename;
-- (void) _resetFieldMappingGlobals;
+- (void)_importBackgroundProcess:(NSString *)filename;
+- (void)_resetFieldMappingGlobals;
@end
@@ -1699,56 +1699,29 @@
}
#pragma mark -
-
-/**
- * Dealloc.
- */
-- (void)dealloc
-{
- if (fieldMappingImportArray) [fieldMappingImportArray release];
- if (geometryFields) [geometryFields release];
- if (geometryFieldsMapIndex) [geometryFieldsMapIndex release];
- if (bitFields) [bitFields release];
- if (nullableNumericFields) [nullableNumericFields release];
- if (bitFieldsMapIndex) [bitFieldsMapIndex release];
- if (nullableNumericFieldsMapIndex) [nullableNumericFieldsMapIndex release];
-
- if (lastFilename) [lastFilename release];
- if (prefs) [prefs release];
- if(selectedTableTarget) [selectedTableTarget release];
-
- for (id retainedObject in nibObjectsToRelease) [retainedObject release];
-
- [nibObjectsToRelease release];
-
- [super dealloc];
-}
-
-@end
-
-@implementation SPDataImport (PrivateAPI)
+#pragma mark Private API
/**
* Starts the import process on a background thread.
*/
-- (void) _importBackgroundProcess:(NSString *)filename
+- (void)_importBackgroundProcess:(NSString *)filename
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *fileType = [[importFormatPopup selectedItem] title];
-
+
// Use the appropriate processing function for the file type
if ([fileType isEqualToString:@"SQL"])
[self importSQLFile:filename];
else if ([fileType isEqualToString:@"CSV"])
[self importCSVFile:filename];
-
+
[pool release];
}
/**
* Release and reset any field mapping global variables.
*/
-- (void) _resetFieldMappingGlobals
+- (void)_resetFieldMappingGlobals
{
if (csvImportTailString) [csvImportTailString release], csvImportTailString = nil;
if (csvImportHeaderString) [csvImportHeaderString release], csvImportHeaderString = nil;
@@ -1759,4 +1732,30 @@
if (fieldMapperOperator) [fieldMapperOperator release], fieldMapperOperator = nil;
}
+#pragma mark -
+
+/**
+ * Dealloc.
+ */
+- (void)dealloc
+{
+ if (fieldMappingImportArray) [fieldMappingImportArray release];
+ if (geometryFields) [geometryFields release];
+ if (geometryFieldsMapIndex) [geometryFieldsMapIndex release];
+ if (bitFields) [bitFields release];
+ if (nullableNumericFields) [nullableNumericFields release];
+ if (bitFieldsMapIndex) [bitFieldsMapIndex release];
+ if (nullableNumericFieldsMapIndex) [nullableNumericFieldsMapIndex release];
+
+ if (lastFilename) [lastFilename release];
+ if (prefs) [prefs release];
+ if(selectedTableTarget) [selectedTableTarget release];
+
+ for (id retainedObject in nibObjectsToRelease) [retainedObject release];
+
+ [nibObjectsToRelease release];
+
+ [super dealloc];
+}
+
@end
diff --git a/Source/SPDatabaseCopy.m b/Source/SPDatabaseCopy.m
index 4dcb4966..ea45c4af 100644
--- a/Source/SPDatabaseCopy.m
+++ b/Source/SPDatabaseCopy.m
@@ -65,21 +65,15 @@
return NO;
}
- BOOL success = [self createDatabase:targetDatabaseName];
+ //abort here if database creation failed
+ if(![self createDatabase:targetDatabaseName])
+ return NO;
SPTableCopy *dbActionTableCopy = [[SPTableCopy alloc] init];
[dbActionTableCopy setConnection:connection];
- for (NSString *currentTable in tables) {
- if ([dbActionTableCopy copyTable:currentTable
- from:sourceDatabaseName
- to:targetDatabaseName
- withContent:copyWithContent]) {
- } else {
- success = NO;
- }
- }
+ BOOL success = [dbActionTableCopy copyTables:tables from:sourceDatabaseName to:targetDatabaseName withContent:copyWithContent];
[dbActionTableCopy release];
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index d43be841..53dfb908 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -34,10 +34,9 @@ enum {
#import "SPDatabaseDocument.h"
#import "SPConnectionController.h"
+#import "SPConnectionHandler.h"
#import "SPConnectionControllerInitializer.h"
-#import <SPMySQL/SPMySQL.h>
-
#import "SPTablesList.h"
#import "SPTableStructure.h"
#ifndef SP_REFACTOR /* headers */
@@ -87,7 +86,6 @@ enum {
#ifndef SP_REFACTOR /* headers */
#import "SPBundleHTMLOutputController.h"
#import "SPConnectionDelegate.h"
-#import "SPConnectionHandler.h"
#endif
#ifdef SP_REFACTOR /* headers */
@@ -97,6 +95,8 @@ enum {
#import "SPDatabaseRename.h"
#endif
+#import <SPMySQL/SPMySQL.h>
+
// Constants
#ifndef SP_REFACTOR
static NSString *SPCreateSyntx = @"SPCreateSyntax";
@@ -258,6 +258,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
#endif
+
- (void)awakeFromNib
{
#ifndef SP_REFACTOR
@@ -4019,6 +4020,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
[createTableSyntaxWindow orderOut:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[self setParentWindow:nil];
+
}
#ifndef SP_REFACTOR
@@ -4103,7 +4105,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
// If the window is being set for the first time - connection controller is visible - update focus
if (!parentWindow && !mySQLConnection) {
#ifndef SP_REFACTOR
- [aWindow makeFirstResponder:(NSView *)[connectionController favoritesOutlineView]];
+ [aWindow makeFirstResponder:(NSResponder *)[connectionController favoritesOutlineView]];
#endif
[connectionController performSelector:@selector(updateFavoriteSelection:) withObject:self afterDelay:0.0];
}
diff --git a/Source/SPDatabaseViewController.m b/Source/SPDatabaseViewController.m
index 4d0548d5..da20b967 100644
--- a/Source/SPDatabaseViewController.m
+++ b/Source/SPDatabaseViewController.m
@@ -46,7 +46,6 @@
@end
-
@implementation SPDatabaseDocument (SPDatabaseViewController)
#pragma mark -
diff --git a/Source/SPExportController.m b/Source/SPExportController.m
index ace630b6..315df604 100644
--- a/Source/SPExportController.m
+++ b/Source/SPExportController.m
@@ -44,8 +44,8 @@ static const NSString *SPTableViewContentColumnID = @"content";
static const NSString *SPTableViewDropColumnID = @"drop";
static const NSString *SPSQLExportStructureEnabled = @"SQLExportStructureEnabled";
-static const NSString *SPSQLExportContentEnabled = @"SQLExportContentEnabled";
-static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
+static const NSString *SPSQLExportContentEnabled = @"SQLExportContentEnabled";
+static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
@interface SPExportController (PrivateAPI)
@@ -642,7 +642,7 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
// Check whether to save the export filename. Save it if it's not blank and contains at least one
// token - this suggests it's not a one-off filename
- if (![exportCustomFilenameTokenField stringValue]) {
+ if ([[exportCustomFilenameTokenField stringValue] length] < 1) {
[prefs removeObjectForKey:SPExportFilenameFormat];
}
else {
diff --git a/Source/SPExportFile.m b/Source/SPExportFile.m
index 09d3b6af..6fd4e217 100644
--- a/Source/SPExportFile.m
+++ b/Source/SPExportFile.m
@@ -98,7 +98,10 @@
- (BOOL)delete
{
if ((![self exportFilePath]) || (![self exportFileHandle]) || ([[self exportFilePath] length] == 0)) return NO;
-
+
+ // Ensure the file is closed to allow all processing threads to close
+ [self close];
+
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:[self exportFilePath]]) {
diff --git a/Source/SPExportFileNameTokenObject.h b/Source/SPExportFileNameTokenObject.h
index 24022745..76c8fa2e 100644
--- a/Source/SPExportFileNameTokenObject.h
+++ b/Source/SPExportFileNameTokenObject.h
@@ -22,13 +22,11 @@
//
// More info at <http://code.google.com/p/sequel-pro/>
-#import <Cocoa/Cocoa.h>
-
-
-@interface SPExportFileNameTokenObject : NSObject<NSCoding> {
+@interface SPExportFileNameTokenObject : NSObject<NSCoding>
+{
NSString *tokenContent;
}
-@property(retain) NSString *tokenContent;
+@property (retain) NSString *tokenContent;
@end
diff --git a/Source/SPExportFileNameTokenObject.m b/Source/SPExportFileNameTokenObject.m
index 9e589f79..f62c50d2 100644
--- a/Source/SPExportFileNameTokenObject.m
+++ b/Source/SPExportFileNameTokenObject.m
@@ -24,7 +24,6 @@
#import "SPExportFileNameTokenObject.h"
-
@implementation SPExportFileNameTokenObject
@synthesize tokenContent;
@@ -37,6 +36,7 @@
if ((self = [super init])) {
[self setTokenContent:[decoder decodeObjectForKey:@"TokenContent"]];
}
+
return self;
}
diff --git a/Source/SPExportFileUtilities.m b/Source/SPExportFileUtilities.m
index 561c5340..c14fd7e0 100644
--- a/Source/SPExportFileUtilities.m
+++ b/Source/SPExportFileUtilities.m
@@ -36,10 +36,13 @@ typedef enum
SPExportErrorCancelExport = 0,
SPExportErrorReplaceFiles = 1,
SPExportErrorSkipErrorFiles = 2
-} SPExportErrorChoice;
+}
+SPExportErrorChoice;
@interface SPExportController (SPExportFileUtilitiesPrivateAPI)
- - (void)_reopenExportSheet;
+
+- (void)_reopenExportSheet;
+
@end
@implementation SPExportController (SPExportFileUtilities)
@@ -130,7 +133,7 @@ typedef enum
*/
- (void)errorCreatingExportFileHandles:(NSArray *)files
{
- // Get the number of files that already exists as well as couldn't be created because of other reasons
+ // Get the number of files that already exist as well as couldn't be created because of other reasons
NSUInteger filesAlreadyExisting = 0;
NSUInteger filesFailed = 0;
@@ -138,17 +141,25 @@ typedef enum
{
if ([file exportFileHandleStatus] == SPExportFileHandleExists) {
filesAlreadyExisting++;
-
+ }
// For file handles that we failed to create for some unknown reason, ignore them and remove any
// exporters that are associated with them.
- } else if ([file exportFileHandleStatus] == SPExportFileHandleFailed) {
+ else if ([file exportFileHandleStatus] == SPExportFileHandleFailed) {
+
filesFailed++;
+
+ NSMutableArray *exportersToRemove = [[NSMutableArray alloc] init];
+
for (SPExporter *exporter in exporters)
{
if ([[exporter exportOutputFile] isEqualTo:file]) {
- [exporters removeObject:exporter];
+ [exportersToRemove addObject:exporter];
}
}
+
+ [exporters removeObjectsInArray:exportersToRemove];
+
+ [exportersToRemove release];
}
}
@@ -164,10 +175,12 @@ typedef enum
if (filesAlreadyExisting == 1) {
[alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"“%@” already exists. Do you want to replace it?", @"Export file already exists message"), [[[files objectAtIndex:0] exportFilePath] lastPathComponent]]];
[alert setInformativeText:[NSString stringWithFormat:@"%@%@", NSLocalizedString(@"A file with the same name already exists in the target folder. Replacing it will overwrite its current contents.", @"Export file already exists explanatory text"), additionalErrors]];
- } else if (filesAlreadyExisting == [exportFiles count]) {
+ }
+ else if (filesAlreadyExisting == [exportFiles count]) {
[alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"All the export files already exist. Do you want to replace them?", @"All export files already exist message")]];
[alert setInformativeText:[NSString stringWithFormat:@"%@%@", NSLocalizedString(@"Files with the same names already exist in the target folder. Replacing them will overwrite their current contents.", @"All export files already exist explanatory text"), additionalErrors]];
- } else {
+ }
+ else {
[alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"%lu files already exist. Do you want to replace them?", @"Export file already exists message"), filesAlreadyExisting]];
[alert setInformativeText:[NSString stringWithFormat:@"%@%@", [NSString stringWithFormat:NSLocalizedString(@"%lu files with the same names already exist in the target folder. Replacing them will overwrite their current contents.", @"Some export files already exist explanatory text"), filesAlreadyExisting], additionalErrors]];
}
@@ -187,20 +200,21 @@ typedef enum
[[[alert buttons] objectAtIndex:2] setKeyEquivalent:@"s"];
[[[alert buttons] objectAtIndex:2] setKeyEquivalentModifierMask:NSCommandKeyMask];
}
-
+ }
// If one or multiple files failed, but only due to unhandled errors, show a short dialog
- } else {
+ else {
if (filesFailed == 1) {
[alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"“%@” could not be created", @"Export file creation error title"), [[[files objectAtIndex:0] exportFilePath] lastPathComponent]]];
[alert setInformativeText:NSLocalizedString(@"An unhandled error occurred when attempting to create the export file. Please check the details and try again.", @"Export file creation error explanatory text")];
- } else if (filesFailed == [exportFiles count]) {
+ }
+ else if (filesFailed == [exportFiles count]) {
[alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"No files could be created", @"All export files creation error title")]];
[alert setInformativeText:NSLocalizedString(@"An unhandled error occurred when attempting to create each of the export files. Please check the details and try again.", @"All export files creation error explanatory text")];
- } else {
+ }
+ else {
[alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"%lu files could not be created", @"Export files creation error title"), filesFailed]];
[alert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"An unhandled error occurred when attempting to create %lu of the export files. Please check the details and try again.", @"Export files creation error explanatory text"), filesFailed]];
}
-
[alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"cancel button")];
[[[alert buttons] objectAtIndex:0] setTag:SPExportErrorCancelExport];
@@ -303,10 +317,6 @@ typedef enum
}
}
-@end
-
-@implementation SPExportController (SPExportFileUtilitiesPrivateAPI)
-
/**
* Re-open the export sheet without resetting the interface - for use on error.
*/
diff --git a/Source/SPExportInitializer.m b/Source/SPExportInitializer.m
index a0c0ef41..b02ef927 100644
--- a/Source/SPExportInitializer.m
+++ b/Source/SPExportInitializer.m
@@ -25,13 +25,14 @@
#import "SPExportInitializer.h"
#import "SPTableData.h"
-#import "SPTableContent.h"
#import "SPDatabaseDocument.h"
#import "SPTablesList.h"
#import "SPGrowlController.h"
#import "SPDatabaseDocument.h"
#import "SPCustomQuery.h"
#import "SPAlertSheets.h"
+#import "SPTableContent.h"
+
#import "SPCSVExporter.h"
#import "SPSQLExporter.h"
#import "SPXMLExporter.h"
@@ -41,7 +42,6 @@
#import "SPExportFileUtilities.h"
#import "SPExportFilenameUtilities.h"
#import "SPExportFileNameTokenObject.h"
-
#import <SPMySQL/SPMySQL.h>
@implementation SPExportController (SPExportInitializer)
@@ -276,6 +276,7 @@
[sqlExporter setSqlOutputIncludeUTF8BOM:[exportUseUTF8BOMButton state]];
[sqlExporter setSqlOutputEncodeBLOBasHex:[exportSQLBLOBFieldsAsHexCheck state]];
[sqlExporter setSqlOutputIncludeErrors:[exportSQLIncludeErrorsCheck state]];
+ [sqlExporter setSqlOutputIncludeAutoIncrement:([exportSQLIncludeStructureCheck state] && [exportSQLIncludeAutoIncrementValueButton state])];
[sqlExporter setSqlInsertAfterNValue:[exportSQLInsertNValueTextField integerValue]];
[sqlExporter setSqlInsertDivider:[exportSQLInsertDividerPopUpButton indexOfSelectedItem]];
diff --git a/Source/SPFieldEditorController.h b/Source/SPFieldEditorController.h
index da78785b..1fc3f812 100644
--- a/Source/SPFieldEditorController.h
+++ b/Source/SPFieldEditorController.h
@@ -32,10 +32,9 @@
* This class offers a sheet for editing different kind of data such as text, blobs (including images) as
* editSheet and bit fields as bitSheet.
*/
-#ifndef SP_REFACTOR
@interface SPFieldEditorController : NSWindowController
-#else
-@interface SPFieldEditorController : NSWindowController <NSComboBoxDataSource>
+#ifdef SP_REFACTOR
+<NSComboBoxDataSource>
#endif
{
IBOutlet id editSheetProgressBar;
@@ -161,7 +160,9 @@
NSUserDefaults *prefs;
+#ifndef SP_REFACTOR
NSDictionary *qlTypes;
+#endif
NSInteger editSheetReturnCode;
BOOL _isGeometry;
diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m
index aabdc171..374bd3dd 100644
--- a/Source/SPFieldMapperController.m
+++ b/Source/SPFieldMapperController.m
@@ -145,10 +145,9 @@ static NSString *SPTableViewSqlColumnID = @"sql";
[tableTargetPopup addItemsWithTitles:allTableNames];
// Select either the currently selected table, or the first item in the list, or if no table in db switch to "New Table" mode
- if ([[theDelegate valueForKeyPath:@"tableDocumentInstance"] table] != nil
- && ![[tablesListInstance tableName] isEqualToString:@""]
- && [allTableNames containsObject:[tablesListInstance tableName]]) {
- [tableTargetPopup selectItemWithTitle:[tablesListInstance tableName]];
+ if ([[tablesListInstance selectedTableNames] count]
+ && [allTableNames containsObject:[[tablesListInstance selectedTableNames] objectAtIndex:0]]) {
+ [tableTargetPopup selectItemWithTitle:[[tablesListInstance selectedTableNames] objectAtIndex:0]];
} else {
if([allTableNames count])
[tableTargetPopup selectItemAtIndex:3];
@@ -515,10 +514,9 @@ static NSString *SPTableViewSqlColumnID = @"sql";
}
// Select either the currently selected table, or the first item in the list, or if no table in db switch to "New Table" mode
- if ([[theDelegate valueForKeyPath:@"tableDocumentInstance"] table] != nil
- && ![[tablesListInstance tableName] isEqualToString:@""]
- && [allTableNames containsObject:[tablesListInstance tableName]]) {
- [tableTargetPopup selectItemWithTitle:[tablesListInstance tableName]];
+ if ([[tablesListInstance selectedTableNames] count]
+ && [allTableNames containsObject:[[tablesListInstance selectedTableNames] objectAtIndex:0]]) {
+ [tableTargetPopup selectItemWithTitle:[[tablesListInstance selectedTableNames] objectAtIndex:0]];
} else {
if([allTableNames count])
[tableTargetPopup selectItemAtIndex:3];
diff --git a/Source/SPGeneralPreferencePane.h b/Source/SPGeneralPreferencePane.h
index c573b84a..a23b6bb8 100644
--- a/Source/SPGeneralPreferencePane.h
+++ b/Source/SPGeneralPreferencePane.h
@@ -34,13 +34,14 @@
*/
@interface SPGeneralPreferencePane : SPPreferencePane <SPPreferencePaneProtocol>
{
- NSImage *folderImage;
-
IBOutlet NSPopUpButton *defaultFavoritePopup;
+
+ IBOutlet NSArrayController *favoritesController;
}
- (IBAction)updateDefaultFavorite:(id)sender;
- (void)updateDefaultFavoritePopup;
+- (void)updateDefaultFavoritePopupSelection;
@end
diff --git a/Source/SPGeneralPreferencePane.m b/Source/SPGeneralPreferencePane.m
index f24dec54..67c43881 100644
--- a/Source/SPGeneralPreferencePane.m
+++ b/Source/SPGeneralPreferencePane.m
@@ -24,51 +24,21 @@
// More info at <http://code.google.com/p/sequel-pro/>
#import "SPGeneralPreferencePane.h"
-#import "SPFavoritesController.h"
-#import "SPTreeNode.h"
-#import "SPFavoriteNode.h"
-#import "SPGroupNode.h"
-
-static NSString *SPDatabaseImage = @"database-small";
-
-@interface SPGeneralPreferencePane ()
-
-- (NSArray *)_constructMenuItemsForNode:(SPTreeNode *)node atLevel:(NSUInteger)level;
-
-@end
@implementation SPGeneralPreferencePane
#pragma mark -
-#pragma mark Initialisation
-
-- (void)awakeFromNib
-{
- // Generic folder image for use in the outline view's groups
- folderImage = [[[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kGenericFolderIcon)] retain];
-
- [folderImage setSize:NSMakeSize(16, 16)];
-}
-
-#pragma mark -
#pragma mark IB action methods
/**
* Updates the default favorite.
*/
- (IBAction)updateDefaultFavorite:(id)sender
-{
- for (NSMenuItem *item in [defaultFavoritePopup itemArray])
- {
- [item setState:NSOffState];
- }
-
- [sender setState:NSOnState];
- [defaultFavoritePopup setTitle:[sender title]];
-
+{
[prefs setBool:([defaultFavoritePopup indexOfSelectedItem] == 0) forKey:SPSelectLastFavoriteUsed];
-
- [prefs setInteger:[sender tag] forKey:SPDefaultFavorite];
+
+ // Minus 2 from index to account for the "Last Used" and separator items
+ [prefs setInteger:([defaultFavoritePopup indexOfSelectedItem] - 2) forKey:SPDefaultFavorite];
}
#pragma mark -
@@ -81,79 +51,43 @@ static NSString *SPDatabaseImage = @"database-small";
{
[defaultFavoritePopup removeAllItems];
+ // Use the last used favorite
[defaultFavoritePopup addItemWithTitle:NSLocalizedString(@"Last Used", @"Last Used entry in favorites menu")];
[[defaultFavoritePopup menu] addItem:[NSMenuItem separatorItem]];
// Add all favorites to the menu
- for (SPTreeNode *node in [[[[[SPFavoritesController sharedFavoritesController] favoritesTree] childNodes] objectAtIndex:0] childNodes])
+ for (NSString *favorite in [[favoritesController arrangedObjects] valueForKeyPath:@"name"])
{
- NSArray *items = [self _constructMenuItemsForNode:node atLevel:0];
+ NSMenuItem *favoriteMenuItem = [[NSMenuItem alloc] initWithTitle:favorite action:NULL keyEquivalent:@""];
+
+ [[defaultFavoritePopup menu] addItem:favoriteMenuItem];
- for (NSMenuItem *item in items)
- {
- [[defaultFavoritePopup menu] addItem:item];
- }
+ [favoriteMenuItem release];
}
- // Select the default favorite from prefs
- [defaultFavoritePopup selectItemWithTag:[prefs boolForKey:SPSelectLastFavoriteUsed] ? 0 : [prefs integerForKey:SPDefaultFavorite]];
+ // Add item to switch to edit favorites pane
+ [[defaultFavoritePopup menu] addItem:[NSMenuItem separatorItem]];
+
+ NSMenuItem *editMenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Edit Favorites…", @"edit favorites menu item") action:@selector(displayFavoritePreferences:) keyEquivalent:@""];
+
+ [editMenuItem setTarget:[[[self view] window] delegate]];
+
+ [[defaultFavoritePopup menu] addItem:editMenuItem];
+
+ [editMenuItem release];
+
+ // Select the default favorite from prefs
+ [self updateDefaultFavoritePopupSelection];
}
-#pragma mark -
-#pragma mark Private API
-
/**
- * Builds a menu item and sub-menu (if required) of the supplied tree node.
- *
- * @param node The node to build the menu item for
- *
- * @return The menu item
+ * Resets the default favorite popup button selection based on the user's preferences.
*/
-- (NSArray *)_constructMenuItemsForNode:(SPTreeNode *)node atLevel:(NSUInteger)level
-{
- NSMutableArray *items = [NSMutableArray array];
-
- if ([node isGroup]) {
-
- level++;
-
- SPGroupNode *groupNode = (SPGroupNode *)[node representedObject];
-
- NSMenuItem *groupItem = [[NSMenuItem alloc] initWithTitle:[groupNode nodeName] action:NULL keyEquivalent:@""];
-
- NSUInteger groupLevel = (level - 1);
-
- [groupItem setEnabled:NO];
- [groupItem setImage:folderImage];
- [groupItem setIndentationLevel:groupLevel];
-
- [items addObject:groupItem];
-
- [groupItem release];
-
- for (SPTreeNode *childNode in [node childNodes])
- {
- NSArray *innerItems = [self _constructMenuItemsForNode:childNode atLevel:level];
-
- [items addObjectsFromArray:innerItems];
- }
- }
- else {
- NSDictionary *favorite = [(SPFavoriteNode *)[node representedObject] nodeFavorite];
-
- NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:[favorite objectForKey:SPFavoriteNameKey] action:@selector(updateDefaultFavorite:) keyEquivalent:@""];
-
- [menuItem setTag:[[favorite objectForKey:SPFavoriteIDKey] integerValue]];
- [menuItem setImage:[NSImage imageNamed:SPDatabaseImage]];
- [menuItem setIndentationLevel:level];
- [menuItem setTarget:self];
-
- [items addObject:menuItem];
-
- [menuItem release];
- }
+- (void)updateDefaultFavoritePopupSelection
+{
+ NSUInteger index = [prefs integerForKey:SPDefaultFavorite];
- return items;
+ [defaultFavoritePopup selectItemAtIndex:(![prefs boolForKey:SPSelectLastFavoriteUsed] && index > 0 && index < [[defaultFavoritePopup itemArray] count]) ? index + 2 : 0];
}
#pragma mark -
@@ -189,13 +123,4 @@ static NSString *SPDatabaseImage = @"database-small";
return NO;
}
-#pragma mark -
-
-- (void)dealloc
-{
- [folderImage release], folderImage = nil;
-
- [super dealloc];
-}
-
@end
diff --git a/Source/SPNotLoaded.m b/Source/SPNotLoaded.m
index 3938823f..99a5a1d0 100644
--- a/Source/SPNotLoaded.m
+++ b/Source/SPNotLoaded.m
@@ -30,7 +30,7 @@ static SPNotLoaded *notLoaded = nil;
@implementation SPNotLoaded
// Return the singleton object
-+ (SPNotLoaded *)notLoaded
++ (SPNotLoaded *) notLoaded
{
@synchronized(self) {
if (notLoaded == nil) {
@@ -40,19 +40,17 @@ static SPNotLoaded *notLoaded = nil;
return notLoaded;
}
-+ (id)allocWithZone:(NSZone *)zone
++ (id) allocWithZone:(NSZone *)zone
{
@synchronized(self) {
return [[self notLoaded] retain];
}
-
return nil;
}
-- (id)init
+- (id) init
{
Class notLoadedClass = [self class];
-
@synchronized(notLoadedClass) {
if (notLoaded == nil) {
if ((self = [super init])) {
@@ -60,19 +58,18 @@ static SPNotLoaded *notLoaded = nil;
}
}
}
-
return notLoaded;
}
-- (id)copyWithZone:(NSZone *)zone { return self; }
+- (id) copyWithZone:(NSZone *)zone { return self; }
-- (id)retain { return self; }
+- (id) retain { return self; }
-- (NSUInteger)retainCount { return NSUIntegerMax; }
+- (NSUInteger) retainCount { return NSUIntegerMax; }
-- (oneway void)release {}
+- (oneway void) release {}
-- (id)autorelease { return self; }
+- (id) autorelease { return self; }
@end
@@ -82,13 +79,11 @@ static SPNotLoaded *notLoaded = nil;
*/
@implementation NSObject (SPNotLoadedTest)
-- (BOOL)isSPNotLoaded
+- (BOOL) isSPNotLoaded
{
static id SPNotLoadedForComparison;
-
if (!SPNotLoadedForComparison) SPNotLoadedForComparison = [SPNotLoaded notLoaded];
-
- return (self == SPNotLoadedForComparison);
+ return (self == SPNotLoadedForComparison);
}
@end
diff --git a/Source/SPPreferencesUpgrade.m b/Source/SPPreferencesUpgrade.m
index a4e15c6b..10a86a5d 100644
--- a/Source/SPPreferencesUpgrade.m
+++ b/Source/SPPreferencesUpgrade.m
@@ -329,7 +329,7 @@ void SPMigrateConnectionFavoritesData(void)
[prefs setInteger:[[[favorites objectAtIndex:defaultFavoriteIndex] objectForKey:SPFavoriteIDKey] integerValue] forKey:SPDefaultFavorite];
}
- // TOOD: Only uncomment when migration is complete
+ // TOOD: Favorites migration - only uncomment when we want to remove backwards compatibility
//[prefs removeObjectForKey:@"LastFavoriteIndex"];
}
@@ -360,7 +360,7 @@ void SPMigrateConnectionFavoritesData(void)
NSLog(@"Error migrating favorites data: %@", [error localizedDescription]);
}
else {
- // TODO: Only uncomment when migration is complete
+ // TOOD: Favorites migration - only uncomment when we want to remove backwards compatibility
//[prefs removeObjectForKey:SPOldFavoritesKey];
}
}
diff --git a/Source/SPPrintController.m b/Source/SPPrintController.m
index a3a0a343..38071ba7 100644
--- a/Source/SPPrintController.m
+++ b/Source/SPPrintController.m
@@ -211,8 +211,10 @@
NSMutableDictionary *printData = [NSMutableDictionary dictionary];
+ NSUInteger view = [tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]];
+
// Table source view
- if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 0) {
+ if (view == 0) {
NSDictionary *tableSource = [tableSourceInstance tableSourceForPrinting];
@@ -249,7 +251,7 @@
[indexes release];
}
// Table content view
- else if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 1) {
+ else if (view == 1) {
NSArray *data = [tableContentInstance currentDataResultWithNULLs:NO hideBLOBs:YES];
@@ -266,7 +268,7 @@
[rows release];
}
// Custom query view
- else if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 2) {
+ else if (view == 2) {
NSArray *data = [customQueryInstance currentResult];
@@ -283,7 +285,7 @@
[rows release];
}
// Table relations view
- else if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 4) {
+ else if (view == 4) {
NSArray *data = [tableRelationsInstance relationDataForPrinting];
@@ -299,7 +301,7 @@
[rows release];
}
// Table triggers view
- else if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 5) {
+ else if (view == 5) {
NSArray *data = [tableTriggersInstance triggerDataForPrinting];
@@ -384,33 +386,30 @@
{
NSArray *columns = nil;
+ NSUInteger view = [tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]];
+
// Table source view
- if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 0
- && [[tableSourceInstance tableSourceForPrinting] count] > 0) {
+ if ((view == 0) && ([[tableSourceInstance tableSourceForPrinting] count] > 0)) {
columns = [[NSArray alloc] initWithArray:[[[tableSourceInstance tableSourceForPrinting] objectForKey:@"structure"] objectAtIndex:0] copyItems:YES];
}
// Table content view
- else if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 1
- && [[tableContentInstance currentResult] count] > 0) {
+ else if ((view == 1) && ([[tableContentInstance currentResult] count] > 0)) {
columns = [[NSArray alloc] initWithArray:[[tableContentInstance currentResult] objectAtIndex:0] copyItems:YES];
}
// Custom query view
- else if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 2
- && [[customQueryInstance currentResult] count] > 0) {
+ else if ((view == 2) && ([[customQueryInstance currentResult] count] > 0)) {
columns = [[NSArray alloc] initWithArray:[[customQueryInstance currentResult] objectAtIndex:0] copyItems:YES];
}
// Table relations view
- else if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 4
- && [[tableRelationsInstance relationDataForPrinting] count] > 0) {
+ else if ((view == 4) && ([[tableRelationsInstance relationDataForPrinting] count] > 0)) {
columns = [[NSArray alloc] initWithArray:[[tableRelationsInstance relationDataForPrinting] objectAtIndex:0] copyItems:YES];
}
// Table triggers view
- else if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 5
- && [[tableTriggersInstance triggerDataForPrinting] count] > 0) {
+ else if ((view == 5) && ([[tableTriggersInstance triggerDataForPrinting] count] > 0)) {
columns = [[NSArray alloc] initWithArray:[[tableTriggersInstance triggerDataForPrinting] objectAtIndex:0] copyItems:YES];
}
diff --git a/Source/SPProcessListController.m b/Source/SPProcessListController.m
index 5b68586d..cc1b40c4 100644
--- a/Source/SPProcessListController.m
+++ b/Source/SPProcessListController.m
@@ -71,6 +71,8 @@ static NSString *SPTableViewIDColumnIdentifier = @"Id";
processes = [[NSMutableArray alloc] init];
prefs = [NSUserDefaults standardUserDefaults];
+
+ showFullProcessList = [prefs boolForKey:SPProcessListShowFullProcessList];
}
return self;
diff --git a/Source/SPQueryController.h b/Source/SPQueryController.h
index 58858ddd..8ac4570d 100644
--- a/Source/SPQueryController.h
+++ b/Source/SPQueryController.h
@@ -33,6 +33,7 @@ static NSString *SPTableViewConnectionColumnID = @"messageConnection";
@interface SPQueryController : NSWindowController
{
+#ifndef SP_REFACTOR /* ivars */
IBOutlet NSView *saveLogView;
IBOutlet NSTableView *consoleTableView;
IBOutlet NSSearchField *consoleSearchField;
@@ -55,6 +56,7 @@ static NSString *SPTableViewConnectionColumnID = @"messageConnection";
NSMutableDictionary *historyContainer;
NSMutableDictionary *contentFilterContainer;
NSUInteger numberOfMaxAllowedHistory;
+#endif
NSArray *completionKeywordList;
NSArray *completionFunctionList;
@@ -62,10 +64,10 @@ static NSString *SPTableViewConnectionColumnID = @"messageConnection";
#ifndef SP_REFACTOR /* ivars */
NSUserDefaults *prefs;
-#endif
NSDateFormatter *dateFormatter;
pthread_mutex_t consoleLock;
+#endif
}
#ifndef SP_REFACTOR
diff --git a/Source/SPQueryFavoriteManager.h b/Source/SPQueryFavoriteManager.h
index 0ebdc837..66d43778 100644
--- a/Source/SPQueryFavoriteManager.h
+++ b/Source/SPQueryFavoriteManager.h
@@ -31,10 +31,9 @@
@end
-#ifndef SP_REFACTOR
@interface SPQueryFavoriteManager : NSWindowController
-#else
-@interface SPQueryFavoriteManager : NSWindowController <NSOpenSavePanelDelegate>
+#ifdef SP_REFACTOR
+<NSOpenSavePanelDelegate>
#endif
{
#ifndef SP_REFACTOR /* ivars */
diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m
index 625f9855..be63e2a4 100644
--- a/Source/SPQueryFavoriteManager.m
+++ b/Source/SPQueryFavoriteManager.m
@@ -585,7 +585,7 @@
*/
- (void)tableView:(NSTableView*)tableView didClickTableColumn:(NSTableColumn *)tableColumn
{
- // TODO: Not yet implemented
+ // TODO: Implement me
return;
}
diff --git a/Source/SPSQLExporter.h b/Source/SPSQLExporter.h
index 559cdc9e..b5621bd1 100644
--- a/Source/SPSQLExporter.h
+++ b/Source/SPSQLExporter.h
@@ -50,6 +50,7 @@
BOOL sqlOutputIncludeUTF8BOM;
BOOL sqlOutputEncodeBLOBasHex;
BOOL sqlOutputIncludeErrors;
+ BOOL sqlOutputIncludeAutoIncrement;
SPSQLExportInsertDivider sqlInsertDivider;
@@ -110,6 +111,11 @@
@property(readwrite, assign) BOOL sqlOutputIncludeErrors;
/**
+ * @property sqlOutputIncludeAutoIncrement Include auto increment in structure definition
+ */
+@property(readwrite, assign) BOOL sqlOutputIncludeAutoIncrement;
+
+/**
* @property sqlCurrentTableExportIndex Number of tables processed by exporter
*/
@property(readwrite, assign) NSUInteger sqlCurrentTableExportIndex;
diff --git a/Source/SPSQLExporter.m b/Source/SPSQLExporter.m
index dab27872..907360ea 100644
--- a/Source/SPSQLExporter.m
+++ b/Source/SPSQLExporter.m
@@ -29,9 +29,10 @@
#import "SPExportUtilities.h"
#import "SPExportFile.h"
#import "SPTableData.h"
+#import "RegexKitLite.h"
#import <SPMySQL/SPMySQL.h>
-@interface SPSQLExporter (PrivateAPI)
+@interface SPSQLExporter ()
- (NSString *)_createViewPlaceholderSyntaxForView:(NSString *)viewName;
@@ -49,6 +50,7 @@
@synthesize sqlOutputIncludeUTF8BOM;
@synthesize sqlOutputEncodeBLOBasHex;
@synthesize sqlOutputIncludeErrors;
+@synthesize sqlOutputIncludeAutoIncrement;
@synthesize sqlCurrentTableExportIndex;
@synthesize sqlInsertAfterNValue;
@synthesize sqlInsertDivider;
@@ -261,6 +263,11 @@
createTableSyntax = [[[NSString alloc] initWithData:createTableSyntax encoding:[self exportOutputEncoding]] autorelease];
}
+ // If necessary strip out the AUTO_INCREMENT from the table structure definition
+ if (![self sqlOutputIncludeAutoIncrement]) {
+ createTableSyntax = [createTableSyntax stringByReplacingOccurrencesOfRegex:[NSString stringWithFormat:@"AUTO_INCREMENT=[0-9]+ "] withString:@""];
+ }
+
[[self exportOutputFile] writeData:[createTableSyntax dataUsingEncoding:NSUTF8StringEncoding]];
[[self exportOutputFile] writeData:[[NSString stringWithString:@";\n\n"] dataUsingEncoding:NSUTF8StringEncoding]];
}
diff --git a/Source/SPSSHTunnel.m b/Source/SPSSHTunnel.m
index aae71891..4839c886 100644
--- a/Source/SPSSHTunnel.m
+++ b/Source/SPSSHTunnel.m
@@ -356,19 +356,6 @@
// Launch and run the tunnel
[task launch];
- // TODO: The below code doesn't actually appear to work. We will probably have to switch to system()/exec() for grouped children...
- // Apply the process group to the child task to ensure it quits with the parent process.
- // Note that if run from within Xcode, Xcode is the parent process!
-/* pid_t group = setsid();
- if (group == -1) group = getpgrp();
- if(setpgid([task processIdentifier], group) == -1) {
- connectionState = SPSSH_STATE_IDLE;
- [task terminate];
- if (lastError) [lastError release];
- lastError = [[NSString alloc] initWithFormat:NSLocalizedString(@"The SSH Tunnel could not safely be marked as belonging to Sequel Pro, and so has been shut down for security reasons. Please try again.\n\n(Error %i)", @"SSH tunnel could not be security marked by Sequel Pro"), errno];
- if (delegate) [delegate performSelectorOnMainThread:stateChangeSelector withObject:self waitUntilDone:NO];
- }*/
-
// Listen for output
[task waitUntilExit];
diff --git a/Source/SPTableCopy.h b/Source/SPTableCopy.h
index 32eadcfc..56e1da8c 100644
--- a/Source/SPTableCopy.h
+++ b/Source/SPTableCopy.h
@@ -35,6 +35,7 @@
* @param name name of the table in the source database
* @param sourceDB name of the source database
* @param targetDB name of the target database
+ * @return YES on success, NO on any kind of error (unspecified)
*/
- (BOOL)copyTable:(NSString *)name from: (NSString *)sourceDB to: (NSString *)targetDB;
@@ -54,7 +55,21 @@
* @param sourceDB name of the source database
* @param targetDB name of the target database
* @param copyWithContent whether to copy the content too, otherwise only structure
+ * @return YES on success, NO on any kind of error (unspecified)
*/
- (BOOL)copyTable:(NSString *)tableName from: (NSString *)sourceDB to: (NSString *)targetDB withContent:(BOOL)copyWithContent;
+/**
+ * This method copies a bunch of tables including their data from one db to another.
+ *
+ * @param tableArray array of NSStrings with the table names in the sourceDB
+ * @param sourceDB name of the source database
+ * @param targetDB name of the target database
+ * @param copyWithContent whether to copy the content too, otherwise only structure
+ * @return YES on success, NO on any kind of error (unspecified)
+ *
+ * This method is able to copy InnoDB tables with foreign key constraints.
+ */
+- (BOOL)copyTables:(NSArray *)tablesArray from:(NSString *)sourceDB to:(NSString *)targetDB withContent:(BOOL)copyWithContent;
+
@end
diff --git a/Source/SPTableCopy.m b/Source/SPTableCopy.m
index 137e18a6..fd9b9055 100644
--- a/Source/SPTableCopy.m
+++ b/Source/SPTableCopy.m
@@ -56,7 +56,7 @@
[createTableStatement release];
- return [connection queryErrored];
+ return ![connection queryErrored];
}
[createTableStatement release];
@@ -67,10 +67,10 @@
- (BOOL)copyTable:(NSString *)tableName from:(NSString *)sourceDB to:(NSString *)targetDB withContent:(BOOL)copyWithContent
{
// Copy the table structure
- BOOL structureCopyResult = [self copyTable:tableName from:sourceDB to:targetDB];
+ BOOL structureCopySuccess = [self copyTable:tableName from:sourceDB to:targetDB];
// Optionally copy the table data using an insert select
- if (structureCopyResult && structureCopyResult && copyWithContent) {
+ if (structureCopySuccess && copyWithContent) {
NSString *copyDataStatement = [NSString stringWithFormat:@"INSERT INTO %@.%@ SELECT * FROM %@.%@",
[targetDB backtickQuotedString],
@@ -81,12 +81,38 @@
[connection queryString:copyDataStatement];
- if ([connection queryErrored]) return NO;
-
- return YES;
+ return ![connection queryErrored];
}
- return structureCopyResult;
+ return structureCopySuccess;
+}
+
+- (BOOL)copyTables:(NSArray *)tablesArray from:(NSString *)sourceDB to:(NSString *)targetDB withContent:(BOOL)copyWithContent
+{
+ BOOL success = YES;
+
+ // Disable foreign key checks
+ [connection queryString:@"/*!32352 SET foreign_key_checks=0 */"];
+
+ if ([connection queryErrored]) {
+ success = NO;
+ }
+
+ for (NSString *tableName in tablesArray)
+ {
+ if (![self copyTable:tableName from:sourceDB to:targetDB withContent:copyWithContent]) {
+ success = NO;
+ }
+ }
+
+ // Enable foreign key checks
+ [connection queryString:@"/*!32352 SET foreign_key_checks=1 */"];
+
+ if ([connection queryErrored]) {
+ success = NO;
+ }
+
+ return success;
}
- (BOOL)moveTable:(NSString *)tableName from:(NSString *)sourceDB to:(NSString *)targetDB
@@ -97,12 +123,10 @@
[targetDB backtickQuotedString],
[tableName backtickQuotedString]
];
- // Move the table
+
[connection queryString:moveStatement];
- if ([connection queryErrored]) return NO;
-
- return YES;
+ return ![connection queryErrored];
}
@end
diff --git a/Source/SPTableFieldValidation.m b/Source/SPTableFieldValidation.m
index ceee9b3b..0811aa33 100644
--- a/Source/SPTableFieldValidation.m
+++ b/Source/SPTableFieldValidation.m
@@ -25,7 +25,7 @@
#import "SPTableFieldValidation.h"
-@interface SPTableFieldValidation (PrivateAPI)
+@interface SPTableFieldValidation ()
- (NSString *)_formatType:(NSString *)type;
diff --git a/Source/SPTableInfo.m b/Source/SPTableInfo.m
index d06198b4..bb9abacd 100644
--- a/Source/SPTableInfo.m
+++ b/Source/SPTableInfo.m
@@ -126,9 +126,11 @@
[info removeAllObjects];
- if ([[tableListInstance tableName] isEqualToString:@""]) {
+ if (![tableListInstance tableName]) {
[info addObject:NSLocalizedString(@"INFORMATION", @"header for blank info pane")];
- [info addObject:NSLocalizedString(@"multiple selection", @"multiple selection")];
+ if ([[tableListInstance selectedTableItems] count]) {
+ [info addObject:NSLocalizedString(@"multiple selection", @"multiple selection")];
+ }
[infoTable reloadData];
return;
}
diff --git a/Source/SPTableStructureDelegate.m b/Source/SPTableStructureDelegate.m
index 6fc5e7b6..383a7474 100644
--- a/Source/SPTableStructureDelegate.m
+++ b/Source/SPTableStructureDelegate.m
@@ -128,12 +128,14 @@
// 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
[chooseKeyButton selectItemWithTag:SPPrimaryKeyMenuTag];
[NSApp beginSheet:keySheet
modalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo:@"autoincrementindex" ];
+#endif
}
} else {
autoIncrementIndex = nil;
diff --git a/Source/SPTableTriggers.m b/Source/SPTableTriggers.m
index d798a76b..ad412061 100644
--- a/Source/SPTableTriggers.m
+++ b/Source/SPTableTriggers.m
@@ -42,7 +42,7 @@ static const NSString *SPTriggerDefiner = @"TriggerDefiner";
static const NSString *SPTriggerCreated = @"TriggerCreated";
static const NSString *SPTriggerSQLMode = @"TriggerSQLMode";
-@interface SPTableTriggers (PrivateAPI)
+@interface SPTableTriggers ()
- (void)_editTriggerAtIndex:(NSInteger)index;
- (void)_toggleConfirmAddTriggerButtonEnabled;
@@ -268,7 +268,6 @@ static const NSString *SPTriggerSQLMode = @"TriggerSQLMode";
*/
- (IBAction)addTrigger:(id)sender
{
-
// Check whether table editing is permitted (necessary as some actions - eg table double-click - bypass validation)
if ([tableDocumentInstance isWorking] || [tablesListInstance tableType] != SPTableTypeTable) return;
diff --git a/Source/SPTextView.m b/Source/SPTextView.m
index a1b80ab4..5466bd83 100644
--- a/Source/SPTextView.m
+++ b/Source/SPTextView.m
@@ -1972,10 +1972,10 @@ NSInteger _alphabeticSort(id string1, id string2, void *reverse)
[self insertText:snip];
// If autopair is enabled check whether snip begins with ( and ends with ), if so mark ) as pair-linked
+ if (
#ifndef SP_REFACTOR
- if ([prefs boolForKey:SPCustomQueryAutoPairCharacters] &&
+ [prefs boolForKey:SPCustomQueryAutoPairCharacters] &&
#else
- if (
#endif
(([snip hasPrefix:@"("] && [snip hasSuffix:@")"])
|| ([snip hasPrefix:@"`"] && [snip hasSuffix:@"`"])
@@ -2189,8 +2189,10 @@ NSInteger _alphabeticSort(id string1, id string2, void *reverse)
// 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
NSRange targetRange = [self getRangeForCurrentWord];
NSString *tabTrigger = [[self string] substringWithRange:targetRange];
+#endif
// Is TAB trigger active change selection according to {SHIFT}TAB
if(snippetControlCounter > -1){
@@ -2233,6 +2235,7 @@ NSInteger _alphabeticSort(id string1, id string2, void *reverse)
}
+#ifndef SP_REFACTOR
// 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];
@@ -2244,7 +2247,6 @@ NSInteger _alphabeticSort(id string1, id string2, void *reverse)
// Check for TAB as indention for current line, i.e. left of the caret there are only white spaces
// but only if Soft Indent is set
-#ifndef SP_REFACTOR
if([prefs boolForKey:SPCustomQuerySoftIndent] && [self isCaretAtIndentPositionIgnoreLineStart:YES]) {
if([self shiftSelectionRight]) return;
}
@@ -2426,7 +2428,13 @@ NSInteger _alphabeticSort(id string1, id string2, void *reverse)
}
return;
}
+
+// Let Xcode 3 match braces correctly...
+#ifndef SP_REFACTOR
+ }
+#else
}
+#endif
// break down the undo grouping level for better undo behavior
[self breakUndoCoalescing];
@@ -3234,8 +3242,8 @@ NSInteger _alphabeticSort(id string1, id string2, void *reverse)
}
// Disable "Copy with Column Names" and "Copy as SQL INSERT"
// in the main menu
- if ( [menuItem tag] == MENU_EDIT_COPY_WITH_COLUMN
- || [menuItem tag] == MENU_EDIT_COPY_AS_SQL ) {
+ if ( [menuItem tag] == SPEditMenuCopyWithColumns
+ || [menuItem tag] == SPEditCopyAsSQL ) {
return NO;
}
@@ -3437,7 +3445,11 @@ NSInteger _alphabeticSort(id string1, id string2, void *reverse)
}
// Check size and NSFileType
+#ifndef SP_REFACTOR
NSDictionary *attr = [[NSFileManager defaultManager] fileAttributesAtPath:filepath traverseLink:YES];
+#else
+ NSDictionary *attr = [[NSFileManager defaultManager] attributesOfItemAtPath:filepath error:nil];
+#endif
if(attr)
{
NSNumber *filesize = [attr objectForKey:NSFileSize];
diff --git a/Source/SPUserMO.m b/Source/SPUserMO.m
index a9e9ddbb..d952f9da 100644
--- a/Source/SPUserMO.m
+++ b/Source/SPUserMO.m
@@ -24,6 +24,11 @@
#import "SPUserMO.h"
+static NSString *SPUserMOParentKey = @"parent";
+static NSString *SPUserMOUserKey = @"user";
+static NSString *SPUserMOHostKey = @"host";
+static NSString *SPUserMOChildrenKey = @"children";
+
@implementation NSManagedObject (CoreDataGeneratedAccessors)
@dynamic user;
@@ -33,23 +38,17 @@
- (NSString *)displayName
{
- return ([self valueForKey:@"parent"] == nil) ? self.user : self.host;
+ return ([self valueForKey:SPUserMOParentKey] == nil) ? self.user : self.host;
}
- (void)setDisplayName:(NSString *)value
{
- if ([self valueForKey:@"parent"] == nil)
- [self setValue:value forKey:@"user"];
+ if ([self valueForKey:SPUserMOParentKey] == nil) {
+ [self setValue:value forKey:SPUserMOUserKey];
+ }
else
{
- if (value == nil)
- {
- [self setValue:@"%" forKey:@"host"];
- }
- else
- {
- [self setValue:value forKey:@"host"];
- }
+ [self setValue:(value == nil) ? @"%" : value forKey:SPUserMOHostKey];
}
}
@@ -57,11 +56,12 @@
{
NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
- [self willChangeValueForKey:@"children" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
- [[self primitiveValueForKey:@"children"] addObject:value];
- [self didChangeValueForKey:@"children" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
+ [self willChangeValueForKey:SPUserMOChildrenKey withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
+ [[self primitiveValueForKey:SPUserMOChildrenKey] addObject:value];
+ [self didChangeValueForKey:SPUserMOChildrenKey withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
[changedObjects release];
+
value.user = self.user;
}
@@ -69,9 +69,9 @@
{
NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
- [self willChangeValueForKey:@"children" withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
- [[self primitiveValueForKey:@"children"] removeObject:value];
- [self didChangeValueForKey:@"children" withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
+ [self willChangeValueForKey:SPUserMOChildrenKey withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
+ [[self primitiveValueForKey:SPUserMOChildrenKey] removeObject:value];
+ [self didChangeValueForKey:SPUserMOChildrenKey withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
[changedObjects release];
}
diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m
index 224b36c6..ac539624 100644
--- a/Source/SPUserManager.m
+++ b/Source/SPUserManager.m
@@ -477,9 +477,9 @@ static const NSString *SPTableViewNameColumnID = @"NameColumn";
NSError *error = nil;
errorsString = [[NSMutableString alloc] init];
- //Change the first responder to end editing in any field
- [[self window] makeFirstResponder:self];
-
+ // Change the first responder to end editing in any field
+ [[self window] makeFirstResponder:self];
+
isSaving = YES;
[[self managedObjectContext] save:&error];
diff --git a/Source/SPWindow.m b/Source/SPWindow.m
index d023b7b4..213d7740 100644
--- a/Source/SPWindow.m
+++ b/Source/SPWindow.m
@@ -39,7 +39,6 @@
*/
- (void) sendEvent:(NSEvent *)theEvent
{
-
if ([theEvent type] == NSKeyDown && [[theEvent charactersIgnoringModifiers] length]) {
unichar theCharacter = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];