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 --- Source/SPTableContent.h | 15 ++++++++++- Source/SPTableContent.m | 68 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 77 insertions(+), 6 deletions(-) (limited to 'Source') 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