private static bool ContextItemAreDecisions() { IEnumerable <IEAElement> selectedTopicsAndDecisions = (from IEAElement element in EAMain.Repository.GetSelectedItems() where (EAMain.IsDecision(element) || EAMain.IsTopic(element)) && !EAMain.IsHistoryDecision(element) select element); return(selectedTopicsAndDecisions.Any()); }
/// <summary> /// Adds an element and its children to the node /// </summary> /// <param name="node">Node to be added to</param> /// <param name="element"></param> /// <returns>A node with element information and its children</returns> private TreeNode AddElementToNode(TreeNode node, IEAElement element) { node.ImageKey = element.GUID; node.Text = element.Name; foreach (IEAElement el in element.GetElements()) { if (el.Name.Equals("") || EAMain.IsHistoryDecision(el)) { continue; } if (_decision && (!EAMain.IsDecision(el) && !EAMain.IsTopic(el))) { continue; } node.Nodes.Add((AddElementToNode(new TreeNode(), el))); } return(node); }
/// <summary> /// Adds a package and its children to the node /// </summary> /// <param name="node">Node to be added to</param> /// <param name="package">Package to be added</param> /// <returns>A node with the package information and its children</returns> private TreeNode AddPackageNode(TreeNode node, IEAPackage package) { node.ImageKey = package.GUID; node.Text = package.Name; foreach (IEAPackage subPackage in package.Packages) { //Skip history package and packages without elements if (subPackage.Stereotype.Equals(EAConstants.ChronologicalStereoType) || !subPackage.GetAllElementsOfSubTree().Any()) { continue; } TreeNode subPackageNode = AddPackageNode(new TreeNode(), subPackage); if (null != subPackageNode) { node.Nodes.Add(subPackageNode); } } int count = 0; foreach (IEAElement element in package.Elements) { if (element.Name.Equals("") || EAMain.IsHistoryDecision(element)) { continue; } if (_decision && (!EAMain.IsDecision(element) && !EAMain.IsTopic(element))) { continue; } node.Nodes.Add(AddElementToNode(new TreeNode(), element)); ++count; } if (node.GetNodeCount(true) == 0) { return(null); } return(node); }
private TreeNode CreateTreeNode(IEAPackage package) { TreeNode packageNode = null; IEnumerable <TreeNode> decisions = package.Elements.Where(e => EAMain.IsDecision(e) && !EAMain.IsHistoryDecision(e)) .Select(e => new TreeNode(Name = e.Name) { ImageKey = e.GUID }); IEnumerable <TreeNode> subpackages = package.Packages.Select(CreateTreeNode).Where(node => node != null); IOrderedEnumerable <TreeNode> subtree = decisions.Union(subpackages).OrderBy(node => node.Name); if (subtree.Any()) { packageNode = new TreeNode(package.Name, subtree.ToArray()) { ImageKey = package.GUID }; } return(packageNode); }
public IEnumerable <IEAElement> GetAllDecisions() { return(GetAllElementsOfSubTree().Where(e => EAMain.IsDecision(e) && !EAMain.IsHistoryDecision(e))); }