aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/DBView.xib36
-rw-r--r--Source/SPTableContent.h2
-rw-r--r--Source/SPTableContent.m74
3 files changed, 79 insertions, 33 deletions
diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib
index b7d518b6..b8a999ce 100644
--- a/Interfaces/English.lproj/DBView.xib
+++ b/Interfaces/English.lproj/DBView.xib
@@ -3,7 +3,7 @@
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">10F569</string>
- <string key="IBDocument.InterfaceBuilderVersion">804</string>
+ <string key="IBDocument.InterfaceBuilderVersion">788</string>
<string key="IBDocument.AppKitVersion">1038.29</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
@@ -16,13 +16,14 @@
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
- <string>804</string>
- <string>804</string>
+ <string>788</string>
+ <string>788</string>
<string>1.2.5</string>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="7518"/>
<integer value="6210"/>
<integer value="27"/>
</object>
@@ -9283,7 +9284,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
<string key="NSWindowContentMinSize">{240, 170}</string>
<object class="NSView" key="NSWindowView" id="257361103">
- <nil key="NSNextResponder"/>
+ <reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -9484,8 +9485,8 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<bytes key="NSWhite">MQA</bytes>
</object>
<reference key="NSGridColor" ref="864903678"/>
- <double key="NSRowHeight">14</double>
- <int key="NSTvFlags">-624918528</int>
+ <double key="NSRowHeight">16</double>
+ <int key="NSTvFlags">-893353984</int>
<reference key="NSDelegate"/>
<reference key="NSDataSource"/>
<int key="NSColumnAutoresizingStyle">1</int>
@@ -9550,7 +9551,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<reference key="NSContentView" ref="824010218"/>
<reference key="NSHeaderClipView" ref="970708568"/>
<reference key="NSCornerView" ref="651821776"/>
- <bytes key="NSScrollAmts">QSAAAEEgAABBgAAAQYAAAA</bytes>
+ <bytes key="NSScrollAmts">QSAAAEEgAABBkAAAQZAAAA</bytes>
</object>
</object>
<string key="NSFrameSize">{480, 106}</string>
@@ -9740,6 +9741,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
</object>
<string key="NSFrameSize">{480, 270}</string>
+ <reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1280, 778}}</string>
<string key="NSMinSize">{240, 189}</string>
@@ -10113,7 +10115,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<string key="NSClassName">NSView</string>
</object>
<object class="NSCustomView" id="730777562">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">265</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -10134,7 +10136,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
<string key="NSFrame">{{5, -2}, {101, 22}}</string>
<reference key="NSSuperview" ref="730777562"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSImageCell" key="NSCell" id="1052485434">
<int key="NSCellFlags">130560</int>
@@ -10151,7 +10152,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<int key="NSvFlags">258</int>
<string key="NSFrame">{{2, 2}, {105, 14}}</string>
<reference key="NSSuperview" ref="730777562"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="186804841">
<int key="NSCellFlags">68288064</int>
@@ -10173,8 +10173,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
</object>
<string key="NSFrameSize">{110, 20}</string>
- <reference key="NSSuperview"/>
- <reference key="NSWindow"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSCustomView" id="260025442">
@@ -15324,6 +15322,14 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
<int key="connectionID">7535</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">initialFirstResponder</string>
+ <reference key="source" ref="633448481"/>
+ <reference key="destination" ref="233010382"/>
+ </object>
+ <int key="connectionID">7536</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -23690,7 +23696,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{603, 458}, {237, 73}}</string>
+ <string>{{503, 458}, {237, 73}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -24124,7 +24130,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{59, 203}, {943, 549}}</string>
+ <string>{{977, 203}, {943, 549}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -24510,7 +24516,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">7535</int>
+ <int key="maxID">7536</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
diff --git a/Source/SPTableContent.h b/Source/SPTableContent.h
index 13ca3d92..fca3fdae 100644
--- a/Source/SPTableContent.h
+++ b/Source/SPTableContent.h
@@ -203,6 +203,6 @@
- (NSArray*)fieldEditStatusForRow:(NSInteger)rowIndex andColumn:(NSInteger)columnIndex;
-- (void)updateFilterTableClause;
+- (void)updateFilterTableClause:(NSString*)currentValue;
@end
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index b7bcd0f9..295dca4b 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -2820,6 +2820,16 @@
- (IBAction)showTableFilter:(id)sender
{
[filterTableWindow makeKeyAndOrderFront:nil];
+ [filterTableWhereClause setContinuousSpellCheckingEnabled:NO];
+ [filterTableWhereClause setAutoindent:NO];
+ [filterTableWhereClause setAutoindentIgnoresEnter:NO];
+ [filterTableWhereClause setAutopair:[prefs boolForKey:SPCustomQueryAutoPairCharacters]];
+ [filterTableWhereClause setAutohelp:NO];
+ [filterTableWhereClause setAutouppercaseKeywords:[prefs boolForKey:SPCustomQueryAutoUppercaseKeywords]];
+ [filterTableWhereClause setCompletionWasReinvokedAutomatically:NO];
+ [filterTableWhereClause insertText:@""];
+ [filterTableWhereClause didChangeText];
+ [[NSApp keyWindow] makeFirstResponder:filterTableView];
}
#pragma mark -
@@ -3273,7 +3283,7 @@
{
if(aTableView == filterTableView) {
[[[filterTableData objectForKey:[aTableColumn identifier]] objectForKey:@"filter"] replaceObjectAtIndex:rowIndex withObject:(NSString*)anObject];
- [self updateFilterTableClause];
+ [self updateFilterTableClause:nil];
return;
}
else if(aTableView == tableContentView) {
@@ -3876,7 +3886,7 @@
- (void)controlTextDidChange:(NSNotification *)notification
{
if ([notification object] == filterTableView) {
- [self updateFilterTableClause];
+ [self updateFilterTableClause:[[[[notification userInfo] objectForKey:@"NSFieldEditor"] textStorage] string]];
}
}
/**
@@ -4022,42 +4032,72 @@
/**
* Update WHERE clause in Filter Table Window - TODO not yet finished - initial approach only by HansJB
*/
-- (void)updateFilterTableClause
+- (void)updateFilterTableClause:(NSString*)currentValue
{
NSMutableString *clause = [NSMutableString string];
NSInteger numberOfRows = [self numberOfRowsInTableView:filterTableView];
NSInteger numberOfCols = [[filterTableView tableColumns] count];
NSInteger numberOfValues = 0;
NSRange opRange;
+
+ NSString *re1 = @"^\\s*(<|>|!?=)\\s*(.*?)\\s*$";
+ NSString *re2 = @"(?i)^\\s*(.*)\\s+(.*?)\\s*$";
+ NSString *defaultOperator = @"LIKE '%%%@%%'";
+ NSCharacterSet *whiteSpaceCharSet = [NSCharacterSet whitespaceAndNewlineCharacterSet];
+
for(NSInteger i=0; i<numberOfRows; i++) {
numberOfValues = 0;
for(NSInteger index=0; index<numberOfCols; index++) {
NSString *filterCell;
NSDictionary *filterCellData = [NSDictionary dictionaryWithDictionary:[filterTableData objectForKey:[NSNumber numberWithInteger:index]]];
- if([filterCell = [[filterCellData objectForKey:@"filter"] objectAtIndex:i] length]) {
+ if(currentValue == nil) {
+ filterCell = NSArrayObjectAtIndex([filterCellData objectForKey:@"filter"], i);
+ } else {
+ if(index == [filterTableView editedColumn] && i == [filterTableView editedRow])
+ filterCell = currentValue;
+ else
+ filterCell = NSArrayObjectAtIndex([filterCellData objectForKey:@"filter"], i);
+ }
+ if([filterCell length]) {
+
if(numberOfValues)
[clause appendString:@" AND "];
- opRange = [filterCell rangeOfString:@" "];
- if(opRange.length) {
- NSString *op = [[filterCell substringToIndex:opRange.location] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
- NSString *pattern = [[filterCell substringFromIndex:NSMaxRange(opRange)] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
- if([op isEqualToString:@">"] ||
- [op isEqualToString:@"<"] ||
- [op isEqualToString:@"="]) {
- [clause appendFormat:@"%@ %@ %@", [[filterCellData objectForKey:@"name"] backtickQuotedString], op, pattern];
- }
- } else {
- [clause appendFormat:@"%@ LIKE '%%%@%%'", [[filterCellData objectForKey:@"name"] backtickQuotedString], filterCell];
+ NSString *fieldName = [[filterCellData objectForKey:@"name"] backtickQuotedString];
+
+ opRange = [filterCell rangeOfString:@"`@`"];
+ if(opRange.length) {
+ filterCell = [filterCell stringByReplacingOccurrencesOfString:@"`@`" withString:fieldName];
+ [clause appendString:[filterCell stringByReplacingOccurrencesOfString:@"`@`" withString:fieldName]];
+ }
+ else if([filterCell isMatchedByRegex:@"(?i)^\\s*null\\s*$"]) {
+ [clause appendFormat:@"%@ IS NULL", fieldName];
+ }
+ else if([filterCell isMatchedByRegex:re1]) {
+ NSArray *matches = [filterCell arrayOfCaptureComponentsMatchedByRegex:re1];
+ if([matches count] && [matches = NSArrayObjectAtIndex(matches,0) count] == 3)
+ [clause appendFormat:@"%@ %@ %@", fieldName, NSArrayObjectAtIndex(matches, 1), NSArrayObjectAtIndex(matches, 2)];
+ }
+ else if([filterCell isMatchedByRegex:re2]) {
+ NSArray *matches = [filterCell arrayOfCaptureComponentsMatchedByRegex:re2];
+ if([matches count] && [matches = NSArrayObjectAtIndex(matches,0) count] == 3)
+ [clause appendFormat:@"%@ %@ %@", fieldName, [NSArrayObjectAtIndex(matches, 1) uppercaseString], NSArrayObjectAtIndex(matches, 2)];
}
+ else {
+ [clause appendFormat:[NSString stringWithFormat:@"%%@ %@", defaultOperator], fieldName, filterCell];
+ }
+
numberOfValues++;
}
}
if(numberOfValues)
[clause appendString:@"\nOR\n"];
}
- [filterTableWhereClause setString:[clause substringToIndex:([clause length]-4)]];
- [filterTableWhereClause insertText:@""];
+ if([clause length] > 3)
+ [filterTableWhereClause setString:[clause substringToIndex:([clause length]-4)]];
+ else
+ [filterTableWhereClause setString:@""];
+ [filterTableWhereClause insertText:@" "];
[filterTableWhereClause didChangeText];
[filterTableWhereClause scrollRangeToVisible:NSMakeRange(0, 0)];
}