コード例 #1
0
 public void SetFilter(CollectionVM collection, FilterExpressionData filter)
 {
     _collection = collection;
     Elements    = collection.AvailableProperties;
     if (filter != null)
     {
         var fge = new FilterGroupEditor(collection, false, this.IsReadOnly, this);
         fge.SetFilter(filter);
         this.FilterExpr = filter;
         SetRootGroup(fge);
         if (filter != null)
         {
             gStartPanel.Visibility = Visibility.Collapsed;
             MyBorder.Visibility    = System.Windows.Visibility.Visible;
             if (!IsReadOnly)
             {
                 spButtons.Visibility = System.Windows.Visibility.Visible;
             }
         }
     }
     else
     {
         this.setProperty(PropertyDefinitionModel.GetEmpty());
     }
 }
コード例 #2
0
        public void SetFilter(FilterExpressionData filter)
        {
            Reset();
            this.Filter = filter;
            if (filter != null)
            {
                if (filter is FltAtomExprData)
                {
                    if (filter.HasActiveFilter)
                    {
                        this.Filter = filter;
                        if (_collection != null)// why was this here?: && _collection.AvailableProperties.Any(ap => ap.Path ==(filter as FltAtomExprData).Field))
                        {
                            this.SetAtomFilter(new FilterElementEditor(_collection, filter as FltAtomExprData, this.IsPopupMode)
                            {
                                IsReadOnly    = this.IsReadOnly,
                                EditorContext = this.EditorContext
                            });
                        }
                    }
                }
                else if (filter is FltGroupExprData)
                {
                    var fge = filter as FltGroupExprData;
                    this.Filter   = new FltGroupExprData(fge.AndOr);
                    this.JoinType = fge.AndOr;
                    foreach (var f in fge.FilterExpressions)
                    {
                        if (f.HasActiveFilter)
                        {
                            var subGroup = new FilterGroupEditor(_collection, !_vertical, this.IsReadOnly, EditorContext, f);
                            this.AddGroupSubFilter(subGroup);
                        }
                    }
                }
                else if (filter is FltFlatGroupExprData)
                {
                    var fge = filter as FltFlatGroupExprData;
                    this.Filter   = new FltFlatGroupExprData(fge.AndOr);
                    this.JoinType = fge.AndOr;
                    foreach (var f in fge.FieldFilters.Values)
                    {
                        if (f.HasActiveFilter)
                        {
                            var subGroup = new FilterGroupEditor(_collection, !_vertical, this.IsReadOnly, EditorContext, f);
                            this.AddGroupSubFilter(subGroup);
                        }
                    }
                }
                this.Negate(filter.Negate);
            }

            if (this.AtomFilter == null && this.SubGroups.Count == 0)
            {
                Reset();
            }
        }
コード例 #3
0
 public void SetFilter(FilterExpressionData filter)
 {
     Reset();
     this.Filter = filter;
     if (filter != null)
     {
         if (filter is FltAtomExprData)
         {
             if (filter.HasActiveFilter)
             {
                 this.Filter = filter;
                 if (_entity != null && _entity.AvailableColumns.Any(column => column.Name == (filter as FltAtomExprData)?.Field))
                 {
                     this.SetAtomFilter(new a7SqlTools.Controls.Filter.a7FilterElementEditor(_entity, filter as FltAtomExprData)
                     {
                         IsReadOnly    = this.IsReadOnly,
                         EditorContext = this.EditorContext
                     });
                 }
             }
         }
         else if (filter is FltGroupExprData)
         {
             var fge = filter as FltGroupExprData;
             this.Filter   = new FltGroupExprData(fge.AndOr);
             this.JoinType = fge.AndOr;
             foreach (var f in fge.FilterExpressions)
             {
                 if (f.HasActiveFilter)
                 {
                     var subGroup = new a7FilterGroupEditor(_entity, !_vertical, this.IsReadOnly, EditorContext, f);
                     this.AddGroupSubFilter(subGroup);
                 }
             }
         }
         else if (filter is FltFlatGroupExprData)
         {
             var fge = filter as FltFlatGroupExprData;
             this.Filter   = new FltFlatGroupExprData(fge.AndOr);
             this.JoinType = fge.AndOr;
             foreach (var f in fge.FieldFilters.Values)
             {
                 if (f.HasActiveFilter)
                 {
                     var subGroup = new a7FilterGroupEditor(_entity, !_vertical, this.IsReadOnly, EditorContext, f);
                     this.AddGroupSubFilter(subGroup);
                 }
             }
         }
         this.Negate(filter.Negate);
     }
     if (this.AtomFilter == null && this.SubGroups.Count == 0)
     {
         Reset();
     }
 }
コード例 #4
0
 /// <summary>
 /// if collName is empty string no collName will be added to field names on where clause, and no relFilters will be replaced, simplified logic.
 /// </summary>
 /// <param name="filter"></param>
 /// <param name="collName"></param>
 public WhereClauseBuilder(FilterExpressionData filter, string collName = "")
 {
     _filter             = filter;
     _whereStringBuilder = new StringBuilder();
     Parameters          = new Dictionary <string, object>();
     filterExprAppendWhereAndParams(_filter, "", collName);
     WhereClause = _whereStringBuilder.ToString();
     if (WhereClause.IsNotEmpty())
     {
         WhereClause = $" WHERE {WhereClause}";
     }
 }
