Exemplo n.º 1
0
        /// <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);
            }
        }