예제 #1
0
        /// <summary>
        /// Constructs the form using the given map info as the source of constructs to match,
        /// and the given file information as a source of constructs to use as matches
        /// </summary>
        /// <param name="fileInfo"></param>
        /// <param name="node"></param>
        public FormSelectMatch(TextFileInformation fileInfo, CodeRootMapNode node)
        {
            InitializeComponent();
            FormSelectMatchHeading.Text = "";
            ArchAngel.Interfaces.Events.ShadeMainForm();
            fileInformation = fileInfo;
            currentNode     = node;

            if (fileInformation.CodeRootMap == null)
            {
                throw new ArgumentException("Cannot match constructs if the diff has not or cannot be performed.");
            }

            if (node.ContainsBaseConstruct == false)
            {
                throw new ArgumentException(
                          "Cannot match constructs when there are no constucts set in the MapInfoType given. "
                          + "Please set at least one of these constructs before starting the Select Match Form.");
            }

            missingObjects = node.DetermineMissingConstructs();
            FillOptionsForConstructs();
            FillComboBoxes();

            SetDefaultSelectedConstruct();
        }
        public void Map_Contains_CodeRoot()
        {
            CodeRootMap    map      = new CodeRootMap();
            ICodeRoot      coderoot = mocks.StrictMock <ICodeRoot>();
            IBaseConstruct bc1      = mocks.DynamicMock <IBaseConstruct>();
            IBaseConstruct bc2      = mocks.DynamicMock <IBaseConstruct>();

            Utility.SetupBaseConstructs(mocks, bc1, bc2, coderoot);

            using (mocks.Playback())
            {
                map.AddCodeRoot(coderoot, Version.User);
            }

            Assert.That(map.ChildNodes, Has.Count(1));
            Assert.That(map.AllNodes, Has.Count(2));
            Assert.That(map.ChildNodes[0], Is.Not.Null);
            Assert.That(map.ChildNodes[0].IsTreeRoot, Is.False);
            Assert.That(map.ChildNodes[0].UserObj, Is.SameAs(bc1));
            Assert.That(map.ChildNodes[0].Omit, Is.False);
            Assert.That(map.ChildNodes[0].ParentNode, Is.SameAs(map));
            Assert.That(map.ChildNodes[0].ParentTree, Is.SameAs(map));

            CodeRootMapNode node = map.ChildNodes[0].ChildNodes[0];

            Assert.That(node, Is.Not.Null);
            Assert.That(node.IsTreeRoot, Is.False);
            Assert.That(node.UserObj, Is.SameAs(bc2));
            Assert.That(node.Omit, Is.False);
            Assert.That(node.ParentNode, Is.SameAs(map.ChildNodes[0]));
            Assert.That(node.ParentTree, Is.SameAs(map));
        }
예제 #3
0
        /// <summary>
        /// Constructs the form using the given map info as the source of constructs to match, 
        /// and the given file information as a source of constructs to use as matches
        /// </summary>
        /// <param name="fileInfo"></param>
        /// <param name="node"></param>
        public FormSelectMatch(TextFileInformation fileInfo, CodeRootMapNode node)
        {
            InitializeComponent();
            FormSelectMatchHeading.Text = "";
            ArchAngel.Interfaces.Events.ShadeMainForm();
            fileInformation = fileInfo;
            currentNode = node;

            if(fileInformation.CodeRootMap == null)
            {
                throw new ArgumentException("Cannot match constructs if the diff has not or cannot be performed.");
            }

            if (node.ContainsBaseConstruct == false)
            {
                throw new ArgumentException(
                    "Cannot match constructs when there are no constucts set in the MapInfoType given. "
                    + "Please set at least one of these constructs before starting the Select Match Form.");
            }

            missingObjects = node.DetermineMissingConstructs();
            FillOptionsForConstructs();
            FillComboBoxes();

            SetDefaultSelectedConstruct();
        }
예제 #4
0
        private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
        {
            if (treeListObjects.SelectedNode != null)
            {
                ToolStripItem item = selectMatchMenuItem;
                if (treeListObjects.SelectedNode.Tag is CodeRootMapNode)
                {
                    CodeRootMapNode mapInfo = (CodeRootMapNode)treeListObjects.SelectedNode.Tag;

                    int numValues = mapInfo.UserObj == null ? 0 : 1;
                    numValues += mapInfo.PrevGenObj == null ? 0 : 1;
                    numValues += mapInfo.NewGenObj == null ? 0 : 1;

                    item.Enabled = (numValues > 0);
                }
                else
                {
                    e.Cancel = true;
                }
            }
            else
            {
                e.Cancel = true;
            }
        }
