diff options
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"] |