コード例 #5
0
 void RefreshButtonHighlight(FilterExpressionData filter)
 {
     if (filter != null && filter.HasActiveFilter)
     {
         this.ActiveBackground = Brushes.MistyRose;
         this.BorderThickness  = new Thickness(1);
         this.BorderBrush      = Brushes.LightCoral;
     }
     else
     {
         this.ActiveBackground = Brushes.Transparent;
         this.BorderThickness  = new Thickness(0);
         this.BorderBrush      = Brushes.Transparent;
     }
 }
コード例 #6
0
 void UpdateFilter(FilterExpressionData filter)
 {
     if (UpdateFilterFunction != null)
     {
         UpdateFilterFunction(filter);
     }
     if (filter != null && filter.HasActiveFilter)
     {
         this.ActiveBackground = Brushes.Red;
     }
     else
     {
         this.ActiveBackground = Brushes.Transparent;
     }
 }
コード例 #7
0
 protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
 {
     base.OnPropertyChanged(e);
     if (e.Property == TableProperty && _table != e.NewValue as a7SingleTableExplorer)
     {
         if (_fePopupControl != null)
         {
             _fePopupControl.SetTable(e.NewValue as a7SingleTableExplorer);
             _table = e.NewValue as a7SingleTableExplorer;
             if (this.FilterExpr != null)
             {
                 _fePopupControl.SetFilter(_table, FilterExpr);
             }
         }
         else
         {
             _table = e.NewValue as a7SingleTableExplorer;
         }
     }
     else if (e.Property == FilterExprProperty)
     {
         if (this.FilterExpr != e.NewValue as FilterExpressionData)
         {
             if (_fePopupControl != null && this._table != null)
             {
                 _fePopupControl.SetFilter(this._table, e.NewValue as FilterExpressionData);
             }
             else
             {
                 this.FilterExpr = e.NewValue as FilterExpressionData;
             }
         }
         RefreshButtonHighlight(e.NewValue as FilterExpressionData);
     }
     else if (e.Property == UpdateFilterFunctionProperty && this._fePopupControl != null)
     {
         this._fePopupControl.UpdateFilterFunction = UpdateFilter;
     }
 }
コード例 #8
0
        public void SetFilter(a7SingleTableExplorer entity, FilterExpressionData filter)
        {
            if (entity == null)
            {
                Reset();
                return;
            }
            Elements = a7FilterEditorUtils.GetFilterEditorElements(entity);
            var fge = new a7FilterGroupEditor(entity, false, this.IsReadOnly, this);

            fge.SetFilter(filter);
            this.FilterExpr = filter;
            SetRootGroup(fge);
            if (filter != null)
            {
                gStartPanel.Visibility = Visibility.Collapsed;
                MyBorder.Visibility    = System.Windows.Visibility.Visible;
                if (!IsReadOnly)
                {
                    spButtons.Visibility = System.Windows.Visibility.Visible;
                }
            }
        }
コード例 #9
0
 private bool filterExprAppendWhereAndParams(FilterExpressionData filter, string preffixToAppend, string collName)
 {
     if (filter != null && filter.HasActiveFilter)
     {
         if (filter.Negate)
         {
             preffixToAppend += " NOT ";
         }
         var fa = filter as FltAtomExprData;//atomic expr
         if (fa != null)
         {
             string val = fa.Value;
             appendFilterAtom2WhereSb(fa, preffixToAppend, collName);
             return(true);
         }
         var fg = filter as FltGroupExprData; //group expr
         if (fg != null)
         {
             if (fg.FilterExpressions.Count == 1)
             {
                 filterExprAppendWhereAndParams(fg.FilterExpressions[0], preffixToAppend, collName);
             }
             else
             {
                 appendFilterGroup2WhereSb(fg, preffixToAppend, collName);
             }
             return(true);
         }
         var fsg = filter as FltFlatGroupExprData;//simple group expr
         if (fsg != null)
         {
             appendFilterSimpleGroup2WhereSb(fsg, preffixToAppend, collName);
             return(true);
         }
     }
     return(true);
 }
コード例 #10
0
 public a7FilterGroupEditor(a7SingleTableExplorer entity, bool vertical, bool isReadOnly, a7SqlTools.Controls.Filter.a7FilterEditor editorContext, FilterExpressionData filter)
     : this(entity, vertical, isReadOnly, editorContext)
 {
     SetFilter(filter);
 }
コード例 #11
0
 public FilterGroupEditor(CollectionVM collection, bool vertical, bool isReadOnly, FilterEditor editorContext, FilterExpressionData filter)
     : this(collection, vertical, isReadOnly, editorContext)
 {
     SetFilter(filter);
 }
コード例 #12
0
 void UpdateFilter(FilterExpressionData filter)
 {
     UpdateFilterFunction?.Invoke(filter);
     RefreshButtonHighlight(filter);
     _fePopup.IsOpen = false;
 }