static void IncomingChangeTreeViewItemGUI(
            string wkPath,
            UnityIncomingChangesTree incomingChangesTree,
            IncomingChangesTreeView treeView,
            ChangeTreeViewItem item,
            Action onCheckedNodeChanged,
            RowGUIArgs args,
            bool isCurrentConflict,
            bool isSolvedConflict)
        {
            for (int visibleColumnIdx = 0; visibleColumnIdx < args.GetNumVisibleColumns(); visibleColumnIdx++)
            {
                Rect cellRect = args.GetCellRect(visibleColumnIdx);

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

                IncomingChangeTreeViewItemCellGUI(
                    wkPath,
                    cellRect,
                    treeView.rowHeight,
                    incomingChangesTree,
                    treeView,
                    item,
                    onCheckedNodeChanged,
                    column,
                    args.selected,
                    args.focused,
                    isCurrentConflict,
                    isSolvedConflict);
            }
        }
        static void UpdateCheckStateForSelection(
            IncomingChangesTreeView treeView,
            ChangeTreeViewItem senderTreeViewItem)
        {
            IList <int> selectedIds = treeView.GetSelection();

            if (selectedIds.Count <= 1)
            {
                return;
            }

            if (!selectedIds.Contains(senderTreeViewItem.id))
            {
                return;
            }

            bool isChecked = senderTreeViewItem.ChangeInfo.IsChecked();

            foreach (TreeViewItem treeViewItem in treeView.FindRows(selectedIds))
            {
                if (treeViewItem is ChangeCategoryTreeViewItem)
                {
                    ((ChangeCategoryTreeViewItem)treeViewItem).Category
                    .UpdateCheckedState(isChecked);
                    continue;
                }

                ((ChangeTreeViewItem)treeViewItem).ChangeInfo
                .UpdateCheckedState(isChecked);
            }
        }
Пример #3
0
        static void IncomingChangeTreeViewItemCellGUI(
            string wkPath,
            Rect rect,
            float rowHeight,
            UnityIncomingChangesTree incomingChangesTree,
            IncomingChangesTreeView treeView,
            ChangeTreeViewItem item,
            Action onCheckedNodeChanged,
            IncomingChangesTreeColumn column,
            bool isSelected,
            bool isFocused,
            bool isCurrentConflict,
            bool isSolvedConflict)
        {
            IncomingChangeInfo incomingChange = item.ChangeInfo;

            string label = incomingChange.GetColumnText(
                IncomingChangesTreeHeaderState.GetColumnName(column));

            if (column == IncomingChangesTreeColumn.Path)
            {
                if (incomingChangesTree.HasMeta(item.ChangeInfo))
                {
                    label = string.Concat(label, UnityConstants.TREEVIEW_META_LABEL);
                }

                Texture icon = GetIcon(wkPath, incomingChange);
                GetChangesOverlayIcon.Data overlayIconData =
                    GetChangesOverlayIcon.ForGluonIncomingChange(
                        incomingChange, isSolvedConflict);

                bool wasChecked = incomingChange.IsChecked();

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

                incomingChange.UpdateCheckedState(isChecked);

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

                return;
            }

            if (column == IncomingChangesTreeColumn.Size)
            {
                DrawTreeViewItem.ForSecondaryLabelRightAligned(
                    rect, label, isSelected, isFocused, isCurrentConflict);
                return;
            }

            DrawTreeViewItem.ForSecondaryLabel(
                rect, label, isSelected, isFocused, isCurrentConflict);
        }
