Example #1
0
        public override void Update(IActionContext context, ref ActionPresentation presentation)
        {
            base.Update(context, ref presentation);
            bool anyHasThreadHandler = false;

            for (int i = 0; i < context.SelectedResources.Count; i++)
            {
                string resType = context.SelectedResources [i].Type;
                IResourceThreadingHandler threadingHandler = Core.PluginLoader.GetResourceThreadingHandler(resType);
                if (threadingHandler != null)
                {
                    IResource threadRoot = ConversationBuilder.GetConversationRoot(context.SelectedResources [i]);
                    if (threadingHandler.CanExpandThread(threadRoot, ThreadExpandReason.Enumerate))
                    {
                        anyHasThreadHandler = true;
                        break;
                    }
                }
            }

            if (!anyHasThreadHandler)
            {
                if (context.Kind == ActionContextKind.MainMenu)
                {
                    presentation.Enabled = false;
                }
                else
                {
                    presentation.Visible = false;
                }
            }
        }
Example #2
0
        /// <summary>
        /// Return <c>true</c> if <c>head</c> of the conversation is reachable from the
        /// <c>intern</c> resource.
        /// </summary>
        public static bool AreLinked(IResource head, IResource intern)
        {
            IResourceThreadingHandler handler = Core.PluginLoader.GetResourceThreadingHandler(head.Type);

            if (handler == null)
            {
                return(false);
            }
            IResource rootRes = intern;

            while (true)
            {
                IResource parent = handler.GetThreadParent(rootRes);
                if (parent == null)
                {
                    break;
                }

                if (parent.Id == head.Id)
                {
                    return(true);
                }

                rootRes = parent;
            }
            return(false);
        }
Example #3
0
        public bool HandleThreadExpand(IResource res, ThreadExpandReason reason)
        {
            IResourceThreadingHandler handler = GetResourceThreadingHandler(res);

            if (handler != null)
            {
                return(handler.HandleThreadExpand(res, reason));
            }
            return(true);
        }
Example #4
0
        public bool CanExpandThread(IResource res, ThreadExpandReason reason)
        {
            IResourceThreadingHandler handler = GetResourceThreadingHandler(res);

            if (handler != null)
            {
                return(handler.CanExpandThread(res, reason));
            }
            return(false);
        }
Example #5
0
        public bool IsThreadChanged(IResource res, IPropertyChangeSet changeSet)
        {
            IResourceThreadingHandler handler = GetResourceThreadingHandler(res);

            if (handler != null)
            {
                return(handler.IsThreadChanged(res, changeSet));
            }
            return(false);
        }
Example #6
0
        public IResourceList GetThreadChildren(IResource res)
        {
            IResourceThreadingHandler handler = GetResourceThreadingHandler(res);

            if (handler != null)
            {
                return(handler.GetThreadChildren(res));
            }
            return(Core.ResourceStore.EmptyResourceList);
        }
Example #7
0
        public IResource GetThreadParent(IResource res)
        {
            IResourceThreadingHandler handler = GetResourceThreadingHandler(res);

            if (handler != null)
            {
                return(handler.GetThreadParent(res));
            }
            return(null);
        }
Example #8
0
        public static IResourceList UnrollConversationFromCurrent(IResource root)
        {
            IResourceThreadingHandler handler = Core.PluginLoader.GetResourceThreadingHandler(root.Type);
            IResourceList             conv    = root.ToResourceListLive();

            if (handler == null)
            {
                return(conv);
            }
            return(UnrollConversationRecursive(conv, root, handler));
        }
Example #9
0
        private static IResourceList UnrollConversationRecursive(IResourceList conv, IResource res,
                                                                 IResourceThreadingHandler handler)
        {
            IResourceList replies = handler.GetThreadChildren(res);

            conv = replies.Union(conv);
            foreach (IResource replyRes in replies)
            {
                conv = UnrollConversationRecursive(conv, replyRes, handler);
            }
            return(conv);
        }