예제 #5
0
        private void ucTextMergeEditor1_MergedFileSavedEvent(object sender, ucTextMergeEditor.MergedFileSavedEventArgs e)
        {
            CodeRootMapNode CurrentMapInfo = (CodeRootMapNode)treeListObjects.SelectedNode.Tag;
            string          mergedCode     = e.MergedFile.GetContents();

            CurrentMapInfo.SetMergedBaseConstruct(mergedCode);

            // Write the resolved changes to the merged file
            FileInformation.MergedFile = new TextFile(FileInformation.CodeRootMap.GetMergedCodeRoot().ToString());
            FileInformation.PerformSuperDiff();
            FireFileUpdatedEvent();
            PopulateGrid();
        }
예제 #6
0
        private void DisplayNodeFiles(CodeRootMapNode node)
        {
            if (DesignMode)
            {
                return;
            }

            string userText     = "";
            string templateText = "";
            string prevGenText  = null;

            if (node.MergedObj != null && node.DiffTypeExcludingChildren == TypeOfDiff.ExactCopy)
            {
                userText = node.MergedObj.IsLeaf ? node.MergedObj.GetFullText() : node.MergedObj.GetOuterText();
                userText = Common.Utility.StandardizeLineBreaks(userText, Common.Utility.LineBreaks.Unix);

                templateText = prevGenText = userText;
            }
            else
            {
                if (node.UserObj != null)
                {
                    userText = GetObjectText(node.UserObj);
                }
                if (node.NewGenObj != null)
                {
                    templateText = GetObjectText(node.NewGenObj);
                }
                if (node.PrevGenObj != null)
                {
                    prevGenText = GetObjectText(node.PrevGenObj);
                }
            }

            TextFileInformation tfi = new TextFileInformation();

            tfi.PrevGenFile      = prevGenText != null ? new TextFile(prevGenText) : TextFile.Blank;
            tfi.NewGenFile       = new TextFile(templateText);
            tfi.UserFile         = new TextFile(userText);
            tfi.RelativeFilePath = FileInformation.RelativeFilePath;
            tfi.IntelliMerge     = IntelliMergeType.PlainText;
            ucTextMergeEditor.FileInformation = tfi;
        }
예제 #7
0
        private void acceptButton_Click(object sender, EventArgs e)
        {
            IBaseConstruct userObj    = GetSelectedBaseConstruct(userComboBox, userOptions);
            IBaseConstruct newGenObj  = GetSelectedBaseConstruct(templateComboBox, templateOptions);
            IBaseConstruct prevGenObj = GetSelectedBaseConstruct(prevgenComboBox, prevgenOptions);

            CodeRootMapNode node       = currentNode.ParentTree.GetExactNode(userObj);
            bool            userWarned = false;

            if (node != null && node != currentNode && (node.NewGenObj != null || node.PrevGenObj != null))
            {
                if (WarnUser() == false)
                {
                    return;
                }
                userWarned = true;
            }

            node = currentNode.ParentTree.GetExactNode(newGenObj);
            if (node != null && node != currentNode && (node.UserObj != null || node.PrevGenObj != null))
            {
                if (userWarned == false && WarnUser() == false)
                {
                    return;
                }
                userWarned = true;
            }

            node = currentNode.ParentTree.GetExactNode(prevGenObj);
            if (node != null && node != currentNode && (node.NewGenObj != null || node.UserObj != null))
            {
                if (userWarned == false && WarnUser() == false)
                {
                    return;
                }
            }

            currentNode.ParentTree.MatchConstructs(currentNode.ParentNode, userObj, newGenObj, prevGenObj);

            Close();
        }
예제 #8
0
        private void AddCodeRootNodeToTreeView(CodeRootMapNode codeRootNode, Node parent)
        {
            //IBaseConstruct baseConstruct = codeRootNode.GetMergedBaseConstruct();
            Node node = new Node();

            parent.Nodes.Add(node);
            node.Tag = codeRootNode;

            node.Style = elementStyle1;
            if (((CodeRootMapNode)node.Tag).DiffTypeExcludingChildren == TypeOfDiff.ExactCopy && AnyChildrenShowing(node) == false)
            {
                node.Style = elementStyleUnchanged;
            }

            node.Cells.Add(new Cell());
            node.Cells.Add(new Cell());
            node.Cells.Add(new Cell());

            node.Text          = codeRootNode.GetFirstValidBaseConstruct().ShortName;
            node.Cells[1].Text = codeRootNode.UserObj != null ? codeRootNode.UserObj.ShortName : "";
            node.Cells[2].Text = codeRootNode.NewGenObj != null ? codeRootNode.NewGenObj.ShortName : "";
            node.Cells[3].Text = codeRootNode.PrevGenObj != null ? codeRootNode.PrevGenObj.ShortName : "";

            ImageLoader.Status status = ImageLoader.Status.Resolved;
            if (codeRootNode.DiffTypeExcludingChildren == TypeOfDiff.Conflict)
            {
                status = ImageLoader.Status.Conflict;
            }
            else if (codeRootNode.DiffTypeExcludingChildren == TypeOfDiff.ExactCopy)
            {
                status = ImageLoader.Status.ExactCopy;
            }
            node.Image = imageLoader.GetImageForBaseConstruct(codeRootNode.GetFirstValidBaseConstruct(), status);

            foreach (CodeRootMapNode child in codeRootNode.ChildNodes)
            {
                AddCodeRootNodeToTreeView(child, node);
                node.Expanded = true;
            }
        }
