public DisplayColumn(ViewInfo viewInfo, ColumnSpec columnSpec, ColumnDescriptor columnDescriptor) { ViewInfo = viewInfo; ColumnDescriptor = columnDescriptor; ColumnSpec = columnSpec; CollectionColumn = columnDescriptor == null ? null : columnDescriptor.CollectionAncestor() ?? viewInfo.ParentColumn; }
public LiveReportForm(IDocumentContainer documentContainer) { InitializeComponent(); Icon = Resources.Skyline; _dataSchema = new SkylineDataSchema(documentContainer); var parentColumn = new ColumnDescriptor(_dataSchema, typeof (Protein)); var viewContext = new SkylineViewContext(parentColumn); bindingListSource.SetViewContext(viewContext); bindingListSource.RowSource = new Proteins(_dataSchema); navBar.BindingNavigator.Items.Insert(0, toolStripDropDownRowSource); }
public FilterInfo(FilterSpec filterSpec, ColumnDescriptor columnDescriptor, ColumnDescriptor collectionColumn) { FilterSpec = filterSpec; ColumnDescriptor = columnDescriptor; CollectionColumn = collectionColumn; try { Predicate = MakePredicate(); } catch (Exception e) { Error = e.Message; } }
public ViewInfo(ColumnDescriptor parentColumn, ViewSpec viewSpec) { ParentColumn = parentColumn; DataSchema = parentColumn.DataSchema; Name = viewSpec.Name; RowSourceName = viewSpec.RowSource; _columnDescriptors.Add(parentColumn.PropertyPath, parentColumn); var displayColumns = new List<DisplayColumn>(); foreach (var column in viewSpec.Columns) { var columnDescriptor = GetColumnDescriptor(column.PropertyPath); displayColumns.Add(new DisplayColumn(this, column, columnDescriptor)); } DisplayColumns = Array.AsReadOnly(displayColumns.ToArray()); SublistId = viewSpec.SublistId; var filters = new List<FilterInfo>(); foreach (var filterSpec in viewSpec.Filters) { var columnDescriptor = GetColumnDescriptor(filterSpec.ColumnId); ColumnDescriptor collectionColumn = null; if (columnDescriptor != null) { collectionColumn = columnDescriptor.CollectionAncestor() ?? ParentColumn; } filters.Add(new FilterInfo(filterSpec, columnDescriptor, collectionColumn)); } Filters = Array.AsReadOnly(filters.ToArray()); var sorts = new List<KeyValuePair<int, DisplayColumn>>(); for (int i = 0; i < DisplayColumns.Count; i++) { if (DisplayColumns[i].ColumnSpec.SortDirection != null) { sorts.Add(new KeyValuePair<int, DisplayColumn>(i, DisplayColumns[i])); } } if (sorts.Count > 0) { sorts.Sort(CompareSortEntries); SortColumns = Array.AsReadOnly(sorts.Select(kvp => kvp.Value).ToArray()); } else { SortColumns = new DisplayColumn[0]; } }
private static void AddIndexPropertyDescriptors(ColumnDescriptor columnDescriptor, List <ColumnDescriptor> indexPropertyDescriptors, HashSet <IdentifierPath> handledIdentifierPaths) { if (columnDescriptor == null) { return; } AddIndexPropertyDescriptors(columnDescriptor.Parent, indexPropertyDescriptors, handledIdentifierPaths); if (handledIdentifierPaths.Contains(columnDescriptor.IdPath)) { return; } if (typeof(IEntity).IsAssignableFrom(columnDescriptor.PropertyType)) { indexPropertyDescriptors.Add(columnDescriptor); } handledIdentifierPaths.Add(columnDescriptor.IdPath); }
public RowItem ApplyFilter(RowItem rowItem) { var predicate = Predicate; if (CollectionColumn.PropertyPath.IsRoot || rowItem.RowKey.Contains(CollectionColumn.PropertyPath)) { if (predicate(ColumnDescriptor.GetPropertyValue(rowItem, null))) { return(rowItem); } return(null); } if (rowItem.PivotKeyCount == 0) { return(FilterSpec.Predicate.FilterOperation == FilterOperations.OP_IS_BLANK ? rowItem : null); } List <PivotKey> newPivotKeys = new List <PivotKey>(); bool anyPivotKeysLeft = false; foreach (var pivotKey in rowItem.PivotKeys) { if (!pivotKey.Contains(CollectionColumn.PropertyPath)) { newPivotKeys.Add(pivotKey); } else { object value = ColumnDescriptor.GetPropertyValue(rowItem, pivotKey); if (predicate(value)) { newPivotKeys.Add(pivotKey); anyPivotKeysLeft = true; } } } if (newPivotKeys.Count == rowItem.PivotKeyCount) { return(rowItem); } if (!anyPivotKeysLeft) { return(null); } return(rowItem.SetPivotKeys(new HashSet <PivotKey>(newPivotKeys))); }
public IList <ColumnDescriptor> ListUnboundColumns() { if (Parent == null) { return(new ColumnDescriptor[0]); } var parentUnboundColumns = Parent.ListUnboundColumns(); if (PropertyDescriptor != null) { return(parentUnboundColumns); } var result = new ColumnDescriptor[parentUnboundColumns.Count + 1]; parentUnboundColumns.CopyTo(result, 0); result[result.Length - 1] = this; return(result); }
private ColumnPropertyDescriptor(ColumnDescriptor columnDescriptor, IdentifierPath identifierPath) : base(ColumnPropertyDescriptorBaseName + identifierPath, new Attribute[0]) { if (columnDescriptor.CollectionInfo != null && columnDescriptor.CollectionInfo.IsDictionary) { // Special case dictionary items. // No one wants to see a KeyValuePair displayed in a GridColumn, // so we display the Value instead. ColumnDescriptor = columnDescriptor.ResolveChild("Value"); } if (ColumnDescriptor == null) { ColumnDescriptor = columnDescriptor; } else { ColumnDescriptor = ColumnDescriptor.SetCaption(columnDescriptor.Caption); } IdentifierPath = identifierPath; }
protected static ViewSpec GetDefaultViewSpec(ColumnDescriptor parentColumn) { var viewSpec = new ViewSpec().SetName(DefaultViewName).SetRowType(parentColumn.PropertyType).SetUiMode(parentColumn.UiMode); var columns = new List <ColumnSpec>(); foreach (var column in parentColumn.GetChildColumns()) { if (null != column.DataSchema.GetCollectionInfo(column.PropertyType)) { continue; } if (column.DataSchema.IsHidden(column)) { continue; } columns.Add(new ColumnSpec(PropertyPath.Root.Property(column.Name))); } viewSpec = viewSpec.SetColumns(columns); return(viewSpec); }
public IDictionary <RowKey, IEnumerable <RowItem> > Group(ColumnDescriptor columnDescriptor, IDictionary <RowKey, IEnumerable <RowItem> > groups) { // var dictionary = new Dictionary<KeyValuePair<RowKey, object>, List<object>>(); // foreach (var group in groups) // { // foreach (var item in group.Value) // { // var value = item == null ? null : columnDescriptor.GetPropertyValue(item, null); // var key = new KeyValuePair<RowKey, object>(group.Key, value); // List<object> list; // if (!dictionary.TryGetValue(key, out list)) // { // list = new List<object>(); // dictionary.Add(key, list); // } // list.Add(item); // } // } // return dictionary.ToDictionary(kvp => kvp.Key.Key.AddValue(columnDescriptor.IdPath, kvp.Key.Value), kvp =>kvp.Value); return(null); }
public virtual bool IsHidden(ColumnDescriptor columnDescriptor) { if (IsObsolete(columnDescriptor)) { return(true); } var hiddenAttribute = FilterAttributes(columnDescriptor.UiMode, columnDescriptor.GetAttributes()).OfType <HiddenAttribute>().FirstOrDefault(); if (hiddenAttribute != null) { return(true); } var hideWhens = columnDescriptor.GetAttributes().OfType <HideWhenAttribute>().ToArray(); var hideIfAncestor = new HashSet <Type>(hideWhens.SelectMany(attr => attr.AncestorsOfAnyOfTheseTypes).Where(type => null != type)); if (hideIfAncestor.Count > 0) { for (ColumnDescriptor ancestor = columnDescriptor.Parent; ancestor != null; ancestor = ancestor.Parent) { if (hideIfAncestor.Any(type => type.IsAssignableFrom(ancestor.PropertyType))) { return(true); } } } ColumnDescriptor oneToManyColumn = columnDescriptor.GetOneToManyColumn(); if (oneToManyColumn != null) { var oneToManyAttribute = oneToManyColumn.GetAttributes().OfType <OneToManyAttribute>().FirstOrDefault(); if (oneToManyAttribute != null && oneToManyAttribute.ForeignKey == columnDescriptor.Name) { return(true); } } return(false); }
static object AggMin(ColumnDescriptor columnDescriptor, IEnumerable <RowItem> items) { object result = null; foreach (var item in items) { if (item == null) { continue; } var value = columnDescriptor.GetPropertyValue(item, null); if (value == null) { continue; } if (result == null || columnDescriptor.DataSchema.Compare(value, result) < 0) { result = value; } } return(result); }
private IColumnCaption GetBaseDisplayName(ColumnDescriptor columnDescriptor) { var oneToManyColumn = columnDescriptor.GetOneToManyColumn(); if (oneToManyColumn != null) { var oneToManyAttribute = oneToManyColumn.GetAttributes().OfType <OneToManyAttribute>().FirstOrDefault(); if (oneToManyAttribute != null) { if (@"Key" == columnDescriptor.Name && oneToManyAttribute.IndexDisplayName != null) { return(new ColumnCaption(oneToManyAttribute.IndexDisplayName)); } if (@"Value" == columnDescriptor.Name && oneToManyAttribute.ItemDisplayName != null) { return(new ColumnCaption(oneToManyAttribute.ItemDisplayName)); } } } var invariantDisplayNameAttribute = columnDescriptor.GetAttributes().OfType <InvariantDisplayNameAttribute>().FirstOrDefault(); if (null != invariantDisplayNameAttribute) { return(new ColumnCaption(invariantDisplayNameAttribute.InvariantDisplayName)); } if (columnDescriptor.Name == null) { if (columnDescriptor.Parent != null) { return(GetBaseDisplayName(columnDescriptor.Parent)); } if (columnDescriptor.PropertyType != null) { return(GetInvariantDisplayName(columnDescriptor.UiMode, columnDescriptor.PropertyType)); } } return(new ColumnCaption(columnDescriptor.Name)); }
private ColumnDescriptor GetColumnDescriptor(IDictionary <IdentifierPath, ColumnSpec> columnSpecs, IdentifierPath idPath) { ColumnDescriptor columnDescriptor; if (_columnDescriptors.TryGetValue(idPath, out columnDescriptor)) { return(columnDescriptor); } var parent = GetColumnDescriptor(columnSpecs, idPath.Parent); if (parent == null) { throw new InvalidOperationException("Could not resolve path " + idPath); } if (idPath.Name != null) { columnDescriptor = new ColumnDescriptor(parent, idPath.Name); } else { var collectionInfo = DataSchema.GetCollectionInfo(parent.PropertyType); if (collectionInfo == null) { throw new InvalidOperationException(parent.PropertyType + " is not a collection."); } columnDescriptor = new ColumnDescriptor(parent, collectionInfo); } ColumnSpec columnSpec; if (columnSpecs.TryGetValue(idPath, out columnSpec)) { columnDescriptor = columnDescriptor.SetColumnSpec(columnSpec); } _columnDescriptors.Add(idPath, columnDescriptor); return(columnDescriptor); }
public ColumnDescriptor(ColumnDescriptor parent, PropertyDescriptor propertyDescriptor) : this(parent, propertyDescriptor.Name, propertyDescriptor) { }
static object AggCount(ColumnDescriptor columnDescriptor, IEnumerable <RowItem> items) { return(items.Count(item => item != null && columnDescriptor.GetPropertyValue(item, null) != null)); }
public bool IsValidFor(ColumnDescriptor columnDescriptor) { return(IsValidFor(columnDescriptor.DataSchema, columnDescriptor.PropertyType)); }
protected bool Equals(ColumnDescriptor other) { return Equals(DataSchema, other.DataSchema) && Equals(Parent, other.Parent) && Equals(PropertyPath, other.PropertyPath); }
public IEnumerable <Attribute> GetAttributes(PivotKey pivotKey) { if (null == ColumnDescriptor) { return(new Attribute[0]); } var columnCaption = GetColumnCaption(pivotKey); var overrideAttributes = new List <Attribute> { new DisplayNameAttribute(columnCaption.GetCaption(DataSchema.DataSchemaLocalizer)), new ColumnCaptionAttribute(columnCaption) }; if (ColumnDescriptor.IsExpensive) { overrideAttributes.Add(new ExpensiveAttribute()); } var mergedAttributes = AttributeCollection.FromExisting(new AttributeCollection(ColumnDescriptor.GetAttributes().ToArray()), overrideAttributes.ToArray()); return(mergedAttributes.Cast <Attribute>()); }
public static Type GetTypeToConvertOperandTo(ColumnDescriptor columnDescriptor) { return(GetTypeToConvertOperandTo(columnDescriptor.DataSchema, columnDescriptor.PropertyType)); }
public Reflected(ColumnDescriptor parent, PropertyDescriptor propertyDescriptor) : base(parent, parent.PropertyPath.Property(propertyDescriptor.Name)) { _propertyDescriptor = propertyDescriptor; }
protected ColumnDescriptor(ColumnDescriptor parent, PropertyPath propertyPath) : this(parent.DataSchema) { Parent = parent; PropertyPath = propertyPath; }
public Predicate <object> MakePredicate(ColumnDescriptor columnDescriptor, string operand) { return(MakePredicate(columnDescriptor.DataSchema, columnDescriptor.PropertyType, operand)); }
protected bool Equals(ColumnDescriptor other) { return(Equals(DataSchema, other.DataSchema) && Equals(Parent, other.Parent) && Equals(PropertyPath, other.PropertyPath)); }
private IEnumerable<ColumnDescriptor> GetChildColumns(ColumnDescriptor columnDescriptor) { var collectionColumn = columnDescriptor.GetCollectionColumn(); if (null != collectionColumn) { if (collectionColumn.PropertyType.IsGenericType && collectionColumn.PropertyType.GetGenericTypeDefinition() == typeof (KeyValuePair<,>)) { return new[] {collectionColumn.ResolveChild("Key"), collectionColumn.ResolveChild("Value")}; } return collectionColumn.GetChildColumns(); } return columnDescriptor.GetChildColumns(); }
public ViewInfo(DataSchema dataSchema, Type rootType, ViewSpec viewSpec) : this(ColumnDescriptor.RootColumn(dataSchema, rootType, viewSpec.UiMode), viewSpec) { }
public virtual ColumnCaption GetColumnCaption(ColumnDescriptor columnDescriptor) { DisplayNameAttribute displayNameAttribute = columnDescriptor.GetAttributes().OfType<DisplayNameAttribute>().FirstOrDefault(); if (null != displayNameAttribute) { return ColumnCaption.UnlocalizableCaption(displayNameAttribute.DisplayName); } return new ColumnCaption(FormatChildDisplayName(columnDescriptor.Parent, GetBaseDisplayName(columnDescriptor))); }
public object GetOperandValue(ColumnDescriptor columnDescriptor) { return(GetOperandValue(columnDescriptor.DataSchema, columnDescriptor.PropertyType)); }
public Collection(ColumnDescriptor parent, ICollectionInfo collectionInfo) : base(parent, parent.PropertyPath.LookupAllItems()) { _collectionInfo = collectionInfo; }
public virtual bool IsObsolete(ColumnDescriptor columnDescriptor) { return columnDescriptor.GetAttributes().OfType<ObsoleteAttribute>().Any(); }
private string FormatChildDisplayName(ColumnDescriptor columnDescriptor, string childDisplayName) { if (null == columnDescriptor) { return childDisplayName; } var childDisplayNameAttribute = columnDescriptor.GetAttributes().OfType<ChildDisplayNameAttribute>().FirstOrDefault(); if (null != childDisplayNameAttribute) { childDisplayName = string.Format(childDisplayNameAttribute.InvariantFormat, childDisplayName); } return FormatChildDisplayName(columnDescriptor.Parent, childDisplayName); }
private string GetBaseDisplayName(ColumnDescriptor columnDescriptor) { var oneToManyColumn = columnDescriptor.GetOneToManyColumn(); if (oneToManyColumn != null) { var oneToManyAttribute = oneToManyColumn.GetAttributes().OfType<OneToManyAttribute>().FirstOrDefault(); if (oneToManyAttribute != null) { if ("Key" == columnDescriptor.Name && oneToManyAttribute.IndexDisplayName != null) // Not L10N { return oneToManyAttribute.IndexDisplayName; } if ("Value" == columnDescriptor.Name && oneToManyAttribute.ItemDisplayName != null) // Not L10N { return oneToManyAttribute.ItemDisplayName; } } } var invariantDisplayNameAttribute = columnDescriptor.GetAttributes().OfType<InvariantDisplayNameAttribute>().FirstOrDefault(); if (null != invariantDisplayNameAttribute) { return invariantDisplayNameAttribute.InvariantDisplayName; } if (columnDescriptor.Name == null) { if (columnDescriptor.Parent != null) { return GetBaseDisplayName(columnDescriptor.Parent); } if (columnDescriptor.PropertyType != null) { return columnDescriptor.PropertyType.Name; } } return columnDescriptor.Name; }
public static object ConvertValue(ColumnDescriptor columnDescriptor, object value) { return ConvertValue(columnDescriptor.DataSchema, columnDescriptor.PropertyType, value); }
public static object ConvertValue(ColumnDescriptor columnDescriptor, object value) { return(ConvertValue(columnDescriptor.DataSchema, columnDescriptor.PropertyType, value)); }
public bool IsValidFor(ColumnDescriptor columnDescriptor) { return IsValidFor(columnDescriptor.DataSchema, columnDescriptor.PropertyType); }
public Type GetOperandType(ColumnDescriptor columnDescriptor) { return(GetOperandType(columnDescriptor.DataSchema, columnDescriptor.PropertyType)); }
public Type GetOperandType(ColumnDescriptor columnDescriptor) { return GetOperandType(columnDescriptor.DataSchema, columnDescriptor.PropertyType); }
public ColumnDescriptor(ColumnDescriptor parent, String name) : this(parent, name, parent.DataSchema.GetPropertyDescriptor(parent.PropertyType, name)) { }
public Predicate<object> MakePredicate(ColumnDescriptor columnDescriptor, string operand) { return MakePredicate(columnDescriptor.DataSchema, columnDescriptor.PropertyType, operand); }
public ColumnDescriptor(ColumnDescriptor parent, CollectionInfo collectionInfo) : this(parent, null, null) { CollectionInfo = collectionInfo; PropertyType = collectionInfo.ElementType; }
public ColumnPropertyDescriptor(ColumnDescriptor columnDescriptor, RowKey rowKey) : this(columnDescriptor, RowKey.QualifyIdentifierPath(rowKey, columnDescriptor.IdPath)) { RowKey = rowKey; }
public object Aggregate(ColumnDescriptor columnDescriptor, KeyValuePair <RowKey, IEnumerable <RowItem> > items) { return(items.Key.FindValue(columnDescriptor.IdPath)); }
protected AbstractViewContext(ColumnDescriptor parentColumn) { ParentColumn = parentColumn; BuiltInViewSpecs = new ViewSpec[0]; }
public virtual bool IsAdvanced(ColumnDescriptor columnDescriptor) { if (IsObsolete(columnDescriptor)) { return true; } var advancedAttribute = columnDescriptor.GetAttributes().OfType<AdvancedAttribute>().FirstOrDefault(); if (advancedAttribute != null) { return advancedAttribute.Advanced; } var hideWhens = columnDescriptor.GetAttributes().OfType<HideWhenAttribute>().ToArray(); var advancedIfAncestor = new HashSet<Type>(hideWhens.SelectMany(attr => attr.AncestorsOfAnyOfTheseTypes).Where(type => null != type)); if (advancedIfAncestor.Count > 0) { for (ColumnDescriptor ancestor = columnDescriptor.Parent; ancestor != null; ancestor = ancestor.Parent) { if (advancedIfAncestor.Any(type => type.IsAssignableFrom(ancestor.PropertyType))) { return true; } } } ColumnDescriptor oneToManyColumn = columnDescriptor.GetOneToManyColumn(); if (oneToManyColumn != null) { var oneToManyAttribute = oneToManyColumn.GetAttributes().OfType<OneToManyAttribute>().FirstOrDefault(); if (oneToManyAttribute != null && oneToManyAttribute.ForeignKey == columnDescriptor.Name) { return true; } } return false; }
public virtual bool IsObsolete(ColumnDescriptor columnDescriptor) { return(columnDescriptor.GetAttributes().OfType <ObsoleteAttribute>().Any()); }
public static Type GetTypeToConvertOperandTo(ColumnDescriptor columnDescriptor) { return GetTypeToConvertOperandTo(columnDescriptor.DataSchema, columnDescriptor.PropertyType); }