Example #10
0
 public ResourceListDisplayOptions(ResourceListDisplayOptions options)
 {
     _caption                  = options.Caption;
     _captionTemplate          = options.CaptionTemplate;
     _columns                  = options.Columns;
     _selectedResource         = options.SelectedResource;
     _highlightDataProvider    = options.HighlightDataProvider;
     _threadingHandler         = options.ThreadingHandler;
     _sortSettings             = options.SortSettings;
     _tabFilter                = options.TabFilter;
     _seeAlsoBar               = options.SeeAlsoBar;
     _suppressContexts         = options.SuppressContexts;
     _statusLine               = options.StatusLine;
     _statusLineClickHandler   = options.StatusLineClickHandler;
     _emptyText                = options.EmptyText;
     _transientContainerPaneId = options._transientContainerPaneId;
     _transientContainerParent = options._transientContainerParent;
 }
Example #11
0
        private IResourceThreadingHandler GetResourceThreadingHandler(IResource res)
        {
            IResourceThreadingHandler handler = (IResourceThreadingHandler)_handlerMap [res.Type];

            if (handler == null)
            {
                lock ( _propHandlerMap )
                {
                    foreach (IntHashTable.Entry entry in _propHandlerMap)
                    {
                        if (res.HasProp(entry.Key))
                        {
                            handler = (IResourceThreadingHandler)entry.Value;
                            break;
                        }
                    }
                }
            }
            return(handler);
        }
Example #12
0
        /// <summary>
        /// Checks the presence of the property upwards the thread parents.
        /// </summary>
        /// <param name="res">The resource in a conversation.</param>
        /// <param name="propId">Property to be checked.</param>
        /// <param name="propId">Resource which has such property, null if none of the parents has it.</param>
        /// <returns>true if any of the parent of the resource contains the specified property.</returns>
        public static bool CheckPropOnParents(IResource res, int propId, out IResource propRes)
        {
            bool result = res.HasProp(propId);

            IResourceThreadingHandler handler = Core.PluginLoader.GetResourceThreadingHandler(res.Type);

            if (handler != null)
            {
                while (!result && res != null)
                {
                    res = handler.GetThreadParent(res);
                    if (res != null)
                    {
                        result = res.HasProp(propId);
                    }
                }
            }
            propRes = result ? res : null;

            return(result);
        }
Example #13
0
        /// <summary>
        /// Returns the root resource of the specified conversation.
        /// </summary>
        /// <param name="res">The resource in a conversation.</param>
        /// <returns>The root resource of the conversation, or <paramref name="res"/> if no
        /// threading handler has been registered for the resource type.</returns>
        public static IResource GetConversationRoot(IResource res)
        {
            IResourceThreadingHandler handler = Core.PluginLoader.GetResourceThreadingHandler(res.Type);

            if (handler == null)
            {
                return(res);
            }
            IResource rootRes = res;

            while (true)
            {
                IResource parent = handler.GetThreadParent(rootRes);
                if (parent == null)
                {
                    break;
                }

                rootRes = parent;
            }
            return(rootRes);
        }
Example #14
0
        private IntHashTable _propHandlerMap = new IntHashTable(); // source link type -> IResourceThreadingHandler

        public void AddHandler(string resType, IResourceThreadingHandler handler)
        {
            _handlerMap [resType] = handler;
        }
Example #15
0
 public ConversationDataProvider(IResourceList resourceList, IResourceThreadingHandler threadingHandler)
     : base(resourceList)
 {
     _threadingHandler = threadingHandler;
     _childComparer    = new ResourceComparer(resourceList, new SortSettings(Core.Props.Date, true), true);
 }
Example #16
0
 public void AddHandler(int propId, IResourceThreadingHandler handler)
 {
     _propHandlerMap [propId] = handler;
 }
Example #17
0
File: Plugins.cs Project: mo5h/omeo
 public void RegisterResourceThreadingHandler(string resType, IResourceThreadingHandler handler)
 {
     _threadingHandler.AddHandler(resType, handler);
 }
Example #18
0
File: Plugins.cs Project: mo5h/omeo
 public void RegisterResourceThreadingHandler(int propId, IResourceThreadingHandler handler)
 {
     _threadingHandler.AddHandler(propId, handler);
 }