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

[WIP] Toggle group intersection/union solved #3739

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
7 changes: 7 additions & 0 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,13 @@ public void update() {
actions.put(Actions.REMOVE_FROM_GROUP, new GroupAddRemoveDialog(this, false, false));
actions.put(Actions.MOVE_TO_GROUP, new GroupAddRemoveDialog(this, true, true));

actions.put(Actions.INTERSECTION_PREF_GROUP, (BaseAction) () -> {
System.out.println("blubb");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

boolean state = Globals.prefs.getBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS);
state = !state;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is hard to understand and not clear on the first sight.
Better create two variables: e.g. union and intersection and then store the corresponding value

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally you would have an enum with two states, e.g. GroupState... but in this case this might be an overkill.

Globals.prefs.putBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS, state);
});

actions.put(Actions.DOWNLOAD_FULL_TEXT, new FindFullTextAction(this));
}

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ public void actionPerformed(ActionEvent e) {
private final AbstractAction removeFromGroup = new GeneralAction(Actions.REMOVE_FROM_GROUP,
Localization.lang("Remove from group") + ELLIPSES);
private final AbstractAction moveToGroup = new GeneralAction(Actions.MOVE_TO_GROUP, Localization.lang("Move to group") + ELLIPSES);
private final AbstractAction intersectPrefGroup = new GeneralAction(Actions.INTERSECTION_PREF_GROUP, Localization.lang("Toggle intersect/union pref group"));
private final Action togglePreview = enableToggle(new GeneralAction(Actions.TOGGLE_PREVIEW,
Localization.menuTitle("Toggle entry preview"),
Localization.lang("Toggle entry preview"),
Expand Down Expand Up @@ -1165,6 +1166,8 @@ private void fillMenu() {
groups.add(addToGroup);
groups.add(removeFromGroup);
groups.add(moveToGroup);
groups.addSeparator();
groups.add(intersectPrefGroup);
mb.add(groups);

view.add(getBackAction());
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/jabref/gui/actions/Actions.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class Actions {
public static final String ABBREVIATE_MEDLINE = "abbreviateMedline";
public static final String ADD_FILE_LINK = "addFileLink";
public static final String ADD_TO_GROUP = "addToGroup";
public static final String INTERSECTION_PREF_GROUP = "intersectionPrefGroup";
public static final String AUTO_SET_FILE = "autoSetFile";
public static final String BACK = "back";
public static final String CLEANUP = "Cleanup";
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/jabref/gui/preftabs/GroupsPrefsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public void setValues() {
keywordSeparator.setText(prefs.get(JabRefPreferences.KEYWORD_SEPARATOR));
autoAssignGroup.setSelected(prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP));
multiSelectionModeIntersection.setSelected(prefs.getBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS));
multiSelectionModeUnion.setSelected(!prefs.getBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is really not a good idea. If you quickly go over the code you most certainly will oerlook the not sign.
The goal is to have clear code which is ideally understanding at first sight.
https://8thlight.com/blog/dariusz-pasciak/2015/05/28/alternatives-to-boolean-parameters.html

}

@Override
Expand Down