Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove entries from prior groups if move operation is selected #3105

Merged
merged 3 commits into from
Aug 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where changes in the source tab were not stored when selecting a new entry. [#3086](https://github.com/JabRef/jabref/issues/3086)
- We fixed an issue where the other tab was not updated when fields where changed in the source tab. [#3063](https://github.com/JabRef/jabref/issues/3063)
- We fixed an issue where the source tab was not updated after fetching data by DOI. [#3103](https://github.com/JabRef/jabref/issues/3103)
- We fixed an issue where the move to group operation did not remove the entry from other groups [#3101](https://github.com/JabRef/jabref/issues/3101)

### Removed

Expand Down
23 changes: 15 additions & 8 deletions src/main/java/org/jabref/gui/groups/GroupAddRemoveDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@

import com.jgoodies.forms.builder.ButtonBarBuilder;

/**
* Created with IntelliJ IDEA.
* User: alver
* Date: 1/22/13
* Time: 6:24 PM
* To change this template use File | Settings | File Templates.
*/
public class GroupAddRemoveDialog implements BaseAction {

private final BasePanel panel;
Expand Down Expand Up @@ -104,6 +97,7 @@ public void action() throws Exception {
ok.addActionListener(actionEvent -> {
if (doAddOrRemove()) {
diag.dispose();
tree.repaint();
}
});
cancel.addActionListener(actionEvent -> diag.dispose());
Expand Down Expand Up @@ -172,8 +166,14 @@ private boolean doAddOrRemove() {
GroupTreeNodeViewModel node = (GroupTreeNodeViewModel) path.getLastPathComponent();
if (checkGroupEnable(node)) {

List<BibEntry> entries = Globals.stateManager.getSelectedEntries();

if (move) {
recuriveRemoveFromNode((GroupTreeNodeViewModel) tree.getModel().getRoot(), entries);
}

if (add) {
node.addEntriesToGroup(Globals.stateManager.getSelectedEntries());
node.addEntriesToGroup(entries);
} else {
node.removeEntriesFromGroup(Globals.stateManager.getSelectedEntries());
}
Expand All @@ -185,6 +185,13 @@ private boolean doAddOrRemove() {
}
}

private void recuriveRemoveFromNode(GroupTreeNodeViewModel node, List<BibEntry> entries) {
node.removeEntriesFromGroup(entries);
for (GroupTreeNodeViewModel child: node.getChildren()) {
recuriveRemoveFromNode(child, entries);
}
}

/**
* Check if we can perform the action for this group. Determines whether
* the group should be shown in an enabled state, and if selecting it should
Expand Down