aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableDocument.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2009-03-26 23:28:27 +0000
committerstuconnolly <stuart02@gmail.com>2009-03-26 23:28:27 +0000
commit3a7dc0b03bc51f46d762e2bbe6d7afdee59288ef (patch)
treeafdf05045c74e6a7f12590a4005a306a76d221e3 /Source/TableDocument.m
parent93dfcc27627fd64c1f6c3124297252298a3f499a (diff)
downloadsequelpro-3a7dc0b03bc51f46d762e2bbe6d7afdee59288ef.tar.gz
sequelpro-3a7dc0b03bc51f46d762e2bbe6d7afdee59288ef.tar.bz2
sequelpro-3a7dc0b03bc51f46d762e2bbe6d7afdee59288ef.zip
Completely redesigned query console that now uses a table view instead of a text view. This should significantly improve import speed, but most importantly resolves the crashes caused by the drawing that was being performed by the text view. Fixes issue #87 and implements #167.
New console provides the following: - Live filtering - Ability to hide message time stamps - Ability to hide SELECT/SHOW statement messages - Ability to copy messages to pasteboard, including multiple messages - Ability to save the current filtered content to a file, with the option to include the message time stamps
Diffstat (limited to 'Source/TableDocument.m')
-rw-r--r--Source/TableDocument.m43
1 files changed, 20 insertions, 23 deletions
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index 2bb95ef4..0be640ec 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -37,6 +37,9 @@
#import "SPSQLParser.h"
#import "SPTableData.h"
#import "SPStringAdditions.h"
+#import "SPQueryConsole.h"
+#import "CMMCPConnection.h"
+#import "CMMCPResult.h"
NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocumentFavoritesControllerSelectionIndexDidChange";
NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFavoritesControllerFavoritesDidChange";
@@ -51,7 +54,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
_encoding = [@"utf8" retain];
chooseDatabaseButton = nil;
chooseDatabaseToolbarItem = nil;
-
+
return self;
}
@@ -600,7 +603,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
*/
- (void)toggleConsole:(id)sender
{
- [[queryConsoleInstance window] setIsVisible:![[queryConsoleInstance window] isVisible]];
+ [[[SPQueryConsole sharedQueryConsole] window] setIsVisible:![[[SPQueryConsole sharedQueryConsole] window] isVisible]];
}
#pragma mark Encoding Methods
@@ -1301,7 +1304,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
//set up tooltip and image
[toolbarItem setToolTip:NSLocalizedString(@"Show or hide the console which shows all MySQL commands performed by Sequel Pro", @"tooltip for toolbar item for show/hide console")];
- if ([[queryConsoleInstance window] isVisible]) {
+ if ([[[SPQueryConsole sharedQueryConsole] window] isVisible]) {
[toolbarItem setLabel:NSLocalizedString(@"Hide Console", @"toolbar item for hide console")];
[toolbarItem setImage:[NSImage imageNamed:@"hideconsole"]];
} else {
@@ -1321,7 +1324,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
[toolbarItem setToolTip:NSLocalizedString(@"Clear the console which shows all MySQL commands performed by Sequel Pro", @"tooltip for toolbar item for clear console")];
[toolbarItem setImage:[NSImage imageNamed:@"clearconsole"]];
//set up the target action
- [toolbarItem setTarget:queryConsoleInstance];
+ [toolbarItem setTarget:[SPQueryConsole sharedQueryConsole]];
[toolbarItem setAction:@selector(clearConsole:)];
} else if ([itemIdentifier isEqualToString:@"SwitchToTableStructureToolbarItemIdentifier"]) {
@@ -1425,7 +1428,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
- (BOOL)validateToolbarItem:(NSToolbarItem *)toolbarItem;
{
if ([[toolbarItem itemIdentifier] isEqualToString:@"ToggleConsoleIdentifier"]) {
- if ([[queryConsoleInstance window] isVisible]) {
+ if ([[[SPQueryConsole sharedQueryConsole] window] isVisible]) {
[toolbarItem setLabel:@"Hide Console"];
[toolbarItem setImage:[NSImage imageNamed:@"hideconsole"]];
} else {
@@ -1447,11 +1450,11 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
return @"DBView";
}
-- (void)windowControllerDidLoadNib:(NSWindowController *) aController
-/*
- code that need to be executed once the windowController has loaded the document's window
- sets upt the interface (small fonts)
+/**
+ * Code that need to be executed once the windowController has loaded the document's window
+ * sets upt the interface (small fonts).
*/
+- (void)windowControllerDidLoadNib:(NSWindowController *) aController
{
[aController setShouldCascadeWindows:YES];
[super windowControllerDidLoadNib:aController];
@@ -1459,8 +1462,6 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
NSEnumerator *theCols = [[variablesTableView tableColumns] objectEnumerator];
NSTableColumn *theCol;
- // [tableWindow makeKeyAndOrderFront:self];
-
prefs = [[NSUserDefaults standardUserDefaults] retain];
//register for notifications
@@ -1473,14 +1474,14 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
//set up interface
if ( [prefs boolForKey:@"useMonospacedFonts"] ) {
- [[queryConsoleInstance consoleTextView] setFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]];
+ [[SPQueryConsole sharedQueryConsole] setConsoleFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]];
[syntaxViewContent setFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]];
while ( (theCol = [theCols nextObject]) ) {
[[theCol dataCell] setFont:[NSFont fontWithName:@"Monaco" size:10]];
}
} else {
- [[queryConsoleInstance consoleTextView] setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
+ [[SPQueryConsole sharedQueryConsole] setConsoleFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
[syntaxViewContent setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
while ( (theCol = [theCols nextObject]) ) {
[[theCol dataCell] setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
@@ -1503,11 +1504,10 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
[self setPrintInfo:[NSPrintInfo sharedPrintInfo]];
if ([mySQLConnection isConnected]) [self closeConnection];
- if ([[queryConsoleInstance window] isVisible]) [self toggleConsole:self];
+ if ([[[SPQueryConsole sharedQueryConsole] window] isVisible]) [self toggleConsole:self];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
-
//NSWindow delegate methods
- (BOOL)windowShouldClose:(id)sender
/*
@@ -1527,22 +1527,19 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
* Invoked when framework will perform a query
*/
- (void)willQueryString:(NSString *)query
-{
- NSString *currentTime = [[NSDate date] descriptionWithCalendarFormat:@"%H:%M:%S" timeZone:nil locale:nil];
-
- [queryConsoleInstance showMessageInConsole:[NSString stringWithFormat:@"/* MySQL %@ */ %@;\n", currentTime, query]];
+{
+ [[SPQueryConsole sharedQueryConsole] showMessageInConsole:query];
}
/**
* Invoked when query gave an error
*/
- (void)queryGaveError:(NSString *)error
-{
- NSString *currentTime = [[NSDate date] descriptionWithCalendarFormat:@"%H:%M:%S" timeZone:nil locale:nil];
-
- [queryConsoleInstance showErrorInConsole:[NSString stringWithFormat:@"/* ERROR %@ */ %@;\n", currentTime, error]];
+{
+ [[SPQueryConsole sharedQueryConsole] showErrorInConsole:error];
}
+#pragma mark -
#pragma mark Connection sheet delegate methods
/**