aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2011-08-31 01:23:29 +0000
committerrowanbeentje <rowan@beent.je>2011-08-31 01:23:29 +0000
commitdebc98eb182d845e4ab803c1cd1d84908da745d3 (patch)
tree178b95a43aceb14c427fb49a7e185115eaab6b39 /Source
parenta15f9f07c618351d61cc1991edf8c8b892e7d13e (diff)
downloadsequelpro-debc98eb182d845e4ab803c1cd1d84908da745d3.tar.gz
sequelpro-debc98eb182d845e4ab803c1cd1d84908da745d3.tar.bz2
sequelpro-debc98eb182d845e4ab803c1cd1d84908da745d3.zip
- Clean up undo manager handling
- Implement an undo manager per tab (strictly speaking, per connection 'document'), addressing Issue #1109.
Diffstat (limited to 'Source')
-rw-r--r--Source/SPBundleEditorController.m1
-rw-r--r--Source/SPCustomQuery.m7
-rw-r--r--Source/SPDatabaseDocument.h2
-rw-r--r--Source/SPDatabaseDocument.m12
-rw-r--r--Source/SPSSHTunnel.m2
-rw-r--r--Source/SPWindow.m14
6 files changed, 37 insertions, 1 deletions
diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m
index ba053236..8736375a 100644
--- a/Source/SPBundleEditorController.m
+++ b/Source/SPBundleEditorController.m
@@ -109,6 +109,7 @@
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];
}
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m
index c26ca28f..80b69358 100644
--- a/Source/SPCustomQuery.m
+++ b/Source/SPCustomQuery.m
@@ -2769,6 +2769,13 @@
}
+#ifndef SP_REFACTOR
+- (NSUndoManager *)undoManagerForTextView:(NSTextView *)aTextView
+{
+ return [tableDocumentInstance undoManager];
+}
+#endif
+
#pragma mark -
#pragma mark SplitView delegate methods
diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h
index 31c3d636..a0d02bb6 100644
--- a/Source/SPDatabaseDocument.h
+++ b/Source/SPDatabaseDocument.h
@@ -170,6 +170,7 @@ SPDatabaseData, SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPS
#ifndef SP_REFACTOR /* ivars */
NSUserDefaults *prefs;
NSMutableArray *nibObjectsToRelease;
+ NSUndoManager *undoManager;
#endif
NSMenu *selectEncodingMenu;
@@ -378,6 +379,7 @@ SPDatabaseData, SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPS
- (NSURL *)fileURL;
- (NSString *)displayName;
#ifndef SP_REFACTOR /* method decls */
+- (NSUndoManager *)undoManager;
// Notification center methods
- (void)willPerformQuery:(NSNotification *)notification;
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index d9e9b671..18bc6407 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -176,6 +176,7 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax";
[printWebView setFrameLoadDelegate:self];
prefs = [NSUserDefaults standardUserDefaults];
+ undoManager = [[NSUndoManager alloc] init];
#endif
queryEditorInitString = nil;
@@ -4128,6 +4129,15 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax";
}
return [[[self fileURL] path] lastPathComponent];
}
+
+#ifndef SP_REFACTOR
+- (NSUndoManager *)undoManager
+{
+ return undoManager;
+}
+#endif
+
+
#ifndef SP_REFACTOR /* state saving and setting */
#pragma mark -
#pragma mark State saving and setting
@@ -5629,11 +5639,13 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax";
for (id retainedObject in nibObjectsToRelease) [retainedObject release];
[nibObjectsToRelease release];
+
#endif
[allDatabases release];
[allSystemDatabases release];
#ifndef SP_REFACTOR /* dealloc ivars */
+ [undoManager release];
[printWebView release];
#endif
[taskProgressWindow close];
diff --git a/Source/SPSSHTunnel.m b/Source/SPSSHTunnel.m
index d0464d59..04e21e5f 100644
--- a/Source/SPSSHTunnel.m
+++ b/Source/SPSSHTunnel.m
@@ -644,7 +644,7 @@
if (requestedResponse) {
NSString *thePassword = [NSString stringWithString:[sshPasswordField stringValue]];
[sshPasswordField setStringValue:@""];
- if ([delegate respondsToSelector:@selector(setUndoManager:)] && [delegate undoManager]) {
+ if ([delegate respondsToSelector:@selector(undoManager)] && [delegate undoManager]) {
[[delegate undoManager] removeAllActionsWithTarget:sshPasswordField];
} else if ([[parentWindow windowController] document] && [[[parentWindow windowController] document] undoManager]) {
[[[[parentWindow windowController] document] undoManager] removeAllActionsWithTarget:sshPasswordField];
diff --git a/Source/SPWindow.m b/Source/SPWindow.m
index 414d043a..2f5cf56e 100644
--- a/Source/SPWindow.m
+++ b/Source/SPWindow.m
@@ -115,5 +115,19 @@
[super sendEvent:theEvent];
}
+/**
+ * If this window is controlled by an SPWindowController, and thus supports being asked
+ * for the frontmost SPTableDocument, request the undoController for that table
+ * document. This allows undo to be individual per tab rather than shared across the
+ * window.
+ */
+- (NSUndoManager *)undoManager
+{
+ if ([[self windowController] respondsToSelector:@selector(selectedTableDocument)]) {
+ NSLog(@"Test: %@", [[[[self windowController] selectedTableDocument] undoManager] description]);
+ return [[[self windowController] selectedTableDocument] undoManager];
+ }
+ return [super undoManager];
+}
@end