public FilterTextBox(PropertyDefinitionModel prop, bool isInlineMode) : base() { if (isInlineMode) { this.Template = ResourcesManager.Instance.GetControlTemplate("FilterTextBoxInlineTemplate"); } else { this.Template = ResourcesManager.Instance.GetControlTemplate("FilterTextBoxTemplate"); } this.IsEditable = true; if (prop.Type == PropertyType.String) { FilterType = FilterFieldOperator.Equal; AvailableFilterTypes = new List <FilterFieldOperator>() { FilterFieldOperator.Contains, FilterFieldOperator.StartsWith, FilterFieldOperator.EndsWith, FilterFieldOperator.Equal }; } else { FilterType = FilterFieldOperator.Equal; AvailableFilterTypes = new List <FilterFieldOperator>() { FilterFieldOperator.Equal, FilterFieldOperator.GreaterThan, FilterFieldOperator.LessThan }; } }
private a7ComboBox getBoolFilter(PropertyDefinitionModel field) { a7ComboBox cb = new a7ComboBox(); cb.SelectedValuePath = "Value"; cb.DisplayMemberPath = "Name"; cb.Width = 120; var items = new ObservableCollection <comboItem>(); items.Add(new comboItem("1", "Yes")); items.Add(new comboItem("0", "No")); cb.ItemsSource = items; cb.Background = Brushes.White; cb.Template = ResourcesManager.Instance.GetControlTemplate("CustomComboBox"); cb.Padding = new Thickness(0.0); cb.Margin = new Thickness(0.0); cb.HorizontalAlignment = HorizontalAlignment.Stretch; cb.BorderBrush = ResourcesManager.Instance.GetBrush("IsReadOnlyBorderBrush"); cb.SetBinding(a7ComboBox.SelectedValueProperty, getFilterValueBinding()); cb.SetBinding(a7ComboBox.IsEnabledProperty, getIsEnabledBinding()); cb.Height = 18; cb.FontSize = 12; cb.SelectionChanged += (s, e) => activateFilter(); return(cb); }
public ProperyModel(PropertyDefinition propertyDefinition, PropertyDefinitionModel propertyDefinitionModel) { var contentTypeRes = ServiceLocator.Current.GetInstance <IContentTypeRepository>(); var propertyDefinitionRes = ServiceLocator.Current.GetInstance <IPropertyDefinitionRepository>(); var propertyDefinitionSync = new PropertyDefinitionSynchronizer(); Id = propertyDefinition.ID; ContentTypeId = propertyDefinition.ContentTypeID; ContentTypeName = contentTypeRes.Load(propertyDefinition.ContentTypeID).Name; Name = propertyDefinition.Name; EditCaption = propertyDefinition.EditCaption; Description = propertyDefinition.HelpText; TabName = propertyDefinition.Tab.Name; TypeName = propertyDefinition.Type.Name; SortOrder = propertyDefinition.FieldOrder; if (propertyDefinitionModel != null) { ModelDescription = propertyDefinitionModel.Description; ModelEditCaption = propertyDefinitionModel.DisplayName; ModelTabName = propertyDefinitionModel.TabName; ModelState = Enum.GetName(typeof(SynchronizationStatus), propertyDefinitionModel.State); ModelSortOrder = propertyDefinitionModel.Order; try { ModelTypeName = propertyDefinitionSync.ResolveType(propertyDefinitionModel).Name; } catch { ModelTypeName = propertyDefinitionModel.Type.Name; } } UsageContents = propertyDefinitionRes.GetUsage(propertyDefinition.ID, false, true, propertyDefinition.IsDynamicProperty); }
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()); } }
private void setField(PropertyDefinitionModel field) { if (this.IsPopupMode) { this.lCaption.Content = field.Path; this.firstColumn.Width = new GridLength(0); } else { this.lCaption.Content = "Field value"; this.firstColumn.Width = new GridLength(50, GridUnitType.Star); } FrameworkElement fe; if (field.Type == PropertyType.Bool) { fe = getBoolFilter(field); } else if (field.Type == PropertyType.DateTime) { fe = getDatePicker(field); } else { fe = getTextBox(field); } fe.Margin = new Thickness(0); this.filterContainer.Content = fe; _frameworkElement = fe; }
private void AutoCompleteBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0 && e.AddedItems[0] is PropertyDefinitionModel) { this.SelectedProperty = e.AddedItems[0] as PropertyDefinitionModel; this.cbType.SelectedValue = this.SelectedProperty.Type; selectedPropertychanged(); } }
private void bAdd_Click(object sender, RoutedEventArgs e) { if (this.IsPopupMode) { popupFieldSelect.IsOpen = true; } else { this.setProperty(PropertyDefinitionModel.GetEmpty()); } }
private FilterTextBox getTextBox(PropertyDefinitionModel field) { var ftb = new FilterTextBox(field, !this.IsPopupMode) { Padding = new Thickness(0), Width = 120 }; if (this.IsPopupMode) { ftb.Height = 26; } else { ftb.Height = 21; } ftb.SetBinding(FilterTextBox.TextProperty, getFilterValueBinding()); var faExpr = this.Filter as FltAtomExprData; if (faExpr != null && faExpr.Value.IsEmpty()) { if (field.Type == PropertyType.String) { (this.Filter as FltAtomExprData).Operator = FilterFieldOperator.Equal; } else { (this.Filter as FltAtomExprData).Operator = FilterFieldOperator.Equal; } } var operatorBinding = new Binding("Operator") { Source = this.Filter, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }; ftb.SetBinding(FilterTextBox.FilterTypeProperty, operatorBinding); ftb.SetBinding(FilterTextBox.PropertyTypeProperty, new Binding("PropertyType") { Source = this.Filter, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }); ftb.SetBinding(FilterTextBox.IsEnabledProperty, this.getIsEnabledBinding()); ftb.BorderBrush = ResourcesManager.Instance.GetBrush("IsReadOnlyBorderBrush"); ftb.KeyUp += (s, e) => { if (e.Key == Key.Enter) { activateFilter(); } }; return(ftb); }
private void bOr_Click(object sender, RoutedEventArgs e) { this.JoinType = eAndOrJoin.Or; if (this.IsPopupMode) { popupFieldSelect.IsOpen = true; } else { this.setProperty(PropertyDefinitionModel.GetEmpty()); } }
public FilterAtomEditor(PropertyDefinitionModel field) { InitializeComponent(); IsWithEntityIdFilter = false; Filter = new FltAtomExprData() { Operator = FilterFieldOperator.Equal, PropertyType = field.Type, Field = field.Path }; setField(field); }
private ContentTypeAnalyzerModel.ContentTypeModel CreateContentTypeModel(PropertyDefinitionModel propertyDefinitionModel, ContentTypeModel contentTypeModel) { var hasConflicts = propertyDefinitionModel.State == SynchronizationStatus.Conflict; return(new ContentTypeAnalyzerModel.ContentTypeModel { Type = "Property Type Model", DisplayName = propertyDefinitionModel.DisplayName, Name = $"{contentTypeModel.Name}-{propertyDefinitionModel.Name}", State = propertyDefinitionModel.State.ToString(), Description = propertyDefinitionModel.Description, HasConflict = hasConflicts, Conflicts = FindConflicts(propertyDefinitionModel, hasConflicts) }); }
private void setProperty(PropertyDefinitionModel selectedProperty) { gStartPanel.Visibility = Visibility.Collapsed; MyBorder.Visibility = System.Windows.Visibility.Visible; spButtons.Visibility = System.Windows.Visibility.Visible; var fge = new FilterGroupEditor(_collection, false, this.IsReadOnly, this); var fae = new FilterElementEditor(_collection, selectedProperty, this.IsPopupMode) { Margin = new Thickness(0, 0, 0, 0), IsReadOnly = this.IsReadOnly }; fae.EditorContext = this; fge.SetAtomFilter(fae); this.FilterExpr = fge.Filter; SetRootGroup(fge); }
private void setProperty(PropertyDefinitionModel selectedField) { var fae = new FilterElementEditor(_collection, selectedField, this.IsPopupMode) { Margin = new Thickness(0, 0, 0, 0), IsReadOnly = this.IsReadOnly }; fae.EditorContext = this.EditorContext; var fge = new FilterGroupEditor(_collection, !_vertical, IsReadOnly, EditorContext) { Background = Brushes.White }; fge.SetAtomFilter(fae); AddGroupSubFilter(fge); popupFieldSelect.IsOpen = false; }
public FilterElementEditor(CollectionVM collection, PropertyDefinitionModel elementDef, bool isPopupMode) { this.IsPopupMode = isPopupMode; InitializeComponent(); this.propSelector.SelectedPropertyChanged += PropSelector_SelectedPropertyChanged; IsWithcollectionIdFilter = false; var field = elementDef; this.propSelector.Properties = collection.AvailableProperties; this.propSelector.SelectedProperty = elementDef; Filter = new FltAtomExprData() { Operator = FilterFieldOperator.Equal, PropertyType = field.Type, Field = field.Path }; setField(field); }
private void AutoCompleteBox_TextChanged(object sender, RoutedEventArgs e) { var type = PropertyType.String; if (cbType.SelectedValue is PropertyType) { type = (PropertyType)cbType.SelectedValue; } else { cbType.SelectedValue = type; } this.SelectedProperty = new PropertyDefinitionModel { Name = acbProperty.Text, Path = acbProperty.Text, Type = type }; selectedPropertychanged(); }
public CollectionGridColumn(CollectionGrid dg, PropertyDefinitionModel prop) { _dg = dg; PropertyDefinition = prop; _fieldName = PropertyDefinition.Path; this.FieldName = PropertyDefinition.Path; TextBinding = new Binding($"[{FieldName}]") { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.OneWay, ValidatesOnDataErrors = true, NotifyOnValidationError = true }; FrameworkElementFactory template = GetTemplate(TextBinding, this); this.CellTemplate = new DataTemplate() { VisualTree = template }; this.Header = PropertyDefinition.Path; }
private void setField(PropertyDefinitionModel field) { this.lCaption.Content = field.Path; FrameworkElement fe; if (field.Type == PropertyType.Float) { fe = getBoolFilter(field); } else if (field.Type == PropertyType.DateTime) { fe = getDatePicker(field); } else { fe = getTextBox(field); } fe.Margin = new Thickness(0); spMain.Children.Add(fe); _frameworkElement = fe; }
private a7ComboBox getCombo(PropertyDefinitionModel field) { a7ComboBox cb = new a7ComboBox(); (Filter as FltAtomExprData).Operator = FilterFieldOperator.Equal; cb.Width = 120; cb.Height = 18; cb.Template = ResourcesManager.Instance.GetControlTemplate("CustomComboBox"); cb.Padding = new Thickness(0.0); cb.Margin = new Thickness(0.0); cb.HorizontalAlignment = HorizontalAlignment.Stretch; cb.Background = Brushes.White; //todo: ugly hardcode! :D cb.BorderBrush = ResourcesManager.Instance.GetBrush("IsReadOnlyBorderBrush"); //and here cb.Height = 18; //yup, hardcode //cb.DisplayMemberPath = "DisplayName"; cb.ItemTemplate = a7ComboBox.CustomItemTemplate; cb.SelectedValuePath = "Id"; cb.SetBinding(a7ComboBox.SelectedValueProperty, getFilterValueBinding()); cb.SetBinding(a7ComboBox.IsEnabledProperty, getIsEnabledBinding()); //cb.ItemsSource = a7Core.Instance.DataSourceManager.GetDataSourceItems(field.DataSourceId, bx).Collection; cb.SelectionChanged += (s, e) => activateFilter(); return(cb); }
private FilterDatePicker getDatePicker(PropertyDefinitionModel field) { FilterDatePicker ftb = new FilterDatePicker(); ftb.HasTime = false; ftb.Padding = new Thickness(0.0); ftb.Margin = new Thickness(0.0); ftb.Width = 120; ftb.HorizontalAlignment = HorizontalAlignment.Stretch; ftb.BorderBrush = ResourcesManager.Instance.GetBrush("IsReadOnlyBorderBrush"); var fa = this.Filter as FltAtomExprData; fa.Operator = FilterFieldOperator.Between; //if(fa!=null) // fa.Operator = FilterFieldOperator.Equal; ftb.SetBinding(FilterDatePicker.TextProperty, getFilterValueBinding()); ftb.Height = 18; ftb.FontSize = 12; var operatorBinding = new Binding("Operator") { Source = this.Filter, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay }; ftb.SetBinding(FilterDatePicker.FilterTypeProperty, operatorBinding); ftb.SetBinding(FilterDatePicker.IsEnabledProperty, getIsEnabledBinding()); ftb.KeyUp += (s, e) => { if (e.Key == Key.Enter) { activateFilter(); } }; return(ftb); }
public void Reset(bool withRefresh = false) { _backgroundIndex = 0; mainGrid.Children.Clear(); this.FilterExpr = null; if (!this.IsReadOnly) { if (IsPopupMode) { gStartPanel.Visibility = Visibility.Visible; MyBorder.Visibility = Visibility.Collapsed; spButtons.Visibility = Visibility.Collapsed; } else { this.setProperty(PropertyDefinitionModel.GetEmpty()); } } // spButtons.Visibility = Visibility.Collapsed; if (withRefresh && UpdateFilterFunction != null) { UpdateFilterFunction(null); } }
public static FilterElementDefinition GetFieldFilterElement(PropertyDefinitionModel fieldData) { return(new FilterElementDefinition(fieldData)); }
private FilterElementDefinition(PropertyDefinitionModel fieldData) { FieldData = fieldData; }
/// <summary> /// Almost exact implementation of the AssignValuesToPropertyDefinition in the ContentDataAttributeScanningAssigner /// the only thing that differs is the added call to CustomAllowedTypes.GetMergedAllowedTypesAttribute. /// That call allows us to add more types to the Allowed/RestricedTypes without using the AllowedTypes attribute. /// </summary> /// <param name="propertyDefinitionModel"></param> /// <param name="property"></param> /// <param name="parentModel"></param> public override void AssignValuesToPropertyDefinition(PropertyDefinitionModel propertyDefinitionModel, PropertyInfo property, ContentTypeModel parentModel) { if (property.IsAutoGenerated() && !property.IsAutoVirtualPublic()) { var exceptionMessage = string.Format(CultureInfo.InvariantCulture, "The property '{0}' on the content type '{1}' is autogenerated but not virtual declared.", property.Name, property.DeclaringType.Name); throw new InvalidOperationException(exceptionMessage); } //This is our added logic to merge a predefined AllowedTypes attribute with our own AllowedTypes specified in code. #region ModularAllowedTypes var customAttributes = Attribute.GetCustomAttributes(property, true).ToList(); var injectedAllowedTypesAttribute = InjectedAllowedTypes.GetInjectedAllowedTypesAttribute(parentModel.ModelType, property.Name); var specifiedAllowedTypesAttribute = property.GetCustomAttribute <InjectedAllowedTypesAttribute>(); //We DO NOT include an existing AllowedTypesAttribute in the merge, because if the AllowedTypesAttribute is used, EPiServer will ONLY //look at the AllowedTypesAttribute thus making the validation fail. We can't hook into that method as far as I know so you will need //to use the InjectedAllowedTypesAttribute instead of the AllowedTypesAttribute. if (customAttributes.Any(x => x is AllowedTypesAttribute)) { var existingAllowedTypesAttribute = customAttributes.FirstOrDefault(x => x is AllowedTypesAttribute) as AllowedTypesAttribute; if (injectedAllowedTypesAttribute != null) { var mergedAllowedTypesAttribute = InjectedAllowedTypes.MergeAttributes(injectedAllowedTypesAttribute, specifiedAllowedTypesAttribute); customAttributes.Remove(existingAllowedTypesAttribute); customAttributes.Add(mergedAllowedTypesAttribute); } } else { var mergedAllowedTypesAttribute = InjectedAllowedTypes.MergeAttributes(injectedAllowedTypesAttribute, specifiedAllowedTypesAttribute); if (mergedAllowedTypesAttribute != null) { customAttributes.Add(mergedAllowedTypesAttribute); } } #endregion foreach (var attribute in customAttributes) { if (attribute is BackingTypeAttribute) { var backingTypeAttribute = attribute as BackingTypeAttribute; if (backingTypeAttribute.BackingType != null) { if (!typeof(PropertyData).IsAssignableFrom(backingTypeAttribute.BackingType)) { var exceptionMessage = string.Format(CultureInfo.InvariantCulture, "The backing type '{0}' attributed to the property '{1}' on '{2}' does not inherit PropertyData.", backingTypeAttribute.BackingType.FullName, property.Name, property.DeclaringType.Name); throw new TypeMismatchException(exceptionMessage); } if (property.IsAutoVirtualPublic()) { ValidateTypeCompability(property, backingTypeAttribute.BackingType); } } propertyDefinitionModel.BackingType = backingTypeAttribute.BackingType; } else if (attribute is AllowedTypesAttribute) { var allowedTypesAttribute = attribute as AllowedTypesAttribute; VerifyAllowedTypesAttribute(allowedTypesAttribute, property); } else if (attribute is DisplayAttribute) { var displayAttribute = attribute as DisplayAttribute; propertyDefinitionModel.DisplayName = displayAttribute.GetName(); propertyDefinitionModel.Description = displayAttribute.GetDescription(); propertyDefinitionModel.Order = displayAttribute.GetOrder(); propertyDefinitionModel.TabName = displayAttribute.GetGroupName(); } else if (attribute is ScaffoldColumnAttribute) { var scaffoldColumnAttribute = attribute as ScaffoldColumnAttribute; propertyDefinitionModel.AvailableInEditMode = scaffoldColumnAttribute.Scaffold; } else if (attribute is CultureSpecificAttribute) { var specificAttribute = attribute as CultureSpecificAttribute; ThrowIfBlockProperty(specificAttribute, property); propertyDefinitionModel.CultureSpecific = specificAttribute.IsCultureSpecific; } else if (attribute is RequiredAttribute) { var requiredAttribute = attribute as RequiredAttribute; ThrowIfBlockProperty(requiredAttribute, property); propertyDefinitionModel.Required = true; } else if (attribute is SearchableAttribute) { var searchableAttribute = attribute as SearchableAttribute; ThrowIfBlockProperty(searchableAttribute, property); propertyDefinitionModel.Searchable = searchableAttribute.IsSearchable; } else if (attribute is UIHintAttribute) { var uiHintAttribute = attribute as UIHintAttribute; if (!string.IsNullOrEmpty(uiHintAttribute.UIHint)) { if (string.Equals(uiHintAttribute.PresentationLayer, "website")) { propertyDefinitionModel.TemplateHint = uiHintAttribute.UIHint; } else if (string.IsNullOrEmpty(uiHintAttribute.PresentationLayer) && string.IsNullOrEmpty(propertyDefinitionModel.TemplateHint)) { propertyDefinitionModel.TemplateHint = uiHintAttribute.UIHint; } } } propertyDefinitionModel.Attributes.AddAttribute(attribute); } }
public void AddColumn(PropertyDefinitionModel columnName) { this.Columns.Add(columnName); updateSelectedViewInConfig(); }
private IEnumerable <ContentTypeAnalyzerModel.ConflictModel> FindConflicts(PropertyDefinitionModel model, bool hasConflicts) { if (!hasConflicts) { yield break; } var propertyDefinition = model.ExistingPropertyDefinition; if (!string.IsNullOrEmpty(model.TabName) && (TabIsNotPersisted(propertyDefinition.Tab) || !string.Equals(model.TabName, propertyDefinition.Tab.Name))) { yield return(new ContentTypeAnalyzerModel.ConflictModel { Name = "Tab name", ContentTypeModelValue = model.TabName, ContentTypeValue = propertyDefinition.Tab.Name }); } if (!string.IsNullOrEmpty(model.Name) && !string.Equals(model.Name, propertyDefinition.Name)) { yield return(new ContentTypeAnalyzerModel.ConflictModel { Name = "Name", ContentTypeModelValue = model.Name, ContentTypeValue = propertyDefinition.Name }); } if (!string.IsNullOrEmpty(model.Description) && !string.Equals(model.Description, propertyDefinition.HelpText)) { yield return(new ContentTypeAnalyzerModel.ConflictModel { Name = "Description (help text)", ContentTypeModelValue = model.Description, ContentTypeValue = propertyDefinition.HelpText }); } if (!string.IsNullOrEmpty(model.DisplayName) && !string.Equals(model.DisplayName, propertyDefinition.EditCaption)) { yield return(new ContentTypeAnalyzerModel.ConflictModel { Name = "Display name (edit caption)", ContentTypeModelValue = model.DisplayName, ContentTypeValue = propertyDefinition.Tab.Name }); } if ((model.CultureSpecific ?? false) != propertyDefinition.LanguageSpecific) { yield return(new ContentTypeAnalyzerModel.ConflictModel { Name = "Culture specific (language specific)", ContentTypeModelValue = model.CultureSpecific?.ToString(), ContentTypeValue = propertyDefinition.LanguageSpecific.ToString() }); } if (model.Required.HasValue && model.Required.Value != propertyDefinition.Required) { yield return(new ContentTypeAnalyzerModel.ConflictModel { Name = "Required", ContentTypeModelValue = model.Required?.ToString(), ContentTypeValue = propertyDefinition.Required.ToString() }); } if (model.Searchable.HasValue && model.Searchable.Value != propertyDefinition.Searchable) { yield return(new ContentTypeAnalyzerModel.ConflictModel { Name = "Searchable", ContentTypeModelValue = model.Searchable?.ToString(), ContentTypeValue = propertyDefinition.Searchable.ToString() }); } if (model.AvailableInEditMode.HasValue && model.AvailableInEditMode.Value != propertyDefinition.DisplayEditUI) { yield return(new ContentTypeAnalyzerModel.ConflictModel { Name = "Available in edit mode (display edit UI)", ContentTypeModelValue = model.AvailableInEditMode?.ToString(), ContentTypeValue = propertyDefinition.DisplayEditUI.ToString() }); } if (model.Order.HasValue && model.Order.Value != propertyDefinition.FieldOrder) { yield return(new ContentTypeAnalyzerModel.ConflictModel { Name = "Field order", ContentTypeModelValue = model.Order?.ToString(), ContentTypeValue = propertyDefinition.FieldOrder.ToString() }); } }