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] Added Select all and Deselect all buttons to the "Review changes" dialog #3731

Closed
wants to merge 1 commit into from

Conversation

N4tus
Copy link

@N4tus N4tus commented Feb 17, 2018

Added "Select all" and "Deselect all" buttons to the "Review changes" dialog. The "Select all" button is the fix for koppor#280 made by janek greif. The "Deselect all" button is an addition to that issue.


  • Change in CHANGELOG.md described
  • Tests created for changes
  • Screenshots added (for bigger UI changes)
  • Manually tested changed features in running JabRef
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)

@@ -27,6 +27,7 @@ For more details refer to the [field mapping help page](http://help.jabref.org/e
- We improved file saving so that hard links are now preserved when a save is performed [#2633](https://github.com/JabRef/jabref/issues/2633)
- We changed the default dialog option when removing a [file link](http://help.jabref.org/en/FileLinks#adding-external-links-to-an-entry) from an entry.
The new default removes the linked file from the entry instead of deleting the file from disk. [#3679](https://github.com/JabRef/jabref/issues/3679)
- Added a "Select all" [#280](https://github.com/koppor/jabref/issues/280) and "Deselect all" button in the "Review changes" dialog.
Copy link
Member

Choose a reason for hiding this comment

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

Please look at the other changelog issues and add koppor#280 as link text

Copy link
Member

Choose a reason for hiding this comment

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

To fix the merge conflict, just move the changelog line a view lines above this line. We will sort the CHANGELOG.md entries before a release.

@@ -50,8 +53,36 @@ public ChangeDisplayDialog(JFrame owner, final BasePanel panel,
tree = new JTree(root);
tree.addTreeSelectionListener(this);

//start fix issue 280
Copy link
Member

Choose a reason for hiding this comment

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

remove your comments as they are useless and don't carry any information

Enumeration<? extends Object> nodes = root.preorderEnumeration();
while (nodes.hasMoreElements()) {
Object o = nodes.nextElement();
if ((o instanceof ChangeViewModel) && (o != root)) {
Copy link
Member

Choose a reason for hiding this comment

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

I am just unsure about the o !=root, but otherwise the code is fine and works

Copy link
Member

Choose a reason for hiding this comment

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

Please add a source code comment at the line above on why this check is necessary.

@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Feb 17, 2018
@koppor koppor added the PE1718 label Feb 18, 2018
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

Minor comments. In general LGTM. The code is straightforward, but better code requires separate methods and I am not sure whether this is worth for 10 SLOC.

buttonAlignment.add(selectAll);
buttonAlignment.add(deselectAll);
treePanel.add(buttonAlignment, BorderLayout.SOUTH);
//end fix issue 280
Copy link
Member

Choose a reason for hiding this comment

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

Remove this line

JSplitPane pane = new JSplitPane();
pane.setLeftComponent(new JScrollPane(tree));
pane.setLeftComponent(new JScrollPane(treePanel)); //fix issue 280 change: tree -> treePanel
Copy link
Member

Choose a reason for hiding this comment

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

Remote the comment. You can elaborate on line 58 why you introduce a new treepanel: Code comments should be self-contained.

Enumeration<? extends Object> nodes = root.preorderEnumeration();
while (nodes.hasMoreElements()) {
Object o = nodes.nextElement();
if ((o instanceof ChangeViewModel) && (o != root)) {
Copy link
Member

Choose a reason for hiding this comment

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

Please add a source code comment at the line above on why this check is necessary.

@@ -27,6 +27,7 @@ For more details refer to the [field mapping help page](http://help.jabref.org/e
- We improved file saving so that hard links are now preserved when a save is performed [#2633](https://github.com/JabRef/jabref/issues/2633)
- We changed the default dialog option when removing a [file link](http://help.jabref.org/en/FileLinks#adding-external-links-to-an-entry) from an entry.
The new default removes the linked file from the entry instead of deleting the file from disk. [#3679](https://github.com/JabRef/jabref/issues/3679)
- Added a "Select all" [#280](https://github.com/koppor/jabref/issues/280) and "Deselect all" button in the "Review changes" dialog.
Copy link
Member

Choose a reason for hiding this comment

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

To fix the merge conflict, just move the changelog line a view lines above this line. We will sort the CHANGELOG.md entries before a release.

JButton selectAll = new JButton(Localization.lang("Select all"));
JButton deselectAll = new JButton(Localization.lang("Deselect all"));
ActionListener selectEvent = (event) -> {
boolean accept = event.getSource() == selectAll;
Copy link
Member

Choose a reason for hiding this comment

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

Please add braces around the expression:

boolean accept = (event.getSource() == selectAll);

Copy link
Member

Choose a reason for hiding this comment

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

Rename the variable to "selectStateSelectAll" (or similar). "accept" is not a speaking name, but "selectAll" is already taken by the button. Maybe, the button could be named "selectAllButton".

treePanel.add(tree, BorderLayout.CENTER);
JButton selectAll = new JButton(Localization.lang("Select all"));
JButton deselectAll = new JButton(Localization.lang("Deselect all"));
ActionListener selectEvent = (event) -> {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe the event should be called "selectOrDelesectEvent" to mirror that it is called by both select and deselect button.

@koppor
Copy link
Member

koppor commented Feb 19, 2018

Please add a screenshot so that we can compare it with #3742.

@lenhard
Copy link
Member

lenhard commented Feb 21, 2018

And added to that, please merge with master to resolve the conflicts in the Changelog.

@koppor
Copy link
Member

koppor commented Mar 9, 2018

At my last review, I decided that the code of #3742 looks better at first sight than this code.

@Siedlerchr could you please decide whether we continue with this code or the other one? Maybe the code of #3742 is very incomplete?

@koppor koppor removed the PE1718 label Mar 9, 2018
@koppor koppor removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Mar 9, 2018
@koppor koppor changed the title Added Select all and Deselect all buttons to the Review changes dialog (fix for issue #280) [WIP] Added Select all and Deselect all buttons to the "Review changes" dialog Mar 9, 2018
@tobiasdiez
Copy link
Member

Since this is still implemented in Swing, it is probably easier to add the button in the progress (or after) converting the dialog to JavaFX. Hence, I'll close this PR now.

@tobiasdiez tobiasdiez closed this Oct 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants