static void RegenerateRows(
            UnityPendingChangesTree pendingChangesTree,
            TreeViewItemIds <PendingChangeCategory, PendingChangeInfo> treeViewItemIds,
            PendingChangesTreeView treeView,
            TreeViewItem rootItem,
            List <TreeViewItem> rows,
            bool expandCategories)
        {
            ClearRows(rootItem, rows);

            List <PendingChangeCategory> categories = pendingChangesTree.GetNodes();

            if (categories == null)
            {
                return;
            }

            foreach (PendingChangeCategory category in categories)
            {
                int categoryId;
                if (!treeViewItemIds.TryGetCategoryItemId(category, out categoryId))
                {
                    categoryId = treeViewItemIds.AddCategoryItem(category);
                }

                ChangeCategoryTreeViewItem categoryTreeViewItem =
                    new ChangeCategoryTreeViewItem(categoryId, category);

                rootItem.AddChild(categoryTreeViewItem);
                rows.Add(categoryTreeViewItem);

                if (!expandCategories &&
                    !treeView.IsExpanded(categoryTreeViewItem.id))
                {
                    continue;
                }

                foreach (PendingChangeInfo change in category.GetCurrentChanges())
                {
                    int changeId;
                    if (!treeViewItemIds.TryGetInfoItemId(change, out changeId))
                    {
                        changeId = treeViewItemIds.AddInfoItem(change);
                    }

                    TreeViewItem changeTreeViewItem =
                        new ChangeTreeViewItem(changeId, change);

                    categoryTreeViewItem.AddChild(changeTreeViewItem);
                    rows.Add(changeTreeViewItem);
                }
            }

            if (!expandCategories)
            {
                return;
            }

            treeView.state.expandedIDs = treeViewItemIds.GetCategoryIds();
        }
Beispiel #2
0
        static void AddClientDiffs(
            TreeViewItem parentItem,
            ITreeViewNode parentNode,
            List <TreeViewItem> rows,
            TreeViewItemIds <IDiffCategory, ITreeViewNode> treeViewItemIds)
        {
            for (int i = 0; i < parentNode.GetChildrenCount(); i++)
            {
                ITreeViewNode child = parentNode.GetChild(i);

                int nodeId;
                if (!treeViewItemIds.TryGetInfoItemId(child, out nodeId))
                {
                    nodeId = treeViewItemIds.AddInfoItem(child);
                }

                TreeViewItem changeTreeViewItem =
                    new ClientDiffTreeViewItem(
                        nodeId,
                        parentItem.depth + 1,
                        (ClientDiffInfo)child);

                parentItem.AddChild(changeTreeViewItem);
                rows.Add(changeTreeViewItem);
            }
        }
Beispiel #3
0
        static void RegenerateRows(
            UnityIncomingChangesTree incomingChangesTree,
            TreeViewItemIds <IncomingChangesCategory, IncomingChangeInfo> treeViewItemIds,
            IncomingChangesTreeView treeView,
            TreeViewItem rootItem,
            List <TreeViewItem> rows,
            bool expandCategories)
        {
            if (incomingChangesTree == null)
            {
                return;
            }

            ClearRows(rootItem, rows);

            List <IncomingChangesCategory> categories = incomingChangesTree.GetNodes();

            if (categories == null)
            {
                return;
            }

            List <int> categoriesToExpand = new List <int>();

            foreach (IncomingChangesCategory category in categories)
            {
                int categoryId;
                if (!treeViewItemIds.TryGetCategoryItemId(category, out categoryId))
                {
                    categoryId = treeViewItemIds.AddCategoryItem(category);
                }

                ChangeCategoryTreeViewItem categoryTreeViewItem =
                    new ChangeCategoryTreeViewItem(categoryId, category);

                rootItem.AddChild(categoryTreeViewItem);
                rows.Add(categoryTreeViewItem);

                if (!ShouldExpandCategory(
                        treeView,
                        categoryTreeViewItem,
                        expandCategories,
                        categories.Count))
                {
                    continue;
                }

                categoriesToExpand.Add(categoryTreeViewItem.id);

                foreach (IncomingChangeInfo changeInfo in category.GetChanges())
                {
                    int differenceId;
                    if (!treeViewItemIds.TryGetInfoItemId(changeInfo, out differenceId))
                    {
                        differenceId = treeViewItemIds.AddInfoItem(changeInfo);
                    }

                    TreeViewItem changeTreeViewItem =
                        new ChangeTreeViewItem(differenceId, changeInfo);

                    categoryTreeViewItem.AddChild(changeTreeViewItem);
                    rows.Add(changeTreeViewItem);
                }
            }

            treeView.state.expandedIDs = categoriesToExpand;
        }