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 | |
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')
-rw-r--r-- | Source/SPCustomQuery.m | 2 | ||||
-rw-r--r-- | Source/SPDataCellFormatter.h | 2 | ||||
-rw-r--r-- | Source/SPDataCellFormatter.m | 17 | ||||
-rw-r--r-- | Source/SPFieldEditorController.m | 2 | ||||
-rw-r--r-- | Source/SPProcessListController.m | 18 | ||||
-rw-r--r-- | Source/SPTableContent.m | 1 |
6 files changed, 35 insertions, 7 deletions
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index 5f8847b7..bc80d971 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -1579,11 +1579,11 @@ [theCol setEditable:YES]; SPTextAndLinkCell *dataCell = [[[SPTextAndLinkCell alloc] initTextCell:@""] autorelease]; [dataCell setEditable:YES]; - [dataCell setFormatter:[[SPDataCellFormatter new] autorelease]]; [dataCell setFont:tableFont]; [dataCell setLineBreakMode:NSLineBreakByTruncatingTail]; [dataCell setFormatter:[[SPDataCellFormatter new] autorelease]]; + [[dataCell formatter] setDisplayLimit:150]; // Set field length limit if field is a varchar to match varchar length if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"string"] diff --git a/Source/SPDataCellFormatter.h b/Source/SPDataCellFormatter.h index 00cc85bb..d1f9c7d4 100644 --- a/Source/SPDataCellFormatter.h +++ b/Source/SPDataCellFormatter.h @@ -33,10 +33,12 @@ @interface SPDataCellFormatter : NSFormatter { NSInteger textLimit; + NSUInteger displayLimit; NSString *fieldType; } @property (readwrite, assign) NSInteger textLimit; +@property (readwrite, assign) NSUInteger displayLimit; @property (readwrite, retain) NSString* fieldType; @end diff --git a/Source/SPDataCellFormatter.m b/Source/SPDataCellFormatter.m index 04c43b7d..951fafbc 100644 --- a/Source/SPDataCellFormatter.m +++ b/Source/SPDataCellFormatter.m @@ -36,13 +36,26 @@ @implementation SPDataCellFormatter @synthesize textLimit; +@synthesize displayLimit; @synthesize fieldType; +- (id)init +{ + if ((self = [super init])) { + displayLimit = NSNotFound; + } + return self; +} + - (NSString *)stringForObjectValue:(id)anObject { // Truncate the string for speed purposes if it's very long - improves table scrolling speed. - if ([anObject isKindOfClass:[NSString class]] && [(NSString *)anObject length] > 150) { - return ([NSString stringWithFormat:@"%@...", [anObject substringToIndex:147]]); + if (displayLimit != NSNotFound && [anObject isKindOfClass:[NSString class]] && [(NSString *)anObject length] > displayLimit) { + return ([NSString stringWithFormat:@"%@...", [anObject substringToIndex:displayLimit - 3]]); + } + + if (![anObject isKindOfClass:[NSString class]]) { + return [anObject description]; } return anObject; diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m index ca88ed14..a3c44c64 100644 --- a/Source/SPFieldEditorController.m +++ b/Source/SPFieldEditorController.m @@ -34,9 +34,7 @@ #ifndef SP_REFACTOR #import "QLPreviewPanel.h" #endif -#import "SPDataCellFormatter.h" #import "RegexKitLite.h" -#import "SPDataCellFormatter.h" #import "SPTooltip.h" #import "SPGeometryDataView.h" #import "SPCopyTable.h" 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; } /** diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 43307746..efb7e771 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -605,6 +605,7 @@ // Set the line break mode and an NSFormatter subclass which truncates long strings for display [dataCell setLineBreakMode:NSLineBreakByTruncatingTail]; [dataCell setFormatter:[[SPDataCellFormatter new] autorelease]]; + [[dataCell formatter] setDisplayLimit:150]; // Set field length limit if field is a varchar to match varchar length if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"string"] |