static void ChangeTreeViewItemGUI(
            string wkPath,
            PendingChangesTreeView treeView,
            UnityPendingChangesTree pendingChangesTree,
            ChangeTreeViewItem item,
            RowGUIArgs args)
        {
            for (int visibleColumnIdx = 0; visibleColumnIdx < args.GetNumVisibleColumns(); visibleColumnIdx++)
            {
                Rect cellRect = args.GetCellRect(visibleColumnIdx);

                PendingChangesTreeColumn column =
                    (PendingChangesTreeColumn)args.GetColumn(visibleColumnIdx);

                ChangeTreeViewItemCellGUI(
                    cellRect,
                    treeView.rowHeight,
                    treeView,
                    pendingChangesTree,
                    item,
                    column,
                    args.selected,
                    args.focused);
            }
        }
        public void TestOnlyMeta()
        {
            UnityPendingChangesTree tree = new UnityPendingChangesTree();

            WorkspaceInfo wkInfo = new WorkspaceInfo("foo", "/foo");

            PlasticGui.WorkspaceWindow.PendingChanges.PendingChanges pendingChanges =
                new PlasticGui.WorkspaceWindow.PendingChanges.PendingChanges(wkInfo);

            ChangeInfo addedMeta = new ChangeInfo()
            {
                Path = "/foo/foo.c.meta",
            };

            pendingChanges.Added.Add(addedMeta);

            tree.BuildChangeCategories(
                wkInfo.ClientPath,
                pendingChanges,
                new PlasticGui.WorkspaceWindow.PendingChanges.CheckedStateManager());

            Assert.IsNull(
                tree.GetMetaChange(addedMeta),
                "Meta change should be null");
        }
        internal PendingChangesTreeView(
            WorkspaceInfo wkInfo,
            PendingChangesTreeHeaderState headerState,
            List <string> columnNames,
            PendingChangesViewMenu menu)
            : base(new TreeViewState())
        {
            mWkInfo      = wkInfo;
            mColumnNames = columnNames;
            mMenu        = menu;

            mPendingChangesTree = new UnityPendingChangesTree();

            multiColumnHeader = new PendingChangesMultiColumnHeader(
                headerState, mPendingChangesTree);
            multiColumnHeader.canSort         = true;
            multiColumnHeader.sortingChanged += SortingChanged;

            customFoldoutYOffset          = UnityConstants.TREEVIEW_FOLDOUT_Y_OFFSET;
            rowHeight                     = UnityConstants.TREEVIEW_ROW_HEIGHT;
            showAlternatingRowBackgrounds = true;

            mCooldownFilterAction = new CooldownWindowDelayer(
                DelayedSearchChanged, UnityConstants.SEARCH_DELAYED_INPUT_ACTION_INTERVAL);
        }
        public void TestMovedNoMeta()
        {
            UnityPendingChangesTree tree = new UnityPendingChangesTree();

            WorkspaceInfo wkInfo = new WorkspaceInfo("foo", "/foo");

            PlasticGui.WorkspaceWindow.PendingChanges.PendingChanges pendingChanges =
                new PlasticGui.WorkspaceWindow.PendingChanges.PendingChanges(wkInfo);

            ChangeInfo moved = new ChangeInfo()
            {
                OldPath = "/foo/foo.c",
                Path    = "/foo/bar/newfoo.c",
            };

            pendingChanges.Moved.Add(moved);

            tree.BuildChangeCategories(
                wkInfo.ClientPath,
                pendingChanges,
                new PlasticGui.WorkspaceWindow.PendingChanges.CheckedStateManager());

            Assert.IsNull(
                tree.GetMetaChange(moved),
                "Meta change should be null");
        }
Beispiel #5
0
        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 #6
