aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/SPConnectionController.m10
-rw-r--r--Source/SPConnectionControllerDelegate.m15
-rw-r--r--Source/SPFavoritesExporter.h4
-rw-r--r--Source/SPFavoritesExporter.m19
-rw-r--r--Source/SPFavoritesImportProtocol.h42
-rw-r--r--Source/SPFavoritesImporter.h17
-rw-r--r--Source/SPFavoritesImporter.m23
-rw-r--r--Source/SPPreferenceController.h2
-rw-r--r--Source/SPTablesList.m2
-rw-r--r--sequel-pro.xcodeproj/project.pbxproj2
10 files changed, 116 insertions, 20 deletions
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index 6ed6e392..a5021206 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -1136,18 +1136,18 @@ static NSComparisonResult compareFavoritesUsingKey(id favorite1, id favorite2, v
* Called when the user dismisses either the import of export favorites panels.
*/
- (void)importExportFavoritesSheetDidEnd:(NSOpenPanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo
-{
- NSError *error = nil;
-
+{
if (contextInfo == SPExportFavorites) {
SPFavoritesExporter *exporter = [[[SPFavoritesExporter alloc] init] autorelease];
[exporter setDelegate:self];
- [exporter writeFavorites:[self selectedFavoriteNodes] toFile:[panel filename] error:&error];
+ [exporter writeFavorites:[self selectedFavoriteNodes] toFile:[panel filename]];
}
else if (contextInfo == SPImportFavorites) {
- //SPFavoritesImporter *importer = [[SPFavoritesImporter alloc] init];
+ SPFavoritesImporter *importer = [[SPFavoritesImporter alloc] init];
+
+ [importer setDelegate:self];
}
}
diff --git a/Source/SPConnectionControllerDelegate.m b/Source/SPConnectionControllerDelegate.m
index 03dbd930..63f58ace 100644
--- a/Source/SPConnectionControllerDelegate.m
+++ b/Source/SPConnectionControllerDelegate.m
@@ -37,7 +37,7 @@
static NSString *SPDatabaseImage = @"database-small";
-@interface SPConnectionController (PrivateAPI)
+@interface SPConnectionController ()
- (void)_checkHost;
- (void)_favoriteTypeDidChange;
@@ -508,4 +508,17 @@ static NSString *SPDatabaseImage = @"database-small";
}
}
+/**
+ * Called by the favorites importer when the import completes.
+ */
+- (void)favoritesImportCompletedWithError:(NSError *)error
+{
+ if (error) {
+ [[NSAlert alertWithError:error] beginSheetModalForWindow:[dbDocument parentWindow]
+ modalDelegate:self
+ didEndSelector:NULL
+ contextInfo:NULL];
+ }
+}
+
@end
diff --git a/Source/SPFavoritesExporter.h b/Source/SPFavoritesExporter.h
index 058c5a42..2ffb2a21 100644
--- a/Source/SPFavoritesExporter.h
+++ b/Source/SPFavoritesExporter.h
@@ -29,8 +29,6 @@
{
NSObject <SPFavoritesExportProtocol> *delegate;
- NSError *exportError;
-
NSString *exportPath;
NSArray *exportFavorites;
}
@@ -47,6 +45,6 @@
*/
@property (readwrite, retain) NSArray *exportFavorites;
-- (void)writeFavorites:(NSArray *)favorites toFile:(NSString *)path error:(NSError **)error;
+- (void)writeFavorites:(NSArray *)favorites toFile:(NSString *)path;
@end
diff --git a/Source/SPFavoritesExporter.m b/Source/SPFavoritesExporter.m
index a818fdcf..cefa5190 100644
--- a/Source/SPFavoritesExporter.m
+++ b/Source/SPFavoritesExporter.m
@@ -29,6 +29,7 @@
@interface SPFavoritesExporter ()
- (void)_writeFavoritesInBackground;
+- (void)_informDelegateOfExportCompletion:(NSError *)error;
@end
@@ -44,11 +45,8 @@
* @param favorites The array of favorites to be written
* @param path The file system path that the file is to be written to
* @param filename The filename of the file to be written
- * @param error Upon return if an error occurred contains the NSError instance
- *
- * @return A BOOL indicating the success of the operation
*/
-- (void)writeFavorites:(NSArray *)favorites toFile:(NSString *)path error:(NSError **)error
+- (void)writeFavorites:(NSArray *)favorites toFile:(NSString *)path
{
[self setExportFavorites:favorites];
[self setExportPath:path];
@@ -96,12 +94,19 @@
[errorString release];
}
- // Inform the delegate that the export has completed and pass the error instance
+ [self _informDelegateOfExportCompletion:error];
+
+ [pool release];
+}
+
+/**
+ * Informs the delegate that the export process has completed.
+ */
+ - (void)_informDelegateOfExportCompletion:(NSError *)error
+{
if ([self delegate] && [[self delegate] respondsToSelector:@selector(favoritesExportCompletedWithError:)]) {
[[self delegate] performSelectorOnMainThread:@selector(favoritesExportCompletedWithError:) withObject:error waitUntilDone:NO];
}
-
- [pool release];
}
@end
diff --git a/Source/SPFavoritesImportProtocol.h b/Source/SPFavoritesImportProtocol.h
new file mode 100644
index 00000000..bb178fc8
--- /dev/null
+++ b/Source/SPFavoritesImportProtocol.h
@@ -0,0 +1,42 @@
+//
+// $Id$
+//
+// SPFavoritesImportProtocol.h
+// sequel-pro
+//
+// Created by Stuart Connolly (stuconnolly.com) on August 1, 2011
+// Copyright (c) 2011 Stuart Connolly. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// More info at <http://code.google.com/p/sequel-pro/>
+
+/**
+ * @protocol SPFavoritesExportProtocol SPFavoritesExportProtocol.h
+ *
+ * @author Stuart Connolly http://stuconnolly.com/
+ *
+ * Favorites importer delegate protocol.
+ */
+@protocol SPFavoritesImportProtocol
+
+/**
+ * Invoked when the favorites import proccess completes
+ *
+ * @param error An error instance. Anything other than nil indicates an error occurred.
+ */
+- (void)favoritesImportCompletedWithError:(NSError *)error;
+
+@end
diff --git a/Source/SPFavoritesImporter.h b/Source/SPFavoritesImporter.h
index fefc54e4..0d86bad1 100644
--- a/Source/SPFavoritesImporter.h
+++ b/Source/SPFavoritesImporter.h
@@ -23,9 +23,24 @@
//
// More info at <http://code.google.com/p/sequel-pro/>
+#import "SPFavoritesImportProtocol.h"
+
@interface SPFavoritesImporter : NSObject
{
-
+ NSObject <SPFavoritesImportProtocol> *delegate;
+
+ NSError *importError;
+
+ NSString *importPath;
}
+@property (readwrite, assign) NSObject <SPFavoritesImportProtocol> *delegate;
+
+/**
+ * @property exportPath The file path to import from
+ */
+@property (readwrite, retain) NSString *importPath;
+
+- (void)importFavoritesFromFileAtPath:(NSString *)path;
+
@end
diff --git a/Source/SPFavoritesImporter.m b/Source/SPFavoritesImporter.m
index 4b62d5d0..1031f5a5 100644
--- a/Source/SPFavoritesImporter.m
+++ b/Source/SPFavoritesImporter.m
@@ -25,6 +25,29 @@
#import "SPFavoritesImporter.h"
+@interface SPFavoritesImporter ()
+
+- (void)_importFavoritesInBackground;
+
+@end
+
@implementation SPFavoritesImporter
+@synthesize delegate;
+@synthesize importPath;
+
+/**
+ *
+ * @param path The path of the file to import
+ */
+- (void)importFavoritesFromFileAtPath:(NSString *)path
+{
+
+}
+
+- (void)_importFavoritesInBackground
+{
+
+}
+
@end
diff --git a/Source/SPPreferenceController.h b/Source/SPPreferenceController.h
index 464a2f0c..f05b63e3 100644
--- a/Source/SPPreferenceController.h
+++ b/Source/SPPreferenceController.h
@@ -78,13 +78,11 @@
*/
@property (readwrite, assign) NSUInteger fontChangeTarget;
-
// Toolbar item IBAction methods
- (IBAction)displayPreferencePane:(id)sender;
- (IBAction)displayTablePreferences:(id)sender;
- (IBAction)displayEditorPreferences:(id)sender;
-// Other
- (void)changeFont:(id)sender;
@end
diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m
index 5054798c..3930406f 100644
--- a/Source/SPTablesList.m
+++ b/Source/SPTablesList.m
@@ -1129,7 +1129,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
/**
* Returns the currently selected table type, or -1 if no table or multiple tables are selected
*/
-- (SPTableType) tableType
+- (SPTableType)tableType
{
return selectedTableType;
}
diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj
index bbad5a65..6d0cca09 100644
--- a/sequel-pro.xcodeproj/project.pbxproj
+++ b/sequel-pro.xcodeproj/project.pbxproj
@@ -588,6 +588,7 @@
1723F04B12F1F8850008253B /* run-tests.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "run-tests.sh"; sourceTree = "<group>"; };
1723F08912F1F9350008253B /* SPWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPWindow.h; sourceTree = "<group>"; };
1723F08A12F1F9350008253B /* SPWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPWindow.m; sourceTree = "<group>"; };
+ 17278EBB13E74938003DD92A /* SPFavoritesImportProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPFavoritesImportProtocol.h; sourceTree = "<group>"; };
17292441107AC41000B21980 /* SPXMLExporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPXMLExporter.h; sourceTree = "<group>"; };
17292442107AC41000B21980 /* SPXMLExporter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPXMLExporter.m; sourceTree = "<group>"; };
172A650F0F7BED7A001E861A /* SPConsoleMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPConsoleMessage.h; sourceTree = "<group>"; };
@@ -2284,6 +2285,7 @@
17F9187013A4274A005EE9BD /* Delegate Protocols */ = {
isa = PBXGroup;
children = (
+ 17278EBB13E74938003DD92A /* SPFavoritesImportProtocol.h */,
17F9185C13A415C5005EE9BD /* SPFavoritesExportProtocol.h */,
17D38FC3127B0CFC00672B13 /* SPConnectionControllerDelegateProtocol.h */,
);