Exemple #1
0
        public void Execute(IActionContext context)
        {
            IResourceList resources = context.SelectedResources;

            if (resources.Count > 1)
            {
                if (MessageBox.Show(Core.MainWindow,
                                    "Are you sure you want to delete selected weblinks and/or folders?", "Delete Bookmarks",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }
            }
            for (int i = 0; i < resources.Count; ++i)
            {
                IResource res = context.SelectedResources[i];
                if (res.Type != "Folder" && res.Type != "Weblink")
                {
                    res = res.GetLinkProp("Source");
                }
                if (res != null && (res.Type == "Folder" || res.Type == "Weblink"))
                {
                    if (resources.Count == 1)
                    {
                        if (res.Type != "Folder" || res.DisplayName != "New Folder")
                        {
                            if (MessageBox.Show(Core.MainWindow,
                                                "Are you sure you want to delete '" + res.DisplayName + "'?", "Delete Bookmark",
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                            {
                                return;
                            }
                        }
                    }
                    IBookmarkService bookmarkService =
                        (IBookmarkService)Core.PluginLoader.GetPluginService(typeof(IBookmarkService));
                    IBookmarkProfile profile = bookmarkService.GetOwnerProfile(res);
                    string           error   = null;
                    if (profile != null && profile.CanDelete(res, out error))
                    {
                        profile.Delete(res);
                    }
                    if (res.Type == "Folder")
                    {
                        bookmarkService.DeleteFolder(res);
                    }
                    else
                    {
                        bookmarkService.DeleteBookmark(res);
                    }
                }
            }
        }
Exemple #2
0
        public void ResourcesDropped(IResource targetResource, IResourceList droppedResources)
        {
            IBookmarkProfile targetProfile = _bookmarkService.GetOwnerProfile(targetResource);

            foreach (IResource dropRes in droppedResources)
            {
                IResource        oldParent     = BookmarkService.GetParent(dropRes);
                IBookmarkProfile sourceProfile = _bookmarkService.GetOwnerProfile(dropRes);
                if (sourceProfile == targetProfile)
                {
                    if (targetProfile != null)
                    {
                        targetProfile.Move(dropRes, targetResource, oldParent);
                    }
                    new ResourceProxy(dropRes).SetProp(_propParent, targetResource);
                }
                else
                {
                    if (sourceProfile != null)
                    {
                        sourceProfile.Delete(dropRes);
                    }
                    new ResourceProxy(dropRes).SetProp(_propParent, targetResource);
                    if (targetProfile != null)
                    {
                        targetProfile.Create(dropRes);
                    }
                }
                // the resource may have been moved from a parent which belonged to a workspace
                // to the top level (#5066)
                if (dropRes.Type == "Weblink")
                {
                    Core.WorkspaceManager.AddToActiveWorkspace(dropRes);
                }
                else
                {
                    Core.WorkspaceManager.AddToActiveWorkspaceRecursive(dropRes);
                }
            }
        }