C2017-002 Allow inheritance of step data elements
This commit is contained in:
parent
9a699e7e40
commit
4c4396e8c8
@ -1882,11 +1882,26 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((int)MyContent.Type < 20000) return null;
|
||||
int typ = (int)MyContent.Type - 20000;
|
||||
foreach (StepData sd in ActiveFormat.PlantFormat.FormatData.StepDataList)
|
||||
{
|
||||
if (sd.Index == typ) return sd;
|
||||
}
|
||||
// Handle inheritance (step data may not be in current format, may inherit from parents:
|
||||
IFormatOrFormatInfo parentFormat = ActiveFormat.PlantFormat.FormatData.MyParentFormat;
|
||||
while (parentFormat != null)
|
||||
{
|
||||
vlnIndexedFormatList<StepData> InheritedList = parentFormat.PlantFormat.FormatData.StepDataList;
|
||||
if (InheritedList != null)
|
||||
{
|
||||
foreach (StepData sdi in InheritedList)
|
||||
{
|
||||
if (sdi.Index == typ) return sdi;
|
||||
}
|
||||
}
|
||||
parentFormat = parentFormat.PlantFormat.FormatData.MyParentFormat;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -434,8 +434,38 @@ namespace VEPROMS.CSLA.Library
|
||||
List<StepDataRetval> sds = new List<StepDataRetval>();
|
||||
foreach (StepData sd in StepDataList)
|
||||
{
|
||||
if (!sd.Inactive && sd.StepEditData.Searchable && sd.StepEditData.TypeMenu.InMenu)
|
||||
sds.Add(new StepDataRetval(sd.StepEditData.TypeMenu.MenuItem, Convert.ToInt32(sd.Index)));
|
||||
if (!sd.Inactive && sd.StepEditData.Searchable && sd.StepEditData.TypeMenu.InMenu)
|
||||
sds.Add(new StepDataRetval(sd.StepEditData.TypeMenu.MenuItem, Convert.ToInt32(sd.Index)));
|
||||
}
|
||||
// now add any from the inherited list (but only if type is not in the list)
|
||||
IFormatOrFormatInfo parentFormat = MyParentFormat;
|
||||
while (parentFormat != null)
|
||||
{
|
||||
vlnIndexedFormatList<StepData> InheritedList = parentFormat.PlantFormat.FormatData.StepDataList;
|
||||
foreach (StepData sd1 in InheritedList)
|
||||
{
|
||||
if (!sd1.Inactive && sd1.StepEditData.Searchable && sd1.StepEditData.TypeMenu.InMenu)
|
||||
{
|
||||
// if not in the sds list, add it:
|
||||
// note that the list of StepDataRetval (sds) 'Contains' method did not find an existing StepData item - that is why the code loops
|
||||
// through list rather than using 'Contains':
|
||||
bool found = false;
|
||||
foreach (StepDataRetval lrtvl in sds)
|
||||
{
|
||||
if (lrtvl.Index == sd1.Index)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
StepDataRetval tmpsdrv = new StepDataRetval(sd1.StepEditData.TypeMenu.MenuItem, Convert.ToInt32(sd1.Index));
|
||||
sds.Add(tmpsdrv);
|
||||
}
|
||||
}
|
||||
}
|
||||
parentFormat = parentFormat.PlantFormat.FormatData.MyParentFormat;
|
||||
}
|
||||
return sds;
|
||||
}
|
||||
@ -444,15 +474,35 @@ namespace VEPROMS.CSLA.Library
|
||||
StepData top = sd;
|
||||
while (top.ParentType != "Base")
|
||||
{
|
||||
bool foundit = false;
|
||||
string sParStp = StepDataList[formatStepType].ParentType;
|
||||
foreach (StepData stp in StepDataList)
|
||||
{
|
||||
if (top.ParentType == stp.Type)
|
||||
{
|
||||
top = stp;
|
||||
foundit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!foundit)
|
||||
{
|
||||
IFormatOrFormatInfo parentFormat = MyParentFormat;
|
||||
while (parentFormat != null && !foundit)
|
||||
{
|
||||
vlnIndexedFormatList<StepData> InheritedList = parentFormat.PlantFormat.FormatData.StepDataList;
|
||||
foreach (StepData stp1 in InheritedList)
|
||||
{
|
||||
if (top.ParentType == stp1.Type)
|
||||
{
|
||||
top = stp1;
|
||||
foundit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
parentFormat = parentFormat.PlantFormat.FormatData.MyParentFormat;
|
||||
}
|
||||
}
|
||||
}
|
||||
return top;
|
||||
}
|
||||
@ -500,13 +550,36 @@ namespace VEPROMS.CSLA.Library
|
||||
if (topType.Type == curType) retval = cntitm;
|
||||
cntitm++;
|
||||
}
|
||||
bool foundInCur = false;
|
||||
foreach (StepData sd in StepDataList)
|
||||
{
|
||||
if (sd.ParentType == topType.Type)
|
||||
{
|
||||
int tmpindx = DoListChildStepTypes(alwaysAdd, ref sds, sd, curType, _CurItemInfo, ref cntitm);
|
||||
int tmpindx = DoListChildStepTypes(alwaysAdd, ref sds, sd, curType, _CurItemInfo, ref cntitm, false);
|
||||
if (sd.Type == curType) retval = tmpindx;
|
||||
if (retval < 0 && tmpindx > 0) retval = tmpindx;
|
||||
foundInCur = true;
|
||||
}
|
||||
}
|
||||
// Handle inheritance (step data may not be in current format, may inherit from parents):
|
||||
if (!foundInCur)
|
||||
{
|
||||
IFormatOrFormatInfo parentFormat = MyParentFormat;
|
||||
bool foundit = false;
|
||||
while (parentFormat != null && !foundit)
|
||||
{
|
||||
vlnIndexedFormatList<StepData> InheritedList = parentFormat.PlantFormat.FormatData.StepDataList;
|
||||
foreach (StepData sd1 in InheritedList)
|
||||
{
|
||||
if (sd1.ParentType == topType.Type)
|
||||
{
|
||||
int tmpindx = DoListChildStepTypes(alwaysAdd, ref sds, sd1, curType, _CurItemInfo, ref cntitm, true);
|
||||
if (sd1.Type == curType) retval = tmpindx;
|
||||
if (retval < 0 && tmpindx > 0) retval = tmpindx;
|
||||
foundit = true; // stop after finding the type in the closest parent, i.e. don't keep walking up tree.
|
||||
}
|
||||
}
|
||||
parentFormat = parentFormat.PlantFormat.FormatData.MyParentFormat;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -514,7 +587,7 @@ namespace VEPROMS.CSLA.Library
|
||||
return sds;
|
||||
}
|
||||
|
||||
private int DoListChildStepTypes(bool alwaysAdd, ref List<StepDataRetval> sds, StepData topType, string curType, ItemInfo _CurItemInfo, ref int cntitm)
|
||||
private int DoListChildStepTypes(bool alwaysAdd, ref List<StepDataRetval> sds, StepData topType, string curType, ItemInfo _CurItemInfo, ref int cntitm, bool doInherit)
|
||||
{
|
||||
int retval = -1;
|
||||
if (alwaysAdd || (topType.StepEditData.TypeMenu.InMenu && ((topType.StepEditData.TypeMenu.RnoInMenu) ||
|
||||
@ -538,13 +611,36 @@ namespace VEPROMS.CSLA.Library
|
||||
cntitm++;
|
||||
}
|
||||
}
|
||||
bool foundInCur = false;
|
||||
foreach (StepData sd in StepDataList)
|
||||
{
|
||||
if (sd.ParentType == topType.Type)
|
||||
{
|
||||
int tmpindx = DoListChildStepTypes(alwaysAdd, ref sds, sd, curType, _CurItemInfo, ref cntitm);
|
||||
int tmpindx = DoListChildStepTypes(alwaysAdd, ref sds, sd, curType, _CurItemInfo, ref cntitm, false);
|
||||
if (sd.Type == curType) retval = tmpindx;
|
||||
if (retval < 0 && tmpindx > 0) retval = tmpindx;
|
||||
foundInCur = true;
|
||||
}
|
||||
}
|
||||
// Handle inheritance (step data may not be in current format, may inherit from parents):
|
||||
if (!foundInCur && doInherit)
|
||||
{
|
||||
IFormatOrFormatInfo parentFormat = MyParentFormat;
|
||||
bool foundit = false;
|
||||
while (parentFormat != null && !foundit)
|
||||
{
|
||||
vlnIndexedFormatList<StepData> InheritedList = parentFormat.PlantFormat.FormatData.StepDataList;
|
||||
foreach (StepData sd1 in InheritedList)
|
||||
{
|
||||
if (sd1.ParentType == topType.Type)
|
||||
{
|
||||
int tmpindx = DoListChildStepTypes(alwaysAdd, ref sds, sd1, curType, _CurItemInfo, ref cntitm, true);
|
||||
if (sd1.Type == curType) retval = tmpindx;
|
||||
if (retval < 0 && tmpindx > 0) retval = tmpindx;
|
||||
foundit = true;
|
||||
}
|
||||
}
|
||||
parentFormat = parentFormat.PlantFormat.FormatData.MyParentFormat;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4832,22 +4928,25 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
foreach (StepData stepData in this)
|
||||
if (stepData.Type == type) return stepData;
|
||||
//foreach (StepData stepData1 in InheritedList)
|
||||
// if (stepData1.Type == type) return stepData1;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public StepData this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (StepData stepData in this)
|
||||
if (stepData.Index == index) return stepData;
|
||||
//foreach (StepData stepData1 in InheritedList)
|
||||
// if (stepData1.Index == index) return stepData1;
|
||||
StepDataList ttlParent = (StepDataList) InheritedList; //Check Inherited Value
|
||||
if (ttlParent != null)
|
||||
return ttlParent[type]; // note that this is recursive, i.e. if doesn't get found in parent, goes to parent's parent.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// the following was commented out because it uses the vlnFormat version of the code that indexes the list.
|
||||
//public StepData this[int index]
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// foreach (StepData stepData in this)
|
||||
// if (stepData.Index == index) return stepData;
|
||||
// StepDataList ttlParent = (StepDataList)InheritedList; //Check Inherited Value
|
||||
// if (ttlParent != null)
|
||||
// return ttlParent[index];
|
||||
// return null;
|
||||
// }
|
||||
//}
|
||||
public StepDataList(XmlNodeList xmlNodeList, IFormatOrFormatInfo myFormat) : base(xmlNodeList, myFormat) { }
|
||||
private StepData _HLS;
|
||||
public StepData HLS
|
||||
@ -5008,14 +5107,24 @@ namespace VEPROMS.CSLA.Library
|
||||
return sd;
|
||||
}
|
||||
}
|
||||
//foreach (StepData sdi in InheritedList)
|
||||
//{
|
||||
// if (sdi.Type == "Equation")
|
||||
// {
|
||||
// _Equation = sdi;
|
||||
// return sdi;
|
||||
// }
|
||||
//}
|
||||
// Handle inheritance (step data may not be in current format, may inherit from parents):
|
||||
IFormatOrFormatInfo parentFormat = this.MyFormat.PlantFormat.FormatData.MyParentFormat;
|
||||
while (parentFormat != null)
|
||||
{
|
||||
vlnIndexedFormatList<StepData> InheritedList = parentFormat.PlantFormat.FormatData.StepDataList;
|
||||
if (InheritedList != null)
|
||||
{
|
||||
foreach (StepData sdi in InheritedList)
|
||||
{
|
||||
if (sdi.Type == "Equation")
|
||||
{
|
||||
_Equation = sdi;
|
||||
return sdi;
|
||||
}
|
||||
}
|
||||
}
|
||||
parentFormat = parentFormat.PlantFormat.FormatData.MyParentFormat;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +279,14 @@ namespace VEPROMS.CSLA.Library
|
||||
return _MyFormat;
|
||||
}
|
||||
}
|
||||
|
||||
private IFormatOrFormatInfo _MyParentFormat;
|
||||
public IFormatOrFormatInfo MyParentFormat
|
||||
{
|
||||
get
|
||||
{
|
||||
return MyFormat.MyIParent;
|
||||
}
|
||||
}
|
||||
public virtual string GetPDDisplayName()
|
||||
{ return ToString(); }
|
||||
public virtual string GetPDName()
|
||||
|
@ -1250,7 +1250,7 @@ namespace Volian.Controls.Library
|
||||
public void SetButtonAndMenuEnabling(bool docontextmenus)
|
||||
{
|
||||
if (_MyStepRTB == null) return;
|
||||
if (_MyStepRTB.FieldToEdit != E_FieldToEdit.StepText && !MyItemInfo.IsFigure & !MyItemInfo.IsRtfRaw) // want menu enabling for figures & aations
|
||||
if (_MyStepRTB.FieldToEdit != E_FieldToEdit.StepText && !MyItemInfo.IsFigure && !MyItemInfo.IsRtfRaw) // want menu enabling for figures & aations
|
||||
return; // No need to change menu that does not get used
|
||||
DocVersionInfo dvi = MyEditItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo;
|
||||
if (dvi == null) return;
|
||||
@ -1682,7 +1682,7 @@ namespace Volian.Controls.Library
|
||||
btnInsSubstep.Enabled = (actable & E_AccStep.AddingSub) > 0;
|
||||
btnInsBefore.Enabled = btnInsBefH.Enabled = !MyItemInfo.IsRNOPart && (actable & E_AccStep.AddingPrev) > 0;
|
||||
btnInsAfter.Enabled = btnInsAftH.Enabled = !MyItemInfo.IsRNOPart && (actable & E_AccStep.AddingNext) > 0;
|
||||
btnInsEquation.Enabled = (actable & E_AccStep.AddingTable) > 0 && MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList.Equation != null;
|
||||
btnInsEquation.Enabled = (actable & E_AccStep.AddingTable) > 0;
|
||||
|
||||
// if this step has a table, figure or equation, disable both of those buttons.
|
||||
if (MyItemInfo.Tables != null && MyItemInfo.Tables.Count > 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user