Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
490 changes: 490 additions & 0 deletions InteractiveAutomationToolkit/Components/Generics/GenericTreeView.cs

Large diffs are not rendered by default.

120 changes: 120 additions & 0 deletions InteractiveAutomationToolkit/Components/Interfaces/ITreeView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
namespace Skyline.DataMiner.Utils.InteractiveAutomationScript
{
using System.Collections.Generic;

using Skyline.DataMiner.Net.AutomationUI.Objects;

/// <summary>
/// Defines a tree view widget with basic operations.
/// </summary>
public interface ITreeView : ITreeViewBase
{
/// <summary>
/// Gets or sets the top-level items in the tree view.
/// The TreeViewItem.ChildItems property can be used to navigate further down the tree.
/// </summary>
IEnumerable<TreeViewItem> Items { get; set; }

/// <summary>
/// Gets all items in the tree view that are selected.
/// </summary>
IEnumerable<TreeViewItem> CheckedItems { get; }

/// <summary>
/// Gets all leaves (= items without children) in the tree view that are selected.
/// </summary>
IEnumerable<TreeViewItem> CheckedLeaves { get; }

/// <summary>
/// Gets all nodes (= items with children) in the tree view that are selected.
/// </summary>
IEnumerable<TreeViewItem> CheckedNodes { get; }

/// <summary>
/// Iterates over all items in the tree and returns them in a flat collection.
/// </summary>
/// <returns>A flat collection containing all items in the tree view.</returns>
IEnumerable<TreeViewItem> GetAllItems();

/// <summary>
/// Returns all items in the tree view that are located at the provided depth.
/// Whenever the requested depth is greater than the longest branch in the tree, an empty collection will be returned.
/// </summary>
/// <param name="depth">Depth of the requested items.</param>
/// <returns>All items in the tree view that are located at the provided depth.</returns>
IEnumerable<TreeViewItem> GetItems(int depth);

/// <summary>
/// Can be used to retrieve an item from the tree view based on its key value.
/// </summary>
/// <param name="key">Key used to search for the item.</param>
/// <param name="item">Item in the tree that matches the provided key.</param>
/// <returns>True if the item was found, otherwise false.</returns>
bool TryFindTreeViewItem(string key, out TreeViewItem item);
}

/// <summary>
/// Defines a generic tree view widget with support for typed treeview items.
/// </summary>
/// <typeparam name="T">The type of the value associated with each treeview item.</typeparam>
public interface ITreeView<T> : ITreeViewBase
{
/// <summary>
/// Gets or sets the top-level items in the tree view.
/// The TreeViewItem.ChildItems property can be used to navigate further down the tree.
/// </summary>
IEnumerable<TreeViewItem<T>> Items { get; set; }

/// <summary>
/// Gets all items in the tree view that are selected.
/// </summary>
IEnumerable<TreeViewItem<T>> CheckedItems { get; }

/// <summary>
/// Gets all leaves (= items without children) in the tree view that are selected.
/// </summary>
IEnumerable<TreeViewItem<T>> CheckedLeaves { get; }

/// <summary>
/// Gets all nodes (= items with children) in the tree view that are selected.
/// </summary>
IEnumerable<TreeViewItem<T>> CheckedNodes { get; }

/// <summary>
/// Gets the values of all items in the tree view that are selected.
/// </summary>
IEnumerable<T> CheckedValues { get; }

/// <summary>
/// Gets the values of all leaves in the tree view that are selected.
/// </summary>
IEnumerable<T> CheckedLeafValues { get; }

/// <summary>
/// Gets the values of all nodes in the tree view that are selected.
/// </summary>
IEnumerable<T> CheckedNodeValues { get; }

/// <summary>
/// Iterates over all items in the tree and returns them in a flat collection.
/// </summary>
/// <returns>A flat collection containing all items in the tree view.</returns>
IEnumerable<TreeViewItem<T>> GetAllItems();

/// <summary>
/// Returns all items in the tree view that are located at the provided depth.
/// Whenever the requested depth is greater than the longest branch in the tree, an empty collection will be returned.
/// </summary>
/// <param name="depth">Depth of the requested items.</param>
/// <returns>All items in the tree view that are located at the provided depth.</returns>
IEnumerable<TreeViewItem<T>> GetItems(int depth);

/// <summary>
/// Can be used to retrieve an item from the tree view based on its key value.
/// </summary>
/// <param name="key">Key used to search for the item.</param>
/// <param name="item">Item in the tree that matches the provided key.</param>
/// <returns>True if the item was found, otherwise false.</returns>
bool TryFindTreeViewItem(string key, out TreeViewItem<T> item);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace Skyline.DataMiner.Utils.InteractiveAutomationScript
{
/// <summary>
/// Defines the base functionality for a treeview widget.
/// </summary>
public interface ITreeViewBase : IIsReadonlyWidget
{
/// <summary>
/// Gets or sets the tooltip text associated with the treeview.
/// </summary>
string Tooltip { get; set; }

/// <summary>
/// Sets the IsCollapsed state for all items in the tree view to false, causing the entire tree view to be expanded.
/// </summary>
void Expand();

/// <summary>
/// Sets the IsCollapsed state for all items in the tree view to true, causing the entire tree view to be collapsed.
/// </summary>
void Collapse();

/// <summary>
/// This method is used to update the cached TreeViewItems and lookup table.
/// This is done after loading the results from the UI Block, after handling the Events or when setting the Items.
/// This method should only be called from outside the TreeView if you are checking or collapsing items from outside of the TreeView and need to access the CheckedItems or CollapsedItems.
/// </summary>
void UpdateItemCache();
}
}
Loading
Loading