Beispiel #1
0
        public void ResourceNodeSelected(IResource res)
        {
            #region Preconditions

            if (res == null)
            {
                throw new ArgumentNullException("res", "FilterRegistry -- Input resource in node selection processing can not be NULL");
            }

            if (!FilterRegistry.IsViewOrFolder(res))
            {
                throw new ArgumentException("FilterRegistry -- IResourceTreeHandler is called with the resource of inappropriate type [" + res.Type + "]");
            }

            #endregion Preconditions

            //  Selecting a tree node (view) in the Shutdown mode is NOP.
            if (Core.State == CoreState.ShuttingDown)
            {
                return;
            }

            string viewName = res.GetPropText(Core.Props.Name);
            if (res.Type == FilterManagerProps.ViewResName)
            {
                if ((res == _lastSelectedView) && (_lastSelectedResult != null) &&
                    (Core.WorkspaceManager.ActiveWorkspace == _lastSelectedWorkspace) &&
                    (res.GetStringProp("DeepName") != FilterManagerProps.ViewUnreadDeepName) &&
                    (!res.HasProp("ForceExec")))
                {
                    Core.ResourceBrowser.DisplayConfigurableResourceList(res, _lastSelectedResult, _displayOptions);
                }
                else
                {
                    _lastSelectedResult = Core.FilterEngine.ExecView(res, viewName);
                    ConfigureDisplayOptions(res, viewName, _lastSelectedResult);
                    Core.ResourceBrowser.DisplayConfigurableResourceList(res, _lastSelectedResult, _displayOptions);
                }
                _lastSelectedView      = res;
                _lastSelectedWorkspace = Core.WorkspaceManager.ActiveWorkspace;
                new ResourceProxy(res).DeletePropAsync("ForceExec");
            }
            else
            {
                Core.ResourceBrowser.DisplayResourceList(res, Core.ResourceStore.EmptyResourceList, viewName, null);
            }
        }
Beispiel #2
0
        public DragDropEffects DragOver(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState)
        {
            if (data.GetDataPresent(typeof(IResourceList)))
            {
                // The resources we're dragging
                IResourceList dragResources = (IResourceList)data.GetData(typeof(IResourceList));

                // Check if really dropping over a view-folder
                if (!(targetResource.Type == FilterManagerProps.ViewFolderResName))
                {
                    return(DragDropEffects.None);
                }

                // Collect all the direct and indirect parents of the droptarget; then we'll check to avoid dropping parent on its children
                IntArrayList parentList = IntArrayListPool.Alloc();
                try
                {
                    IResource parent = targetResource;
                    while (parent != null)
                    {
                        parentList.Add(parent.Id);
                        parent = parent.GetLinkProp(Core.Props.Parent);
                    }

                    // Check
                    foreach (IResource res in dragResources)
                    {
                        // Dropping parent over its child?
                        if (parentList.IndexOf(res.Id) >= 0)
                        {
                            return(DragDropEffects.None);
                        }
                        // Can drop only views and view-folders on view-folders
                        if (!FilterRegistry.IsViewOrFolder(res))
                        {
                            return(DragDropEffects.None);
                        }
                    }
                    return(DragDropEffects.Move);
                }
                finally
                {
                    IntArrayListPool.Dispose(parentList);
                }
            }
            return(DragDropEffects.None);
        }
Beispiel #3
0
        public DragDropEffects DragOver(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState)
        {
            if (data.GetDataPresent(typeof(IResourceList)))
            {
                // The resources we're dragging
                IResourceList dragResources = (IResourceList)data.GetData(typeof(IResourceList));

                // Check if really dropping over our resource (resource tree root for Views'n'Cats)
                if (!(targetResource == Core.ResourceTreeManager.ResourceTreeRoot))
                {
                    return(DragDropEffects.None);
                }

                // Collect all the direct and indirect parents of the droptarget; then we'll check to avoid dropping parent on its children
                List <int> parentList = new List <int>();
                IResource  parent     = targetResource;
                while (parent != null)
                {
                    parentList.Add(parent.Id);
                    parent = parent.GetLinkProp(Core.Props.Parent);
                }

                // Check
                foreach (IResource res in dragResources)
                {
                    // Dropping parent over its child?
                    if (parentList.IndexOf(res.Id) >= 0)
                    {
                        return(DragDropEffects.None);
                    }
                    // Can drop only views, view-folders, and category-tree-roots on the views'n'cats tree root
                    if (!(
                            (FilterRegistry.IsViewOrFolder(res)) ||
                            ((res.Type == "ResourceTreeRoot") && (res.HasProp("RootResourceType")) && (res.GetStringProp("RootResourceType").StartsWith("Category")))
                            ))
                    {
                        return(DragDropEffects.None);
                    }
                }
                return(DragDropEffects.Move);
            }

            return(DragDropEffects.None);
        }