aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableContent.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-09-20 16:54:12 +0000
committerBibiko <bibiko@eva.mpg.de>2010-09-20 16:54:12 +0000
commite0ed4d4743e255c3a381396a46b3e1c6efa93ccb (patch)
tree998a95e34cd05a07ce236bc02d93e79457e9993c /Source/SPTableContent.m
parent26eb1e9fb81f28b49ebe4b4e8977af965149b84c (diff)
downloadsequelpro-e0ed4d4743e255c3a381396a46b3e1c6efa93ccb.tar.gz
sequelpro-e0ed4d4743e255c3a381396a46b3e1c6efa93ccb.tar.bz2
sequelpro-e0ed4d4743e255c3a381396a46b3e1c6efa93ccb.zip
• avoid exceptions etc. if content filter clause is empty
- in addition alert the user that this clause was empty to avoid confusion of filtered result set
Diffstat (limited to 'Source/SPTableContent.m')
-rw-r--r--Source/SPTableContent.m32
1 files changed, 22 insertions, 10 deletions
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index e79b2c36..9a1fc14c 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -828,12 +828,20 @@
}
NSDictionary *filter = [[contentFilters objectForKey:compareType] objectAtIndex:[[compareField selectedItem] tag]];
- if(![filter objectForKey:@"Clause"] || ![filter objectForKey:@"NumberOfArguments"]) {
+ if(![filter objectForKey:@"NumberOfArguments"]) {
NSLog(@"Error while retrieving filter clause. No “Clause” or/and “NumberOfArguments” key found.");
NSBeep();
return nil;
}
+ if(![filter objectForKey:@"Clause"] || ![[filter objectForKey:@"Clause"] length]) {
+
+ SPBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil,
+ NSLocalizedString(@"Content Filter clause is empty.", @"content filter clause is empty tooltip."));
+
+ return nil;
+ }
+
NSUInteger numberOfArguments = [[filter objectForKey:@"NumberOfArguments"] integerValue];
BOOL suppressLeadingTablePlaceholder = NO;
@@ -2202,16 +2210,20 @@
[item setToolTip:[filter objectForKey:@"Tooltip"]];
else {
NSMutableString *tip = [[NSMutableString alloc] init];
- [tip setString:[[filter objectForKey:@"Clause"] stringByReplacingOccurrencesOfRegex:@"(?<!\\\\)(\\$\\{.*?\\})" withString:@"[arg]"]];
- if([tip isMatchedByRegex:@"(?<!\\\\)\\$BINARY"]) {
- [tip replaceOccurrencesOfRegex:@"(?<!\\\\)\\$BINARY" withString:@""];
- [tip appendString:NSLocalizedString(@"\n\nPress ⇧ for binary search (case-sensitive).", @"\n\npress shift for binary search tooltip message")];
+ if([filter objectForKey:@"Clause"] && [[filter objectForKey:@"Clause"] length]) {
+ [tip setString:[[filter objectForKey:@"Clause"] stringByReplacingOccurrencesOfRegex:@"(?<!\\\\)(\\$\\{.*?\\})" withString:@"[arg]"]];
+ if([tip isMatchedByRegex:@"(?<!\\\\)\\$BINARY"]) {
+ [tip replaceOccurrencesOfRegex:@"(?<!\\\\)\\$BINARY" withString:@""];
+ [tip appendString:NSLocalizedString(@"\n\nPress ⇧ for binary search (case-sensitive).", @"\n\npress shift for binary search tooltip message")];
+ }
+ [tip flushCachedRegexData];
+ [tip replaceOccurrencesOfRegex:@"(?<!\\\\)\\$CURRENT_FIELD" withString:[[fieldField titleOfSelectedItem] backtickQuotedString]];
+ [tip flushCachedRegexData];
+ [item setToolTip:tip];
+ [tip release];
+ } else {
+ [item setToolTip:@""];
}
- [tip flushCachedRegexData];
- [tip replaceOccurrencesOfRegex:@"(?<!\\\\)\\$CURRENT_FIELD" withString:[[fieldField titleOfSelectedItem] backtickQuotedString]];
- [tip flushCachedRegexData];
- [item setToolTip:tip];
- [tip release];
}
[item setTag:i];
[menu addItem:item];