From e3179ea344beea9d1eaced32f2f5c38d04801412 Mon Sep 17 00:00:00 2001 From: N4tus Date: Fri, 16 Feb 2018 17:33:59 +0100 Subject: [PATCH] Added Select all and Deselect all Buttons to the Review changes dialog (fix for issue #280) --- CHANGELOG.md | 1 + .../gui/collab/ChangeDisplayDialog.java | 33 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index edb325d075c..13f59d1dc0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. ### Fixed - We fixed an issue where pressing space caused the cursor to jump to the start of the text field. [#3471](https://github.com/JabRef/jabref/issues/3471) diff --git a/src/main/java/org/jabref/gui/collab/ChangeDisplayDialog.java b/src/main/java/org/jabref/gui/collab/ChangeDisplayDialog.java index 1bf8978f1f0..e443c43f8f1 100644 --- a/src/main/java/org/jabref/gui/collab/ChangeDisplayDialog.java +++ b/src/main/java/org/jabref/gui/collab/ChangeDisplayDialog.java @@ -1,7 +1,10 @@ package org.jabref.gui.collab; import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; import java.awt.Insets; +import java.awt.event.ActionListener; import java.util.Collections; import java.util.Enumeration; @@ -50,8 +53,36 @@ public ChangeDisplayDialog(JFrame owner, final BasePanel panel, tree = new JTree(root); tree.addTreeSelectionListener(this); + //start fix issue 280 + this.setMinimumSize(new Dimension(400, 400)); + JPanel treePanel = new JPanel(new BorderLayout()); + JPanel buttonAlignment = new JPanel(new FlowLayout(FlowLayout.LEADING)); + treePanel.add(tree, BorderLayout.CENTER); + JButton selectAll = new JButton(Localization.lang("Select all")); + JButton deselectAll = new JButton(Localization.lang("Deselect all")); + ActionListener selectEvent = (event) -> { + boolean accept = event.getSource() == selectAll; + Enumeration nodes = root.preorderEnumeration(); + while (nodes.hasMoreElements()) { + Object o = nodes.nextElement(); + if ((o instanceof ChangeViewModel) && (o != root)) { + ((ChangeViewModel) o).setAccepted(accept); + } + } + cb.setSelected(accept); + if (selected != null) { + cb.setEnabled(selected.isAcceptable()); + } + }; + selectAll.addActionListener(selectEvent); + deselectAll.addActionListener(selectEvent); + buttonAlignment.add(selectAll); + buttonAlignment.add(deselectAll); + treePanel.add(buttonAlignment, BorderLayout.SOUTH); + //end fix issue 280 + JSplitPane pane = new JSplitPane(); - pane.setLeftComponent(new JScrollPane(tree)); + pane.setLeftComponent(new JScrollPane(treePanel)); //fix issue 280 change: tree -> treePanel JPanel infoBorder = new JPanel(); pane.setRightComponent(infoBorder);