From e20796dfbfc7654437474d61e9b1be72625db2ba Mon Sep 17 00:00:00 2001 From: Rich Date: Mon, 15 Nov 2010 17:01:36 +0000 Subject: [PATCH] Fixed NextItems logic Replaced duplicate logic in GetChildren with MyItems Fixed logic to check for Sections = null --- PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs | 2 +- PROMS/VEPROMS.CSLA.Library/Extension/PartExt.cs | 3 ++- PROMS/VEPROMS.CSLA.Library/Extension/TransitionExt.cs | 2 ++ PROMS/Volian.Controls.Library/DisplayTags.cs | 2 +- PROMS/Volian.Controls.Library/DisplayTransition.cs | 6 +++--- PROMS/Volian.Controls.Library/StepPanel.cs | 6 +++--- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs index f0549359..de17af90 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs @@ -725,7 +725,7 @@ namespace VEPROMS.CSLA.Library { get { - if (NextItemCount > 0 && NextItems.Count > 0) + if (NextItemCount > 0 && NextItems != null && NextItems.Count > 0) return NextItems[0]; return null; } diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/PartExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/PartExt.cs index ca6c8805..ede4b79e 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/PartExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/PartExt.cs @@ -111,7 +111,8 @@ namespace VEPROMS.CSLA.Library { get { return (_MyItems != null ? _MyItems : _MyItems = ItemInfoList.GetList(_ItemID, _FromType)); } } public System.Collections.IList GetChildren() { - return (_MyItems != null ? _MyItems : _MyItems = ItemInfoList.GetList(_ItemID, _FromType)); + //return (_MyItems != null ? _MyItems : _MyItems = ItemInfoList.GetList(_ItemID, _FromType)); + return MyItems; } //public bool ChildrenAreLoaded //{ diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/TransitionExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/TransitionExt.cs index d4dc5bab..04b57a05 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/TransitionExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/TransitionExt.cs @@ -630,6 +630,8 @@ namespace VEPROMS.CSLA.Library int cntsect = 0; ItemInfo sect = TranGetSectionItem(tb._ToItem); + if (tb._ToItem.MyProcedure.Sections == null) + tb._ToItem.MyProcedure.MyContent.RefreshContentParts(); foreach (ItemInfo ii in tb._ToItem.MyProcedure.Sections) if (ii.IsStepSection) cntsect++; // If Procedure going to has only 1 step section, do not add it. if (cntsect == 1) return false; // tb.TextAdded; diff --git a/PROMS/Volian.Controls.Library/DisplayTags.cs b/PROMS/Volian.Controls.Library/DisplayTags.cs index 61d90f77..e03b4ff1 100644 --- a/PROMS/Volian.Controls.Library/DisplayTags.cs +++ b/PROMS/Volian.Controls.Library/DisplayTags.cs @@ -266,7 +266,7 @@ namespace Volian.Controls.Library Content cnt = Content.Get(startitm.MyContent.ContentID); cnt.Type = 20000 + fmtdata.StepDataList[_MyStepTypeInd[listBoxStepTypes.SelectedIndex]].Index; cnt.Save(); - startitm = (startitm.NextItemCount > 0 ? startitm.NextItems[0] : null); + startitm = (startitm.NextItem != null && startitm.NextItems.Count > 0 ? startitm.NextItems[0] : null); } msgBox = string.Format("All Step Types at this level were changed to {0}", listBoxStepTypes.Items[listBoxStepTypes.SelectedIndex]); } diff --git a/PROMS/Volian.Controls.Library/DisplayTransition.cs b/PROMS/Volian.Controls.Library/DisplayTransition.cs index 3fc76114..ee538ddf 100644 --- a/PROMS/Volian.Controls.Library/DisplayTransition.cs +++ b/PROMS/Volian.Controls.Library/DisplayTransition.cs @@ -428,7 +428,7 @@ namespace Volian.Controls.Library tvTran.SelectedNode = tvTran.Nodes[active]; setsel = true; } - startitm = (startitm.NextItemCount > 0 ? startitm.NextItems[0] : null); + startitm = (startitm.NextItem != null && startitm.NextItems.Count > 0 ? startitm.NextItems[0] : null); } if (!setsel) tvTran.SelectedNode = tvTran.Nodes[0]; tvTran.BeforeExpand += new TreeViewCancelEventHandler(tvTran_BeforeExpand); @@ -457,7 +457,7 @@ namespace Volian.Controls.Library int active = cbTranSects.Items.Add(secitm); if (secitm.ItemID == secstart) cbTranSects.SelectedIndex = active; } - secitm = (secitm.NextItemCount > 0 ? secitm.NextItems[0] : null); + secitm = (secitm.NextItem != null && secitm.NextItems.Count > 0 ? secitm.NextItems[0] : null); } } @@ -471,7 +471,7 @@ namespace Volian.Controls.Library int active = cbTranProcs.Items.Add(prcitm); if (_CurrentProcedure.ContentID == prcitm.MyContent.ContentID) _CurrentProcIndex = active; if (prcitm.MyContent.ContentID == selitm.MyContent.ContentID) cbTranProcs.SelectedIndex = active; - prcitm = (prcitm.NextItemCount > 0 ? prcitm.NextItems[0] : null); + prcitm = (prcitm.NextItem != null && prcitm.NextItems.Count > 0 ? prcitm.NextItems[0] : null); } } private void SetControlsEnabling() diff --git a/PROMS/Volian.Controls.Library/StepPanel.cs b/PROMS/Volian.Controls.Library/StepPanel.cs index 1a8e375c..27f1186d 100644 --- a/PROMS/Volian.Controls.Library/StepPanel.cs +++ b/PROMS/Volian.Controls.Library/StepPanel.cs @@ -778,7 +778,7 @@ namespace Volian.Controls.Library { if (lookAtSub && ii.Sections != null) return TopPart(ii.Sections[0]); if (lookAtSub && ii.Steps != null) return TopPart(ii.Steps[0]); - if (ii.IsSection && ii.NextItems != null) return TopPart(ii.NextItems[0]); + if (ii.IsSection && ii.NextItems != null && ii.NextItems.Count > 0) return TopPart(ii.NextItems[0]); } else { @@ -793,7 +793,7 @@ namespace Volian.Controls.Library if (lookAtRNO && ii.RNOs != null && ii.RNOLevel >= ii.ColumnMode) return TopPart(ii.RNOs[0]); // Nextsibling - go to top part of sibling // TODO: RHM - NextItems was not null when it should have been after delete of a note below a caution - if (ii.NextItems != null && ii.NextItemCount > 0) return TopPart(ii.NextItems[0]); + if (ii.NextItems != null && ii.NextItems.Count > 0) return TopPart(ii.NextItems[0]); // If on caution, if parent has note - go to note if (ii.IsCautionPart && ii.MyParent.Notes != null) return ii.MyParent.Notes[0]; // If on caution, if parent !has note or if on note go to parent @@ -822,7 +822,7 @@ namespace Volian.Controls.Library ii = ii.LastSibling; break; case Keys.PageDown: - ii = ii.NextItems == null ? null : ii.NextItems[0]; + ii = ii.NextItems != null && ii.NextItems.Count > 0 ? ii.NextItems[0] : null; break; case Keys.PageUp: ii = ii.MyPrevious;