aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordrx777 <david.rekowski@gmx.de>2010-04-29 18:00:09 +0000
committerdrx777 <david.rekowski@gmx.de>2010-04-29 18:00:09 +0000
commit47d42106c45d7663c05aaf6d3f0feab71798b51c (patch)
tree8d33140d9ed7713318bd4dcf1ec40c67fbceb385
parenta980040e8546060e71166c363d2247407af12179 (diff)
downloadsequelpro-47d42106c45d7663c05aaf6d3f0feab71798b51c.tar.gz
sequelpro-47d42106c45d7663c05aaf6d3f0feab71798b51c.tar.bz2
sequelpro-47d42106c45d7663c05aaf6d3f0feab71798b51c.zip
Added class SPDBActionCommons providing common functionality to all derived DatabaseActions classes, thus reducing code duplicates.
-rw-r--r--Source/SPDBActionCommons.h54
-rw-r--r--Source/SPDBActionCommons.m36
-rw-r--r--Source/SPDatabaseCopy.h18
-rw-r--r--Source/SPDatabaseCopy.m9
-rw-r--r--Source/SPDatabaseInfo.h18
-rw-r--r--Source/SPDatabaseInfo.m7
-rw-r--r--Source/SPDatabaseRename.h19
-rw-r--r--Source/SPDatabaseRename.m9
-rw-r--r--Source/SPTableCopy.h17
-rw-r--r--Source/SPTableCopy.m8
-rw-r--r--sequel-pro.xcodeproj/project.pbxproj6
11 files changed, 108 insertions, 93 deletions
diff --git a/Source/SPDBActionCommons.h b/Source/SPDBActionCommons.h
new file mode 100644
index 00000000..042fd5dc
--- /dev/null
+++ b/Source/SPDBActionCommons.h
@@ -0,0 +1,54 @@
+//
+// $Id$
+//
+// SPDBActionCommons.h
+// sequel-pro
+//
+// Created by David Rekowski on Apr 29, 2010
+//
+// 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/>
+
+#import <Foundation/Foundation.h>
+#import <Cocoa/Cocoa.h>
+#import <MCPKit/MCPConnection.h>
+#import <MCPKit/MCPResult.h>
+#import "SPAlertSheets.h"
+#import "SPStringAdditions.h"
+#import "Sequel-Pro.pch"
+
+@interface SPDBActionCommons : NSObject {
+ MCPConnection *connection;
+ NSObject *parent;
+ NSDocument *messageDocument;
+}
+
+/**
+ * @property MCPConnection references the MCPKit connection to MySQL; it has to be set.
+ */
+@property (retain) MCPConnection *connection;
+
+/**
+ * @property the parent object that issues the action, needs to provide stuff like tableWindow for messages
+ */
+@property (retain) NSObject *parent;
+
+/**
+ * @property the NSDocument instance to send message sheets to
+ */
+@property (retain) NSDocument *messageDocument;
+
+@end
diff --git a/Source/SPDBActionCommons.m b/Source/SPDBActionCommons.m
new file mode 100644
index 00000000..c0580622
--- /dev/null
+++ b/Source/SPDBActionCommons.m
@@ -0,0 +1,36 @@
+//
+// $Id$
+//
+// SPDBActionCommons.m
+// sequel-pro
+//
+// Created by David Rekowski on Apr 29, 2010
+//
+// 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/>
+
+#import "SPDBActionCommons.h"
+#import "SPAlertSheets.h"
+#import "SPStringAdditions.h"
+#import "Sequel-Pro.pch"
+
+@implementation SPDBActionCommons
+
+@synthesize connection;
+@synthesize parent;
+@synthesize messageDocument;
+
+@end
diff --git a/Source/SPDatabaseCopy.h b/Source/SPDatabaseCopy.h
index 48219298..3776d5a1 100644
--- a/Source/SPDatabaseCopy.h
+++ b/Source/SPDatabaseCopy.h
@@ -23,36 +23,22 @@
// More info at <http://code.google.com/p/sequel-pro/>
-#import <Foundation/Foundation.h>
-#import <MCPKit/MCPConnection.h>
+#import "SPDBActionCommons.h"
#import "SPDatabaseInfo.h"
/**
* The SPDatabaseCopy class povides functionality to create a copy of a database.
*/
-@interface SPDatabaseCopy : NSObject {
- MCPConnection *connection;
+@interface SPDatabaseCopy : SPDBActionCommons {
SPDatabaseInfo *dbInfo;
- NSObject *parent;
}
/**
- * @property MCPConnection references the MCPKit connection to MySQL; it has to be set.
- */
-@property (retain) MCPConnection *connection;
-
-/**
* @property SPDatabaseInfo an instance of the database info class
*/
@property (retain) SPDatabaseInfo *dbInfo;
/**
- * @property the parent object that issues the action, needs to provide stuff like tableWindow for messages
- */
-@property (retain) NSObject *parent;
-
-
-/**
* This method retrieves the dbInfo object if it exists; otherwise it is generated and the
* connection is passed to it.
*
diff --git a/Source/SPDatabaseCopy.m b/Source/SPDatabaseCopy.m
index e12d650c..e5daae0c 100644
--- a/Source/SPDatabaseCopy.m
+++ b/Source/SPDatabaseCopy.m
@@ -22,20 +22,13 @@
//
// More info at <http://code.google.com/p/sequel-pro/>
-#import <MCPKit/MCPConnection.h>
-#import <MCPKit/MCPResult.h>
-#import "SPAlertSheets.h"
-#import "SPStringAdditions.h"
+#import "SPDBActionCommons.h"
#import "SPDatabaseCopy.h"
#import "SPTableCopy.h"
-#import "SPDatabaseInfo.h"
-#import "Sequel-Pro.pch"
@implementation SPDatabaseCopy
-@synthesize connection;
@synthesize dbInfo;
-@synthesize parent;
- (SPDatabaseInfo *)getDBInfoObject {
if (dbInfo != nil) {
diff --git a/Source/SPDatabaseInfo.h b/Source/SPDatabaseInfo.h
index 45583e5c..3f68b773 100644
--- a/Source/SPDatabaseInfo.h
+++ b/Source/SPDatabaseInfo.h
@@ -22,29 +22,15 @@
//
// More info at <http://code.google.com/p/sequel-pro/>
-#import <Foundation/Foundation.h>
-#import "MCPConnection.h"
-#import "MCPResult.h"
+#import "SPDBActionCommons.h"
/*
* The SPDatabaseInfo class provides means of retrieving a list of database names
*/
-@interface SPDatabaseInfo : NSObject {
- MCPConnection *connection;
- NSObject *parent;
+@interface SPDatabaseInfo : SPDBActionCommons {
}
/**
- * @property MCPConnection references the MCPKit connection to MySQL; it has to be set.
- */
-@property (retain) MCPConnection *connection;
-
-/**
- * @property the parent object that issues the action, needs to provide stuff like tableWindow for messages
- */
-@property (retain) NSObject *parent;
-
-/**
* This method checks, whether a database exists.
*
* @param databaseName the name of the database to check
diff --git a/Source/SPDatabaseInfo.m b/Source/SPDatabaseInfo.m
index 6e5cbcc6..9dbf2098 100644
--- a/Source/SPDatabaseInfo.m
+++ b/Source/SPDatabaseInfo.m
@@ -22,16 +22,11 @@
//
// More info at <http://code.google.com/p/sequel-pro/>
-#import "SPAlertSheets.h"
+#import "SPDBActionCommons.h"
#import "SPDatabaseInfo.h"
-#import "SPStringAdditions.h"
-#import "Sequel-Pro.pch"
@implementation SPDatabaseInfo
-@synthesize connection;
-@synthesize parent;
-
- (NSObject *)getTableWindow {
return [NSApp mainWindow];
}
diff --git a/Source/SPDatabaseRename.h b/Source/SPDatabaseRename.h
index 9085cc54..bd52a86f 100644
--- a/Source/SPDatabaseRename.h
+++ b/Source/SPDatabaseRename.h
@@ -23,37 +23,22 @@
// More info at <http://code.google.com/p/sequel-pro/>
-#import <Foundation/Foundation.h>
-#import <MCPKit/MCPConnection.h>
+#import "SPDBActionCommons.h"
#import "SPDatabaseInfo.h"
-#import "SPStringAdditions.h"
/**
* The SPDatabaseRename class povides functionality to rename a database.
*/
-@interface SPDatabaseRename : NSObject {
- MCPConnection *connection;
+@interface SPDatabaseRename : SPDBActionCommons {
SPDatabaseInfo *dbInfo;
- NSObject *parent;
}
/**
- * @property MCPConnection references the MCPKit connection to MySQL; it has to be set.
- */
-@property (retain) MCPConnection *connection;
-
-/**
* @property SPDatabaseInfo an instance of the database info class
*/
@property (retain) SPDatabaseInfo *dbInfo;
/**
- * @property the parent object that issues the action, needs to provide stuff like tableWindow for messages
- */
-@property (retain) NSObject *parent;
-
-
-/**
* This method retrieves the dbInfo object if it exists; otherwise it is generated and the
* connection is passed to it.
*
diff --git a/Source/SPDatabaseRename.m b/Source/SPDatabaseRename.m
index 7ff91b29..75478412 100644
--- a/Source/SPDatabaseRename.m
+++ b/Source/SPDatabaseRename.m
@@ -23,20 +23,13 @@
// More info at <http://code.google.com/p/sequel-pro/>
-#import <MCPKit/MCPConnection.h>
-#import <MCPKit/MCPResult.h>
-#import "SPAlertSheets.h"
-#import "SPStringAdditions.h"
+#import "SPDBActionCommons.h"
#import "SPDatabaseRename.h"
-#import "SPDatabaseInfo.h"
#import "SPTableCopy.h"
-#import "Sequel-Pro.pch"
@implementation SPDatabaseRename
-@synthesize connection;
@synthesize dbInfo;
-@synthesize parent;
- (SPDatabaseInfo *)getDBInfoObject {
if (dbInfo != nil) {
diff --git a/Source/SPTableCopy.h b/Source/SPTableCopy.h
index a9c1f389..37ed452a 100644
--- a/Source/SPTableCopy.h
+++ b/Source/SPTableCopy.h
@@ -22,28 +22,15 @@
//
// More info at <http://code.google.com/p/sequel-pro/>
-#import <Foundation/Foundation.h>
-#import <MCPKit/MCPConnection.h>
+#import "SPDBActionCommons.h"
/**
* The SPTableCopy class povides functionality to copy tables between databases.
*/
-@interface SPTableCopy : NSObject {
- MCPConnection *connection;
- NSObject *parent;
+@interface SPTableCopy : SPDBActionCommons {
}
/**
- * @property MCPConnection references the MCPKit connection to MySQL; it has to be set.
- */
-@property (retain) MCPConnection *connection;
-
-/**
- * @property the parent object that issues the action, needs to provide stuff like tableWindow for messages
- */
-@property (retain) NSObject *parent;
-
-/**
* This method copies a table structure from one db to another.
*
* @param name name of the table in the source database
diff --git a/Source/SPTableCopy.m b/Source/SPTableCopy.m
index f9bb159a..6a73bb20 100644
--- a/Source/SPTableCopy.m
+++ b/Source/SPTableCopy.m
@@ -22,17 +22,11 @@
//
// More info at <http://code.google.com/p/sequel-pro/>
-#import <MCPKit/MCPConnection.h>
-#import "SPAlertSheets.h"
-#import "SPStringAdditions.h"
+#import "SPDBActionCommons.h"
#import "SPTableCopy.h"
-#import "Sequel-Pro.pch"
@implementation SPTableCopy
-@synthesize connection;
-@synthesize parent;
-
- (NSObject *)getTableWindow {
return [NSApp mainWindow];
}
diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj
index 3bd6fd36..aa2144b6 100644
--- a/sequel-pro.xcodeproj/project.pbxproj
+++ b/sequel-pro.xcodeproj/project.pbxproj
@@ -17,6 +17,7 @@
1198F5C41174EF3F00670590 /* SPDatabaseCopyTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1198F5C31174EF3F00670590 /* SPDatabaseCopyTest.m */; };
1198F7541174FFCF00670590 /* SPDatabaseCopy.m in Sources */ = {isa = PBXBuildFile; fileRef = 1198F5B21174EDD500670590 /* SPDatabaseCopy.m */; };
1198F873117510EE00670590 /* OCMock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1198F872117510EE00670590 /* OCMock.framework */; };
+ 11B55BFE1189E3B2009EF465 /* SPDBActionCommons.m in Sources */ = {isa = PBXBuildFile; fileRef = 11B55BFD1189E3B2009EF465 /* SPDBActionCommons.m */; };
11C211261180EBFF00758039 /* SPDatabaseRenameTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 11C210DE1180E9B800758039 /* SPDatabaseRenameTest.m */; };
11C211271180EC0400758039 /* SPDatabaseRename.m in Sources */ = {isa = PBXBuildFile; fileRef = 11C2109D1180E70800758039 /* SPDatabaseRename.m */; };
11C211301180EC9A00758039 /* SPDatabaseRename.m in Sources */ = {isa = PBXBuildFile; fileRef = 11C2109D1180E70800758039 /* SPDatabaseRename.m */; };
@@ -334,6 +335,8 @@
1198F5C21174EF3F00670590 /* SPDatabaseCopyTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPDatabaseCopyTest.h; sourceTree = "<group>"; };
1198F5C31174EF3F00670590 /* SPDatabaseCopyTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPDatabaseCopyTest.m; sourceTree = "<group>"; };
1198F872117510EE00670590 /* OCMock.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OCMock.framework; path = Library/Frameworks/OCMock.framework; sourceTree = DEVELOPER_DIR; };
+ 11B55BFC1189E3B2009EF465 /* SPDBActionCommons.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPDBActionCommons.h; sourceTree = "<group>"; };
+ 11B55BFD1189E3B2009EF465 /* SPDBActionCommons.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPDBActionCommons.m; sourceTree = "<group>"; };
11C2109C1180E70800758039 /* SPDatabaseRename.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPDatabaseRename.h; sourceTree = "<group>"; };
11C2109D1180E70800758039 /* SPDatabaseRename.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPDatabaseRename.m; sourceTree = "<group>"; };
11C210DD1180E9B800758039 /* SPDatabaseRenameTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPDatabaseRenameTest.h; sourceTree = "<group>"; };
@@ -816,6 +819,8 @@
115D63E1117CBC5900419057 /* SPDatabaseInfo.m */,
11C2109C1180E70800758039 /* SPDatabaseRename.h */,
11C2109D1180E70800758039 /* SPDatabaseRename.m */,
+ 11B55BFC1189E3B2009EF465 /* SPDBActionCommons.h */,
+ 11B55BFD1189E3B2009EF465 /* SPDBActionCommons.m */,
);
name = DatabaseActions;
sourceTree = "<group>";
@@ -1995,6 +2000,7 @@
1198F5B31174EDD500670590 /* SPDatabaseCopy.m in Sources */,
1141A389117BBFF200126A28 /* SPTableCopy.m in Sources */,
115D63E2117CBC5900419057 /* SPDatabaseInfo.m in Sources */,
+ 11B55BFE1189E3B2009EF465 /* SPDBActionCommons.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};