Пример #4
0
        protected override void RowGUI(RowGUIArgs args)
        {
            DrawTreeViewItem.InitializeStyles();

            if (args.item is ChangeCategoryTreeViewItem)
            {
                CategoryTreeViewItemGUI(
                    args.rowRect, rowHeight,
                    (ChangeCategoryTreeViewItem)args.item,
                    mOnCheckedNodeChanged,
                    mSolvedConflicts.Count,
                    args.selected, args.focused);
                return;
            }

            if (args.item is ChangeTreeViewItem)
            {
                ChangeTreeViewItem changeTreeViewItem =
                    (ChangeTreeViewItem)args.item;

                IncomingChangeInfo changeInfo     = changeTreeViewItem.ChangeInfo;
                IncomingChangeInfo metaChangeInfo = mIncomingChangesTree.GetMetaChange(
                    changeInfo);

                bool isCurrentConflict = IsCurrentConflict(
                    changeInfo,
                    metaChangeInfo,
                    mCurrentConflict);

                bool isSolvedConflict = IsSolvedConflict(
                    changeInfo,
                    metaChangeInfo,
                    mSolvedConflicts);

                IncomingChangeTreeViewItemGUI(
                    mWkInfo.ClientPath,
                    mIncomingChangesTree,
                    this,
                    changeTreeViewItem,
                    mOnCheckedNodeChanged, args,
                    isCurrentConflict,
                    isSolvedConflict);
                return;
            }

            base.RowGUI(args);
        }
        static void IncomingChangeTreeViewItemCellGUI(
            string wkPath,
            Rect rect,
            float rowHeight,
            UnityIncomingChangesTree incomingChangesTree,
            IncomingChangesTreeView treeView,
            ChangeTreeViewItem item,
            Action onCheckedNodeChanged,
            IncomingChangesTreeColumn column,
            bool isSelected,
            bool isFocused,
            bool isCurrentConflict,
            bool isSolvedConflict)
        {
            IncomingChangeInfo incomingChange = item.ChangeInfo;

            string label = incomingChange.GetColumnText(
                IncomingChangesTreeHeaderState.GetColumnName(column));

            if (column == IncomingChangesTreeColumn.Path)
            {
                if (incomingChangesTree.HasMeta(item.ChangeInfo))
                {
                    label = string.Concat(label, UnityConstants.TREEVIEW_META_LABEL);
                }

                Texture icon        = GetIcon(wkPath, incomingChange);
                Texture overlayIcon =
                    GetChangesOverlayIcon.ForGluonIncomingChange(
                        incomingChange, isSolvedConflict);

                bool wasChecked = incomingChange.IsChecked();

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

                incomingChange.UpdateCheckedState(isChecked);

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

                return;
            }

            if (column == IncomingChangesTreeColumn.Size)
            {
                // If there is a meta file, add the meta file to the file size so that it is consistent
                // with the Incoming Changes overview
                if (incomingChangesTree.HasMeta(item.ChangeInfo))
                {
                    IncomingChangeInfo metaFileInfo = incomingChangesTree.GetMetaChange(incomingChange);
                    long metaFileSize = metaFileInfo.GetSize();
                    long fileSize     = incomingChange.GetSize();

                    label = SizeConverter.ConvertToSizeString(fileSize + metaFileSize);
                }

                DrawTreeViewItem.ForSecondaryLabelRightAligned(
                    rect, label, isSelected, isFocused, isCurrentConflict);
                return;
            }

            DrawTreeViewItem.ForSecondaryLabel(
                rect, label, isSelected, isFocused, isCurrentConflict);
        }
        static void RegenerateRows(
            UnityIncomingChangesTree incomingChangesTree,
            TreeViewItemIds <IncomingChangeCategory, IncomingChangeInfo> treeViewItemIds,
            IncomingChangesTreeView treeView,
            TreeViewItem rootItem,
            List <TreeViewItem> rows,
            bool expandCategories)
        {
            if (incomingChangesTree == null)
            {
                return;
            }

            ClearRows(rootItem, rows);

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

            if (categories == null)
            {
                return;
            }

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

            foreach (IncomingChangeCategory 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,
                        categories.Count, expandCategories))
                {
                    continue;
                }

                categoriesToExpand.Add(categoryTreeViewItem.id);

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

                    TreeViewItem changeTreeViewItem =
                        new ChangeTreeViewItem(changeId, incomingChange);

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

            treeView.state.expandedIDs = categoriesToExpand;
        }