Search in sources :

Example 1 with MatcherSet

use of org.jabref.model.search.matchers.MatcherSet in project jabref by JabRef.

the class GroupSidePane method updateShownEntriesAccordingToSelectedGroups.

private void updateShownEntriesAccordingToSelectedGroups(List<GroupTreeNode> selectedGroups) {
    if (selectedGroups == null || selectedGroups.isEmpty()) {
        // No selected group, nothing to do
        return;
    }
    final MatcherSet searchRules = MatcherSets.build(Globals.prefs.getBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS) ? MatcherSets.MatcherType.AND : MatcherSets.MatcherType.OR);
    for (GroupTreeNode node : selectedGroups) {
        searchRules.addRule(node.getSearchMatcher());
    }
    GroupingWorker worker = new GroupingWorker(frame, panel);
    worker.run(searchRules);
    worker.update();
}
Also used : MatcherSet(org.jabref.model.search.matchers.MatcherSet) GroupTreeNode(org.jabref.model.groups.GroupTreeNode)

Example 2 with MatcherSet

use of org.jabref.model.search.matchers.MatcherSet in project jabref by JabRef.

the class GroupTreeNode method getSearchMatcher.

private SearchMatcher getSearchMatcher(GroupHierarchyType originalContext) {
    final GroupHierarchyType context = group.getHierarchicalContext();
    if (context == GroupHierarchyType.INDEPENDENT) {
        return group;
    }
    MatcherSet searchRule = MatcherSets.build(context == GroupHierarchyType.REFINING ? MatcherSets.MatcherType.AND : MatcherSets.MatcherType.OR);
    searchRule.addRule(group);
    if ((context == GroupHierarchyType.INCLUDING) && (originalContext != GroupHierarchyType.REFINING)) {
        for (GroupTreeNode child : getChildren()) {
            searchRule.addRule(child.getSearchMatcher(originalContext));
        }
    } else if ((context == GroupHierarchyType.REFINING) && !isRoot() && (originalContext != GroupHierarchyType.INCLUDING)) {
        //noinspection OptionalGetWithoutIsPresent
        searchRule.addRule(getParent().get().getSearchMatcher(originalContext));
    }
    return searchRule;
}
Also used : MatcherSet(org.jabref.model.search.matchers.MatcherSet)

Aggregations

MatcherSet (org.jabref.model.search.matchers.MatcherSet)2 GroupTreeNode (org.jabref.model.groups.GroupTreeNode)1