Exemplo n.º 1
0
        public void Update(IActionContext context, ref ActionPresentation presentation)
        {
            presentation.Visible = presentation.Enabled =
                (context.Instance == Core.LeftSidebar.DefaultViewPane) &&
                (context.SelectedResources.Count == 1) &&
                (context.SelectedResources[0].Type == FilterManagerProps.ViewResName) &&
                (context.SelectedResources[0].GetStringProp("DeepName") == FilterManagerProps.ViewDeletedItemsDeepName);

            //  Resources of some types can not be deleted permanently, e.g.
            //  Contacts and IM conversations. Thus this menu must be forbidden
            //  for the view in the corresponding tabs.
            if (presentation.Visible)
            {
                string[] types = Core.TabManager.CurrentTab.GetResourceTypes();

                //  "All Resources" tab always returns NULL
                if (types != null)
                {
                    bool canDelete = false;
                    foreach (string type in types)
                    {
                        if (type.Length > 0 && Core.ResourceStore.ResourceTypes.Exist(type))
                        {
                            IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(type);
                            if (deleter != null)
                            {
                                canDelete = canDelete || deleter.CanDeleteResource(null, true);
                            }
                        }
                    }
                    presentation.Visible = canDelete;
                }
            }
        }
Exemplo n.º 2
0
        private static bool AllHaveEnabledDeleters(IResourceList selectedResources)
        {
            if (selectedResources.Count == 0)
            {
                return(false);
            }

            foreach (IResource res in selectedResources.ValidResources)
            {
                IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(res.Type);
                if (deleter == null)
                {
                    return(false);
                }
                if (!deleter.CanDeleteResource(res, res.HasProp(Core.Props.IsDeleted)))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 3
0
        private void ShowPaneImpl()
        {
            if (!Core.UserInterfaceAP.IsOwnerThread)
            {
                Core.UserInterfaceAP.QueueJob(new MethodInvoker(ShowPaneImpl));
                return;
            }
            _deletersListView.Nodes.Clear();
            IResourceList resTypes = Core.ResourceStore.GetAllResources("ResourceType");

            foreach (IResource resType in resTypes.ValidResources)
            {
                if (resType.GetIntProp("Internal") != 0)
                {
                    continue;
                }
                string type = resType.GetPropText(Core.Props.Name);
                if (type.Length > 0 && Core.ResourceStore.ResourceTypes.Exist(type))
                {
                    IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(type);
                    if (deleter != null)
                    {
                        _deletersListView.Nodes.Add(resType);
                        bool canDelete = deleter.CanDeleteResource(null, false);
                        if (!canDelete)
                        {
                            _confirmDeleteColumn.SetItemCheckState(resType, CheckBoxState.Grayed | CheckBoxState.Unchecked);
                        }
                        else
                        {
                            _confirmDeleteColumn.SetItemCheckState(resType,
                                                                   ResourceDeleterOptions.GetConfirmDeleteToRecycleBin(type) ? CheckBoxState.Checked : CheckBoxState.Unchecked);
                        }
                        bool canDeletePermanently = deleter.CanDeleteResource(null, true);
                        if (!canDeletePermanently)
                        {
                            _confirmPermanentDeleteColumn.SetItemCheckState(resType, CheckBoxState.Grayed | CheckBoxState.Unchecked);
                        }
                        else
                        {
                            _confirmPermanentDeleteColumn.SetItemCheckState(resType,
                                                                            ResourceDeleterOptions.GetConfirmDeletePermanently(type) ? CheckBoxState.Checked : CheckBoxState.Unchecked);
                        }

                        if (!deleter.CanIgnoreRecyclebin())
                        {
                            _alwaysDeletePermanentlyColumn.SetItemCheckState(resType, CheckBoxState.Grayed | CheckBoxState.Unchecked);
                        }
                        else
                        if (canDelete != canDeletePermanently)
                        {
                            _alwaysDeletePermanentlyColumn.SetItemCheckState(resType, CheckBoxState.Grayed |
                                                                             (canDelete ? CheckBoxState.Unchecked : CheckBoxState.Checked));
                        }
                        else
                        {
                            _alwaysDeletePermanentlyColumn.SetItemCheckState(resType,
                                                                             ResourceDeleterOptions.GetDeleteAlwaysPermanently(type) ? CheckBoxState.Checked : CheckBoxState.Unchecked);
                        }
                    }
                }
            }
        }