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())); } }
/** @param node The node whose assignments were edited. */ public UndoableChangeAssignment( GroupTreeNodeViewModel node, Set<BibEntry> previousAssignments, Set<BibEntry> newAssignments) { this.previousAssignments = new ArrayList<>(previousAssignments); this.newAssignments = new ArrayList<>(newAssignments); this.root = node.getNode().getRoot(); this.pathToNode = node.getNode().getIndexedPathFromRoot(); }
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())); } }
/** @param move If true, remove entries from all other groups. */ public AddToGroupAction(GroupTreeNodeViewModel node, boolean move, BasePanel panel) { super(node.getNode().getGroup().getName()); this.node = node; this.move = move; this.panel = panel; }