Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
0
        void BuildComponents(
            PlasticGUIClient plasticClient,
            EditorWindow plasticWindow)
        {
            mHelpPanel = new HelpPanel(plasticWindow);

            mAdvancedDropdownMenu = new GenericMenu();
            mAdvancedDropdownMenu.AddItem(new GUIContent(
                                              PlasticLocalization.GetString(PlasticLocalization.Name.UndoUnchangedButton)),
                                          false, () => { });

            mSearchField = new SearchField();
            mSearchField.downOrUpArrowKeyPressed += SearchField_OnDownOrUpArrowKeyPressed;

            PendingChangesTreeHeaderState headerState = PendingChangesTreeHeaderState.Default;

            TreeHeaderSettings.Load(headerState,
                                    UnityConstants.PENDING_CHANGES_TABLE_SETTINGS_NAME,
                                    (int)PendingChangesTreeColumn.Item, true);

            mPendingChangesTreeView = new PendingChangesTreeView(
                mWkInfo, headerState,
                PendingChangesTreeHeaderState.GetColumnNames(),
                new PendingChangesViewMenu(this, this, this));
            mPendingChangesTreeView.Reload();

            mMergeLinksListView = new MergeLinksListView();
            mMergeLinksListView.Reload();
        }
Ejemplo n.º 3
0
        static void UpdateCheckStateForSelection(
            PendingChangesTreeView 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);
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        internal static SelectedChangesGroupInfo GetSelectedChangesGroupInfo(
            PendingChangesTreeView treeView)
        {
            SelectedChangesGroupInfo result = treeView.GetSelectedChangesGroupInfo();

            result.IsApplicableDiffWorkspaceContent = IsApplicableDiffWorkspaceContent(treeView);
            return(result);
        }
Ejemplo n.º 6
0
        static void DoChangesArea(
            PendingChangesTreeView changesTreeView,
            bool isOperationRunning)
        {
            GUI.enabled = !isOperationRunning;

            Rect rect = GUILayoutUtility.GetRect(0, 100000, 0, 100000);

            changesTreeView.OnGUI(rect);

            GUI.enabled = true;
        }
Ejemplo n.º 7
0
        static bool IsApplicableDiffWorkspaceContent(
            PendingChangesTreeView treeView)
        {
            ChangeInfo selectedRow = GetSelectedChange(treeView);

            if (selectedRow == null)
            {
                return(false);
            }

            return(DiffOperation.IsApplicableDiffWorkspaceContent(selectedRow));
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        static void DoSearchField(SearchField searchField,
                                  PendingChangesTreeView changesTreeView,
                                  float width)
        {
            var searchFieldRect = GUILayoutUtility.GetRect(
                width / 2, EditorGUIUtility.singleLineHeight);

            searchFieldRect.y += 2;

            changesTreeView.searchString = searchField.OnToolbarGUI(
                searchFieldRect, changesTreeView.searchString);

            if (string.IsNullOrEmpty(changesTreeView.searchString))
            {
                GUI.Label(searchFieldRect, PlasticLocalization.GetString(
                              PlasticLocalization.Name.SearchTooltip), UnityStyles.Search);
            }
        }
Ejemplo n.º 10
0
        internal static void SelectChanges(
            PendingChangesTreeView treeView,
            List <ChangeInfo> changesToSelect)
        {
            if (changesToSelect == null || changesToSelect.Count == 0)
            {
                treeView.SelectFirstPendingChangeOnTree();
                return;
            }

            treeView.SelectPreviouslySelectedPendingChanges(changesToSelect);

            if (treeView.HasSelection())
            {
                return;
            }

            treeView.SelectFirstPendingChangeOnTree();
        }
Ejemplo n.º 11
0
        internal static List <string> GetSelectedMetaPaths(
            PendingChangesTreeView treeView)
        {
            List <ChangeInfo> selectedChanges = PendingChangesSelection
                                                .GetSelectedChanges(treeView);

            List <string> result = new List <string>();

            foreach (ChangeInfo change in selectedChanges)
            {
                string path = change.GetFullPath();

                if (!MetaPath.IsMetaPath(path))
                {
                    continue;
                }

                result.Add(path);
            }

            return(result);
        }
Ejemplo n.º 12
0
        internal static List <ChangeInfo> GetChangesToFocus(
            PendingChangesTreeView treeView)
        {
            List <ChangeInfo> selectedChanges = treeView.GetSelectedChanges(true);

            if (selectedChanges.Count == 0)
            {
                return(selectedChanges);
            }

            List <ChangeInfo> changesToFocus =
                selectedChanges.Where(change => !IsAddedFile(change)).ToList();

            if (changesToFocus.Count() == 0)
            {
                ChangeInfo nearestAddedChange = treeView.GetNearestAddedChange();
                if (nearestAddedChange != null)
                {
                    changesToFocus.Add(nearestAddedChange);
                }
            }

            return(changesToFocus);
        }
Ejemplo n.º 13
0
 internal static List <ChangeInfo> GetAllChanges(
     PendingChangesTreeView treeView)
 {
     return(treeView.GetAllChanges());
 }
Ejemplo n.º 14
0
 internal static List <string> GetSelectedPaths(
     PendingChangesTreeView treeView)
 {
     return(treeView.GetSelectedChanges(true)
            .Select(change => change.GetFullPath()).ToList());
 }
Ejemplo n.º 15
0
 internal static ChangeInfo GetSelectedChange(
     PendingChangesTreeView treeView)
 {
     return(treeView.GetSelectedRow());
 }
Ejemplo n.º 16
0
 internal static List <ChangeInfo> GetSelectedChanges(
     PendingChangesTreeView treeView)
 {
     return(treeView.GetSelectedChanges(true));
 }