/// <summary> /// Adds a new function /// </summary> /// <param name="function"></param> public FunctionTreeNode AddFunction(DataDictionary.Functions.Function function) { // Ensure that functions always have a type if (function.ReturnType == null) { function.ReturnType = function.EFSSystem.BoolType; } Item.appendFunctions(function); FunctionTreeNode retVal = new FunctionTreeNode(function); Nodes.Add(retVal); SortSubNodes(); return(retVal); }
/// <summary> /// Accepts drop of a tree node, in a drag & drop operation /// </summary> /// <param name="SourceNode"></param> public override void AcceptDrop(BaseTreeNode SourceNode) { base.AcceptDrop(SourceNode); if (SourceNode is FunctionTreeNode) { FunctionTreeNode node = SourceNode as FunctionTreeNode; DataDictionary.Functions.Function function = node.Item; DataDictionary.Functions.Function duplFunction = DataDictionary.OverallFunctionFinder.INSTANCE.findByName(function.Dictionary, function.Name); if (duplFunction != null) // If there is a function with the same name, we must delete it { if (MessageBox.Show("Are you sure you want to move the corresponding function?", "Move action", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { for (int i = 0; i < Nodes.Count; i++) { FunctionTreeNode temp = Nodes[i] as FunctionTreeNode; if (temp.Item.Name == function.Name) { temp.Delete(); } } node.Delete(); AddFunction(function); } } else { node.Delete(); AddFunction(function); } } else if (SourceNode is SpecificationView.ParagraphTreeNode) { SpecificationView.ParagraphTreeNode node = SourceNode as SpecificationView.ParagraphTreeNode; DataDictionary.Specification.Paragraph paragaph = node.Item; DataDictionary.Functions.Function function = (DataDictionary.Functions.Function)DataDictionary.Generated.acceptor.getFactory().createFunction(); function.Name = paragaph.Name; DataDictionary.ReqRef reqRef = (DataDictionary.ReqRef)DataDictionary.Generated.acceptor.getFactory().createReqRef(); reqRef.Name = paragaph.FullId; function.appendRequirements(reqRef); AddFunction(function); } }
/// <summary> /// Accepts drop of a tree node, in a drag & drop operation /// </summary> /// <param name="sourceNode"></param> public override void AcceptDrop(BaseTreeNode sourceNode) { base.AcceptDrop(sourceNode); if (sourceNode is FunctionTreeNode) { FunctionTreeNode node = sourceNode as FunctionTreeNode; Function function = node.Item; Function duplFunction = OverallFunctionFinder.INSTANCE.findByName(function.Dictionary, function.Name); if (duplFunction != null) // If there is a function with the same name, we must delete it { if ( MessageBox.Show("Are you sure you want to move the corresponding function?", "Move action", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { for (int i = 0; i < Nodes.Count; i++) { FunctionTreeNode temp = Nodes[i] as FunctionTreeNode; if (temp != null && temp.Item.Name == function.Name) { temp.Delete(); } } node.Delete(); Item.appendFunctions(function); } } else { node.Delete(); Item.appendFunctions(function); } } else if (sourceNode is ParagraphTreeNode) { ParagraphTreeNode node = sourceNode as ParagraphTreeNode; Paragraph paragraph = node.Item; Function function = Function.CreateDefault(Item.Functions); Item.appendFunctions(function); function.FindOrCreateReqRef(paragraph); } }