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: RODefFrm.cs $ $Revision: 18 $
@@ -105,6 +105,7 @@ using System.Text;
using ROFields;
using RODBInterface;
using VlnStatus;
using System.Collections.Generic;
namespace ROEditor
@@ -125,6 +126,7 @@ namespace ROEditor
private System.Windows.Forms.Label lblInUse;
private System.Windows.Forms.Label lblAvail;
private System.Windows.Forms.ListBox lboxInUse;
private System.Windows.Forms.CheckedListBox lboxInUseCB; // C2021-026 added a checked list box for Parent/Child capabilites
private System.Windows.Forms.ListBox lboxAvail;
private System.Windows.Forms.Button btnAdd;
private System.Windows.Forms.Button btnEdit;
@@ -139,15 +141,24 @@ namespace ROEditor
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel;
ArrayList InUseList;
ArrayList InUseApplcList; // C2021-026 hold the list of fields that have child values
private VlnXmlElement elem;
private uint editlevel; // flag for group definition or ro definition
private uint editlevel; // flag for group definition or ro definition
private string strFieldsInUse;
private string origFieldsInUse;
private string origApplicFields;
private string origRetVal;
private string origMenuItem;
StringBuilder parseerror;
StringBuilder parseerror;
private int hi, lo;
private Label lb_chkApplc;
private int dbtype;
// C2021-026 returns true is Parent/Child info was passed into the RO Editor
public bool PCApplicabilityEnabled
{
get { return ROEditor.Form1.ApplicabilityEnabled(); }
}
// pass in Group Element
public RODefFrm(VlnXmlElement pelem, RODB rodb, string fields, string grptxt, int idbtype)
{
@@ -164,7 +175,20 @@ namespace ROEditor
//
InitializeComponent();
if(editlevel==(uint)RecordType.GroupSchema)this.Text = "Subgroup Definition";
// C2021-024 toggle which check boxes are visable based on if Parent/Child is available
if (PCApplicabilityEnabled)
{
lboxInUseCB.Visible = true;
lboxInUse.Visible = false;
lb_chkApplc.Visible = true;
}
else
{
lboxInUseCB.Visible = false;
lboxInUse.Visible = true;
lb_chkApplc.Visible = false;
}
if (editlevel==(uint)RecordType.GroupSchema)this.Text = "Subgroup Definition";
FillInData(grptxt);
}
@@ -195,31 +219,62 @@ namespace ROEditor
this.lboxAvail.Items.Add(rof.GetFieldname);
}
}
// C2021-024 see if the give RO field is checked to have child values
private bool ContainedInUseApplicList(ROField rof)
{
bool isInList = false;
foreach (ROField arof in InUseApplcList)
{
if (arof.GetRecID == rof.GetRecID)
{
isInList = true;
break;
}
}
return isInList;
}
private bool _initializing = false;
private void SetUpListBoxes()
{
_initializing = true;
ROField rof;
// Get list of available fields (all fields in this type, i.e. rectype = 'Schema'
// or 'GroupSchema') and get list of inuse from the schema definition.
ArrayList tmp = myrodb.RODB_GetFields(elem, editlevel);
// 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(elem, AvailList, strFieldsInUse, ref origFieldsInUse, false);
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(elem, AvailList, strFieldsInUse, ref origFieldsInUse, true);
// C2021-024 get the list of fields that are have P/C values turned on (fields that are checked)
InUseApplcList = myrodb.RODB_GetApplicabilityEnabledFields(elem, InUseList, ref origApplicFields, PCApplicabilityEnabled);
FillInAvailable();
// set up the listbox for inuse items.
if (InUseList != null)
if (InUseList != null)
{
// add items to the InUseList box.
for (int i=0; i< InUseList.Count; i++)
for (int i = 0; i < InUseList.Count; i++)
{
rof = (ROField) InUseList[i];
rof = (ROField)InUseList[i];
if (rof.GetFieldname != null) //DO YET: why null?
this.lboxInUse.Items.Add(rof.GetFieldname);
{
// C2021-026 populate the relative In Use list base on if Parent/Child is enabled
if (PCApplicabilityEnabled)
{
this.lboxInUseCB.Items.Add(rof.GetFieldname);
if (rof.FieldTypeCanDoApplicability())
{
if (ContainedInUseApplicList(rof))
this.lboxInUseCB.SetItemCheckState(lboxInUseCB.Items.IndexOf(rof.GetFieldname), CheckState.Checked);
}
}
else
this.lboxInUse.Items.Add(rof.GetFieldname);
}
}
}
_initializing = false;
}
@@ -281,8 +336,12 @@ namespace ROEditor
this.lblGroupText.Text = grptxt;
DoValueTextBoxes();
SetUpListBoxes();
lboxInUse.GotFocus += new EventHandler(this.lboxInUse_GotFocus);
if (PCApplicabilityEnabled) // C2021-026 Check Box list focus event
lboxInUseCB.GotFocus += new EventHandler(this.lboxInUseCB_GotFocus);
else
lboxInUse.GotFocus += new EventHandler(this.lboxInUse_GotFocus);
lboxAvail.GotFocus += new EventHandler(this.lboxAvail_GotFocus);
// save copies of local data, so if there is a change, we know we must save them.
@@ -309,9 +368,19 @@ namespace ROEditor
this.btnAdd.Enabled = false;
this.btnEdit.Enabled = true;
}
protected void lboxInUseCB_GotFocus(object sender, EventArgs e)
{
lboxAvail.ClearSelected();
this.btnRemove.Enabled = true;
this.btnAdd.Enabled = false;
this.btnEdit.Enabled = true;
}
protected void lboxAvail_GotFocus (object sender, EventArgs e)
{
lboxInUse.ClearSelected();
if (PCApplicabilityEnabled)
lboxInUseCB.ClearSelected();
else
lboxInUse.ClearSelected();
this.btnAdd.Enabled = true;
this.btnRemove.Enabled = false;
this.btnEdit.Enabled = true;
@@ -320,48 +389,101 @@ namespace ROEditor
{
//get item in lboxInUse (in use list) and remove it from there
// and add it to the lboxAvail list.
if (lboxInUse.SelectedIndex >=0 )
if (PCApplicabilityEnabled) // C2021-026 use the Check Box list
{
// get the selected item and its string. Remove it from the listbox,
// add it to the available array list & listbox & then remove it from
// the inuse array list.
int indx = lboxInUse.SelectedIndex;
lboxInUse.Items.RemoveAt(indx);
if (lboxInUseCB.SelectedIndex >= 0)
{
// get the selected item and its string. Remove it from the listbox,
// add it to the available array list & listbox & then remove it from
// the inuse array list.
int indx = lboxInUseCB.SelectedIndex;
lboxInUseCB.Items.RemoveAt(indx);
// copy if over to availlist
ROField rof = (ROField) InUseList[indx];
ROField copyrof = new ROField(rof.GetFieldname,rof.GetRecID,rof.GetMasterRecID, rof.GetFieldType);
AvailList.Add(copyrof);
// copy if over to availlist
ROField rof = (ROField)InUseList[indx];
ROField copyrof = new ROField(rof.GetFieldname, rof.GetRecID, rof.GetMasterRecID, rof.GetFieldType);
AvailList.Add(copyrof);
lboxAvail.Items.Add(copyrof.GetFieldname);
InUseList.RemoveAt(indx);
lboxAvail.Refresh();
lboxInUse.Refresh();
lboxAvail.Items.Add(copyrof.GetFieldname);
InUseList.RemoveAt(indx);
if (InUseApplcList.Contains(rof)) // C2021-026 remove from the field applicability list
InUseApplcList.Remove(rof);
lboxAvail.Refresh();
lboxInUseCB.Refresh();
}
}
else
{
if (lboxInUse.SelectedIndex >= 0)
{
// get the selected item and its string. Remove it from the listbox,
// add it to the available array list & listbox & then remove it from
// the inuse array list.
int indx = lboxInUse.SelectedIndex;
lboxInUse.Items.RemoveAt(indx);
// copy if over to availlist
ROField rof = (ROField)InUseList[indx];
ROField copyrof = new ROField(rof.GetFieldname, rof.GetRecID, rof.GetMasterRecID, rof.GetFieldType);
AvailList.Add(copyrof);
lboxAvail.Items.Add(copyrof.GetFieldname);
InUseList.RemoveAt(indx);
if (InUseApplcList.Contains(rof)) // C2021-026 remove from the field applicability list
InUseApplcList.Remove(rof);
lboxAvail.Refresh();
lboxInUse.Refresh();
}
}
}
private void btnAdd_Click(object sender, System.EventArgs e)
{
//get item in lboxInUse (in use list) and remove it from there
// and add it to the lboxAvail list.
if (lboxAvail.SelectedIndex >=0 )
if (PCApplicabilityEnabled) // C2021-026 using the Check Box List
{
// get the selected item and its string. Remove it from the listbox,
// add it to the inuse array list & listbox & then remove it from
// the avail(able) array list.
int indx = lboxAvail.SelectedIndex;
lboxAvail.Items.RemoveAt(indx);
// copy if over to availlist
ROField rof = (ROField) AvailList[indx];
ROField copyrof = new ROField(rof.GetFieldname,rof.GetRecID,rof.GetMasterRecID,rof.GetFieldType);
InUseList.Add(copyrof);
if (lboxAvail.SelectedIndex >= 0)
{
// get the selected item and its string. Remove it from the listbox,
// add it to the inuse array list & listbox & then remove it from
// the avail(able) array list.
int indx = lboxAvail.SelectedIndex;
lboxAvail.Items.RemoveAt(indx);
lboxInUse.Items.Add(copyrof.GetFieldname);
AvailList.RemoveAt(indx);
lboxAvail.Refresh();
lboxInUse.Refresh();
btnOK.Enabled=true;
// copy if over to availlist
ROField rof = (ROField)AvailList[indx];
ROField copyrof = new ROField(rof.GetFieldname, rof.GetRecID, rof.GetMasterRecID, rof.GetFieldType);
InUseList.Add(copyrof);
lboxInUseCB.Items.Add(copyrof.GetFieldname);
AvailList.RemoveAt(indx);
lboxAvail.Refresh();
lboxInUseCB.Refresh();
btnOK.Enabled = true;
}
}
else
{
if (lboxAvail.SelectedIndex >= 0)
{
// get the selected item and its string. Remove it from the listbox,
// add it to the inuse array list & listbox & then remove it from
// the avail(able) array list.
int indx = lboxAvail.SelectedIndex;
lboxAvail.Items.RemoveAt(indx);
// copy if over to availlist
ROField rof = (ROField)AvailList[indx];
ROField copyrof = new ROField(rof.GetFieldname, rof.GetRecID, rof.GetMasterRecID, rof.GetFieldType);
InUseList.Add(copyrof);
lboxInUse.Items.Add(copyrof.GetFieldname);
AvailList.RemoveAt(indx);
lboxAvail.Refresh();
lboxInUse.Refresh();
btnOK.Enabled = true;
}
}
}
@@ -849,6 +971,17 @@ namespace ROEditor
if (i+1 < InUseList.Count) inuserecs = inuserecs + " ";
}
}
// C2021-026 save the fields with applicability set
string applicfieldrecs = null;
for (int i = 0; i < InUseApplcList.Count; i++)
{
rof = (ROField)InUseApplcList[i];
if (rof.GetFieldname != null)
{
applicfieldrecs = applicfieldrecs + rof.GetRecID;
if (i + 1 < InUseApplcList.Count) applicfieldrecs = applicfieldrecs + " ";
}
}
// save the database record, saving modified data as appropriate -- if a mod
// occurred at this level, add it to the attribute list too.
@@ -877,6 +1010,12 @@ namespace ROEditor
elem.SetAttribute("FieldsInUse", inuserecs);
mod = true;
}
//C2021-026 save the list of field recids that use applicability
if (applicfieldrecs != origApplicFields)
{
elem.SetAttribute("ApplicabilityEnabled", applicfieldrecs);
mod = true;
}
}
if (editlevel == (uint) RecordType.GroupSchema)
@@ -941,7 +1080,8 @@ namespace ROEditor
// Get the field which is active & it's type. Pass the field through to the field
// editor.
int indx;
indx = lboxInUse.SelectedIndex;
// C2021-026 get the selected index base on wich InUse list is being used
indx = (PCApplicabilityEnabled)? lboxInUseCB.SelectedIndex : lboxInUse.SelectedIndex;
if (indx >= 0)
rof = (ROField) InUseList[indx];
else
@@ -975,13 +1115,29 @@ namespace ROEditor
// Update Lists & Text boxes to represent any modified text.
if (isInSelList)
{
lboxInUse.Items.Clear();
if (PCApplicabilityEnabled)
lboxInUseCB.Items.Clear();
else
lboxInUse.Items.Clear();
// add items to the InUseList box.
for (int i=0; i< InUseList.Count; i++)
{
rof = (ROField) InUseList[i];
if (rof.GetFieldname != null)
this.lboxInUse.Items.Add(rof.GetFieldname);
{
// C2021-026 if doing Parent/Child enabled RO Editor, put the In Use fields in the Check Box List instead of the normal list
if (PCApplicabilityEnabled)
{
this.lboxInUseCB.Items.Add(rof.GetFieldname);
if (rof.FieldTypeCanDoApplicability())
{
if (ContainedInUseApplicList(rof))
this.lboxInUseCB.SetItemCheckState(lboxInUseCB.Items.IndexOf(rof.GetFieldname), CheckState.Checked);
}
}
else
this.lboxInUse.Items.Add(rof.GetFieldname);
}
}
}
else
@@ -1009,6 +1165,32 @@ namespace ROEditor
lboxAvail.Items.Add(rof.GetFieldname);
}
}
// C2021-026 Check/un-check field for Parent/Child values
private void lboxInUseCB_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (_initializing) return;
ROField rof = (ROField)InUseList[e.Index];
bool isInAplicList = ContainedInUseApplicList(rof);
if (!rof.FieldTypeCanDoApplicability())
{
MessageBox.Show("Cannot Enable Applicability on this RO Field type.", "Enable Applicabilty", MessageBoxButtons.OK, MessageBoxIcon.Information);
e.NewValue = CheckState.Unchecked;
}
else if (e.NewValue == CheckState.Checked) //we are going to check it - add tothe applic list
{
if (!isInAplicList) // make sure it's not already in the list (this should never happen)
InUseApplcList.Add(rof);
}
else if (isInAplicList) // we are un-checking it. Remove it from the applic list
{
for (int i = 0; i < InUseApplcList.Count; i++)
if ((InUseApplcList[i] as ROField).GetRecID == rof.GetRecID)
{
InUseApplcList.RemoveAt(i);
break;
}
}
}
#region Windows Form Designer generated code
/// <summary>
@@ -1024,12 +1206,14 @@ namespace ROEditor
this.tbMenuVal = new System.Windows.Forms.TextBox();
this.lblGroupText = new System.Windows.Forms.Label();
this.gbFields = new System.Windows.Forms.GroupBox();
this.lb_chkApplc = new System.Windows.Forms.Label();
this.btnNew = new System.Windows.Forms.Button();
this.btnRemove = new System.Windows.Forms.Button();
this.btnEdit = new System.Windows.Forms.Button();
this.btnAdd = new System.Windows.Forms.Button();
this.lboxAvail = new System.Windows.Forms.ListBox();
this.lboxInUse = new System.Windows.Forms.ListBox();
this.lboxInUseCB = new System.Windows.Forms.CheckedListBox(); // C2021-026 list with check boxes to enable P/C on field
this.lblAvail = new System.Windows.Forms.Label();
this.lblInUse = new System.Windows.Forms.Label();
this.btnOK = new System.Windows.Forms.Button();
@@ -1090,22 +1274,32 @@ namespace ROEditor
//
// gbFields
//
this.gbFields.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btnNew,
this.btnRemove,
this.btnEdit,
this.btnAdd,
this.lboxAvail,
this.lboxInUse,
this.lblAvail,
this.lblInUse});
this.gbFields.Controls.Add(this.lb_chkApplc);
this.gbFields.Controls.Add(this.btnNew);
this.gbFields.Controls.Add(this.btnRemove);
this.gbFields.Controls.Add(this.btnEdit);
this.gbFields.Controls.Add(this.btnAdd);
this.gbFields.Controls.Add(this.lboxAvail);
this.gbFields.Controls.Add(this.lboxInUse);
this.gbFields.Controls.Add(this.lboxInUseCB);
this.gbFields.Controls.Add(this.lblAvail);
this.gbFields.Controls.Add(this.lblInUse);
this.gbFields.Location = new System.Drawing.Point(8, 112);
this.gbFields.Name = "gbFields";
this.gbFields.Size = new System.Drawing.Size(704, 224);
this.gbFields.Size = new System.Drawing.Size(704, 247);
this.gbFields.TabIndex = 8;
this.gbFields.TabStop = false;
this.gbFields.Text = "Fields";
//
// lb_chkApplc
//
this.lb_chkApplc.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lb_chkApplc.Location = new System.Drawing.Point(69, 24);
this.lb_chkApplc.Name = "lb_chkApplc";
this.lb_chkApplc.Size = new System.Drawing.Size(227, 16);
this.lb_chkApplc.TabIndex = 8;
this.lb_chkApplc.Text = "(Check Parent/Child Applicability Fields)";
//
// btnNew
//
this.btnNew.Location = new System.Drawing.Point(608, 48);
@@ -1150,17 +1344,25 @@ namespace ROEditor
this.lboxAvail.ItemHeight = 14;
this.lboxAvail.Location = new System.Drawing.Point(376, 48);
this.lboxAvail.Name = "lboxAvail";
this.lboxAvail.Size = new System.Drawing.Size(216, 144);
this.lboxAvail.Size = new System.Drawing.Size(216, 172);
this.lboxAvail.TabIndex = 3;
//
// lboxInUse
//
this.lboxInUse.ItemHeight = 14;
this.lboxInUse.Location = new System.Drawing.Point(24, 48);
this.lboxInUse.Location = new System.Drawing.Point(27, 48);
this.lboxInUse.Name = "lboxInUse";
this.lboxInUse.Size = new System.Drawing.Size(216, 144);
this.lboxInUse.Size = new System.Drawing.Size(216, 172);
this.lboxInUse.TabIndex = 2;
//
// lboxInUseCB
//
this.lboxInUseCB.Location = new System.Drawing.Point(27, 48);
this.lboxInUseCB.Name = "lboxInUseCB";
this.lboxInUseCB.Size = new System.Drawing.Size(216, 174);
this.lboxInUseCB.TabIndex = 2;
this.lboxInUseCB.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.lboxInUseCB_ItemCheck);
//
// lblAvail
//
this.lblAvail.Location = new System.Drawing.Point(384, 24);
@@ -1200,21 +1402,21 @@ namespace ROEditor
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
this.ClientSize = new System.Drawing.Size(792, 437);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btnCancel,
this.btnOK,
this.gbFields,
this.lblGroupText,
this.tbMenuVal,
this.tbRetVal,
this.lblMenuVal,
this.lblRetVal,
this.lblGroup});
this.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.gbFields);
this.Controls.Add(this.lblGroupText);
this.Controls.Add(this.tbMenuVal);
this.Controls.Add(this.tbRetVal);
this.Controls.Add(this.lblMenuVal);
this.Controls.Add(this.lblRetVal);
this.Controls.Add(this.lblGroup);
this.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "RODefFrm";
this.Text = "Referenced Object Definition";
this.gbFields.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion