aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDataCellFormatter.m
diff options
context:
space:
mode:
authoravenjamin <avenjamin@gmail.com>2009-02-27 01:37:27 +0000
committeravenjamin <avenjamin@gmail.com>2009-02-27 01:37:27 +0000
commit51b094e48b68420cd53be08648eab7b671ce1639 (patch)
tree6df11a0bbc1a8528ba43ad05d6f6533e6b37fb7a /Source/SPDataCellFormatter.m
parent10a7c5a32983070158a736e479b2c6200ecd70fd (diff)
downloadsequelpro-51b094e48b68420cd53be08648eab7b671ce1639.tar.gz
sequelpro-51b094e48b68420cd53be08648eab7b671ce1639.tar.bz2
sequelpro-51b094e48b68420cd53be08648eab7b671ce1639.zip
Added length limits to varchar and char fields. Issue #170
Ideally we should add these limits for other field types depending on their length value.
Diffstat (limited to 'Source/SPDataCellFormatter.m')
-rw-r--r--Source/SPDataCellFormatter.m18
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/SPDataCellFormatter.m b/Source/SPDataCellFormatter.m
index c23fccf5..051a7ac6 100644
--- a/Source/SPDataCellFormatter.m
+++ b/Source/SPDataCellFormatter.m
@@ -26,6 +26,8 @@
@implementation SPDataCellFormatter
+@synthesize textLimit;
+
- (NSString *)stringForObjectValue:(id)anObject
{
@@ -54,4 +56,20 @@
return [[[NSAttributedString alloc] initWithString:[self stringForObjectValue:anObject] attributes:attributes] autorelease];
}
+
+
+- (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error
+{
+ // No limit set
+ if (textLimit == 0)
+ return YES;
+
+ if ([partialString length] > textLimit) {
+ NSBeep();
+ newString = [NSString stringWithCharacters:partialString length:textLimit];
+ }
+
+ return ([partialString length] <= textLimit);
+}
+
@end