0
        internal PendingChangesTreeView(
            WorkspaceInfo wkInfo,
            PendingChangesTreeHeaderState headerState,
            PendingChangesViewMenu menu)
            : base(new TreeViewState())
        {
            mWkInfo             = wkInfo;
            mMenu               = menu;
            mPendingChangesTree = new UnityPendingChangesTree();

            mColumnNames = new List <string>();
            mColumnNames.Add(PlasticLocalization.GetString(PlasticLocalization.Name.ItemColumn));
            mColumnNames.Add(PlasticLocalization.GetString(PlasticLocalization.Name.StatusColumn));
            mColumnNames.Add(PlasticLocalization.GetString(PlasticLocalization.Name.SizeColumn));
            mColumnNames.Add(PlasticLocalization.GetString(PlasticLocalization.Name.ExtensionColumn));
            mColumnNames.Add(PlasticLocalization.GetString(PlasticLocalization.Name.TypeColumn));
            mColumnNames.Add(PlasticLocalization.GetString(PlasticLocalization.Name.DateModifiedColumn));
            mColumnNames.Add(PlasticLocalization.GetString(PlasticLocalization.Name.RepositoryColumn));

            multiColumnHeader = new PendingChangesMultiColumnHeader(
                headerState, mPendingChangesTree);
            multiColumnHeader.canSort         = true;
            multiColumnHeader.sortingChanged += SortingChanged;

            customFoldoutYOffset          = UnityConstants.TREEVIEW_FOLDOUT_Y_OFFSET;
            rowHeight                     = UnityConstants.TREEVIEW_ROW_HEIGHT;
            showAlternatingRowBackgrounds = true;

            mCooldownFilterAction = new CooldownWindowDelayer(DelayedSearchChanged, 0.25);
        }
        static void ChangeTreeViewItemCellGUI(
            Rect rect,
            float rowHeight,
            PendingChangesTreeView treeView,
            UnityPendingChangesTree pendingChangesTree,
            ChangeTreeViewItem item,
            PendingChangesTreeColumn column,
            bool isSelected,
            bool isFocused)
        {
            PendingChangeInfo changeInfo = item.ChangeInfo;

            string label = changeInfo.GetColumnText(
                PendingChangesTreeHeaderState.GetColumnName(column));

            if (column == PendingChangesTreeColumn.Item)
            {
                if (pendingChangesTree.HasMeta(changeInfo.ChangeInfo))
                {
                    label = string.Concat(label, UnityConstants.TREEVIEW_META_LABEL);
                }

                Texture             icon            = GetIcon(changeInfo);
                GetOverlayIcon.Data overlayIconData =
                    GetOverlayIcon.ForChange(changeInfo.ChangeInfo);

                bool wasChecked = changeInfo.IsChecked();

                bool isChecked = DrawTreeViewItem.ForCheckableItemCell(
                    rect, rowHeight, item.depth,
                    icon, overlayIconData, label,
                    isSelected, isFocused, false,
                    wasChecked);

                changeInfo.UpdateCheckedState(isChecked);

                if (wasChecked != isChecked)
                {
                    UpdateCheckStateForSelection(treeView, item);
                }

                return;
            }

            if (column == PendingChangesTreeColumn.Size)
            {
                DefaultGUI.LabelRightAligned(rect, label, isSelected, isFocused);
                return;
            }

            DefaultGUI.Label(rect, label, isSelected, isFocused);
        }
        public void TestCheckedChangesWithMeta()
        {
            UnityPendingChangesTree tree = new UnityPendingChangesTree();

            WorkspaceInfo wkInfo = new WorkspaceInfo("foo", "/foo");

            PlasticGui.WorkspaceWindow.PendingChanges.PendingChanges pendingChanges =
                new PlasticGui.WorkspaceWindow.PendingChanges.PendingChanges(wkInfo);

            ChangeInfo added = new ChangeInfo()
            {
                Path = "/foo/foo.c",
            };

            ChangeInfo addedMeta = new ChangeInfo()
            {
                Path = "/foo/foo.c",
            };

            pendingChanges.Added.Add(added);
            pendingChanges.Added.Add(addedMeta);

            PlasticGui.WorkspaceWindow.PendingChanges.CheckedStateManager checkedStateManager =
                new PlasticGui.WorkspaceWindow.PendingChanges.CheckedStateManager();

            tree.BuildChangeCategories(
                wkInfo.ClientPath,
                pendingChanges,
                checkedStateManager);

            checkedStateManager.Update(added, true);

            List <ChangeInfo> changes;
            List <ChangeInfo> dependenciesCandidates;

            tree.GetCheckedChanges(
                false,
                out changes,
                out dependenciesCandidates);

            Assert.IsTrue(changes.Contains(added),
                          "Changes should contains the change");

            Assert.IsTrue(changes.Contains(addedMeta),
                          "Changes should contains the meta change");
        }
        public void TestMovedWithMeta()
        {
            UnityPendingChangesTree tree = new UnityPendingChangesTree();

            WorkspaceInfo wkInfo = new WorkspaceInfo("foo", "/foo");

            PlasticGui.WorkspaceWindow.PendingChanges.PendingChanges pendingChanges =
                new PlasticGui.WorkspaceWindow.PendingChanges.PendingChanges(wkInfo);

            ChangeInfo moved = new ChangeInfo()
            {
                OldPath = "/foo/foo.c",
                Path    = "/foo/bar/newfoo.c",
            };

            ChangeInfo movedMeta = new ChangeInfo()
            {
                OldPath = "/foo/foo.c.meta",
                Path    = "/foo/bar/newfoo.c.meta",
            };

            pendingChanges.Moved.Add(moved);
            pendingChanges.Moved.Add(movedMeta);

            tree.BuildChangeCategories(
                wkInfo.ClientPath,
                pendingChanges,
                new PlasticGui.WorkspaceWindow.PendingChanges.CheckedStateManager());

            Assert.IsTrue(
                pendingChanges.Moved.Contains(moved),
                "Pending changes should contain the change");

            Assert.IsFalse(
                pendingChanges.Moved.Contains(movedMeta),
                "Pending changes should not contain the meta");

            Assert.AreEqual(movedMeta, tree.GetMetaChange(moved));
        }
        public void TestFileAddedMetaPrivate()
        {
            UnityPendingChangesTree tree = new UnityPendingChangesTree();

            WorkspaceInfo wkInfo = new WorkspaceInfo("foo", "/foo");

            PlasticGui.WorkspaceWindow.PendingChanges.PendingChanges pendingChanges =
                new PlasticGui.WorkspaceWindow.PendingChanges.PendingChanges(wkInfo);

            ChangeInfo added = new ChangeInfo()
            {
                Path        = "/foo/foo.c",
                ChangeTypes = ChangeTypes.Added,
            };

            ChangeInfo privateMeta = new ChangeInfo()
            {
                Path        = "/foo/foo.c.meta",
                ChangeTypes = ChangeTypes.Private,
            };

            pendingChanges.Added.Add(added);
            pendingChanges.Added.Add(privateMeta);

            tree.BuildChangeCategories(
                wkInfo.ClientPath,
                pendingChanges,
                new PlasticGui.WorkspaceWindow.PendingChanges.CheckedStateManager());

            Assert.IsTrue(
                pendingChanges.Added.Contains(added),
                "Pending changes should contain the change");

            Assert.IsTrue(
                pendingChanges.Added.Contains(privateMeta),
                "Pending changes should contain the meta");
        }
Beispiel #11
0
 internal PendingChangesMultiColumnHeader(
     MultiColumnHeaderState headerState, UnityPendingChangesTree tree)
     : base(headerState)
 {
     mPendingChangesTree = tree;
 }