Enhanced Documents, handle enhanced steps
Enhanced Documents, delete items Enhanced Documents button disable/enable Enhanced Documents, tree view support for insert/delete/copy-paste Move DisplayText.cs to CSLA Enhanced Documents adding links (method added in docversion)
This commit is contained in:
@@ -810,6 +810,7 @@ namespace Volian.Controls.Library
|
||||
// A word doc section can contain another subsection (either step section or word doc section),
|
||||
// but cannot contain steps.
|
||||
SectionInfo si = tn.VEObject as SectionInfo;
|
||||
// if this is an enhanced section, don't do 'New Step'
|
||||
if (ui.IsAdministrator() || ui.IsSetAdministrator(si.MyProcedure.MyDocVersion) || ui.IsWriter(si.MyProcedure.MyDocVersion))
|
||||
{
|
||||
if (si.HasWordContent)
|
||||
@@ -832,7 +833,7 @@ namespace Volian.Controls.Library
|
||||
if (si.IsStepSection)
|
||||
{
|
||||
SectionConfig sc = si.MyConfig as SectionConfig;
|
||||
if (si.Sections == null || si.Sections.Count == 0 || (meta && sc != null && si.Sections != null && si.Sections.Count > 0 && sc.SubSection_Edit == "Y"))
|
||||
if (!si.IsEnhancedSection && (si.Sections == null || si.Sections.Count == 0 || (meta && sc != null && si.Sections != null && si.Sections.Count > 0 && sc.SubSection_Edit == "Y")))
|
||||
cm.MenuItems.Add("New Step", new EventHandler(mi_Click));
|
||||
}
|
||||
}
|
||||
@@ -897,7 +898,15 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
DocVersionInfo di = tn.VEObject as DocVersionInfo;
|
||||
if (di == null || tn.Nodes.Count == 0) // it's not a docversion or it has no children
|
||||
cm.MenuItems.Add("Delete", new EventHandler(mi_Click));
|
||||
{
|
||||
// if it's an enhanced step that was linked from a source, don't allow delete
|
||||
bool canDoDel = true;
|
||||
ItemInfo iienh = tn.VEObject as ItemInfo;
|
||||
if (iienh != null && iienh.IsProcedure && iienh.IsEnhancedProcedure) canDoDel = false;
|
||||
if (iienh != null && iienh.IsSection && iienh.IsEnhancedSection && !iienh.IsEnhancedSectionTitleOnly) canDoDel = false;
|
||||
if (iienh != null && iienh.IsEnhancedStep) canDoDel = false;
|
||||
if (canDoDel) cm.MenuItems.Add("Delete", new EventHandler(mi_Click));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1750,6 +1759,12 @@ namespace Volian.Controls.Library
|
||||
string chgId = OnGetChangeId(this, new vlnTreeItemInfoEventArgs(ii));
|
||||
ItemInfo newItemInfo = null;
|
||||
newItemInfo = ii.PasteChild(copyStartID, chgId);
|
||||
if (newItemInfo != null)
|
||||
{
|
||||
// paste enhanced steps if applicable (this code is only run if a step is pasted, not for a section).
|
||||
ItemInfo.EAddpingPart addpart = ItemInfo.EAddpingPart.Child;
|
||||
ItemInfo newEnhStep = newItemInfo.PasteEnhancedItems(copyStartID, ii, addpart, chgId);
|
||||
}
|
||||
}
|
||||
if (pasteSectIntoEmptySect)
|
||||
{
|
||||
@@ -1766,16 +1781,23 @@ namespace Volian.Controls.Library
|
||||
ItemInfo.EAddpingPart pasteOpt = newtype == MenuSelections.StepBefore ? ItemInfo.EAddpingPart.Before : ItemInfo.EAddpingPart.After;
|
||||
// If parent step is open in step editor, the 'OnPasteItemInfo' event will cause
|
||||
// the item to be pasted in the step editor and the tree.
|
||||
ItemInfo newItemInfo = null;
|
||||
if (ii.IsProcedure || !OnPasteItemInfo(this, new vlnTreeItemInfoPasteEventArgs(ii, copyStartID, pasteOpt, ii.MyContent.Type)))
|
||||
{
|
||||
// The parent step was not open in the step editor, just paste step (in data) and add treenode.
|
||||
// first, check if a changeid is required.
|
||||
string chgId = OnGetChangeId(this, new vlnTreeItemInfoEventArgs(ii));
|
||||
ItemInfo newItemInfo = null;
|
||||
if (newtype == MenuSelections.StepBefore)
|
||||
newItemInfo = ii.PasteSiblingBefore(copyStartID, chgId);
|
||||
else
|
||||
newItemInfo = ii.PasteSiblingAfter(copyStartID, chgId);
|
||||
if (newItemInfo != null)
|
||||
{
|
||||
// paste enhanced steps if applicable (this code is only run if a step is pasted, not for a section).
|
||||
ItemInfo.EAddpingPart addpart = ItemInfo.EAddpingPart.After;
|
||||
if (newtype == MenuSelections.StepBefore) addpart = ItemInfo.EAddpingPart.Before;
|
||||
ItemInfo newEnhStep = newItemInfo.PasteEnhancedItems(copyStartID, ii, addpart, chgId);
|
||||
}
|
||||
}
|
||||
SelectedNode = (VETreeNode)((newtype == MenuSelections.StepAfter) ? tn.NextNode : tn.PrevNode);
|
||||
}
|
||||
@@ -1789,7 +1811,12 @@ namespace Volian.Controls.Library
|
||||
// first, check if a changeid is required.
|
||||
string chgId = OnGetChangeId(this, new vlnTreeItemInfoEventArgs(ii));
|
||||
ItemInfo replItemInfo = Item.PasteReplace(ii, copyStartID, chgId);
|
||||
if(replItemInfo != null) OnOpenItem(this,new vlnTreeItemInfoEventArgs(replItemInfo));
|
||||
StepConfig replItemConfig = ii.MyConfig as StepConfig;
|
||||
if (replItemInfo != null)
|
||||
{
|
||||
OnOpenItem(this, new vlnTreeItemInfoEventArgs(replItemInfo));
|
||||
ItemInfo newEnhStep = replItemInfo.EnhancedPasteItem(copyStartID, ii, ItemInfo.EAddpingPart.Replace, chgId);
|
||||
}
|
||||
}
|
||||
SelectedNode = (VETreeNode)((prevtn != null) ? prevtn.NextNode : partn.FirstNode);
|
||||
}
|
||||
@@ -1978,6 +2005,11 @@ namespace Volian.Controls.Library
|
||||
procedure.Save();
|
||||
tn = new VETreeNode(_LastProcedureInfo);
|
||||
SelectedNode.Nodes.Add(tn); // add tree node to end of list.
|
||||
if (procedure.MyProcedureInfo.CreateEnhanced)
|
||||
{
|
||||
procedure.MyProcedureInfo.CreateEnhanced = false;
|
||||
CreateEnhancedForProcedure(newtype, procedure, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
p1 = procedure.ItemID;
|
||||
@@ -1990,6 +2022,7 @@ namespace Volian.Controls.Library
|
||||
int p2 = -1;
|
||||
int tvindex = SelectedNode.Index;
|
||||
// if inserting before, the parent is set in case previous is null, i.e. beginning of the list.
|
||||
ProcedureInfo savLastProcedureInfo = _LastProcedureInfo;
|
||||
using (Procedure procedure = Procedure.MakeProcedure((newtype == MenuSelections.ProcedureAfter) ? null : _LastProcedureInfo.ActiveParent, (newtype == MenuSelections.ProcedureAfter) ? _LastProcedureInfo : _LastProcedureInfo.MyPrevious, null, "New Procedure", 0))
|
||||
{
|
||||
ShowBrokenRules(procedure.BrokenRulesCollection);
|
||||
@@ -2000,6 +2033,11 @@ namespace Volian.Controls.Library
|
||||
tn = new VETreeNode(_LastProcedureInfo);
|
||||
TreeNode par = SelectedNode.Parent;
|
||||
par.Nodes.Insert(tvindex + ((newtype == MenuSelections.ProcedureBefore) ? 0 : 1), tn);
|
||||
if (procedure.MyProcedureInfo.CreateEnhanced)
|
||||
{
|
||||
procedure.MyProcedureInfo.CreateEnhanced = false;
|
||||
CreateEnhancedForProcedure(newtype, procedure, savLastProcedureInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
p2 = procedure.ItemID;
|
||||
@@ -2044,6 +2082,7 @@ namespace Volian.Controls.Library
|
||||
using(Section section = CreateNewSection())
|
||||
{
|
||||
ShowBrokenRules(section.BrokenRulesCollection);
|
||||
SectionInfo savLastSectionInfo = _LastSectionInfo;
|
||||
SetLastValues(SectionInfo.Get(section.ItemID));
|
||||
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Section", section.SectionConfig)) == DialogResult.OK)
|
||||
{
|
||||
@@ -2051,6 +2090,12 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
tn = new VETreeNode(_LastSectionInfo);
|
||||
SelectedNode.Nodes.Add(tn); // add tree node to end of list.
|
||||
// if the new section was flagged as either having an enhanced link for Title or Contents, create the
|
||||
// Enhanced section:
|
||||
Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem.
|
||||
if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y")
|
||||
CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo);
|
||||
sectiontmp.Dispose();
|
||||
OnNodeSelect(this, new vlnTreeEventArgs(tn));
|
||||
}
|
||||
else
|
||||
@@ -2094,6 +2139,12 @@ namespace Volian.Controls.Library
|
||||
SelectedNode.Nodes.Add(tnPart);
|
||||
tn = new VETreeNode(_LastSectionInfo);
|
||||
tnPart.Nodes.Add(tn); // add tree node to end of list.
|
||||
// if the new section was flagged as either having an enhanced link for Title or Contents, create the
|
||||
// Enhanced section:
|
||||
Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem.
|
||||
if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y")
|
||||
CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo);
|
||||
sectiontmp.Dispose();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2117,15 +2168,23 @@ namespace Volian.Controls.Library
|
||||
using (Section section = Section.MakeSection((newtype == MenuSelections.SectionAfter) ? null : _LastSectionInfo.MyParent, (newtype == MenuSelections.SectionAfter) ? _LastSectionInfo : _LastSectionInfo.MyPrevious, null, "New Section", 10000))
|
||||
{
|
||||
ShowBrokenRules(section.BrokenRulesCollection);
|
||||
SectionInfo savLastSectionInfo = _LastSectionInfo;
|
||||
SetLastValues(SectionInfo.Get(section.ItemID));
|
||||
TreeNode par = SelectedNode.Parent;
|
||||
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Section", section.SectionConfig)) == DialogResult.OK)
|
||||
{
|
||||
int indx = tvindex + ((newtype == MenuSelections.SectionBefore) ? 0 : 1);
|
||||
if (indx >= par.Nodes.Count || (par.Nodes[indx] as VETreeNode).VEObject.ToString() != _LastSectionInfo.ToString())
|
||||
int itemido = (indx >= par.Nodes.Count)?-1:(((par.Nodes[indx] as VETreeNode).VEObject) as ItemInfo).ItemID;
|
||||
if (indx >= par.Nodes.Count || (par.Nodes[indx] as VETreeNode).VEObject.ToString() != _LastSectionInfo.ToString() || itemido !=section.ItemID)
|
||||
{
|
||||
tn = new VETreeNode(_LastSectionInfo);
|
||||
par.Nodes.Insert(indx, tn);
|
||||
// if the new section was flagged as either having an enhanced link for Title or Contents, create the
|
||||
// Enhanced section:
|
||||
Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem.
|
||||
if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y")
|
||||
CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo);
|
||||
sectiontmp.Dispose();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2166,6 +2225,151 @@ namespace Volian.Controls.Library
|
||||
OnNodeInsert(this, new vlnTreeEventArgs(SelectedNode));
|
||||
}
|
||||
}
|
||||
private void CreateEnhancedForProcedure(MenuSelections typ, Procedure sourceProc, ProcedureInfo lastProcedureInfo)
|
||||
{
|
||||
if (typ == MenuSelections.ProcedureAfter || typ == MenuSelections.ProcedureBefore) // new from procedure (before or after)
|
||||
{
|
||||
// The procedure that this is inserted from may not have associated enhanced procedures. Going up list, look for a procedure
|
||||
// that has enhanced.
|
||||
ItemInfo tmpPI = lastProcedureInfo;
|
||||
EnhancedDocuments eds = null;
|
||||
while (eds == null && tmpPI != null)
|
||||
{
|
||||
ProcedureConfig pc = tmpPI.MyConfig as ProcedureConfig;
|
||||
if (pc.MyEnhancedDocuments != null && pc.MyEnhancedDocuments.Count > 0)
|
||||
{
|
||||
eds = pc.MyEnhancedDocuments;
|
||||
break;
|
||||
}
|
||||
tmpPI = tmpPI.MyPrevious;
|
||||
}
|
||||
if (eds != null)
|
||||
{
|
||||
foreach (EnhancedDocument ped in eds)
|
||||
{
|
||||
ProcedureInfo epi = ProcedureInfo.Get(ped.ItemID);
|
||||
using (Procedure newenhProcedure = Procedure.MakeProcedure((typ == MenuSelections.ProcedureAfter) ? null : epi.ActiveParent, (typ == MenuSelections.ProcedureAfter) ? epi : epi.MyPrevious, null, "New Procedure", 0))
|
||||
{
|
||||
SaveEnhancedForProcedure(sourceProc, newenhProcedure, ped.Type);
|
||||
RefreshRelatedNode(ProcedureInfo.Get(newenhProcedure.ItemID));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
// do the following code if insert the procedure from docverion, or if no linked procedure was found above while doing an insert section from before/after
|
||||
DocVersionConfig dvc = sourceProc.MyProcedureInfo.MyDocVersion.MyConfig as DocVersionConfig;
|
||||
ProcedureConfig sourcecfg = sourceProc.ProcedureConfig;
|
||||
if (dvc != null)
|
||||
{
|
||||
foreach (DVEnhancedDocument ded in dvc.MyEnhancedDocuments)
|
||||
{
|
||||
// get the enhaced docversioninfo:
|
||||
DocVersionInfo enhDVInfo = DocVersionInfo.Get(ded.VersionID);
|
||||
using (Procedure newenhProcedure = Procedure.MakeProcedure(enhDVInfo, enhDVInfo.Procedures.Count != 0 ? enhDVInfo.Procedures[enhDVInfo.Procedures.Count - 1] : null, null, "New Procedure", 0))
|
||||
{
|
||||
SaveEnhancedForProcedure(sourceProc, newenhProcedure, ded.Type);
|
||||
RefreshRelatedNode(ProcedureInfo.Get(newenhProcedure.ItemID)); // this updates the treeview to include the new enhanced procedure
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void SaveEnhancedForProcedure(Procedure sourceProc, Procedure newenhProcedure, int enhtype)
|
||||
{
|
||||
ProcedureConfig newenhcfg = new ProcedureConfig(newenhProcedure);
|
||||
newenhcfg.AddEnhancedDocument(0, sourceProc.ItemID);
|
||||
newenhcfg.SaveEnhancedDocuments();
|
||||
using (Content c1 = Content.Get(newenhProcedure.ContentID))
|
||||
{
|
||||
c1.Config = newenhcfg.ToString();
|
||||
c1.Save();
|
||||
}
|
||||
sourceProc.ProcedureConfig.AddEnhancedDocument(enhtype, newenhProcedure.ItemID);
|
||||
sourceProc.ProcedureConfig.SaveEnhancedDocuments();
|
||||
using (Content cs = Content.Get(sourceProc.ContentID))
|
||||
{
|
||||
cs.Config = sourceProc.ProcedureConfig.ToString();
|
||||
cs.Save();
|
||||
}
|
||||
}
|
||||
private void CreateEnhancedForSection(MenuSelections typ, Section sourceSect, SectionInfo lastSectionInfo)
|
||||
{
|
||||
if (typ == MenuSelections.SectionAfter || typ == MenuSelections.SectionBefore)
|
||||
{
|
||||
ItemInfo tmpSI = lastSectionInfo;
|
||||
EnhancedDocuments eds = null; // need to find a good list, i.e. there may be non-linked sections before/after:
|
||||
while (eds == null && tmpSI != null)
|
||||
{
|
||||
SectionConfig sc = tmpSI.MyConfig as SectionConfig;
|
||||
if (sc.MyEnhancedDocuments != null && sc.MyEnhancedDocuments.Count > 0)
|
||||
{
|
||||
eds = sc.MyEnhancedDocuments;
|
||||
break;
|
||||
}
|
||||
tmpSI = tmpSI.MyPrevious;
|
||||
}
|
||||
if (eds != null) // found valid enhanced ids to insert from:
|
||||
{
|
||||
foreach (EnhancedDocument sed in eds)
|
||||
{
|
||||
SectionInfo esi = SectionInfo.Get(sed.ItemID);
|
||||
using (Section newenhSection = Section.MakeSection((typ == MenuSelections.SectionAfter) ? null : esi.ActiveParent, (typ == MenuSelections.SectionAfter) ? esi : esi.MyPrevious, null, "New Section", 10000))
|
||||
{
|
||||
SaveEnhancedForSection(sourceSect, newenhSection, sed.Type);
|
||||
RefreshRelatedNode(SectionInfo.Get(newenhSection.ItemID));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
// do the following code if insert the section from the procedure, or if no linked section was found above while doing an insert section from before/after
|
||||
ProcedureConfig pc = sourceSect.MyItemInfo.MyProcedure.MyConfig as ProcedureConfig;
|
||||
SectionConfig sourcecfg = sourceSect.SectionConfig;
|
||||
if (pc != null)
|
||||
{
|
||||
foreach (EnhancedDocument ed in pc.MyEnhancedDocuments)
|
||||
{
|
||||
// get the enhanced procedureinfo:
|
||||
ProcedureInfo enhInfo = ProcedureInfo.Get(ed.ItemID);
|
||||
if (enhInfo.LastChild(E_FromType.Section) != null)
|
||||
{
|
||||
using (Section newenhSection = Section.MakeSection(enhInfo, (enhInfo.Sections != null && enhInfo.Sections.Count != 0) ? enhInfo.Sections[enhInfo.Sections.Count - 1] : null, null, "New Section", 10000))
|
||||
{
|
||||
SaveEnhancedForSection(sourceSect, newenhSection, ed.Type);
|
||||
RefreshRelatedNode(SectionInfo.Get(newenhSection.ItemID));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemInfo newenhSectionII = enhInfo.InsertChild(E_FromType.Section, 10000, "New Section", null);
|
||||
using (Section newenhSect = Section.Get(newenhSectionII.ItemID))
|
||||
{
|
||||
SaveEnhancedForSection(sourceSect, newenhSect, ed.Type);
|
||||
RefreshRelatedNode(SectionInfo.Get(newenhSect.ItemID));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void SaveEnhancedForSection(Section sourceSect, Section newenhSection, int enhtype)
|
||||
{
|
||||
SectionConfig newenhcfg = new SectionConfig(newenhSection);
|
||||
newenhcfg.AddEnhancedDocument(0, sourceSect.ItemID);
|
||||
newenhcfg.SaveEnhancedDocuments(); // does this save data?
|
||||
using (Content c1 = Content.Get(newenhSection.ContentID))
|
||||
{
|
||||
c1.Config = newenhcfg.ToString();
|
||||
c1.Save();
|
||||
}
|
||||
sourceSect.SectionConfig.AddEnhancedDocument(enhtype, newenhSection.ItemID);
|
||||
sourceSect.SectionConfig.SaveEnhancedDocuments();
|
||||
using (Content cs = Content.Get(sourceSect.ContentID))
|
||||
{
|
||||
cs.Config = sourceSect.SectionConfig.ToString();
|
||||
cs.Save();
|
||||
}
|
||||
}
|
||||
|
||||
private Section CreateNewSection()
|
||||
{
|
||||
if(_LastItemInfo.LastChild(E_FromType.Section) != null)
|
||||
@@ -2175,12 +2379,21 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
private VETreeNode InsertChildStep(VETreeNode tn)
|
||||
{
|
||||
// 11/17/15: if inserted with step editor open, step gets inserted as child first child. If step editor is not
|
||||
// open, step gets inserted at end (as last item in list)
|
||||
|
||||
// If parent step is open in editor, use the OnInsertItemInfo to insert step & add RTBItems to step editor panel
|
||||
ItemInfo ii = tn.VEObject as ItemInfo;
|
||||
if (OnInsertItemInfo(this, new vlnTreeItemInfoInsertEventArgs(ii, E_InsertType.Child, "New Step", 20002, E_FromType.Step)))
|
||||
{
|
||||
return null; // should we try to get to the child?
|
||||
if (ii.IsStep) return null;
|
||||
// if this was a section, it may have enhanced, so the enhanced steps will need to be created also.
|
||||
SectionConfig scfg = ii.MyConfig as SectionConfig;
|
||||
if (scfg.Section_LnkEnh != "Y") return null;
|
||||
SetLastValues(StepInfo.Get(ii.Steps[0].ItemID));
|
||||
}
|
||||
else
|
||||
{
|
||||
// The parent step was not open in the step editor, just create new step and add treenode.
|
||||
using (Step step = Step.MakeStep(_LastItemInfo, _LastItemInfo.LastChild(E_FromType.Step), null, "New Step", 20002, E_FromType.Step))
|
||||
{
|
||||
@@ -2189,6 +2402,35 @@ namespace Volian.Controls.Library
|
||||
tn = new VETreeNode(_LastStepInfo);
|
||||
SelectedNode.Nodes.Add(tn); // add tree node to end of list.
|
||||
}
|
||||
}
|
||||
|
||||
// see if enhanced related steps need created:
|
||||
SectionConfig scfgE = _LastItemInfo.MyActiveSection.MyConfig as SectionConfig;
|
||||
if (scfgE != null && scfgE.Section_LnkEnh=="Y")
|
||||
{
|
||||
// set up which item to insert from based on whether editor was open (see comment from 11/17 above).
|
||||
EnhancedDocuments enhdocs = null;
|
||||
ItemInfo.EAddpingPart addpart = ItemInfo.EAddpingPart.Child;
|
||||
if (_LastItemInfo.MyPrevious != null) // the code above will do the MakeStep regardless of whether editor is up if this is the only step.
|
||||
{
|
||||
addpart = ItemInfo.EAddpingPart.After;
|
||||
ItemInfo lstSrc = _LastItemInfo.MyPrevious;
|
||||
StepConfig stcfg = lstSrc.MyConfig as StepConfig;
|
||||
if (stcfg == null) enhdocs = scfgE.MyEnhancedDocuments;
|
||||
else enhdocs = stcfg.MyEnhancedDocuments;
|
||||
}
|
||||
else
|
||||
{
|
||||
enhdocs = scfgE.MyEnhancedDocuments;
|
||||
}
|
||||
foreach (EnhancedDocument ed in enhdocs)
|
||||
{
|
||||
// the new source step's item is passed in to know what type & what to link to.
|
||||
// The ed.Type & itemid show what type of enhanced document (used to create new
|
||||
// config Type)
|
||||
_LastItemInfo.DoAddEnhancedSteps(ed.Type, ed.ItemID, addpart);
|
||||
}
|
||||
}
|
||||
return tn;
|
||||
}
|
||||
|
||||
@@ -2198,8 +2440,10 @@ namespace Volian.Controls.Library
|
||||
ItemInfo ii = tn.VEObject as ItemInfo;
|
||||
if (OnInsertItemInfo(this, new vlnTreeItemInfoInsertEventArgs(ii, (newtype == MenuSelections.StepAfter) ? E_InsertType.After : E_InsertType.Before, "New Step")))
|
||||
{
|
||||
return (VETreeNode)((newtype == MenuSelections.StepAfter) ? tn.NextNode : tn.PrevNode);
|
||||
tn = (VETreeNode)((newtype == MenuSelections.StepAfter) ? tn.NextNode : tn.PrevNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The parent step was not open in the step editor, just create new step and add treenode.
|
||||
int tvindex = SelectedNode.Index;
|
||||
// if inserting before, the parent is set in case previous is null, i.e. beginning of the list.
|
||||
@@ -2214,6 +2458,25 @@ namespace Volian.Controls.Library
|
||||
TreeNode par = SelectedNode.Parent;
|
||||
par.Nodes.Insert(tvindex + ((newtype == MenuSelections.StepBefore) ? 0 : 1), tn);
|
||||
}
|
||||
}
|
||||
if (tn != null)
|
||||
{
|
||||
// add enhanced steps if applicable (this code is only run if a step is inserted, not for a section).
|
||||
// Also, NOTE that this is not needed for InsertChildStep from tree because there is no menu item
|
||||
// to support inserting a type that would have enhanced from tree.
|
||||
StepConfig sib = ii.MyConfig as StepConfig;
|
||||
foreach (EnhancedDocument ed in sib.MyEnhancedDocuments)
|
||||
{
|
||||
// create a new enhanced step and link it to this new source step.
|
||||
// the new source step's item is passed in to know what type & what to link to.
|
||||
// The ed.Type & itemid show what type of enhanced document (use to create new
|
||||
// config Type) and itemid is the one to insert after.
|
||||
ItemInfo.EAddpingPart addpart = ItemInfo.EAddpingPart.After;
|
||||
if (newtype == MenuSelections.StepBefore) addpart = ItemInfo.EAddpingPart.Before;
|
||||
ItemInfo newSourceStep = tn.VEObject as ItemInfo;
|
||||
newSourceStep.DoAddEnhancedSteps(ed.Type, ed.ItemID, addpart);
|
||||
}
|
||||
}
|
||||
return tn;
|
||||
}
|
||||
private void ShowBrokenRules(BrokenRulesCollection brs)
|
||||
@@ -2299,19 +2562,71 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
else if (_LastDocVersionInfo != null)
|
||||
{
|
||||
// if this has enhanced linked DocVersions, delete them first.
|
||||
DocVersionConfig dvc = _LastDocVersionInfo.MyConfig as DocVersionConfig;
|
||||
if (dvc != null && dvc.MyEnhancedDocuments != null && dvc.MyEnhancedDocuments.Count > 0)
|
||||
{
|
||||
foreach (DVEnhancedDocument dve in dvc.MyEnhancedDocuments)
|
||||
{
|
||||
if (dve.Type != 0) DocVersion.Delete(dve.VersionID);
|
||||
}
|
||||
}
|
||||
DocVersion.Delete(_LastDocVersionInfo.VersionID);
|
||||
_LastDocVersionInfo = null;
|
||||
return true;
|
||||
}
|
||||
else if (_LastProcedureInfo != null)
|
||||
{
|
||||
//If there are enhanced, they will also need deleted, save the ids so that they
|
||||
// can be deleted after this item gets deleted.
|
||||
List<int> enhIds = new List<int>();
|
||||
ProcedureConfig prc = _LastProcedureInfo.MyConfig as ProcedureConfig;
|
||||
foreach (EnhancedDocument ed in prc.MyEnhancedDocuments)
|
||||
if (ed.Type != 0) enhIds.Add(ed.ItemID);
|
||||
// always return false because an event gets fired to delete tree nodes.
|
||||
if (!DeleteItemInfoAndChildren(_LastProcedureInfo)) return false;
|
||||
_LastProcedureInfo = null;
|
||||
foreach (int enhId in enhIds)
|
||||
{
|
||||
ProcedureInfo pi = ProcedureInfo.Get(enhId);
|
||||
// if the item was displayed in the editor, the 'DeleteItemInfoAndChildren' call
|
||||
// above will go through user interface code that deletes the enhanced, so 'Get'
|
||||
// will return a null (i.e. the data no longer exists).
|
||||
if (pi != null)
|
||||
{
|
||||
if (!DeleteItemInfoAndChildren(pi)) Console.WriteLine("do an error log item");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (_LastSectionInfo != null)
|
||||
{
|
||||
// For sections, there are a number of things to check for if enhanced is active:
|
||||
// 1) in a source and the enhanced link can be none, title or contents.
|
||||
// 2) if none, just delete
|
||||
// 3) If just title and in source, clear links in enhanced back to this source
|
||||
// before delete.
|
||||
// 4) If in enhanced, by source has link type set to title, can delete this
|
||||
// section, but first clear source's links
|
||||
|
||||
//If there are enhanced, they will also need deleted, save the ids so that they
|
||||
// can be deleted after this item gets deleted.
|
||||
List<int> enhIds = new List<int>();
|
||||
SectionConfig sec = _LastSectionInfo.MyConfig as SectionConfig;
|
||||
if (_LastSectionInfo.IsEnhancedSectionTitleOnly)
|
||||
{
|
||||
_LastSectionInfo.ClearEnhancedSectionFromSource(sec.MyEnhancedDocuments[0].ItemID);
|
||||
}
|
||||
else if (sec.Section_LnkEnh == "Y")
|
||||
{
|
||||
foreach (EnhancedDocument ed in sec.MyEnhancedDocuments)
|
||||
if (ed.Type != 0) enhIds.Add(ed.ItemID);
|
||||
}
|
||||
else if (sec.Section_LnkEnh == "T")
|
||||
{
|
||||
// just clear enhanced links back
|
||||
_LastSectionInfo.ClearEnhancedSectionLink();
|
||||
}
|
||||
OnSectionShouldClose(this, new vlnTreeSectionInfoEventArgs(_LastSectionInfo,true));
|
||||
// always return false because an event gets fired to delete tree nodes.
|
||||
if (!DeleteItemInfoAndChildren(_LastSectionInfo))
|
||||
@@ -2321,13 +2636,43 @@ namespace Volian.Controls.Library
|
||||
WordSectionEventArgs args = new WordSectionEventArgs(_LastSectionInfo);
|
||||
OnWordSectionDeleted(this, args);
|
||||
_LastSectionInfo = null;
|
||||
foreach (int enhId in enhIds)
|
||||
{
|
||||
SectionInfo si = SectionInfo.Get(enhId);
|
||||
// if the item was displayed in the editor, the 'DeleteItemInfoAndChildren' call
|
||||
// above will go through user interface code that deletes the enhanced, so 'Get'
|
||||
// will return a null (i.e. the data no longer exists).
|
||||
if (si != null)
|
||||
{
|
||||
if (!DeleteItemInfoAndChildren(si)) Console.WriteLine("do an error log item");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (_LastStepInfo != null)
|
||||
{
|
||||
//If there are enhanced, they will also need deleted, save the ids so that they
|
||||
// can be deleted after this item gets deleted. Note that if the step(s) were
|
||||
// displayed in step editor, that code deletes the enhanced steps.
|
||||
List<int> enhIds = new List<int>();
|
||||
StepConfig sc = _LastStepInfo.MyConfig as StepConfig;
|
||||
foreach (EnhancedDocument ed in sc.MyEnhancedDocuments)
|
||||
if (ed.Type != 0) enhIds.Add(ed.ItemID);
|
||||
|
||||
// always return false because an event gets fired to delete tree nodes.
|
||||
if (!DeleteItemInfoAndChildren(_LastStepInfo)) return false;
|
||||
_LastStepInfo = null;
|
||||
foreach (int enhId in enhIds)
|
||||
{
|
||||
StepInfo si = StepInfo.Get(enhId);
|
||||
// if the item was displayed in the editor, the 'DeleteItemInfoAndChildren' call
|
||||
// above will go through user interface code that deletes the enhanced, so 'Get'
|
||||
// will return a null (i.e. the data no longer exists).
|
||||
if (si != null)
|
||||
{
|
||||
if (!DeleteItemInfoAndChildren(si)) Console.WriteLine("do an error log item");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -3022,6 +3367,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
public bool CompareVEObject(IVEDrillDownReadOnly obj1, IVEDrillDownReadOnly obj2)
|
||||
{
|
||||
if (obj1.GetType().Name != obj2.GetType().Name) return false;
|
||||
ItemInfo myItem = obj1 as ItemInfo;
|
||||
if (myItem != null)
|
||||
if (myItem.ItemID == ((ItemInfo)obj2).ItemID) return true;
|
||||
|
Reference in New Issue
Block a user