use of org.jabref.gui.groups.UndoableModifySubtree in project jabref by JabRef.
the class GroupChange method makeChange.
@Override
public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound undoEdit) {
final GroupTreeNode root = panel.getBibDatabaseContext().getMetaData().getGroups().orElse(null);
final UndoableModifySubtree undo = new UndoableModifySubtree(new GroupTreeNodeViewModel(panel.getBibDatabaseContext().getMetaData().getGroups().orElse(null)), new GroupTreeNodeViewModel(root), Localization.lang("Modified groups"));
root.removeAllChildren();
if (changedGroups == null) {
// I think setting root to null is not possible
root.setGroup(DefaultGroupsFactory.getAllEntriesGroup());
} else {
// change root group, even though it'll be AllEntries anyway
root.setGroup(changedGroups.getGroup());
for (GroupTreeNode child : changedGroups.getChildren()) {
child.copySubtree().moveTo(root);
}
}
undoEdit.addEdit(undo);
// Update tmp database:
tmpGroupRoot.removeAllChildren();
if (changedGroups != null) {
GroupTreeNode copied = changedGroups.copySubtree();
tmpGroupRoot.setGroup(copied.getGroup());
for (GroupTreeNode child : copied.getChildren()) {
child.copySubtree().moveTo(tmpGroupRoot);
}
}
return true;
}
Aggregations