C2021-026 Parent/Child applicability in RO Editor

This commit is contained in:
2021-07-29 18:28:12 +00:00
parent 697490d5bf
commit ce9e9e182e
16 changed files with 1103 additions and 263 deletions

View File

@@ -1,5 +1,5 @@
/*********************************************************************************************
* Copyright 2002 - Volian Enterprises, Inc. All rights reserved.
* Copyright 2021 - Volian Enterprises, Inc. All rights reserved.
* Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
* ------------------------------------------------------------------------------
* $Workfile: ROEditor.cs $ $Revision: 54 $
@@ -350,6 +350,7 @@ namespace ROEditor
private System.Windows.Forms.MenuItem menuEditSelAll;
private TreeNode LastSelectedNode;
private TextBox _CurrentTextBox; // currently selected TextBox field
public static string[] PCChildren; //C2021-026 list of Parent/Child Children
public TextBox CurrentTextBox
{
@@ -887,9 +888,9 @@ namespace ROEditor
}
}
private void CreateCtlXmlEdit2(VlnXmlElement curelem, XmlSchema myschema, ArrayList reqfields)
private void CreateCtlXmlEdit2(VlnXmlElement curelem, XmlSchema myschema, ArrayList reqfields, ArrayList fieldsWithApplic)
{
ctlXMLEdit2 = new ctlXMLEditLib.ctlXMLEdit(curelem,myschema,reqfields);
ctlXMLEdit2 = new ctlXMLEditLib.ctlXMLEdit(curelem,myschema,reqfields,fieldsWithApplic,PCChildren); // C2021-026 pass in P/C enabled information
ctlXMLEdit2.AutoScroll = true;
ctlXMLEdit2.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
ctlXMLEdit2.Name = "ctlXMLEdit2";
@@ -927,9 +928,29 @@ namespace ROEditor
this.panel2.Controls.Add(ctlXMLEdit2);
tbtnCancel.Enabled = true;
}
// C2021-026 Get a list of fields that are P/C enabled
private ArrayList GetApplcFieldListForElement(VlnXmlElement elem)
{
ArrayList rtnval = null;
ArrayList InUseApplcList = null;
ArrayList AvailList = null;
ArrayList InUseList = null;
string origFieldsInUse = "";
string origApplicFields = "";
ArrayList tmp = myrodb.RODB_GetFields((VlnXmlElement)elem.ParentNode, (uint)RecordType.Schema);
// put the items in the AvailList box.
if (AvailList == null) AvailList = new ArrayList();
for (int i = 0; i < tmp.Count; i++) AvailList.Add(tmp[i]); // don't modify the list returned from RODB_GetFields since it is part of dictionary
InUseList = myrodb.RODB_GetFieldsInUse((VlnXmlElement)elem.ParentNode, AvailList, "FieldsInUse", ref origFieldsInUse, false);
InUseApplcList = myrodb.RODB_GetApplicabilityEnabledFields((VlnXmlElement)elem.ParentNode, InUseList, ref origApplicFields, ApplicabilityEnabled());
rtnval = new ArrayList();
foreach (ROField rof in InUseApplcList)
rtnval.Add(rof.GetFieldname);
return rtnval;
}
private void EditRO(VlnXmlElement curelem)
{
ArrayList fieldsWithApplic = null;
newone=null;
// can't edit fields for top or top group nodes (top node not editable,
// and top group node data change at properties level).
@@ -944,6 +965,10 @@ namespace ROEditor
// a message. (B2004-017)
if (curelem.Name != "vlnGroup")
{
// C2021-026 Get the list of fields with P/C enabled
// use the curelm.parent and calls similar to what is in RODefFrm.cs
fieldsWithApplic = GetApplcFieldListForElement(curelem);
myschema = myrodb.RODB_GetSchema(curelem);
if (myschema==null)
{
@@ -965,7 +990,7 @@ namespace ROEditor
}
ArrayList reqfields = curelem.GetRequiredFields();
CreateCtlXmlEdit2(curelem,myschema,reqfields);
CreateCtlXmlEdit2(curelem,myschema, reqfields, fieldsWithApplic); // C2021-026 pass in P/C enabled fields
this.panel2.Controls.Add(ctlXMLEdit2);
tbtnSave.Enabled=false; // set initial states of buttons on edit
tbtnRestore.Enabled=false;
@@ -1406,7 +1431,7 @@ namespace ROEditor
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(228, 28);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(588, 591);
this.panel1.Size = new System.Drawing.Size(710, 591);
this.panel1.TabIndex = 5;
//
// panel2
@@ -1447,7 +1472,7 @@ namespace ROEditor
this.tbar.Location = new System.Drawing.Point(0, 0);
this.tbar.Name = "tbar";
this.tbar.ShowToolTips = true;
this.tbar.Size = new System.Drawing.Size(816, 28);
this.tbar.Size = new System.Drawing.Size(938, 28);
this.tbar.TabIndex = 0;
this.tbar.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right;
this.tbar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.tbar_OnClick);
@@ -1519,7 +1544,7 @@ namespace ROEditor
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(816, 619);
this.ClientSize = new System.Drawing.Size(980, 619);
this.Controls.Add(this.lblDuplicateRO);
this.Controls.Add(this.panel1);
this.Controls.Add(this.splitter1);
@@ -1574,24 +1599,37 @@ namespace ROEditor
// the the Access database.
if (args.Length > 0)
{
ConnectionPath = args[0];
if (args[0].ToUpper().StartsWith("PC="))
PCChildren = args[0].Substring(3).Split(','); //C2021-026 list of Parent/Child Children
else
ConnectionPath = args[0];
// Directory.SetCurrentDirectory(ConnectionPath);
}
else // find ROPATH
if (ConnectionPath == null) // RO Path was not passed in, find ROPATH
{
ConnectionPath = FindTheRODirectory();
}
if (args.Length > 1)
{
if (args[1].ToUpper().Contains("DATA SOURCE")) SqlConnectionStr = args[1];
if (args[1].ToUpper().StartsWith("PC="))
PCChildren = args[1].Substring(3).Split(','); //C2021-026 list of Parent/Child Children
else if (args[1].ToUpper().Contains("DATA SOURCE")) SqlConnectionStr = args[1];
else specificro = args[1];
}
if (args.Length > 2)
{
if (args[2].ToUpper().Contains("DATA SOURCE")) SqlConnectionStr = args[2];
if (args[2].ToUpper().StartsWith("PC="))
PCChildren = args[2].Substring(3).Split(','); //C2021-026 list of Parent/Child Children
else if (args[2].ToUpper().Contains("DATA SOURCE")) SqlConnectionStr = args[2];
else specificro = args[2];
}
try
if (args.Length > 3)
if (args[3].ToUpper().StartsWith("PC="))
PCChildren = args[3].Substring(3).Split(','); //C2021-026 list of Parent/Child Children
else if (args[3].ToUpper().Contains("DATA SOURCE")) SqlConnectionStr = args[3];
else specificro = args[3];
RODB.PCChildList = PCChildren; //C2021-026 pass the Parent/Child info to the RODB class
try
{
// Convert the RO data if needed
if (!CheckForDataConversion(ConnectionPath))
@@ -1726,6 +1764,12 @@ namespace ROEditor
}
}
// C2021-026 was Parent/Child information passed into the RO Editor?
public static bool ApplicabilityEnabled()
{
return (PCChildren != null && PCChildren.Length > 0);
}
/*
* Look for the RO directory via PROC.INI and by
* looking for a \RO directory in the current VEplant
@@ -2011,7 +2055,7 @@ namespace ROEditor
int retval = roTreeView_ClearEditDisplay(false);
if (retval == -1) return;
roListView_ClearListDisplay();
CreateCtlXmlEdit2(nelem,myschema,reqfields);
CreateCtlXmlEdit2(nelem,myschema,reqfields, null);
tbtnSave.Enabled=false; // initial disable the save button
ctlXMLEdit2.Focus();
tbtnZoom.Enabled = false;
@@ -2024,6 +2068,7 @@ namespace ROEditor
private void menuNewRefObj_Click(object sender, System.EventArgs e)
{
int retval = roTreeView_ClearEditDisplay(false);
ArrayList InUseApplcList=null;
if (retval == -1) return;
roListView_ClearListDisplay();
VlnXmlElement curelem = (VlnXmlElement) roTreeView.SelectedNode.Tag;
@@ -2051,6 +2096,7 @@ namespace ROEditor
{
curelem.ParentNode.AppendChild((XmlNode) nelem);
TreeNewparent = roTreeView.SelectedNode.Parent;
InUseApplcList = GetApplcFieldListForElement(curelem); //C2021-026 get list of fields with P/C enabled
}
else
{
@@ -2060,7 +2106,7 @@ namespace ROEditor
newone = nelem;
ArrayList reqfields = nelem.GetRequiredFields();
CreateCtlXmlEdit2(nelem,myschema,reqfields);
CreateCtlXmlEdit2(nelem,myschema,reqfields, InUseApplcList);
tbtnSave.Enabled=false; // initial disable the save button
ctlXMLEdit2.Focus();
tbtnZoom.Enabled = false;
@@ -2555,7 +2601,8 @@ namespace ROEditor
if (rof.GetFieldname != null)
{
uint ftype = rof.GetFieldType;
if (ftype == 1 || ftype == 2 || ftype==4 || ftype==128)
if (ftype == (uint)ROFields.FieldTypes.SingleTxt || ftype == (uint)ROFields.FieldTypes.VariableTxt ||
ftype == (uint)ROFields.FieldTypes.FrmtSingleTxt || ftype == (uint)ROFields.FieldTypes.Combination)
roListView.Columns.Add(rof.GetFieldname, 100,HorizontalAlignment.Left);
}
}
@@ -2594,7 +2641,8 @@ namespace ROEditor
if (rof.GetFieldname != null)
{
uint ftype = rof.GetFieldType;
if (ftype == 1 || ftype == 2 || ftype == 4 || ftype == 128)
if (ftype == (uint)ROFields.FieldTypes.SingleTxt || ftype == (uint)ROFields.FieldTypes.VariableTxt ||
ftype == (uint)ROFields.FieldTypes.FrmtSingleTxt || ftype == (uint)ROFields.FieldTypes.Combination)
{
string nm0 = rof.GetFieldname;
nm = rof.MakeFieldName(nm0);
@@ -2711,9 +2759,9 @@ namespace ROEditor
byte xbyte, ybyte;
xlen = xbuff.Length;
ylen = ybuff.Length;
if (xbuff[0] == '<')
if (xbuff.Length > 0 && xbuff[0] == '<')
rtnval = 0;
if (ybuff[0] == '<')
if (ybuff.Length > 0 && ybuff[0] == '<')
rtnval = 0;
while ((rtnval==0) && ((xcnt < xlen) || (ycnt < ylen)))
{