예제 #9
0
        private static bool AnyChildrenShowing(Node node)
        {
            foreach (Node child in node.Nodes)
            {
                if (AnyChildrenShowing(child))
                {
                    return(true);
                }
                CodeRootMapNode crmn = child.Tag as CodeRootMapNode;
                if (crmn == null)
                {
                    return(true);
                }

                if (crmn.DiffTypeExcludingChildren != TypeOfDiff.ExactCopy)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #10
0
        private void DisplayNodeFiles(CodeRootMapNode node)
        {
            if (DesignMode)
                return;

            string userText = "";
            string templateText = "";
            string prevGenText = null;

            if (node.MergedObj != null && node.DiffTypeExcludingChildren == TypeOfDiff.ExactCopy)
            {
                userText = node.MergedObj.IsLeaf ? node.MergedObj.GetFullText() : node.MergedObj.GetOuterText();
                userText = Common.Utility.StandardizeLineBreaks(userText, Common.Utility.LineBreaks.Unix);

                templateText = prevGenText = userText;
            }
            else
            {
                if (node.UserObj != null)
                {
                    userText = GetObjectText(node.UserObj);
                }
                if (node.NewGenObj != null)
                {
                    templateText = GetObjectText(node.NewGenObj);
                }
                if (node.PrevGenObj != null)
                {
                    prevGenText = GetObjectText(node.PrevGenObj);
                }
            }

            TextFileInformation tfi = new TextFileInformation();
            tfi.PrevGenFile = prevGenText != null ? new TextFile(prevGenText) : TextFile.Blank;
            tfi.NewGenFile = new TextFile(templateText);
            tfi.UserFile = new TextFile(userText);
            tfi.RelativeFilePath = FileInformation.RelativeFilePath;
            tfi.IntelliMerge = IntelliMergeType.PlainText;
            ucTextMergeEditor.FileInformation = tfi;
        }
예제 #11
0
        private void AddCodeRootNodeToTreeView(CodeRootMapNode codeRootNode, Node parent)
        {
            //IBaseConstruct baseConstruct = codeRootNode.GetMergedBaseConstruct();
            Node node = new Node();
            parent.Nodes.Add(node);
            node.Tag = codeRootNode;

            node.Style = elementStyle1;
            if (((CodeRootMapNode)node.Tag).DiffTypeExcludingChildren == TypeOfDiff.ExactCopy && AnyChildrenShowing(node) == false)
                node.Style = elementStyleUnchanged;

            node.Cells.Add(new Cell());
            node.Cells.Add(new Cell());
            node.Cells.Add(new Cell());

            node.Text = codeRootNode.GetFirstValidBaseConstruct().ShortName;
            node.Cells[1].Text = codeRootNode.UserObj != null ? codeRootNode.UserObj.ShortName : "";
            node.Cells[2].Text = codeRootNode.NewGenObj != null ? codeRootNode.NewGenObj.ShortName : "";
            node.Cells[3].Text = codeRootNode.PrevGenObj != null ? codeRootNode.PrevGenObj.ShortName : "";

            ImageLoader.Status status = ImageLoader.Status.Resolved;
            if (codeRootNode.DiffTypeExcludingChildren == TypeOfDiff.Conflict)
            {
                status = ImageLoader.Status.Conflict;
            }
            else if (codeRootNode.DiffTypeExcludingChildren == TypeOfDiff.ExactCopy)
            {
                status = ImageLoader.Status.ExactCopy;
            }
            node.Image = imageLoader.GetImageForBaseConstruct(codeRootNode.GetFirstValidBaseConstruct(), status);

            foreach (CodeRootMapNode child in codeRootNode.ChildNodes)
            {
                AddCodeRootNodeToTreeView(child, node);
                node.Expanded = true;
            }
        }