support paste into parent if steps are open in step editor
implement functionality behind the Paste menu items when pasting from a parent (proc pasted into docversion, section into proc, etc)
This commit is contained in:
parent
90b46d6873
commit
dbcca8a8b9
@ -442,6 +442,9 @@ namespace Volian.Controls.Library
|
||||
EditItem edtitm = pg.MyStepTabPanel.MyStepPanel._LookupEditItems[myItemInfo.ItemID];
|
||||
switch (pasteType)
|
||||
{
|
||||
case ItemInfo.EAddpingPart.Child:
|
||||
edtitm.PasteChild(copyStartID);
|
||||
break;
|
||||
case ItemInfo.EAddpingPart.Before:
|
||||
edtitm.PasteSiblingBefore(copyStartID);
|
||||
break;
|
||||
@ -450,11 +453,11 @@ namespace Volian.Controls.Library
|
||||
break;
|
||||
case ItemInfo.EAddpingPart.Replace:
|
||||
EditItem ei = edtitm.PasteReplace(copyStartID);
|
||||
if (ei.MyItemInfo.ItemID != edtitm.MyItemInfo.ItemID)
|
||||
{
|
||||
edtitm.Dispose();
|
||||
MyCopyStep = ei.MyItemInfo;
|
||||
}
|
||||
if (ei.MyItemInfo.ItemID != edtitm.MyItemInfo.ItemID)
|
||||
{
|
||||
edtitm.Dispose();
|
||||
MyCopyStep = ei.MyItemInfo;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false; ;
|
||||
|
@ -1233,6 +1233,55 @@ namespace Volian.Controls.Library
|
||||
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.After, newItemInfo.MyContent.Type));
|
||||
|
||||
}
|
||||
public void PasteChild(int copyStartID)
|
||||
{
|
||||
ItemInfo newItemInfo = MyItemInfo.PasteChild(copyStartID, GetChangeId(MyItemInfo));
|
||||
|
||||
E_FromType fromType = E_FromType.Step;
|
||||
if (MyItemInfo.MyContent.Type < 10000)
|
||||
fromType = E_FromType.Procedure;
|
||||
else if (MyItemInfo.MyContent.Type < 20000)
|
||||
fromType = E_FromType.Section;
|
||||
else if (MyItemInfo.MyContent.Type > 19999)
|
||||
{
|
||||
int tmptype = (int)MyItemInfo.MyContent.Type - 20000;
|
||||
if (MyItemInfo.IsCaution) fromType = E_FromType.Caution;
|
||||
else if (MyItemInfo.IsNote) fromType = E_FromType.Note;
|
||||
else if (MyItemInfo.IsTable) fromType = E_FromType.Table;
|
||||
else if (MyItemInfo.IsRNOPart) fromType = E_FromType.RNO;
|
||||
}
|
||||
EditItem nextItem = GetNextItem(fromType, newItemInfo);
|
||||
EditItem newEditItem;
|
||||
|
||||
switch (fromType)
|
||||
{
|
||||
case E_FromType.Caution:
|
||||
newEditItem = this.AddChildBefore(newItemInfo, nextItem);
|
||||
break;
|
||||
case E_FromType.Note:
|
||||
newEditItem = this.AddChildBefore(newItemInfo, nextItem);
|
||||
break;
|
||||
case E_FromType.Procedure:
|
||||
newEditItem = this.AddChildAfter(newItemInfo, nextItem);
|
||||
break;
|
||||
case E_FromType.RNO:
|
||||
newEditItem = this.AddChildRNO(newItemInfo, nextItem);
|
||||
break;
|
||||
case E_FromType.Section:
|
||||
newEditItem = this.AddChildAfter(newItemInfo, nextItem);
|
||||
break;
|
||||
case E_FromType.Step:
|
||||
newEditItem = this.AddChildAfter(newItemInfo, nextItem);
|
||||
break;
|
||||
case E_FromType.Table:
|
||||
newEditItem = this.AddChildAfter(newItemInfo, nextItem);
|
||||
break;
|
||||
default:
|
||||
newEditItem = this.AddChildAfter(newItemInfo, nextItem);
|
||||
break;
|
||||
}
|
||||
MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
|
||||
}
|
||||
public EditItem PasteReplace(int copyStartID)
|
||||
{
|
||||
// To allow a Paste Step into an empty (new) step/substep, we need to add a character to the the Text field
|
||||
|
@ -1077,9 +1077,9 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
#region MenuPaste
|
||||
// Find what's in paste buffer & determine whether the paste can occur for the selected node.
|
||||
ItemInfo iiClipboard = OnClipboardStatus(this,new vlnTreeEventArgs(tn));
|
||||
if(iiClipboard != null)
|
||||
{
|
||||
ItemInfo iiClipboard = OnClipboardStatus(this, new vlnTreeEventArgs(tn));
|
||||
if (iiClipboard != null)
|
||||
{
|
||||
// can it be pasted at current node.
|
||||
if (tn.VEObject as DocVersionInfo != null) // paste item must be a proc
|
||||
{
|
||||
@ -1088,14 +1088,15 @@ namespace Volian.Controls.Library
|
||||
else
|
||||
{
|
||||
ItemInfo iiPasteHere = tn.VEObject as ItemInfo;
|
||||
if (iiPasteHere == null) return;
|
||||
bool okToReplace = iiClipboard.ItemID != iiPasteHere.ItemID;
|
||||
if (iiPasteHere == null) return;
|
||||
bool okToReplace = iiClipboard.ItemID != iiPasteHere.ItemID;
|
||||
if (iiPasteHere != null)
|
||||
{
|
||||
SectionInfo si = (tn.VEObject as SectionInfo != null) ? tn.VEObject as SectionInfo : null;
|
||||
if (iiPasteHere.IsProcedure && iiClipboard.IsProcedure) // procedure can be pasted before/replace/after
|
||||
{
|
||||
cm.MenuItems.Add("Paste Procedure Before", new EventHandler(mi_Click));
|
||||
if (okToReplace) cm.MenuItems.Add("Replace Existing Procedure", new EventHandler(mi_Click));
|
||||
if (okToReplace) cm.MenuItems.Add("Replace Existing Procedure", new EventHandler(mi_Click));
|
||||
cm.MenuItems.Add("Paste Procedure After", new EventHandler(mi_Click));
|
||||
}
|
||||
else if (iiPasteHere.IsProcedure && iiClipboard.IsSection) // procedure must have sections only
|
||||
@ -1103,21 +1104,28 @@ namespace Volian.Controls.Library
|
||||
else if (iiPasteHere.IsSection && iiClipboard.IsSection)
|
||||
{
|
||||
cm.MenuItems.Add("Paste Section Before", new EventHandler(mi_Click));
|
||||
if (okToReplace) cm.MenuItems.Add("Replace Existing Section", new EventHandler(mi_Click));
|
||||
if (okToReplace) cm.MenuItems.Add("Replace Existing Section", new EventHandler(mi_Click));
|
||||
cm.MenuItems.Add("Paste Section After", new EventHandler(mi_Click));
|
||||
if (si.ActiveFormat.PlantFormat.FormatData.SectData.UseMetaSections && iiPasteHere.IsStepSection && iiClipboard.IsStepSection)
|
||||
{
|
||||
// only paste a subsection if the paste here is an empty section or has
|
||||
// subsections.
|
||||
if (iiPasteHere.Sections == null || iiPasteHere.Sections.Count > 0)
|
||||
cm.MenuItems.Add("Paste Subsection", new EventHandler(mi_Click));
|
||||
}
|
||||
}
|
||||
else if (iiPasteHere.IsStepSection && iiClipboard.IsStep)
|
||||
cm.MenuItems.Add("Paste Step", new EventHandler(mi_Click));
|
||||
else if (iiPasteHere.IsStep && iiClipboard.IsStep)
|
||||
{
|
||||
if (AddToInsertMenu(iiPasteHere, 0)) cm.MenuItems.Add("Paste Step Before", new EventHandler(mi_Click));
|
||||
if (okToReplace) cm.MenuItems.Add("Replace Existing Step", new EventHandler(mi_Click));
|
||||
if (okToReplace) cm.MenuItems.Add("Replace Existing Step", new EventHandler(mi_Click));
|
||||
if (AddToInsertMenu(iiPasteHere, 1)) cm.MenuItems.Add("Paste Step After", new EventHandler(mi_Click));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion menupaste
|
||||
}
|
||||
//jcb multiunit
|
||||
void miMultiUnit_Click(object sender, EventArgs e)
|
||||
@ -1246,6 +1254,7 @@ namespace Volian.Controls.Library
|
||||
case "Paste Step Before":
|
||||
case "Replace Existing Step":
|
||||
case "Paste Step After":
|
||||
case "Paste Subsection":
|
||||
tv_NodePaste(mi.Text);
|
||||
break;
|
||||
case "Delete":
|
||||
@ -1487,8 +1496,8 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
private void tv_NodePaste(string p)
|
||||
{
|
||||
ItemInfo iiClipboard = OnClipboardStatus(this, null);
|
||||
if (iiClipboard == null) return;
|
||||
ItemInfo iiClipboard = OnClipboardStatus(this, null);
|
||||
if (iiClipboard == null) return;
|
||||
string message = string.Empty;
|
||||
if (iiClipboard.MyContent.MyEntry == null)
|
||||
{
|
||||
@ -1508,22 +1517,96 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
VETreeNode tn = SelectedNode as VETreeNode;
|
||||
DocVersionInfo dvi = tn.VEObject as DocVersionInfo;
|
||||
// Check for paste into a docversion - queries/code is different than paste related to an item (into a proc or section)
|
||||
if (dvi != null)
|
||||
{
|
||||
return;
|
||||
// If the docversion has procedures (children), change to a 'paste-after the last procedure'.
|
||||
if (tn.Nodes.Count > 0)
|
||||
{
|
||||
// if the node count is 1, children may not have been loaded yet - load if necessary:
|
||||
if (tn.Nodes.Count == 1 && tn.Nodes[0].Text.ToUpper().Contains("DUMMY VETREENODE"))
|
||||
tn.LoadChildren();
|
||||
|
||||
// assume that item to paste is a procedure, otherwise the menuing would not have
|
||||
// included the paste options
|
||||
tn = (VETreeNode) tn.Nodes[tn.Nodes.Count - 1];
|
||||
p = "After";
|
||||
}
|
||||
else // this is an empty docversion:
|
||||
{
|
||||
// First check if the doc version has RO's
|
||||
// Paste as a child to the doc version:
|
||||
this.Cursor = Cursors.WaitCursor;
|
||||
PasteAsDocVersionChild(tn, iiClipboard.ItemID);
|
||||
this.Cursor = Cursors.Default;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ItemInfo iiPaste = tn.VEObject as ItemInfo;
|
||||
if (iiPaste == null) return;
|
||||
this.Cursor = Cursors.WaitCursor;
|
||||
if (p.IndexOf("Before") > -1)
|
||||
PasteBeforeOrAfter(MenuSelections.StepBefore, tn, iiClipboard.ItemID);
|
||||
else if (p.IndexOf("After") > -1)
|
||||
PasteBeforeOrAfter(MenuSelections.StepAfter, tn, iiClipboard.ItemID);
|
||||
else if (p.IndexOf("Replace") > -1)
|
||||
PasteReplace(tn, iiClipboard.ItemID);
|
||||
this.Cursor = Cursors.Default;
|
||||
}
|
||||
this.Cursor = Cursors.WaitCursor;
|
||||
if (p.IndexOf("Before") > -1)
|
||||
PasteBeforeOrAfter(MenuSelections.StepBefore, tn, iiClipboard.ItemID);
|
||||
else if (p.IndexOf("After") > -1)
|
||||
PasteBeforeOrAfter(MenuSelections.StepAfter, tn, iiClipboard.ItemID);
|
||||
else if (p.IndexOf("Replace") > -1)
|
||||
PasteReplace(tn, iiClipboard.ItemID);
|
||||
else // paste as child
|
||||
PasteAsChild(tn, iiClipboard.ItemID);
|
||||
this.Cursor = Cursors.Default;
|
||||
}
|
||||
|
||||
private void PasteAsDocVersionChild(VETreeNode tn, int copyStartID)
|
||||
{
|
||||
// Only need to handle paste in tree since this will create a new procedure.
|
||||
DocVersionInfo dvi = tn.VEObject as DocVersionInfo;
|
||||
if (dvi.DocVersionAssociationCount == 0)
|
||||
{
|
||||
// Set docversionassociation to the copied docversion association
|
||||
// so that the rofst for ro's can be found. (if there is no association set)
|
||||
ROFstInfo rfi = GetAssociationRofstId(copyStartID);
|
||||
Association myAs = Association.MakeAssociation(dvi.Get(), rfi.GetJustROFst(), "");
|
||||
dvi.RefreshDocVersionAssociations();
|
||||
}
|
||||
ItemInfo newProc = dvi.PasteChild(copyStartID);
|
||||
VETreeNode tn1 = new VETreeNode(newProc);
|
||||
SelectedNode.Nodes.Add(tn1); // add tree node to end of list.
|
||||
SelectedNode = tn1;
|
||||
}
|
||||
|
||||
private ROFstInfo GetAssociationRofstId(int copyStartID)
|
||||
{
|
||||
ItemInfo ii = ItemInfo.Get(copyStartID);
|
||||
return ii.MyDocVersion.DocVersionAssociations[0].MyROFst;
|
||||
}
|
||||
private void PasteAsChild(VETreeNode tn, int copyStartID)
|
||||
{
|
||||
bool pasteSectIntoEmptySect = false;
|
||||
ItemInfo ii = tn.VEObject as ItemInfo;
|
||||
if (ii.IsStepSection) // is pasting a subsection, need to force a reload of the treeview
|
||||
{
|
||||
ItemInfo tmpcopy = ItemInfo.Get(copyStartID);
|
||||
if (tmpcopy.IsStepSection) pasteSectIntoEmptySect = true;
|
||||
}
|
||||
ItemInfo.EAddpingPart pasteOpt = ItemInfo.EAddpingPart.Child;
|
||||
// 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.
|
||||
if (!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;
|
||||
newItemInfo = ii.PasteChild(copyStartID, chgId);
|
||||
}
|
||||
if (pasteSectIntoEmptySect)
|
||||
{
|
||||
tn.ChildrenLoaded = false; // force a reload of treenode
|
||||
tn.LoadChildren(true);
|
||||
}
|
||||
SelectedNode = tn;
|
||||
}
|
||||
private void PasteBeforeOrAfter(MenuSelections newtype, VETreeNode tn, int copyStartID)
|
||||
{
|
||||
// If paste-from step is open in the editor, use the OnPasteItemInfo to paste the step and add RTBItems
|
||||
|
Loading…
x
Reference in New Issue
Block a user