Beispiel #1
0
    public void RenameClick(bool removeOnCancel, UnityAction confirmCallback = null, bool keepObjectLocked = false)
    {
        InteractiveObject selectedObject = SelectorMenu.Instance.GetSelectedObject();

        if (selectedObject is null)
        {
            return;
        }

        if (!SelectorMenu.Instance.gameObject.activeSelf) //other menu/dialog opened
        {
            SetActiveSubmenu(LeftMenuSelection.Utility);  //close all other opened menus/dialogs and takes care of red background of buttons
        }

        UpdateVisibility(false, true);
        SelectorMenu.Instance.gameObject.SetActive(false);
        if (removeOnCancel)
        {
            RenameDialog.Init(selectedObject, UpdateVisibility, true, () => selectedObject.Remove(), confirmCallback, keepObjectLocked);
        }
        else
        {
            RenameDialog.Init(selectedObject, UpdateVisibility, false, null, confirmCallback, keepObjectLocked);
        }
        RenameDialog.Open();
    }
        private List <MenuItem> EditGroup(List <ExtendedItem> items)
        {
            var groupItems = new List <MenuItem>();
            //Check Out
            var checkOutItems = items.Where(i => i.ChangeType == ChangeType.None || i.ChangeType == ChangeType.Lock || i.ItemType == ItemType.Folder).ToList();

            if (checkOutItems.Any())
            {
                MenuItem checkOutItem = new MenuItem(GettextCatalog.GetString("Check out items"));
                checkOutItem.Activated += (sender, e) =>
                {
                    CheckOutDialog.Open(checkOutItems, _currentWorkspace);
                    FireFilesChanged(checkOutItems);
                    RefreshList(items);
                };
                groupItems.Add(checkOutItem);
            }
            //Lock
            var lockItems = items.Where(i => !i.IsLocked).ToList();

            if (lockItems.Any())
            {
                MenuItem lockItem = new MenuItem(GettextCatalog.GetString("Lock"));
                lockItem.Activated += (sender, e) =>
                {
                    LockDialog.Open(lockItems, _currentWorkspace);
                    FireFilesChanged(lockItems);
                    RefreshList(items);
                };
                groupItems.Add(lockItem);
            }
            //UnLock
            var unLockItems = items.Where(i => i.IsLocked && !i.HasOtherPendingChange).ToList();

            if (unLockItems.Any())
            {
                MenuItem unLockItem = new MenuItem(GettextCatalog.GetString("UnLock"));
                unLockItem.Activated += (sender, e) =>
                {
                    var folders = new List <string>(unLockItems.Where(i => i.ItemType == ItemType.Folder).Select(i => (string)i.ServerPath));
                    var files   = new List <string>(unLockItems.Where(i => i.ItemType == ItemType.File).Select(i => (string)i.ServerPath));
                    _currentWorkspace.LockFolders(folders, LockLevel.None);
                    _currentWorkspace.LockFiles(files, LockLevel.None);
                    FireFilesChanged(unLockItems);
                    RefreshList(items);
                };
                groupItems.Add(unLockItem);
            }
            //Rename
            var ableToRename = items.FirstOrDefault(i => !i.ChangeType.HasFlag(ChangeType.Delete));

            if (ableToRename != null)
            {
                MenuItem renameItem = new MenuItem(GettextCatalog.GetString("Rename"));
                renameItem.Activated += (sender, e) =>
                {
                    RenameDialog.Open(ableToRename, _currentWorkspace);
                    FireFilesChanged(new List <ExtendedItem> {
                        ableToRename
                    });
                    RefreshList(items);
                };
                groupItems.Add(renameItem);
            }
            //Delete
            var ableToDelete = items.Where(i => !i.ChangeType.HasFlag(ChangeType.Delete)).ToList();

            if (ableToDelete.Any())
            {
                MenuItem deleteItem = new MenuItem(GettextCatalog.GetString("Delete"));
                deleteItem.Activated += (sender, e) => DeleteItems(ableToDelete);
                groupItems.Add(deleteItem);
            }
            //Undo
            var undoItems = items.Where(i => !i.ChangeType.HasFlag(ChangeType.None) || i.ItemType == ItemType.Folder).ToList();

            if (undoItems.Any())
            {
                MenuItem revertItem = new MenuItem(GettextCatalog.GetString("Undo Changes"));
                revertItem.Activated += (sender, e) =>
                {
                    UndoDialog.Open(undoItems, _currentWorkspace);
                    FireFilesChanged(undoItems);
                    RefreshList(items);
                };
                groupItems.Add(revertItem);

                MenuItem checkinItem = new MenuItem(GettextCatalog.GetString("Check In pending changes"));
                checkinItem.Activated += (sender, e) =>
                {
                    CheckInDialog.Open(undoItems, _currentWorkspace);
                    FireFilesChanged(undoItems);
                    RefreshList(items);
                };
                groupItems.Add(checkinItem);
            }
            return(groupItems);
        }