diff options
author | rowanbeentje <rowan@beent.je> | 2012-08-06 01:06:27 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2012-08-06 01:06:27 +0000 |
commit | bec9204f21160fe4c001df75050e5d0ec8e42a2f (patch) | |
tree | c9d5b570ed0fda96d320dd6ea4b2da850aa46f21 /Source/SPProcessListController.m | |
parent | 6b79f6517a56c96c272cd4c2583f3431418385a9 (diff) | |
download | sequelpro-bec9204f21160fe4c001df75050e5d0ec8e42a2f.tar.gz sequelpro-bec9204f21160fe4c001df75050e5d0ec8e42a2f.tar.bz2 sequelpro-bec9204f21160fe4c001df75050e5d0ec8e42a2f.zip |
- Add linebreak display in the database processes list, preventing display of truncated queries for clarity (Issue #1407)
- If SHOW FULL PROCESSLIST isn't on, and the query appears to be truncated (length == 100), add a trailing ellipsis to suggest more content
Diffstat (limited to 'Source/SPProcessListController.m')
-rw-r--r-- | Source/SPProcessListController.m | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/Source/SPProcessListController.m b/Source/SPProcessListController.m index d3850061..c958edc3 100644 --- a/Source/SPProcessListController.m +++ b/Source/SPProcessListController.m @@ -34,6 +34,7 @@ #import "SPDatabaseDocument.h" #import "SPAlertSheets.h" #import "SPAppController.h" +#import "SPDataCellFormatter.h" #import <SPMySQL/SPMySQL.h> @@ -107,6 +108,9 @@ static NSString *SPTableViewIDColumnIdentifier = @"Id"; for (NSTableColumn *column in [processListTableView tableColumns]) { [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + + // Add a formatter for linebreak display + [[column dataCell] setFormatter:[[SPDataCellFormatter new] autorelease]]; // Also, if available restore the table's column widths NSNumber *columnWidth = [[prefs objectForKey:SPProcessListTableColumnWidths] objectForKey:[[column headerCell] stringValue]]; @@ -495,8 +499,18 @@ static NSString *SPTableViewIDColumnIdentifier = @"Id"; - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { id object = ((NSUInteger)row < [processesFiltered count]) ? [[processesFiltered objectAtIndex:row] valueForKey:[tableColumn identifier]] : @""; - - return (![object isNSNull]) ? object : [prefs stringForKey:SPNullValue]; + + if ([object isNSNull]) { + return [prefs stringForKey:SPNullValue]; + } + + // If the string is exactly 100 characters long, and FULL process lists are not enabled, it's a safe + // bet that the string is truncated + if (!showFullProcessList && [object isKindOfClass:[NSString class]] && [(NSString *)object length] == 100) { + return [object stringByAppendingString:@"…"]; + } + + return object; } /** |