From 8516506a682a8218727fcab92266b5ce0177dcd3 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 28 Sep 2010 11:57:26 +0000 Subject: =?UTF-8?q?=E2=80=A2=20some=20progress=20on=20the=20filter=20table?= =?UTF-8?q?=20approach?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/DBView.xib | 757 +++++++++++++++++++++++++++++++++++- Source/SPTableContent.h | 15 +- Source/SPTableContent.m | 68 +++- 3 files changed, 820 insertions(+), 20 deletions(-) diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index b8a999ce..19cd1ac2 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -23,9 +23,8 @@ YES - - + YES @@ -3774,7 +3773,7 @@ 1048576 2147483647 - + NSImage button_action @@ -9277,12 +9276,12 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 8347 2 {{131, 159}, {480, 270}} - 1685585920 + -461896704 Filter NSPanel {3.40282e+38, 3.40282e+38} - {240, 170} + {340, 170} 256 @@ -9443,13 +9442,13 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 -2147483392 - {{224, 0}, {16, 17}} + {{464, 0}, {16, 17}} YES - 242 + 475 40 1000 @@ -9510,7 +9509,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 -2147483392 - {{224, 17}, {15, 102}} + {{464, 17}, {15, 72}} _doScroller: @@ -9519,7 +9518,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 -2147483392 - {{1, 119}, {223, 15}} + {{1, 89}, {463, 15}} 1 @@ -9739,12 +9738,148 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 0 NO + + + 292 + {{68, 27}, {139, 18}} + + YES + + 67239424 + 131072 + Negate Clause + + + 1211912703 + 130 + + + + + 200 + 25 + + + + + 292 + {{68, 9}, {139, 18}} + + YES + + 67239424 + 131072 + Select Distinct + + + 1211912703 + 130 + + + + + 200 + 25 + + + + + 292 + {{14, 13}, {49, 31}} + + YES + + 71433792 + 2048 + + + -2041954049 + 32 + + + 400 + 75 + + + YES + + + 2147483647 + 1 + + + + _popUpItemAction: + + + YES + + OtherViews + + YES + + + + Set Default Operator + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + Look into all Fields + a + 1572864 + 2147483647 + + + _popUpItemAction: + 1 + + + + + YES + YES + + + 2147483647 + + + _popUpItemAction: + + + + + Swap Table + s + 1572864 + 2147483647 + + + _popUpItemAction: + 2 + + + + + + YES + 1 + YES + YES + + {480, 270} {{0, 0}, {1280, 778}} - {240, 189} + {340, 189} {3.40282e+38, 3.40282e+38} SPTableFilterPanel @@ -15330,6 +15465,62 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 7536 + + + filterTableNegateCheckbox + + + + 7571 + + + + setDefaultOperator: + + + + 7572 + + + + toggleLookAllFieldsMode: + + + + 7573 + + + + filterTableGearLookAllFields + + + + 7574 + + + + swapFilterTable: + + + + 7575 + + + + toggleNegateClause: + + + + 7576 + + + + toggleNegateClause: + + + + 7579 + @@ -21377,6 +21568,9 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 + + + @@ -21552,6 +21746,90 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 + + 7537 + + + YES + + + + + + 7538 + + + + + 7563 + + + YES + + + + + + 7564 + + + YES + + + + + + 7565 + + + YES + + + + + + + + + + 7570 + + + + + 7569 + + + + + 7568 + + + + + 7567 + + + + + 7566 + + + + + 7577 + + + YES + + + + + + 7578 + + + @@ -22798,6 +23076,19 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 7525.IBPluginDependency 7533.IBPluginDependency 7534.IBPluginDependency + 7537.IBPluginDependency + 7538.IBPluginDependency + 7563.IBPluginDependency + 7564.IBPluginDependency + 7565.IBEditorWindowLastContentRect + 7565.IBPluginDependency + 7566.IBPluginDependency + 7567.IBPluginDependency + 7568.IBPluginDependency + 7569.IBPluginDependency + 7570.IBPluginDependency + 7577.IBPluginDependency + 7578.IBPluginDependency 858.IBPluginDependency 858.ImportedFromIB2 959.IBEditorWindowLastContentRect @@ -24445,12 +24736,12 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{153, 361}, {480, 270}} + {{242, 511}, {480, 270}} com.apple.InterfaceBuilder.CocoaPlugin - {{153, 361}, {480, 270}} + {{242, 511}, {480, 270}} - {240, 170} + {340, 170} com.apple.InterfaceBuilder.CocoaPlugin com.brandonwalkin.BWToolkit com.brandonwalkin.BWToolkit @@ -24478,6 +24769,19 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.brandonwalkin.BWToolkit + com.brandonwalkin.BWToolkit + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{429, 466}, {188, 81}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.brandonwalkin.BWToolkit + com.brandonwalkin.BWToolkit com.apple.InterfaceBuilder.CocoaPlugin {{265, 489}, {405, 267}} @@ -24516,7 +24820,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 - 7536 + 7579 @@ -29873,6 +30177,431 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 + + YES + + SPTableContent + NSObject + + YES + + YES + addRow: + copyRow: + filterTable: + navigatePaginationFromButton: + reloadTable: + removeRow: + setCompareTypes: + setDefaultOperator: + showTableFilter: + swapFilterTable: + tableFilterClear: + tableFilterExecute: + toggleFilterField: + toggleLookAllFieldsMode: + toggleNegateClause: + togglePagination: + + + YES + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + + + + YES + + YES + addRow: + copyRow: + filterTable: + navigatePaginationFromButton: + reloadTable: + removeRow: + setCompareTypes: + setDefaultOperator: + showTableFilter: + swapFilterTable: + tableFilterClear: + tableFilterExecute: + toggleFilterField: + toggleLookAllFieldsMode: + toggleNegateClause: + togglePagination: + + + YES + + addRow: + id + + + copyRow: + id + + + filterTable: + id + + + navigatePaginationFromButton: + id + + + reloadTable: + id + + + removeRow: + id + + + setCompareTypes: + id + + + setDefaultOperator: + id + + + showTableFilter: + id + + + swapFilterTable: + id + + + tableFilterClear: + id + + + tableFilterExecute: + id + + + toggleFilterField: + id + + + toggleLookAllFieldsMode: + id + + + toggleNegateClause: + id + + + togglePagination: + id + + + + + YES + + YES + addButton + argumentField + betweenTextField + compareField + contentFilterManager + contentViewPane + copyButton + countText + fieldField + filterButton + filterTableClearButton + filterTableFilterButton + filterTableGearLookAllFields + filterTableNegateCheckbox + filterTableView + filterTableWhereClause + filterTableWindow + firstBetweenField + limitRowsButton + limitRowsField + limitRowsStepper + multipleLineEditingButton + paginationButton + paginationNextButton + paginationPageField + paginationPageStepper + paginationPreviousButton + paginationView + reloadButton + removeButton + secondBetweenField + spHistoryControllerInstance + tableContentView + tableDataInstance + tableDocumentInstance + tableInfoInstance + tableSourceInstance + tablesListInstance + + + YES + id + id + id + id + id + NSView + id + id + NSPopUpButton + id + NSButton + NSButton + NSMenuItem + id + SPCopyTable + SPTextView + NSPanel + id + id + id + id + id + NSButton + NSButton + NSTextField + NSStepper + NSButton + NSView + id + id + id + SPHistoryController + SPCopyTable + id + id + SPTableInfo + id + id + + + + YES + + YES + addButton + argumentField + betweenTextField + compareField + contentFilterManager + contentViewPane + copyButton + countText + fieldField + filterButton + filterTableClearButton + filterTableFilterButton + filterTableGearLookAllFields + filterTableNegateCheckbox + filterTableView + filterTableWhereClause + filterTableWindow + firstBetweenField + limitRowsButton + limitRowsField + limitRowsStepper + multipleLineEditingButton + paginationButton + paginationNextButton + paginationPageField + paginationPageStepper + paginationPreviousButton + paginationView + reloadButton + removeButton + secondBetweenField + spHistoryControllerInstance + tableContentView + tableDataInstance + tableDocumentInstance + tableInfoInstance + tableSourceInstance + tablesListInstance + + + YES + + addButton + id + + + argumentField + id + + + betweenTextField + id + + + compareField + id + + + contentFilterManager + id + + + contentViewPane + NSView + + + copyButton + id + + + countText + id + + + fieldField + NSPopUpButton + + + filterButton + id + + + filterTableClearButton + NSButton + + + filterTableFilterButton + NSButton + + + filterTableGearLookAllFields + NSMenuItem + + + filterTableNegateCheckbox + id + + + filterTableView + SPCopyTable + + + filterTableWhereClause + SPTextView + + + filterTableWindow + NSPanel + + + firstBetweenField + id + + + limitRowsButton + id + + + limitRowsField + id + + + limitRowsStepper + id + + + multipleLineEditingButton + id + + + paginationButton + NSButton + + + paginationNextButton + NSButton + + + paginationPageField + NSTextField + + + paginationPageStepper + NSStepper + + + paginationPreviousButton + NSButton + + + paginationView + NSView + + + reloadButton + id + + + removeButton + id + + + secondBetweenField + id + + + spHistoryControllerInstance + SPHistoryController + + + tableContentView + SPCopyTable + + + tableDataInstance + id + + + tableDocumentInstance + id + + + tableInfoInstance + SPTableInfo + + + tableSourceInstance + id + + + tablesListInstance + id + + + + + IBDocumentRelativeSource + ../../Source/SPTableContent.h + + + YES diff --git a/Source/SPTableContent.h b/Source/SPTableContent.h index fca3fdae..e6d41ca9 100644 --- a/Source/SPTableContent.h +++ b/Source/SPTableContent.h @@ -71,6 +71,9 @@ IBOutlet NSButton *filterTableFilterButton; IBOutlet NSButton *filterTableClearButton; IBOutlet SPTextView *filterTableWhereClause; + IBOutlet id filterTableNegateCheckbox; + IBOutlet id filterTableDistinctCheckbox; + IBOutlet NSMenuItem *filterTableGearLookAllFields; MCPConnection *mySQLConnection; @@ -82,7 +85,6 @@ NSString *selectedTable, *usedQuery; SPDataStorage *tableValues; NSMutableArray *dataColumns, *keys, *oldRow; - NSMutableDictionary *filterTableData; NSUInteger tableRowsCount, previousTableRowsCount; NSString *compareType; NSNumber *sortCol; @@ -97,6 +99,12 @@ id contentFilterManager; NSUInteger contentPage; + NSMutableDictionary *filterTableData; + BOOL filterTableNegate; + BOOL filterTableDistinct; + NSString *filterTableDefaultOperator; + NSString *lastEditedFilterTableValue; + BOOL sortColumnToRestoreIsAsc; BOOL tableRowsSelectable; NSString *sortColumnToRestore; @@ -154,6 +162,11 @@ - (IBAction)tableFilterExecute:(id)sender; - (IBAction)tableFilterClear:(id)sender; - (IBAction)showTableFilter:(id)sender; +- (IBAction)toggleNegateClause:(id)sender; +- (IBAction)toggleDistinctSelect:(id)sender; +- (IBAction)setDefaultOperator:(id)sender; +- (IBAction)swapFilterTable:(id)sender; +- (IBAction)toggleLookAllFieldsMode:(id)sender; // Getter methods - (NSArray *)currentResult; diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 153718f8..b63c6062 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -70,7 +70,11 @@ previousTableRowsCount = 0; dataColumns = [[NSMutableArray alloc] init]; oldRow = [[NSMutableArray alloc] init]; + filterTableData = [[NSMutableDictionary alloc] initWithCapacity:1]; + filterTableNegate = NO; + filterTableDistinct = NO; + lastEditedFilterTableValue = nil; selectedTable = nil; sortCol = nil; @@ -166,6 +170,11 @@ [paginationView setFrame:paginationViewFrame]; [contentViewPane addSubview:paginationView]; + // Init Filter Table GUI + [filterTableDistinctCheckbox setState:(filterTableDistinct) ? NSOnState : NSOffState]; + [filterTableNegateCheckbox setState:(filterTableNegate) ? NSOnState : NSOffState]; + filterTableDefaultOperator = @"LIKE '%%%@%%'"; + // Add observers for document task activity [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startDocumentTaskForTab:) @@ -2800,6 +2809,8 @@ - (IBAction)tableFilterClear:(id)sender { + [filterTableView abortEditing]; + for(NSNumber *col in [filterTableData allKeys]) [[filterTableData objectForKey:col] setObject:[NSMutableArray arrayWithObjects:@"", @"", @"", @"", @"", @"", @"", @"", @"", @"", nil] forKey:@"filter"]; @@ -2821,7 +2832,33 @@ [filterTableWhereClause setCompletionWasReinvokedAutomatically:NO]; [filterTableWhereClause insertText:@""]; [filterTableWhereClause didChangeText]; - [[NSApp keyWindow] makeFirstResponder:filterTableView]; + [[tableDocumentInstance parentWindow] makeFirstResponder:filterTableView]; +} + +- (IBAction)toggleNegateClause:(id)sender +{ + filterTableNegate = !filterTableNegate; +} + +- (IBAction)toggleDistinctSelect:(id)sender +{ + filterTableDistinct = !filterTableDistinct; +} + +- (IBAction)setDefaultOperator:(id)sender +{ + NSLog(@"DEFAULT"); +} + +- (IBAction)swapFilterTable:(id)sender +{ + NSLog(@"SWAP"); +} + +- (IBAction)toggleLookAllFieldsMode:(id)sender +{ + NSLog(@"ddd %@", lastEditedFilterTableValue); + // [self tableFilterClear:nil]; } #pragma mark - @@ -3878,7 +3915,14 @@ - (void)controlTextDidChange:(NSNotification *)notification { if ([notification object] == filterTableView) { - [self updateFilterTableClause:[[[[notification userInfo] objectForKey:@"NSFieldEditor"] textStorage] string]]; + + NSString *str = [[[[notification userInfo] objectForKey:@"NSFieldEditor"] textStorage] string]; + if(str && [str length]) { + if(lastEditedFilterTableValue) [lastEditedFilterTableValue release]; + lastEditedFilterTableValue = [[NSString stringWithString:str] retain]; + } + [self updateFilterTableClause:lastEditedFilterTableValue]; + } } /** @@ -4034,7 +4078,6 @@ NSString *re1 = @"^\\s*(<|>|!?=)\\s*(.*?)\\s*$"; NSString *re2 = @"(?i)^\\s*(.*)\\s+(.*?)\\s*$"; - NSString *defaultOperator = @"LIKE '%%%@%%'"; NSCharacterSet *whiteSpaceCharSet = [NSCharacterSet whitespaceAndNewlineCharacterSet]; for(NSInteger i=0; i