private void LoadDatabases([NotNull] IEnumerable <DatabaseInfo> databases, [NotNull] GetChildrenDelegate callback) { Debug.ArgumentNotNull(databases, nameof(databases)); Debug.ArgumentNotNull(callback, nameof(callback)); var result = new List <BaseTreeViewItem>(); foreach (var databaseInfo in databases) { if (databaseInfo.DatabaseName.ToString() == @"filesystem") { continue; } var item = new DatabaseTreeViewItem(new DatabaseUri(Site, databaseInfo.DatabaseName)) { Text = databaseInfo.DatabaseName.ToString() }; item.MakeExpandable(); result.Add(item); } callback(result); }
public override bool GetChildren(GetChildrenDelegate callback, bool async) { Assert.ArgumentNotNull(callback, nameof(callback)); if (!async) { var databases = Site.DataService.GetDatabases(); LoadDatabases(databases, callback); return(true); } var thread = new DataServiceThread(delegate { var databases = Site.DataService.GetDatabases().ToList(); Dispatcher.Invoke(new Action(() => LoadDatabases(databases, callback))); }); var result = thread.Start(Site); if (!result) { IsExpanded = false; MakeExpandable(); UpdateStatus(); } return(result); }
public StringResourcesObject(Type ObjectType, GetStringsDelegate GetStrings, SetStringsDelegate SetStrings, GetChildrenDelegate GetChildren) { this.ObjectType = ObjectType; this.GetStrings = GetStrings; this.SetStrings = SetStrings; this.GetChildren = GetChildren; }
public DynamicTreeUiItem(Object valueMember, String displayMember, GetChildrenDelegate childrenGetter, CreateChildDelegate childrenCreator, Boolean cacheChildren, TreeUiItem parent = null) : base(valueMember, displayMember, parent) { this.childrenGetter = childrenGetter; this.childrenCreator = childrenCreator; this.cacheChildren = cacheChildren; }
private static void CollectNodes <T>(T node, GetChildrenDelegate <T> getChildren, ICollection <T> nodes, Stack <T> ancestors, IDictionary <T, T[]> ancestorsByNode, bool includeRoot, bool leafsOnly) { var children = getChildren(node); if (includeRoot) { if (leafsOnly && !children.Any()) { nodes.Add(node); } if (!leafsOnly) { nodes.Add(node); } ancestorsByNode.Add(node, ancestors.ToArray()); ancestors.Push(node); } foreach (var child in children) { CollectNodes(child, getChildren, nodes, ancestors, ancestorsByNode, true, leafsOnly); } if (ancestors.Any()) { ancestors.Pop(); } }
public override bool GetChildren(GetChildrenDelegate callback, bool async) { Assert.ArgumentNotNull(callback, nameof(callback)); bool[] busy = { true }; GetItemsCompleted <ItemHeader> completed = delegate(IEnumerable <ItemHeader> children) { if (!busy[0]) { return; } Dispatcher.Invoke(new Action(() => GetChildren(children.ToList(), callback))); busy[0] = false; }; Site.DataService.GetChildrenAsync(ItemUri, completed); if (!async) { if (AppHost.DoEvents(ref busy[0])) { return(false); } } return(true); }
private void GetChildren([NotNull] IEnumerable <ItemHeader> children, [NotNull] GetChildrenDelegate callback) { Diagnostics.Debug.ArgumentNotNull(children, nameof(children)); Diagnostics.Debug.ArgumentNotNull(callback, nameof(callback)); var result = new List <BaseTreeViewItem>(); var count = children.Count(); if (count > 100) { count = LoadManyItemsDialog.Execute(count); if (count < 0) { callback(result); return; } } for (var n = 0; n < count; n++) { var child = children.ElementAt(n); var item = GetChildTreeViewItem(child); if (child.HasChildren) { item.Add(DummyTreeViewItem.Instance); } result.Add(item); } callback(result); }
public static IEnumerable <FilterableTreeViewItem> TreeViewFolderChildren(this IADOTabularObjectReference objRef, ADOTabularTable table, IGlobalOptions options, IEventAggregator eventAggregator, IMetadataPane metadataPane) { var lst = new List <FilterableTreeViewItem>(); var folder = objRef as IADOTabularFolderReference; if (folder != null) { foreach (var folderItem in folder.FolderItems) { GetChildrenDelegate getChildren = null; if (folderItem is IADOTabularFolderReference) { getChildren = ((IADOTabularObjectReference)folderItem).TreeViewFolderChildren; } lst.Add(new TreeViewColumn(folderItem, getChildren, table, options, eventAggregator, metadataPane)); } } else { var col = table.Columns.GetByPropertyRef(objRef.InternalReference); lst.Add(new TreeViewColumn(col, null, options, eventAggregator, metadataPane)); } return(lst); }
private void GetFiles([NotNull] IEnumerable <ItemHeader> files, [NotNull] GetChildrenDelegate callback) { Debug.ArgumentNotNull(files, nameof(files)); Debug.ArgumentNotNull(callback, nameof(callback)); var result = new List <BaseTreeViewItem>(); foreach (var child in files) { var fileUri = new FileUri(Site, child.Path, child.HasChildren); var fileName = ((IItemData)child).GetData("ServerFileName") ?? string.Empty; var item = new FileTreeViewItem(fileUri) { Text = child.Name, Updated = child.Updated, ServerFileName = fileName }; if (child.HasChildren) { item.Icon = new Icon("Resources/16x16/folder.png"); item.Add(DummyTreeViewItem.Instance); } result.Add(item); } callback(result); }
public StringResourcesObject(Type ObjectType, GetStringsDelegate GetStrings, SetStringsDelegate SetStrings, GetChildrenDelegate GetChildren) { this.ObjectType = ObjectType; this.GetStrings = GetStrings; this.SetStrings = SetStrings; this.GetChildren = GetChildren; }
public override bool GetChildren(GetChildrenDelegate callback, bool async) { Assert.ArgumentNotNull(callback, nameof(callback)); callback(Enumerable.Empty <BaseTreeViewItem>()); return(true); }
public override bool GetChildren(GetChildrenDelegate callback, bool async) { Assert.ArgumentNotNull(callback, nameof(callback)); var result = new List <BaseSiteTreeViewItem>(); var children = Site.DataService.GetRootItems(DatabaseUri).ToList(); if (!children.Any()) { return(false); } foreach (var child in children) { var item = new ItemTreeViewItem(child); if (child.HasChildren) { item.MakeExpandable(); } result.Add(item); } callback(result); return(true); }
public static IEnumerable <T> GetNodes <T>(T rootNode, GetChildrenDelegate <T> getChildren, Action <T, T[]> collectedNodeAction, bool includeRoot, bool leafsOnly) { if (rootNode == null) { throw new ArgumentNullException("rootNode"); } if (getChildren == null) { throw new ArgumentNullException("getChildren"); } var nodes = new List <T>(); var ancestorsByNode = new Dictionary <T, T[]>(); CollectNodes(rootNode, getChildren, nodes, new Stack <T>(), ancestorsByNode, includeRoot, leafsOnly); foreach (var pair in ancestorsByNode) { var node = pair.Key; var ancestors = pair.Value; if (collectedNodeAction != null) { collectedNodeAction(node, ancestors); } } return(nodes); }
public TreeViewFunction(ADOTabularFunction function, GetChildrenDelegate getChildren, IGlobalOptions options, IEventAggregator eventAggregator, IMetadataPane metadataPane) : base(function, getChildren, options, eventAggregator, metadataPane) { _eventAggregator = eventAggregator; Function = function; Options = options; Description = function.Description; MetadataImage = function.MetadataImage; }
public FilterableTreeViewItem(ADOTabularTable table, GetChildrenDelegate getChildren, IGlobalOptions options, IEventAggregator eventAggregator, IMetadataPane metadataPane) { _eventAggregator = eventAggregator; _options = options; _tabularObject = table; _getChildren = getChildren; MetadataPane = metadataPane; }
public override bool GetChildren(GetChildrenDelegate callback, bool async) { Assert.ArgumentNotNull(callback, nameof(callback)); callback(recentItems); return(true); }
public override bool GetChildren(GetChildrenDelegate callback, bool async) { Assert.ArgumentNotNull(callback, nameof(callback)); var result = Element.Elements().Select(element => new TemplateHierarchyTreeViewItem(element, DatabaseUri)).ToList(); callback(result); return(true); }
public TreeViewColumn(ADOTabularColumn column, GetChildrenDelegate getChildren) : base(getChildren) { _column = column; Description = column.Description; DataTypeName = column.DataTypeName; MetadataImage = column.MetadataImage; FormatString = column.FormatString; MinValue = column.MinValue; MaxValue = column.MaxValue; DistinctValues = column.DistinctValueCount; }
/// <summary> /// Init iterative depth-first search. /// </summary> /// <param name="context">Custom data to be passed to delegates.</param> /// <param name="getChildren">Delegate to obtain children for current branch.</param> /// <param name="maxDepth">Depth limit (negative is treated as no limit).</param> public void Init(object context, GetChildrenDelegate <T> getChildren, int maxDepth = -1) { if (getChildren == null) { throw new ArgumentNullException("getChildren"); } this.context = context; this.getChildren = getChildren; this.maxDepth = maxDepth; branch = new List <T>(); }
public static IEnumerable <FilterableTreeViewItem> TreeViewFolderChildren(this IADOTabularObjectReference objRef, IADOTabularObject table, IGlobalOptions options, IEventAggregator eventAggregator, IMetadataPane metadataPane) { var lst = new List <FilterableTreeViewItem>(); var folder = objRef as IADOTabularFolderReference; if (folder != null) { foreach (var folderItem in folder.FolderItems) { GetChildrenDelegate getChildren = null; if (folderItem is IADOTabularFolderReference fi) { // if the current item is a sub-folder look for it's children getChildren = fi.TreeViewFolderChildren; } else { var col = (table as ADOTabularTable).Columns.GetByPropertyRef(folderItem.InternalReference); switch (col) { // if this item is a KPI get it's child components case ADOTabularKpi k: getChildren = k.TreeViewColumnChildren; break; // if this item is a hierarchy get it's child levels case ADOTabularHierarchy h: getChildren = h.TreeViewColumnChildren; break; default: getChildren = null; break; } ; } lst.Add(new TreeViewColumn(folderItem, getChildren, (table as ADOTabularTable), options, eventAggregator, metadataPane)); } } else { var col = (table as ADOTabularTable).Columns.GetByPropertyRef(objRef.InternalReference); lst.Add(new TreeViewColumn(col, null, options, eventAggregator, metadataPane)); } return(lst); }
public override bool GetChildren(GetChildrenDelegate callback, bool async) { Assert.ArgumentNotNull(callback, nameof(callback)); if (!async) { return(false); } var path = FileUri.ToServerPath(); Site.DataService.GetFiles(new DatabaseUri(Site, DatabaseName.Empty), path, items => GetFiles(items, callback)); return(true); }
public TreeViewColumn(ADOTabularColumn column, GetChildrenDelegate getChildren, IGlobalOptions options, IEventAggregator eventAggregator) : base(getChildren, options, eventAggregator) { _eventAggregator = eventAggregator; _sampleData = new List <string>(); Column = column; _column = column; Options = options; Description = column.Description; DataTypeName = column.DataTypeName; MetadataImage = column.MetadataImage; FormatString = column.FormatString; MinValue = column.MinValue; MaxValue = column.MaxValue; DistinctValues = column.DistinctValues; }
public override bool GetChildren(GetChildrenDelegate callback, bool async) { Assert.ArgumentNotNull(callback, nameof(callback)); var result = new List <BaseTreeViewItem>(); foreach (var item in Library.Items) { var libraryItemTreeViewItem = new LibraryItemTreeViewItem(item); result.Add(libraryItemTreeViewItem); } callback(result); return(true); }
public override bool GetChildren(GetChildrenDelegate callback, bool async) { Assert.ArgumentNotNull(callback, nameof(callback)); var busy = true; GetItemsCompleted <ItemHeader> c = delegate(IEnumerable <ItemHeader> items) { var result = new List <TemplatedTreeViewItem>(); var count = items.Count(); if (count > 100) { count = LoadManyItemsDialog.Execute(count); if (count < 0) { callback(result); return; } } for (var n = 0; n < count; n++) { var item = items.ElementAt(n); var i = GetTreeViewItem(item.ItemUri, item.Name, item.Icon, item.TemplateId, item.TemplateName); result.Add(i); } callback(result); busy = false; }; DatabaseUri.Site.DataService.SelectItems(GetQueryText(), DatabaseUri, c); if (!async) { while (busy) { AppHost.DoEvents(); } } return(true); }
public TreeViewColumn(IADOTabularObjectReference reference, GetChildrenDelegate getChildren, ADOTabularTable table, IGlobalOptions options, IEventAggregator eventAggregator, IMetadataPane metadataPane) : base(table, getChildren, options, eventAggregator, metadataPane) { Options = options; IADOTabularFolderReference folder = reference as IADOTabularFolderReference; if (folder == null) { Column = table.Columns.GetByPropertyRef(reference.InternalReference); MetadataImage = Column.GetMetadataImage(); } else { _caption = reference.Name; MetadataImage = MetadataImages.Folder; } }
public override bool GetChildren(GetChildrenDelegate callback, bool async) { Assert.ArgumentNotNull(callback, nameof(callback)); var result = new List <BaseTreeViewItem>(); var libraries = LibraryManager.Libraries; foreach (var library in libraries) { var libraryTreeViewItem = new LibraryTreeViewItem(library); libraryTreeViewItem.MakeExpandable(); result.Add(libraryTreeViewItem); } callback(result); return(true); }
public override bool GetChildren([NotNull] GetChildrenDelegate callback, bool async) { Assert.ArgumentNotNull(callback, nameof(callback)); var result = new List <BaseTreeViewItem>(); var savedSearches = SearchManager.SavedSearches; foreach (var savedSearch in savedSearches) { var item = new SearchTreeViewItem(); item.Initialize(savedSearch); result.Add(item); } callback(result); return(true); }
protected virtual void Expand(bool async) { var itemTreeView = GetItemTreeView(); var filterText = itemTreeView == null ? string.Empty : itemTreeView.FilterText; IsLoading = true; GetChildrenDelegate completed = delegate(IEnumerable <BaseTreeViewItem> childItems) { var items = new List <BaseTreeViewItem>(childItems.Where(i => i != null)); if (itemTreeView != null) { if (itemTreeView.SupportsVirtualItems) { GetVirtualChildren(items); } itemTreeView.InternalFilterChildren(this, items); } RemoveDummy(); foreach (var item in items) { item.Visibility = item.Text.IsFilterMatch(filterText) ? Visibility.Visible : Visibility.Collapsed; Items.Add(item); } IsLoading = false; UpdateGutter(items); }; if (!GetChildren(completed, async)) { IsLoading = false; } }
public override bool GetChildren(GetChildrenDelegate callback, bool async) { Assert.ArgumentNotNull(callback, nameof(callback)); var result = new List <BaseTreeViewItem>(); var favorites = FavoriteManager.GetFavorites(); foreach (var favorite in favorites) { var favoriteTreeViewItem = new FavoriteTreeViewItem { Text = favorite.Name }; favoriteTreeViewItem.Initialize(favorite); result.Add(favoriteTreeViewItem); } callback(result); return(true); }
public TreeViewTable(ADOTabularTable table, GetChildrenDelegate getChildren) : base(getChildren) { _table = table; }
public FilterableTreeViewItem(GetChildrenDelegate getChildren) { _getChildren = getChildren; }
public abstract bool GetChildren([NotNull] GetChildrenDelegate callback, bool async);
public FilterableTreeViewItem(GetChildrenDelegate getChildren, IGlobalOptions options, IEventAggregator eventAggregator) { _eventAggregator = eventAggregator; _options = options; _getChildren = getChildren; }
public TreeViewTable(ADOTabularTable table, GetChildrenDelegate getChildren, IGlobalOptions options, IEventAggregator eventAggregator) : base(getChildren, options, eventAggregator) { _table = table; }
public TreeViewColumn(ADOTabularColumn column, GetChildrenDelegate getChildren) : base(getChildren) { _column = column; Description = column.Description; DataTypeName = column.DataTypeName; MetadataImage = column.MetadataImage; }