protected override void Execute() { string[] currentResTypes = Core.TabManager.CurrentTab.GetResourceTypes(); IResourceList unreadList = Core.ResourceStore.FindResourcesWithProp(null, Core.Props.IsUnread); foreach (IResource view in _views) { IResourceList inView = Core.FilterEngine.ExecView(view); IResource ws = Core.WorkspaceManager.ActiveWorkspace; if (ws != null) { inView = inView.Intersect(Core.WorkspaceManager.GetFilterList(ws), true); } inView = inView.Intersect(unreadList, true); for (int i = inView.Count - 1; i >= 0; --i) { IResource res = inView[i]; if (currentResTypes == null || Array.IndexOf(currentResTypes, res.Type) != -1) { res.DeleteProp("IsUnread"); } } } }
public bool DecorateNode(IResource res, RichText nodeText) { if (res.HasProp(Core.Props.ShowTotalCount)) { IResource wsp = Core.WorkspaceManager.ActiveWorkspace; if (res.Type == FilterManagerProps.ViewResName) { IResourceList total = Core.FilterEngine.ExecView(res); if (!res.HasProp("ShowDeletedItems")) { total = total.Minus(_allDeleted); } total = total.Intersect(_allTyped); if (wsp != null) { total = total.Intersect(wsp.GetLinksOfType(null, "WorkspaceVisible"), true); } if (total.Count != 0) { nodeText.Append(" "); nodeText.Append("[" + total.Count + "]", _textStyle); } return(true); } else if (res.Type == "Category") { bool leafCategory = (res.GetLinksTo(null, Core.Props.Parent).Count == 0); IResourceList inThis = Core.ResourceStore.EmptyResourceList, total; if (leafCategory) { total = CollectResources(res, wsp); } else { CollectResources(res, wsp, out inThis, out total); } if (total.Count != 0) { nodeText.Append(" "); if (leafCategory) { nodeText.Append("[" + total.Count + "]", _textStyle); } else { nodeText.Append("[" + inThis.Count + "|" + total.Count + "]", _textStyle); } } return(true); } } return(false); }
public override void Execute(IResourceList selectedResources) { foreach (IResource category in selectedResources) { IResourceList categoryResources = category.GetLinksOfType(null, (Core.CategoryManager as CategoryManager).PropCategory); categoryResources = categoryResources.Intersect(Core.TabManager.CurrentTab.GetFilterList(false), true); categoryResources = categoryResources.Intersect(Core.ResourceStore.FindResourcesWithProp(null, "IsUnread"), true); foreach (IResource res in categoryResources) { res.SetProp("IsUnread", false); } } }
/// <summary> /// Queue for download those enclosures of the feed's unread items which /// are not yet downloaded or queued. /// </summary> /// <param name="feed">A feed resource which items are to be analyzed.</param> private void ScheduleEnclosures(IResource feed) { IResourceList items = feed.GetLinksOfType(Props.RSSItemResource, Props.RSSItem); items = items.Intersect(Core.ResourceStore.FindResourcesWithProp(Props.RSSItemResource, Core.Props.IsUnread), true); items = items.Minus(Core.ResourceStore.FindResourcesWithProp(Props.RSSItemResource, Core.Props.IsDeleted)); IResourceList itemsWithEncls = Core.ResourceStore.FindResources(null, Props.EnclosureDownloadingState, (int)EnclosureDownloadState.NotDownloaded); items = items.Intersect(itemsWithEncls, true); foreach (IResource item in items) { EnclosureDownloadManager.PlanToDownload(item); } }
public IResource ParseTokenStream(string stream) { IResource condition = null; IResourceList candidates = Core.ResourceStore.EmptyResourceList; stream = stream.ToLower().Trim(); if (stream == "me" || stream == "myself") { candidates = candidates.Union(Core.ContactManager.MySelf.Resource.ToResourceList()); } else { string[] tokens = stream.Split(' '); foreach (string token in tokens) { IResourceList list = Core.ResourceStore.FindResources("Contact", ContactManager._propFirstName, token); list = list.Union(Core.ResourceStore.FindResources("Contact", ContactManager._propLastName, token)); candidates = (candidates.Count == 0) ? list : candidates.Intersect(list); } } if (candidates.Count > 0) { IResource template = Core.FilterRegistry.Std.FromContactX; if (template != null) // Everything is possible :-( { condition = Core.FilterRegistry.InstantiateConditionTemplate(template, candidates, null); } } return(condition); }
public bool DecorateNode(IResource res, RichText nodeText) { if (res.Type == NntpPlugin._newsGroup) { int count = 0; if (_groups2watchedHeads.ContainsKey(res)) { IResourceList groupItems = NntpPlugin.CollectArticles(res, false); groupItems = groupItems.Intersect(_unreadArticles); List <IResource> heads = _groups2watchedHeads[res]; foreach (IResource head in heads) { IResourceList thread = ConversationBuilder.UnrollConversationFromCurrent(head); count += thread.Intersect(groupItems).Count; } } if (count != 0) { nodeText.Append(" !", _watchedTextStyle); } return(count != 0); } return(false); }
private static void UpgradeContactNames() { int percent = 0; IResourceList contacts = Core.ResourceStore.GetAllResources("Contact"); for (int i = 0; i < contacts.Count; i++) { Trace.WriteLine("ViewsInitializer -- Upgrading contact names for contact: " + contacts[i].DisplayName); IResourceList accounts = contacts[i].GetLinksOfType("EmailAccount", Core.ContactManager.Props.LinkEmailAcct); foreach (IResource accnt in accounts) { IResourceList cNames = contacts[i].GetLinksOfType("ContactName", Core.ContactManager.Props.LinkBaseContact); cNames = cNames.Intersect(accnt.GetLinksOfType("ContactName", Core.ContactManager.Props.LinkEmailAcct), true); ProcessContactNamesList(cNames); } int newPercent = (int)(i * 100.0 / contacts.Count); if (newPercent != percent) { percent = newPercent; if (Core.ProgressWindow != null) { Core.ProgressWindow.UpdateProgress(percent, "Updating Contact Names pool from older builds...", null); } } } }
private int GetUnreadCountFromLinks(IResource res, UnreadState state) { int count; int persistentCount = GetPersistentUnreadCount(res); if (persistentCount == 0) { count = 0; } else { int unfilteredCount; IResourceList links = GetUnreadCountedLinks(res, out unfilteredCount); if (links == null) { count = 0; } else { links = links.Intersect(_tabProvider.GetTabFilterList(state.Tab), true); count = CountUnreadResources(links); // HACK: Cleanup for out-of-sync UnreadCount values if (links.Count == unfilteredCount && count != persistentCount) { SetPersistentUnreadCount(res, count); MarkUnreadCounterChanged(res); } } } return(count); }
public override void Execute(IActionContext context) { int count = 0, maxCount = 0; string maxContact = ""; IResourceList contacts = Core.ResourceStore.GetAllResources("Contact"); for (int i = 0; i < contacts.Count; i++) { Trace.WriteLine("ViewsInitializer -- Upgrading contact names for contact: " + contacts[i].DisplayName); IResourceList accounts = contacts[i].GetLinksOfType("EmailAccount", Core.ContactManager.Props.LinkEmailAcct); foreach (IResource accnt in accounts) { IResourceList cNames = contacts[i].GetLinksOfType("ContactName", Core.ContactManager.Props.LinkBaseContact); cNames = cNames.Intersect(accnt.GetLinksOfType("ContactName", Core.ContactManager.Props.LinkEmailAcct)); int localCount = ProcessContactNamesList(cNames); if (localCount > maxCount) { maxCount = localCount; maxContact = contacts[i].DisplayName; } count += localCount; } } MessageBox.Show("Met " + count + " repeatable contact names. Maximal duplicating contact is [" + maxContact + "]"); }
/** * If a workspace is active, removes the category combo and shows only the * contacts linked to the workspace. */ public override void SetActiveWorkspace(IResource workspace) { if (workspace == _lastWorkspace) { return; } _lastWorkspace = workspace; if (workspace == null) { _cmbCategory.Visible = true; _lblShowCategory.Visible = true; _listContacts.Top = _cmbCategory.Top + 28; UpdateSelectedCategory(); } else { _cmbCategory.Visible = false; _lblShowCategory.Visible = false; _listContacts.Top = _cmbCategory.Top; IResourceList correspondentList = workspace.GetLinksToLive("Contact", "InWorkspace"); if (_correspondentFilterList != null) { correspondentList = correspondentList.Intersect(_correspondentFilterList, true); } ShowCorrespondents(correspondentList); } _listContacts.Height = Height - _listContacts.Top; }
public override void EnumerationStarting() { IResourceList inView = Core.FilterEngine.ExecView(_savedView); inView = inView.Intersect(Core.ResourceBrowser.FilterResourceList, true); ResourceIds = new IntArrayList(inView.ResourceIds); Index = 0; }
public IResource FindRule(string name) { IResourceList list = Core.ResourceStore.FindResources(null, Core.Props.Name, name); list = list.Intersect(AllRules, true); return((list.Count > 0) ? list[0] : null); }
/** * Returns the count of unread resources returned by the specified provider and * filtered by the workspace. */ private int GetProviderUnreadCount(IResource res, UnreadState state, IUnreadCountProvider provider) { IResourceList unreadList = provider.GetResourcesForView(res); if (unreadList == Core.ResourceStore.EmptyResourceList) { return(0); } if (state != _defaultUnreadState) { unreadList = unreadList.Intersect(_tabProvider.GetTabFilterList(state.Tab)); if (state.Workspace != null) { unreadList = unreadList.Intersect(_workspaceManager.GetFilterList(state.Workspace)); } } return(unreadList.Count); }
public IResource FindRule(string name) { IResourceList list = Core.ResourceStore.FindResourcesWithProp(FilterManagerProps.ViewCompositeResName, "IsFormattingFilter"); IResourceList named = Core.ResourceStore.FindResources(null, Core.Props.Name, name); list = list.Intersect(named, true); return((list.Count > 0) ? list[0] : null); }
private static IResourceList ComputeList(IResource view) { IResourceList list = Core.FilterEngine.ExecView(view, null, SelectionType.Live); list = ResourceTypeHelper.ExcludeUnloadedPluginResources(list); list = list.Minus(Core.ResourceStore.FindResourcesWithProp(null, Core.Props.IsDeleted)); list = list.Intersect(Core.ResourceStore.FindResourcesWithProp(null, Core.Props.IsUnread), true); return(list); }
private static IResourceList[] SplitResourceList(string[] resTypes, IResourceList selectedResources) { IResourceList[] result = new IResourceList[resTypes.Length]; for (int i = 0; i < resTypes.Length; i++) { result [i] = selectedResources.Intersect(Core.ResourceStore.GetAllResources(resTypes[i])); } return(result); }
public bool MatchResource(IResource res, IActionParameterStore actionStore) { IResourceList contacts = actionStore.ParametersAsResList(); IResourceList linked = res.GetLinksOfType(null, Core.ContactManager.Props.LinkFrom); linked = linked.Union(res.GetLinksOfType(null, Core.ContactManager.Props.LinkTo), true); linked = linked.Intersect(contacts, true); return(linked.Count > 0); }
private IResourceList GetPureList(IResource res, IResource wsp) { IResourceList total = res.GetLinksOfType(null, "Category").Minus(_allDeleted).Intersect(_allTyped); if (wsp != null) { total = total.Intersect(wsp.GetLinksOfType(null, "WorkspaceVisible"), true); } return(total); }
private static void RegisterCustomConditions() { IResource res; IFilterRegistry fMgr = Core.FilterRegistry; #region Core.FilterRegistry.Std.ResourceIsCategorized Cleaning // Fix previous version of this condition (it was implemented as // predicate-type). IResourceList old = Core.ResourceStore.FindResources(FilterManagerProps.ConditionResName, "Name", Core.FilterRegistry.Std.ResourceIsCategorizedName); old = old.Intersect(Core.ResourceStore.FindResources(FilterManagerProps.ConditionResName, "ConditionType", "predicate"), true); old.DeleteAll(); #endregion Core.FilterRegistry.Std.ResourceIsCategorized Cleaning fMgr.RegisterCustomCondition(fMgr.Std.ResourceIsCategorizedName, fMgr.Std.ResourceIsCategorizedNameDeep, null, new ResourceIsCategorized()); res = fMgr.RegisterCustomCondition(fMgr.Std.ResourceHasEmptyContentName, fMgr.Std.ResourceHasEmptyContentNameDeep, null, new ResourceHasEmptyContent()); fMgr.MarkConditionOnlyForRule(res); res = fMgr.CreateStandardCondition(FilterManagerStandards.DummyConditionName, FilterManagerStandards.DummyConditionName, null, "Id", ConditionOp.Gt, "0"); res.SetProp("Invisible", true); res = fMgr.CreateCustomConditionTemplate(fMgr.Std.InTheCategoryAndSubcategoriesXName, fMgr.Std.InTheCategoryAndSubcategoriesXNameDeep, null, new MatchCategoryAndSubcategories(), ConditionOp.In, "Category", "Category"); fMgr.AssociateConditionWithGroup(res, "Category Conditions"); res = fMgr.CreateCustomConditionTemplate(fMgr.Std.FromToCCContactXName, fMgr.Std.FromToCCContactXNameDeep, null, new CorrespondenceOfContact(), ConditionOp.In, "Contact", "Category"); fMgr.AssociateConditionWithGroup(res, "Address and Contact Conditions"); res = fMgr.CreateCustomConditionTemplate(fMgr.Std.FromToContactXName, fMgr.Std.FromToContactXNameDeep, null, new FromToOfContact(), ConditionOp.In, "Contact", "Category"); fMgr.AssociateConditionWithGroup(res, "Address and Contact Conditions"); res = fMgr.CreateCustomConditionTemplate(fMgr.Std.ResourceContainsTextXName, fMgr.Std.ResourceContainsTextXNameDeep, null, new ResourceContainsText(), ConditionOp.Eq, "Subject"); fMgr.AssociateConditionWithGroup(res, "Text Query Conditions"); fMgr.MarkConditionOnlyForRule(res); res = fMgr.CreateCustomConditionTemplate(fMgr.Std.MessageIsInThreadOfXName, fMgr.Std.MessageIsInThreadOfXNameDeep, null, new MessageIsInThreadOf(), ConditionOp.In, "Email", "Category"); res.SetProp("Invisible", true); // Interversion consistency. In old build this condition was // registered in other plugin(s). Since they now refer to Std, // we have to register it again. res = fMgr.CreateConditionTemplate(fMgr.Std.FromContactXName, fMgr.Std.FromContactXNameDeep, null, ConditionOp.In, "Contact", "From"); fMgr.AssociateConditionWithGroup(res, "Address and Contact Conditions"); // Upgrade for old versions. res = fMgr.CreateConditionTemplate(fMgr.Std.DeletedInTheTimeSpanXName, fMgr.Std.DeletedInTheTimeSpanXNameDeep, null, ConditionOp.Eq, "DelDate"); fMgr.AssociateConditionWithGroup(res, "Temporal Conditions"); }
private static void MarkFolderAsRead(IResource folder) { IResourceList mails = folder.GetLinksOfType(STR.Email, PROP.MAPIFolder); mails = mails.Intersect( Core.ResourceStore.FindResourcesWithProp(STR.Email, Core.Props.IsUnread), true); foreach (IResource mail in mails) { mail.SetProp(Core.Props.IsUnread, false); } }
private static IResourceList CollectAllTextConditions() { // NOTE: Do not change to int value since FilterRegistry might not been initialized to that time. string condProp = "ConditionOp" /*FilterRegistry.OpProp*/; // Get ALL conditions with text queries and remove those which are // "hanged" due to the bug of Search Views cleanup. IResourceList allQuery = Core.ResourceStore.FindResourcesLive(FilterManagerProps.ConditionResName, condProp, (int)ConditionOp.QueryMatch); IResourceList allActive = Core.ResourceStore.FindResourcesWithPropLive(FilterManagerProps.ConditionResName, "LinkedCondition"); IResourceList result = allQuery.Intersect(allActive); return(result); }
private void DeleteIgnoredClientChangesets(IResource repository, string[] clients) { foreach (string client in clients) { IResourceList changeSets = Core.ResourceStore.FindResources(Props.ChangeSetResource, Props.P4Client, client); changeSets = changeSets.Intersect(repository.GetLinksOfType(Props.ChangeSetResource, Props.ChangeSetRepository)); foreach (IResource changeSet in changeSets) { DeleteRepositoryAction.DeleteChangeSet(changeSet); } } }
protected static IResource FindChangeSet(IResource repository, int number) { IResourceList existingCS = Core.ResourceStore.FindResources(Props.ChangeSetResource, Props.ChangeSetNumber, number); existingCS = existingCS.Intersect( repository.GetLinksOfType(Props.ChangeSetResource, Props.ChangeSetRepository)); if (existingCS.Count > 0) { return(existingCS [0]); } return(null); }
/** * finds resource for a file */ public IResource FindFile(FileInfo fileInfo) { IResource folder = FindDirectory(IOTools.GetDirectoryName(fileInfo)); if (folder == null) { return(null); } IResourceList files = folder.GetLinksTo(null, FileProxy._propParentFolder); files = files.Intersect( Core.ResourceStore.FindResources(null, Core.Props.Name, IOTools.GetName(fileInfo)), true); return((files.Count > 0) ? files[0] : null); }
public IResourceList GetFilterList(bool live, bool includeFragments) { if (_resTypes == null) { return(null); } IResourceList list = live ? Core.ResourceStore.GetAllResourcesLive(_resTypes) : Core.ResourceStore.GetAllResources(_resTypes); IResourceList fragmentList = null; SelectionType selType = live ? SelectionType.Live : SelectionType.Normal; if (includeFragments) { for (int i = 0; i < _resTypes.Length; i++) { IResourceList foundList = Core.ResourceStore.FindResources(selType, null, "ContentType", _resTypes[i]); if (fragmentList == null) { fragmentList = foundList; } else { fragmentList = fragmentList.Union(foundList, true); } } if (fragmentList != null) { fragmentList = fragmentList.Intersect(Core.ResourceStore.GetAllResources("Fragment"), true); } list = list.Union(fragmentList); } if (_linkPropId != -1) { IResourceList fileResourceTypes = Core.ResourceStore.GetAllResources(ResourceTypeHelper.GetFileResourceTypes()); fileResourceTypes = fileResourceTypes.Intersect( Core.ResourceStore.FindResourcesWithProp(selType, null, _linkPropId), true); list = list.Union(fileResourceTypes, true); if (includeFragments) { list = list.Union(Core.ResourceStore.FindResources("Fragment", "ContentLinks", Core.ResourceStore.PropTypes[_linkPropId].Name), true); } } return(list); }
public JiraProject FindProjectByJiraId(string id) { IResourceList resources = Core.ResourceStore.FindResources(Types.JiraProject, Props.JiraId, id); resources = resources.Intersect(Resource.GetLinksTo(Types.JiraProject, Core.Props.Parent), true); if (resources.Count > 0) { return(GetProject(resources[0])); } else { return(null); } }
public TResourceObject FindByJiraId(string id) { IResourceList resources = Core.ResourceStore.FindResources(_restype, Props.JiraId, id); resources = resources.Intersect(_server.Resource.GetLinksTo(_restype, Core.Props.Parent), true); if (resources.Count > 0) { return(CreateResourceObject(resources[0])); } else { return(null); } }
private void UpdateGroupUnreadCountRecursive(IResource group, bool fireDecorationChanged) { Trace.WriteLineIf(Settings.Trace, "Recursive update of unread count for group " + group.DisplayName); int count = 0; IResourceList childGroups = group.GetLinksTo("RSSFeedGroup", Core.Props.Parent); if (Core.WorkspaceManager.ActiveWorkspace != null) { childGroups = childGroups.Intersect(Core.WorkspaceManager.ActiveWorkspace.GetLinksOfType(null, "WorkspaceVisible"), true); } foreach (IResource childGroup in childGroups) { UpdateGroupUnreadCountRecursive(childGroup, fireDecorationChanged); int childUnreadCount = GetGroupUnreadCount(childGroup); Trace.WriteLineIf(Settings.Trace, group.DisplayName + ": Included " + childUnreadCount + " unreads from child group " + childGroup.DisplayName); count += childUnreadCount; } IResourceList childFeeds = group.GetLinksTo("RSSFeed", Core.Props.Parent); if (Core.WorkspaceManager.ActiveWorkspace != null) { childFeeds = childFeeds.Intersect(Core.WorkspaceManager.ActiveWorkspace.GetLinksOfType(null, "WorkspaceVisible"), true); } foreach (IResource feed in childFeeds) { int feedCount = feed.GetIntProp(_propUnreadCount); Trace.WriteLineIf(Settings.Trace, group.DisplayName + ": Included " + feedCount + " unreads from feed " + feed.DisplayName); count += feedCount; } if (GetGroupUnreadCount(group) != count) { SetGroupUnreadCount(group, count); if (fireDecorationChanged && DecorationChanged != null) { DecorationChanged(this, new ResourceEventArgs(group)); } } else { Trace.WriteLineIf(Settings.Trace, "Skipped update of group unread count for " + group.DisplayName + " because the value did not change"); } }
/// <summary> /// Update the filter list based on the active tab and workspace. /// </summary> private void UpdateResourceBrowserFilterList() { IResourceList tabFilterList = null; if (_curTabFilter != null) { tabFilterList = _curTabFilter.GetFilterList(true); } if (_activeWorkspaceFilterList != null) { Trace.WriteLine("Intersecting tab filter list with workspace filter list"); tabFilterList = _activeWorkspaceFilterList.Intersect(tabFilterList); } _resourceBrowser.SetFilterResourceList(tabFilterList); _curUnreadState = _unreadManager.SetUnreadState(CurrentTabId, _activeWorkspace); }
public bool MatchResource(IResource res, IActionParameterStore actionStore) { bool match = false; if (res.Type != "Category") { IResourceList linkedCategories = res.GetLinksOfType("Category", "Category"); if (linkedCategories.Count > 0) { IResourceList matchCats = actionStore.ParametersAsResList(); matchCats = CategoriesTree(matchCats); match = (matchCats.Intersect(linkedCategories, true).Count > 0); } } return(match); }