Skip to content

Commit 9d1c448

Browse files
apurvachurijosipovicjohndamasshdaolin
authored
Fix for issue 4682 : Restructuring the side pane structure having additional functionality and merging the remove group menus (#7714)
Co-authored-by: John Josipovic <[email protected]> Co-authored-by: Khate Damaso <[email protected]> Co-authored-by: daolin <[email protected]>
1 parent 2497ba4 commit 9d1c448

File tree

10 files changed

+108
-44
lines changed

10 files changed

+108
-44
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
2121
- We added two new fields to track the creation and most recent modification date and time for each entry. [koppor#130](https://github.com/koppor/jabref/issues/130)
2222
- We added a feature that allows the user to copy highlighted text in the preview window. [#6962](https://github.com/JabRef/jabref/issues/6962)
2323
- We added a feature that allows you to create new BibEntry via paste arxivId [#2292](https://github.com/JabRef/jabref/issues/2292)
24+
- We added a add group functionality at the bottom of the side pane. [#4682](https://github.com/JabRef/jabref/issues/4682)
2425
- We added a feature that allows the user to choose whether to trust the target site when unable to find a valid certification path from the file download site. [#7616](https://github.com/JabRef/jabref/issues/7616)
2526
- We added a feature that allows the user to open all linked files of multiple selected entries by "Open file" option. [#6966](https://github.com/JabRef/jabref/issues/6966)
2627
- We added a keybinding preset for new entries. [#7705](https://github.com/JabRef/jabref/issues/7705)
@@ -38,6 +39,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
3839
- We improved the linking of the `python3` interpreter via the shebang to dynamically use the systems default Python. Related to [JabRef-Browser-Extension #177](https://github.com/JabRef/JabRef-Browser-Extension/issues/177)
3940
- Automatically found pdf files now have the linking button to the far left and uses a link icon with a plus instead of a briefcase. The file name also has lowered opacity(70%) until added. [#3607](https://github.com/JabRef/jabref/issues/3607)
4041
- We simplified the select entry type form by splitting it into two parts ("Recommended" and "Others") based on internal usage data. [#6730](https://github.com/JabRef/jabref/issues/6730)
42+
- We improved the submenu list by merging the'Remove group' having two options, with or without subgroups. [#4682](https://github.com/JabRef/jabref/issues/4682)
4143
- The export to MS Office XML now uses the month name for the field `Month` instead of the two digit number [forum#2685](https://discourse.jabref.org/t/export-month-as-text-not-number/2685)
4244
- We reintroduced missing default keybindings for new entries. [#7346](https://github.com/JabRef/jabref/issues/7346) [#7439](https://github.com/JabRef/jabref/issues/7439)
4345
- Lists of available fields are now sorted alphabetically. [#7716](https://github.com/JabRef/jabref/issues/7716)
@@ -88,6 +90,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
8890
- We fixed an issue where font size of the preferences dialog does not update with the rest of the GUI. [#7416](https://github.com/JabRef/jabref/issues/7416)
8991
- We fixed an issue in which a linked online file consisting of a web page was saved as an invalid pdf file upon being downloaded. The user is now notified when downloading a linked file results in an HTML file. [#7452](https://github.com/JabRef/jabref/issues/7452)
9092
- We fixed an issue where opening BibTex file (doubleclick) from Folder with spaces not working. [#6487](https://github.com/JabRef/jabref/issues/6487)
93+
- We fixed the header title in the Add Group/Subgroup Dialog box. [#4682](https://github.com/JabRef/jabref/issues/4682)
9194
- We fixed an issue with saving large `.bib` files [#7265](https://github.com/JabRef/jabref/issues/7265)
9295
- We fixed an issue with very large page numbers [#7590](https://github.com/JabRef/jabref/issues/7590)
9396
- We fixed an issue where the file extension is missing on saving the library file on linux [#7451](https://github.com/JabRef/jabref/issues/7451)
@@ -108,6 +111,8 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
108111

109112
### Removed
110113

114+
- We removed add group button beside the filter group tab. [#4682](https://github.com/JabRef/jabref/issues/4682)
115+
111116
## [5.2] – 2020-12-24
112117

113118
### Added
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package org.jabref.gui.groups;
2+
3+
public enum GroupDialogHeader {
4+
GROUP, SUBGROUP
5+
}

src/main/java/org/jabref/gui/groups/GroupDialogView.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,19 @@ public class GroupDialogView extends BaseDialog<AbstractGroup> {
6767
private final ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer();
6868
private final GroupDialogViewModel viewModel;
6969

70-
public GroupDialogView(DialogService dialogService, BibDatabaseContext currentDatabase, PreferencesService preferencesService, AbstractGroup editedGroup) {
71-
viewModel = new GroupDialogViewModel(dialogService, currentDatabase, preferencesService, editedGroup);
70+
public GroupDialogView(DialogService dialogService, BibDatabaseContext currentDatabase, PreferencesService preferencesService, AbstractGroup editedGroup, GroupDialogHeader groupDialogHeader) {
71+
viewModel = new GroupDialogViewModel(dialogService, currentDatabase, preferencesService, editedGroup, groupDialogHeader);
7272

7373
ViewLoader.view(this)
7474
.load()
7575
.setAsDialogPane(this);
7676

7777
if (editedGroup == null) {
78-
this.setTitle(Localization.lang("Add subgroup"));
78+
if (groupDialogHeader == GroupDialogHeader.GROUP) {
79+
this.setTitle(Localization.lang("Add group"));
80+
} else if (groupDialogHeader == GroupDialogHeader.SUBGROUP) {
81+
this.setTitle(Localization.lang("Add subgroup"));
82+
}
7983
} else {
8084
this.setTitle(Localization.lang("Edit group") + " " + editedGroup.getName());
8185
}

src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,14 @@ public class GroupDialogViewModel {
107107
private final PreferencesService preferencesService;
108108
private final BibDatabaseContext currentDatabase;
109109
private final AbstractGroup editedGroup;
110+
private final GroupDialogHeader groupDialogHeader;
110111

111-
public GroupDialogViewModel(DialogService dialogService, BibDatabaseContext currentDatabase, PreferencesService preferencesService, AbstractGroup editedGroup) {
112+
public GroupDialogViewModel(DialogService dialogService, BibDatabaseContext currentDatabase, PreferencesService preferencesService, AbstractGroup editedGroup, GroupDialogHeader groupDialogHeader) {
112113
this.dialogService = dialogService;
113114
this.preferencesService = preferencesService;
114115
this.currentDatabase = currentDatabase;
115116
this.editedGroup = editedGroup;
117+
this.groupDialogHeader = groupDialogHeader;
116118

117119
setupValidation();
118120
setValues();

src/main/java/org/jabref/gui/groups/GroupTree.css

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,18 @@
102102
-fx-translate-x: -0.4em;
103103
}
104104

105-
#newGroupButton {
106-
-fx-padding: 0.1em 1.5em 0.1em 1.5em;
105+
#addNewGroup:active {
106+
-fx-border-width: 0px;
107+
-fx-background-color: -jr-theme;
108+
-fx-padding: 0.5em;
109+
-fx-text-fill: -jr-white;
110+
}
111+
112+
#addNewGroup:inactive {
113+
-fx-border-width: 0px;
114+
-fx-background-color: -jr-icon-background-active;
115+
-fx-padding: 0.5em;
116+
-fx-text-fill:-jr-black;
107117
}
108118

109119
#groupFilterBar {
@@ -116,3 +126,7 @@
116126
#groupFilterBar .glyph-icon {
117127
-fx-font-size: 2em;
118128
}
129+
130+
#groupBar .glyph-icon {
131+
-fx-font-size: 2em;
132+
}

src/main/java/org/jabref/gui/groups/GroupTree.fxml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,12 @@
77
<?import javafx.scene.control.TreeTableView?>
88
<?import javafx.scene.layout.BorderPane?>
99
<?import javafx.scene.layout.HBox?>
10-
<?import org.jabref.gui.icon.JabRefIconView?>
1110
<?import org.controlsfx.control.textfield.CustomTextField?>
1211
<BorderPane xmlns:fx="http://javafx.com/fxml/1" prefHeight="600.0" prefWidth="150.0"
1312
xmlns="http://javafx.com/javafx/8.0.112" fx:controller="org.jabref.gui.groups.GroupTreeView">
1413
<top>
1514
<HBox fx:id="groupFilterBar" alignment="CENTER" spacing="8">
1615
<CustomTextField fx:id="searchField" promptText="%Filter groups" HBox.hgrow="ALWAYS"/>
17-
<Button fx:id="newGroupButton" onAction="#addNewGroup" styleClass="icon-button"
18-
ButtonBar.buttonData="RIGHT">
19-
<graphic>
20-
<JabRefIconView glyph="NEW_GROUP" glyphSize="18"/>
21-
</graphic>
22-
<tooltip>
23-
<Tooltip text="%New group"/>
24-
</tooltip>
25-
</Button>
2616
</HBox>
2717
</top>
2818
<center>
@@ -39,4 +29,15 @@
3929
</columnResizePolicy>
4030
</TreeTableView>
4131
</center>
32+
<bottom>
33+
<HBox fx:id="groupBar" alignment="CENTER" spacing="8">
34+
<Button fx:id="addNewGroup" onAction="#addNewGroup"
35+
text="%Add group" maxWidth="Infinity" HBox.hgrow="ALWAYS">
36+
<tooltip>
37+
<Tooltip text="%New group"/>
38+
</tooltip>
39+
</Button>
40+
</HBox>
41+
42+
</bottom>
4243
</BorderPane>

src/main/java/org/jabref/gui/groups/GroupTreeView.java

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
import javafx.beans.property.ObjectProperty;
1616
import javafx.css.PseudoClass;
1717
import javafx.fxml.FXML;
18+
import javafx.scene.control.Button;
1819
import javafx.scene.control.ContextMenu;
1920
import javafx.scene.control.Control;
21+
import javafx.scene.control.Menu;
2022
import javafx.scene.control.MenuItem;
2123
import javafx.scene.control.SelectionMode;
2224
import javafx.scene.control.SeparatorMenuItem;
@@ -64,6 +66,7 @@ public class GroupTreeView {
6466
@FXML private TreeTableColumn<GroupNodeViewModel, GroupNodeViewModel> numberColumn;
6567
@FXML private TreeTableColumn<GroupNodeViewModel, GroupNodeViewModel> expansionNodeColumn;
6668
@FXML private CustomTextField searchField;
69+
@FXML private Button addNewGroup;
6770

6871
@Inject private StateManager stateManager;
6972
@Inject private DialogService dialogService;
@@ -101,6 +104,8 @@ public void initialize() {
101104
});
102105
searchField.textProperty().addListener((observable, oldValue, newValue) -> searchTask.restart());
103106

107+
setNewGroupButtonStyle(groupTree);
108+
104109
groupTree.rootProperty().bind(
105110
EasyBind.map(viewModel.rootGroupProperty(),
106111
group -> {
@@ -171,6 +176,7 @@ public void initialize() {
171176
groupTree.setRowFactory(treeTable -> {
172177
TreeTableRow<GroupNodeViewModel> row = new TreeTableRow<>();
173178
row.treeItemProperty().addListener((ov, oldTreeItem, newTreeItem) -> {
179+
setNewGroupButtonStyle(treeTable);
174180
boolean isRoot = newTreeItem == treeTable.getRoot();
175181
row.pseudoClassStateChanged(rootPseudoClass, isRoot);
176182

@@ -322,7 +328,9 @@ private Optional<TreeItem<GroupNodeViewModel>> getTreeItemByValue(TreeItem<Group
322328
}
323329

324330
private ContextMenu createContextMenuForGroup(GroupNodeViewModel group) {
331+
325332
ContextMenu menu = new ContextMenu();
333+
Menu removeGroup = new Menu(Localization.lang("Remove group"));
326334

327335
MenuItem editGroup = new MenuItem(Localization.lang("Edit group"));
328336
editGroup.setOnAction(event -> {
@@ -331,33 +339,43 @@ private ContextMenu createContextMenuForGroup(GroupNodeViewModel group) {
331339
groupTree.refresh();
332340
});
333341

342+
MenuItem removeGroupKeepSubgroups = new MenuItem(Localization.lang("Keep subgroups"));
343+
removeGroupKeepSubgroups.setOnAction(event -> viewModel.removeGroupKeepSubgroups(group));
344+
345+
MenuItem removeGroupAndSubgroups = new MenuItem(Localization.lang("Also remove subgroups"));
346+
removeGroupAndSubgroups.setOnAction(event -> viewModel.removeGroupAndSubgroups(group));
347+
334348
MenuItem addSubgroup = new MenuItem(Localization.lang("Add subgroup"));
335349
addSubgroup.setOnAction(event -> {
336350
menu.hide();
337-
viewModel.addNewSubgroup(group);
351+
viewModel.addNewSubgroup(group, GroupDialogHeader.SUBGROUP);
338352
});
339-
MenuItem removeGroupAndSubgroups = new MenuItem(Localization.lang("Remove group and subgroups"));
340-
removeGroupAndSubgroups.setOnAction(event -> viewModel.removeGroupAndSubgroups(group));
341-
MenuItem removeGroupKeepSubgroups = new MenuItem(Localization.lang("Remove group, keep subgroups"));
342-
removeGroupKeepSubgroups.setOnAction(event -> viewModel.removeGroupKeepSubgroups(group));
353+
343354
MenuItem removeSubgroups = new MenuItem(Localization.lang("Remove subgroups"));
344-
removeSubgroups.setOnAction(event -> viewModel.removeSubgroups(group));
355+
removeSubgroups.setOnAction(event -> {
356+
viewModel.removeSubgroups(group);
357+
});
358+
359+
MenuItem sortSubgroups = new MenuItem(Localization.lang("Sort subgroups"));
360+
sortSubgroups.setOnAction(event -> viewModel.sortAlphabeticallyRecursive(group));
345361

346362
MenuItem addEntries = new MenuItem(Localization.lang("Add selected entries to this group"));
347363
addEntries.setOnAction(event -> viewModel.addSelectedEntries(group));
364+
348365
MenuItem removeEntries = new MenuItem(Localization.lang("Remove selected entries from this group"));
349366
removeEntries.setOnAction(event -> viewModel.removeSelectedEntries(group));
350367

351-
MenuItem sortAlphabetically = new MenuItem(Localization.lang("Sort all subgroups (recursively)"));
352-
sortAlphabetically.setOnAction(event -> viewModel.sortAlphabeticallyRecursive(group));
353-
354368
menu.getItems().add(editGroup);
369+
removeGroup.getItems().add(removeGroupKeepSubgroups);
370+
removeGroup.getItems().add(removeGroupAndSubgroups);
371+
menu.getItems().add(removeGroup);
355372
menu.getItems().add(new SeparatorMenuItem());
356-
menu.getItems().addAll(addSubgroup, removeSubgroups, removeGroupAndSubgroups, removeGroupKeepSubgroups);
373+
menu.getItems().add(addSubgroup);
374+
menu.getItems().add(removeSubgroups);
375+
menu.getItems().add(sortSubgroups);
357376
menu.getItems().add(new SeparatorMenuItem());
358-
menu.getItems().addAll(addEntries, removeEntries);
359-
menu.getItems().add(new SeparatorMenuItem());
360-
menu.getItems().add(sortAlphabetically);
377+
menu.getItems().add(addEntries);
378+
menu.getItems().add(removeEntries);
361379

362380
// TODO: Disable some actions under certain conditions
363381
// if (group.canBeEdited()) {
@@ -397,6 +415,19 @@ private void setupClearButtonField(CustomTextField customTextField) {
397415
}
398416
}
399417

418+
private void setNewGroupButtonStyle(TreeTableView<GroupNodeViewModel> groupTree) {
419+
PseudoClass active = PseudoClass.getPseudoClass("active");
420+
PseudoClass inactive = PseudoClass.getPseudoClass("inactive");
421+
422+
if (groupTree.getRoot() != null) {
423+
boolean isActive = groupTree.getExpandedItemCount() <= 10;
424+
addNewGroup.pseudoClassStateChanged(active, isActive);
425+
addNewGroup.pseudoClassStateChanged(inactive, !isActive);
426+
} else {
427+
addNewGroup.pseudoClassStateChanged(active, true);
428+
}
429+
}
430+
400431
private static class DragExpansionHandler {
401432
private static final long DRAG_TIME_BEFORE_EXPANDING_MS = 1000;
402433
private TreeItem<GroupNodeViewModel> draggedItem;

src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private void onSelectedGroupChanged(ObservableList<GroupNodeViewModel> newValue)
111111
*/
112112
public void addNewGroupToRoot() {
113113
if (currentDatabase.isPresent()) {
114-
addNewSubgroup(rootGroup.get());
114+
addNewSubgroup(rootGroup.get(), GroupDialogHeader.GROUP);
115115
} else {
116116
dialogService.showWarningDialogAndWait(Localization.lang("Cannot create group"), Localization.lang("Cannot create group. Please create a library first."));
117117
}
@@ -147,13 +147,15 @@ private void onActiveDatabaseChanged(Optional<BibDatabaseContext> newDatabase) {
147147
/**
148148
* Opens "New Group Dialog" and add the resulting group to the specified group
149149
*/
150-
public void addNewSubgroup(GroupNodeViewModel parent) {
150+
151+
public void addNewSubgroup(GroupNodeViewModel parent, GroupDialogHeader groupDialogHeader) {
151152
currentDatabase.ifPresent(database -> {
152153
Optional<AbstractGroup> newGroup = dialogService.showCustomDialogAndWait(new GroupDialogView(
153154
dialogService,
154155
database,
155156
preferences,
156-
null));
157+
null,
158+
groupDialogHeader));
157159

158160
newGroup.ifPresent(group -> {
159161
parent.addSubgroup(group);
@@ -184,7 +186,8 @@ public void editGroup(GroupNodeViewModel oldGroup) {
184186
dialogService,
185187
database,
186188
preferences,
187-
oldGroup.getGroupNode().getGroup()));
189+
oldGroup.getGroupNode().getGroup(),
190+
GroupDialogHeader.SUBGROUP));
188191

189192
newGroup.ifPresent(group -> {
190193
// TODO: Keep assignments

src/main/java/org/jabref/gui/groups/UndoableAddOrRemoveGroup.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ public UndoableAddOrRemoveGroup(GroupTreeNodeViewModel groupsRoot,
8484
public String getPresentationName() {
8585
switch (m_editType) {
8686
case ADD_NODE:
87-
return Localization.lang("add group");
87+
return Localization.lang("Add group");
8888
case REMOVE_NODE_KEEP_CHILDREN:
89-
return Localization.lang("remove group (keep subgroups)");
89+
return Localization.lang("Keep subgroups)");
9090
case REMOVE_NODE_AND_CHILDREN:
91-
return Localization.lang("remove group and subgroups");
91+
return Localization.lang("Also remove subgroups");
9292
default:
9393
break;
9494
}

src/main/resources/l10n/JabRef_en.properties

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ Added\ string=Added string
5252

5353
All\ entries=All entries
5454

55+
Also\ remove\ subgroups=Also remove subgroups
56+
5557
Always\ reformat\ BIB\ file\ on\ save\ and\ export=Always reformat BIB file on save and export
5658

5759
and=and
@@ -450,6 +452,8 @@ JabRef\ Version\ (Required\ to\ ensure\ backwards\ compatibility\ with\ Mr.\ DLi
450452
Journal\ abbreviations=Journal abbreviations
451453
Keep\ both=Keep both
452454

455+
Keep\ subgroups=Keep subgroups
456+
453457
Key\ bindings=Key bindings
454458

455459
Key\ bindings\ changed=Key bindings changed
@@ -664,16 +668,10 @@ Remove\ selected\ entries\ from\ this\ group=Remove selected entries from this g
664668

665669
Remove\ group=Remove group
666670

667-
Remove\ group,\ keep\ subgroups=Remove group, keep subgroups
668-
669671
Remove\ group\ "%0"?=Remove group "%0"?
670672

671673
Remove\ group\ "%0"\ and\ its\ subgroups?=Remove group "%0" and its subgroups?
672674

673-
remove\ group\ (keep\ subgroups)=remove group (keep subgroups)
674-
675-
remove\ group\ and\ subgroups=remove group and subgroups
676-
677675
Remove\ group\ and\ subgroups=Remove group and subgroups
678676

679677
Remove\ link=Remove link
@@ -796,6 +794,8 @@ Skipped\ -\ PDF\ does\ not\ exist=Skipped - PDF does not exist
796794

797795
Skipped\ entry.=Skipped entry.
798796

797+
Sort\ subgroups=Sort subgroups
798+
799799
source\ edit=source edit
800800
Special\ name\ formatters=Special name formatters
801801

@@ -1722,7 +1722,6 @@ Show\ the\ document\ of\ the\ currently\ selected\ entry.=Show the document of t
17221722
Show\ this\ document\ until\ unlocked.=Show this document until unlocked.
17231723
Set\ current\ user\ name\ as\ owner.=Set current user name as owner.
17241724
1725-
Sort\ all\ subgroups\ (recursively)=Sort all subgroups (recursively)
17261725
Collect\ and\ share\ telemetry\ data\ to\ help\ improve\ JabRef=Collect and share telemetry data to help improve JabRef
17271726
Don't\ share=Don't share
17281727
Share\ anonymous\ statistics=Share anonymous statistics
@@ -1780,7 +1779,7 @@ No\ full\ text\ document\ found\ for\ entry\ %0.=No full text document found for
17801779
Delete\ Entry=Delete Entry
17811780
Next\ library=Next library
17821781
Previous\ library=Previous library
1783-
add\ group=add group
1782+
Add\ group=Add group
17841783
Entry\ is\ contained\ in\ the\ following\ groups\:=Entry is contained in the following groups\:
17851784
Delete\ entries=Delete entries
17861785
Keep\ entries=Keep entries

0 commit comments

Comments
 (0)