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; } } }
/// <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); }
public bool HandleThreadExpand(IResource res, ThreadExpandReason reason) { IResourceThreadingHandler handler = GetResourceThreadingHandler(res); if (handler != null) { return(handler.HandleThreadExpand(res, reason)); } return(true); }
public bool CanExpandThread(IResource res, ThreadExpandReason reason) { IResourceThreadingHandler handler = GetResourceThreadingHandler(res); if (handler != null) { return(handler.CanExpandThread(res, reason)); } return(false); }
public bool IsThreadChanged(IResource res, IPropertyChangeSet changeSet) { IResourceThreadingHandler handler = GetResourceThreadingHandler(res); if (handler != null) { return(handler.IsThreadChanged(res, changeSet)); } return(false); }
public IResourceList GetThreadChildren(IResource res) { IResourceThreadingHandler handler = GetResourceThreadingHandler(res); if (handler != null) { return(handler.GetThreadChildren(res)); } return(Core.ResourceStore.EmptyResourceList); }
public IResource GetThreadParent(IResource res) { IResourceThreadingHandler handler = GetResourceThreadingHandler(res); if (handler != null) { return(handler.GetThreadParent(res)); } return(null); }
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)); }
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); }
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; }
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); }
/// <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); }
/// <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); }
private IntHashTable _propHandlerMap = new IntHashTable(); // source link type -> IResourceThreadingHandler public void AddHandler(string resType, IResourceThreadingHandler handler) { _handlerMap [resType] = handler; }
public ConversationDataProvider(IResourceList resourceList, IResourceThreadingHandler threadingHandler) : base(resourceList) { _threadingHandler = threadingHandler; _childComparer = new ResourceComparer(resourceList, new SortSettings(Core.Props.Date, true), true); }
public void AddHandler(int propId, IResourceThreadingHandler handler) { _propHandlerMap [propId] = handler; }
public void RegisterResourceThreadingHandler(string resType, IResourceThreadingHandler handler) { _threadingHandler.AddHandler(resType, handler); }
public void RegisterResourceThreadingHandler(int propId, IResourceThreadingHandler handler) { _threadingHandler.AddHandler(propId, handler); }