aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-02-19 14:43:01 +0000
committerBibiko <bibiko@eva.mpg.de>2010-02-19 14:43:01 +0000
commit10316c1a2e8448e5dd93a1d10c7e039115864925 (patch)
tree6f7e086731df3be9fdf5f7bd4aa844857f19e4cf /Source
parent69497bca10ddacbee15d48496455a371ea5ab9b0 (diff)
downloadsequelpro-10316c1a2e8448e5dd93a1d10c7e039115864925.tar.gz
sequelpro-10316c1a2e8448e5dd93a1d10c7e039115864925.tar.bz2
sequelpro-10316c1a2e8448e5dd93a1d10c7e039115864925.zip
• added the chance to the user-defined Content Filter Editor to specify whether the leading <field> placeholder should be suppressed or not in order to be able to write a filter like "LENGTH($CURRENT_FIELD)>${}"
Diffstat (limited to 'Source')
-rw-r--r--Source/SPContentFilterManager.h2
-rw-r--r--Source/SPContentFilterManager.m7
-rw-r--r--Source/TableContent.m55
3 files changed, 46 insertions, 18 deletions
diff --git a/Source/SPContentFilterManager.h b/Source/SPContentFilterManager.h
index f8ffe16e..7c6525ba 100644
--- a/Source/SPContentFilterManager.h
+++ b/Source/SPContentFilterManager.h
@@ -49,6 +49,7 @@
IBOutlet id resultingClauseLabel;
IBOutlet id resultingClauseContentLabel;
IBOutlet id insertPlaceholderButton;
+ IBOutlet id suppressLeadingFiledPlaceholderCheckbox;
IBOutlet BWAnchoredButtonBar *splitViewButtonBar;
@@ -75,5 +76,6 @@
- (IBAction)exportContentFilter:(id)sender;
- (IBAction)importContentFilterByAdding:(id)sender;
- (IBAction)closeContentFilterManagerSheet:(id)sender;
+- (IBAction)suppressLeadingFiledPlaceholderWasChanged:(id)sender;
@end
diff --git a/Source/SPContentFilterManager.m b/Source/SPContentFilterManager.m
index 8e3fa5fe..8e79cc8e 100644
--- a/Source/SPContentFilterManager.m
+++ b/Source/SPContentFilterManager.m
@@ -533,6 +533,11 @@
}
+- (IBAction)suppressLeadingFiledPlaceholderWasChanged:(id)sender
+{
+ [contentFilterTextView insertText:@""];
+}
+
/*
* Parse clause and update labels accordingly
*/
@@ -568,7 +573,7 @@
[c flushCachedRegexData];
[c replaceOccurrencesOfRegex:@"(?<!\\\\)\\$CURRENT_FIELD" withString:@"<field>"];
[c flushCachedRegexData];
- [resultingClauseContentLabel setStringValue:[NSString stringWithFormat:@"<field> %@", c]];
+ [resultingClauseContentLabel setStringValue:[NSString stringWithFormat:@"%@%@", ([suppressLeadingFiledPlaceholderCheckbox state] == NSOnState) ? @"" : @"<field> ", c]];
[c release];
}
diff --git a/Source/TableContent.m b/Source/TableContent.m
index 50bcfd9f..da6577cb 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -809,6 +809,10 @@
NSUInteger numberOfArguments = [[filter objectForKey:@"NumberOfArguments"] integerValue];
+ BOOL suppressLeadingTablePlaceholder = NO;
+ if([filter objectForKey:@"SuppressLeadingFieldPlaceholder"])
+ suppressLeadingTablePlaceholder = YES;
+
// argument if Filter requires only one argument
NSMutableString *argument = [[NSMutableString alloc] initWithString:[argumentField stringValue]];
@@ -870,24 +874,41 @@
}
// Construct the filter string according the required number of arguments
- if (numberOfArguments == 2) {
- filterString = [NSString stringWithFormat:@"%@ %@",
- [[fieldField titleOfSelectedItem] backtickQuotedString],
- [NSString stringWithFormat:clause,
- [self escapeFilterArgument:firstBetweenArgument againstClause:clause],
- [self escapeFilterArgument:secondBetweenArgument againstClause:clause]]];
- } else if (numberOfArguments == 1) {
- filterString = [NSString stringWithFormat:@"%@ %@",
- [[fieldField titleOfSelectedItem] backtickQuotedString],
- [NSString stringWithFormat:clause, [self escapeFilterArgument:argument againstClause:clause]]];
+
+ if(suppressLeadingTablePlaceholder) {
+ if (numberOfArguments == 2) {
+ filterString = [NSString stringWithFormat:clause,
+ [self escapeFilterArgument:firstBetweenArgument againstClause:clause],
+ [self escapeFilterArgument:secondBetweenArgument againstClause:clause]];
+ } else if (numberOfArguments == 1) {
+ filterString = [NSString stringWithFormat:clause, [self escapeFilterArgument:argument againstClause:clause]];
+ } else {
+ filterString = [NSString stringWithString:[filter objectForKey:@"Clause"]];
+ if(numberOfArguments > 2) {
+ NSLog(@"Filter with more than 2 arguments is not yet supported.");
+ NSBeep();
+ }
+ }
} else {
- filterString = [NSString stringWithFormat:@"%@ %@",
- [[fieldField titleOfSelectedItem] backtickQuotedString],
- [filter objectForKey:@"Clause"]];
- if(numberOfArguments > 2) {
- NSLog(@"Filter with more than 2 arguments is not yet supported.");
- NSBeep();
- }
+ if (numberOfArguments == 2) {
+ filterString = [NSString stringWithFormat:@"%@ %@",
+ [[fieldField titleOfSelectedItem] backtickQuotedString],
+ [NSString stringWithFormat:clause,
+ [self escapeFilterArgument:firstBetweenArgument againstClause:clause],
+ [self escapeFilterArgument:secondBetweenArgument againstClause:clause]]];
+ } else if (numberOfArguments == 1) {
+ filterString = [NSString stringWithFormat:@"%@ %@",
+ [[fieldField titleOfSelectedItem] backtickQuotedString],
+ [NSString stringWithFormat:clause, [self escapeFilterArgument:argument againstClause:clause]]];
+ } else {
+ filterString = [NSString stringWithFormat:@"%@ %@",
+ [[fieldField titleOfSelectedItem] backtickQuotedString],
+ [filter objectForKey:@"Clause"]];
+ if(numberOfArguments > 2) {
+ NSLog(@"Filter with more than 2 arguments is not yet supported.");
+ NSBeep();
+ }
+ }
}
[argument release];