Пример #1
0
  public void moveToGroup(List<BibEntry> entries, NamedCompound undoAll) {
    List<GroupTreeNode> groupsContainingEntries =
        node.getNode()
            .getRoot()
            .getContainingGroups(entries, false)
            .stream()
            .filter(node -> node.getGroup().supportsRemove())
            .collect(Collectors.toList());

    List<AbstractGroup> affectedGroups =
        groupsContainingEntries.stream().map(GroupTreeNode::getGroup).collect(Collectors.toList());
    affectedGroups.add(node.getNode().getGroup());
    if (!WarnAssignmentSideEffects.warnAssignmentSideEffects(affectedGroups, panel.frame())) {
      return; // user aborted operation
    }

    // first remove
    for (GroupTreeNode group : groupsContainingEntries) {
      Optional<EntriesGroupChange> undoRemove = group.getGroup().remove(entries);
      if (undoRemove.isPresent()) {
        undoAll.addEdit(UndoableChangeEntriesOfGroup.getUndoableEdit(node, undoRemove.get()));
      }
    }

    // then add
    Optional<EntriesGroupChange> undoAdd = node.addEntriesToGroup(entries);
    if (undoAdd.isPresent()) {
      undoAll.addEdit(UndoableChangeEntriesOfGroup.getUndoableEdit(node, undoAdd.get()));
    }
  }
Пример #2
0
  public void addToGroup(List<BibEntry> entries, NamedCompound undo) {
    if (!WarnAssignmentSideEffects.warnAssignmentSideEffects(
        node.getNode().getGroup(), panel.frame())) {
      return; // user aborted operation
    }

    Optional<EntriesGroupChange> undoAdd = node.addEntriesToGroup(entries);
    if (undoAdd.isPresent()) {
      undo.addEdit(UndoableChangeEntriesOfGroup.getUndoableEdit(node, undoAdd.get()));
    }
  }