From 8e5896f118592867ac581950c52f6a00e2bb904b Mon Sep 17 00:00:00 2001 From: Kathy Date: Thu, 7 Oct 2010 12:36:42 +0000 Subject: [PATCH] --- .../VEObjects/VETreeNode.cs | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/VEObjects/VETreeNode.cs b/PROMS/VEPROMS.CSLA.Library/VEObjects/VETreeNode.cs index 58a2b1fa..d5a54b3b 100644 --- a/PROMS/VEPROMS.CSLA.Library/VEObjects/VETreeNode.cs +++ b/PROMS/VEPROMS.CSLA.Library/VEObjects/VETreeNode.cs @@ -113,7 +113,7 @@ namespace VEPROMS.CSLA.Library } public void ResetNode(string dummy) { - if (_VEObject!=null && _VEObject.HasChildren && _ChildrenLoaded == false) + if (_VEObject!=null && _VEObject.HasChildren && _ChildrenLoaded == false && CheckForParts()) { _ChildrenLoaded = false;// Reset the children loaded flag this.Nodes.Add(dummy);// Add a Dummy Node so that the item will appear to be expanable. @@ -130,6 +130,18 @@ namespace VEPROMS.CSLA.Library SetProperty("SelectedImageIndex"); // ToDo: Need to reset object as well } + + private bool CheckForParts() + { + if (_allParts) return true; + // only has 'children' if parts are steps or sections + if (_VEObject.GetType() == typeof(StepInfo) || _VEObject.GetType() == typeof(SectionInfo) || _VEObject.GetType() == typeof(ItemInfo)) + { + IList ol = ((ItemInfo)_VEObject).GetChildren(_allParts); + if (ol == null || ol.Count == 0) return false; + } + return true; + } public void RefreshNode() { ResetNode("Dummy RefreshNode");// Drop Children @@ -173,8 +185,10 @@ namespace VEPROMS.CSLA.Library { LoadChildren(true); } + private bool _allParts = true; public virtual void LoadChildren(bool allParts) { + _allParts = allParts; if (!_ChildrenLoaded) { this.Nodes.Clear(); @@ -184,6 +198,7 @@ namespace VEPROMS.CSLA.Library OnLoadingChildrenSQL(this, new VETreeNodeEventArgs()); IList ol; ItemInfo item = _VEObject as ItemInfo; + if (item != null) item.RefreshItemParts(); if (_VEObject.GetType() == typeof(StepInfo) || _VEObject.GetType() == typeof(SectionInfo) || _VEObject.GetType() == typeof(ItemInfo)) ol = ((ItemInfo)_VEObject).GetChildren(allParts); else @@ -214,7 +229,7 @@ namespace VEPROMS.CSLA.Library //tNext("Cycle"); try { - VETreeNode tmp = new VETreeNode(o); + VETreeNode tmp = new VETreeNode(o,_allParts); if (o.HasChildren) { if (o is PartInfo) @@ -316,6 +331,23 @@ namespace VEPROMS.CSLA.Library #region Factory Methods // Constructors public VETreeNode() : base("NoText") { ; } + public VETreeNode(IVEDrillDownReadOnly o, bool allParts) + : base(o.ToString()) + { + _allParts = allParts; + _VEObject = o;// Save the BusinessObject + ResetNode("Dummy VETreeNode(IVEDrillDownReadOnly o)"); + ItemInfo myItemInfo = o as ItemInfo; + if (myItemInfo != null) + { + myItemInfo.Deleted += new ItemInfoEvent(myItemInfo_Deleted); + myItemInfo.ChildrenDeleted += new ItemInfoEvent(myItemInfo_ChildrenDeleted); + myItemInfo.MyContent.Changed += new ContentInfoEvent(MyContent_Changed); + myItemInfo.NewSiblingAfter += new ItemInfoInsertEvent(myItemInfo_NewSiblingAfter); + myItemInfo.NewSiblingBefore += new ItemInfoInsertEvent(myItemInfo_NewSiblingBefore); + myItemInfo.NewChild += new ItemInfoInsertEvent(myItemInfo_NewChild); + } + } public VETreeNode(IVEDrillDownReadOnly o) : base(o.ToString()) {