Skip to content

Commit

Permalink
Fix for issue 4682 : Restructuring the side pane structure having add…
Browse files Browse the repository at this point in the history
…itional functionality and merging the remove group menus (#7714)

Co-authored-by: John Josipovic <josipovicjohn@gmail.com>
Co-authored-by: Khate Damaso <khate.damaso@gmail.com>
Co-authored-by: daolin <s4380597@uq.edu.au>
  • Loading branch information
4 people authored Jun 8, 2021
1 parent 2497ba4 commit 9d1c448
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 44 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- 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)
- We added a feature that allows the user to copy highlighted text in the preview window. [#6962](https://github.com/JabRef/jabref/issues/6962)
- We added a feature that allows you to create new BibEntry via paste arxivId [#2292](https://github.com/JabRef/jabref/issues/2292)
- We added a add group functionality at the bottom of the side pane. [#4682](https://github.com/JabRef/jabref/issues/4682)
- 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)
- 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)
- We added a keybinding preset for new entries. [#7705](https://github.com/JabRef/jabref/issues/7705)
Expand All @@ -38,6 +39,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- 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)
- 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)
- 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)
- 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)
- 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)
- We reintroduced missing default keybindings for new entries. [#7346](https://github.com/JabRef/jabref/issues/7346) [#7439](https://github.com/JabRef/jabref/issues/7439)
- Lists of available fields are now sorted alphabetically. [#7716](https://github.com/JabRef/jabref/issues/7716)
Expand Down Expand Up @@ -88,6 +90,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- 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)
- 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)
- We fixed an issue where opening BibTex file (doubleclick) from Folder with spaces not working. [#6487](https://github.com/JabRef/jabref/issues/6487)
- We fixed the header title in the Add Group/Subgroup Dialog box. [#4682](https://github.com/JabRef/jabref/issues/4682)
- We fixed an issue with saving large `.bib` files [#7265](https://github.com/JabRef/jabref/issues/7265)
- We fixed an issue with very large page numbers [#7590](https://github.com/JabRef/jabref/issues/7590)
- 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)
Expand All @@ -108,6 +111,8 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Removed

- We removed add group button beside the filter group tab. [#4682](https://github.com/JabRef/jabref/issues/4682)

## [5.2] – 2020-12-24

### Added
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/gui/groups/GroupDialogHeader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.jabref.gui.groups;

public enum GroupDialogHeader {
GROUP, SUBGROUP
}
10 changes: 7 additions & 3 deletions src/main/java/org/jabref/gui/groups/GroupDialogView.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,19 @@ public class GroupDialogView extends BaseDialog<AbstractGroup> {
private final ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer();
private final GroupDialogViewModel viewModel;

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

ViewLoader.view(this)
.load()
.setAsDialogPane(this);

if (editedGroup == null) {
this.setTitle(Localization.lang("Add subgroup"));
if (groupDialogHeader == GroupDialogHeader.GROUP) {
this.setTitle(Localization.lang("Add group"));
} else if (groupDialogHeader == GroupDialogHeader.SUBGROUP) {
this.setTitle(Localization.lang("Add subgroup"));
}
} else {
this.setTitle(Localization.lang("Edit group") + " " + editedGroup.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,14 @@ public class GroupDialogViewModel {
private final PreferencesService preferencesService;
private final BibDatabaseContext currentDatabase;
private final AbstractGroup editedGroup;
private final GroupDialogHeader groupDialogHeader;

public GroupDialogViewModel(DialogService dialogService, BibDatabaseContext currentDatabase, PreferencesService preferencesService, AbstractGroup editedGroup) {
public GroupDialogViewModel(DialogService dialogService, BibDatabaseContext currentDatabase, PreferencesService preferencesService, AbstractGroup editedGroup, GroupDialogHeader groupDialogHeader) {
this.dialogService = dialogService;
this.preferencesService = preferencesService;
this.currentDatabase = currentDatabase;
this.editedGroup = editedGroup;
this.groupDialogHeader = groupDialogHeader;

setupValidation();
setValues();
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/org/jabref/gui/groups/GroupTree.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,18 @@
-fx-translate-x: -0.4em;
}

#newGroupButton {
-fx-padding: 0.1em 1.5em 0.1em 1.5em;
#addNewGroup:active {
-fx-border-width: 0px;
-fx-background-color: -jr-theme;
-fx-padding: 0.5em;
-fx-text-fill: -jr-white;
}

#addNewGroup:inactive {
-fx-border-width: 0px;
-fx-background-color: -jr-icon-background-active;
-fx-padding: 0.5em;
-fx-text-fill:-jr-black;
}

#groupFilterBar {
Expand All @@ -116,3 +126,7 @@
#groupFilterBar .glyph-icon {
-fx-font-size: 2em;
}

#groupBar .glyph-icon {
-fx-font-size: 2em;
}
21 changes: 11 additions & 10 deletions src/main/java/org/jabref/gui/groups/GroupTree.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,12 @@
<?import javafx.scene.control.TreeTableView?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import org.jabref.gui.icon.JabRefIconView?>
<?import org.controlsfx.control.textfield.CustomTextField?>
<BorderPane xmlns:fx="http://javafx.com/fxml/1" prefHeight="600.0" prefWidth="150.0"
xmlns="http://javafx.com/javafx/8.0.112" fx:controller="org.jabref.gui.groups.GroupTreeView">
<top>
<HBox fx:id="groupFilterBar" alignment="CENTER" spacing="8">
<CustomTextField fx:id="searchField" promptText="%Filter groups" HBox.hgrow="ALWAYS"/>
<Button fx:id="newGroupButton" onAction="#addNewGroup" styleClass="icon-button"
ButtonBar.buttonData="RIGHT">
<graphic>
<JabRefIconView glyph="NEW_GROUP" glyphSize="18"/>
</graphic>
<tooltip>
<Tooltip text="%New group"/>
</tooltip>
</Button>
</HBox>
</top>
<center>
Expand All @@ -39,4 +29,15 @@
</columnResizePolicy>
</TreeTableView>
</center>
<bottom>
<HBox fx:id="groupBar" alignment="CENTER" spacing="8">
<Button fx:id="addNewGroup" onAction="#addNewGroup"
text="%Add group" maxWidth="Infinity" HBox.hgrow="ALWAYS">
<tooltip>
<Tooltip text="%New group"/>
</tooltip>
</Button>
</HBox>

</bottom>
</BorderPane>
57 changes: 44 additions & 13 deletions src/main/java/org/jabref/gui/groups/GroupTreeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
import javafx.beans.property.ObjectProperty;
import javafx.css.PseudoClass;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Control;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.SeparatorMenuItem;
Expand Down Expand Up @@ -64,6 +66,7 @@ public class GroupTreeView {
@FXML private TreeTableColumn<GroupNodeViewModel, GroupNodeViewModel> numberColumn;
@FXML private TreeTableColumn<GroupNodeViewModel, GroupNodeViewModel> expansionNodeColumn;
@FXML private CustomTextField searchField;
@FXML private Button addNewGroup;

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

setNewGroupButtonStyle(groupTree);

groupTree.rootProperty().bind(
EasyBind.map(viewModel.rootGroupProperty(),
group -> {
Expand Down Expand Up @@ -171,6 +176,7 @@ public void initialize() {
groupTree.setRowFactory(treeTable -> {
TreeTableRow<GroupNodeViewModel> row = new TreeTableRow<>();
row.treeItemProperty().addListener((ov, oldTreeItem, newTreeItem) -> {
setNewGroupButtonStyle(treeTable);
boolean isRoot = newTreeItem == treeTable.getRoot();
row.pseudoClassStateChanged(rootPseudoClass, isRoot);

Expand Down Expand Up @@ -322,7 +328,9 @@ private Optional<TreeItem<GroupNodeViewModel>> getTreeItemByValue(TreeItem<Group
}

private ContextMenu createContextMenuForGroup(GroupNodeViewModel group) {

ContextMenu menu = new ContextMenu();
Menu removeGroup = new Menu(Localization.lang("Remove group"));

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

MenuItem removeGroupKeepSubgroups = new MenuItem(Localization.lang("Keep subgroups"));
removeGroupKeepSubgroups.setOnAction(event -> viewModel.removeGroupKeepSubgroups(group));

MenuItem removeGroupAndSubgroups = new MenuItem(Localization.lang("Also remove subgroups"));
removeGroupAndSubgroups.setOnAction(event -> viewModel.removeGroupAndSubgroups(group));

MenuItem addSubgroup = new MenuItem(Localization.lang("Add subgroup"));
addSubgroup.setOnAction(event -> {
menu.hide();
viewModel.addNewSubgroup(group);
viewModel.addNewSubgroup(group, GroupDialogHeader.SUBGROUP);
});
MenuItem removeGroupAndSubgroups = new MenuItem(Localization.lang("Remove group and subgroups"));
removeGroupAndSubgroups.setOnAction(event -> viewModel.removeGroupAndSubgroups(group));
MenuItem removeGroupKeepSubgroups = new MenuItem(Localization.lang("Remove group, keep subgroups"));
removeGroupKeepSubgroups.setOnAction(event -> viewModel.removeGroupKeepSubgroups(group));

MenuItem removeSubgroups = new MenuItem(Localization.lang("Remove subgroups"));
removeSubgroups.setOnAction(event -> viewModel.removeSubgroups(group));
removeSubgroups.setOnAction(event -> {
viewModel.removeSubgroups(group);
});

MenuItem sortSubgroups = new MenuItem(Localization.lang("Sort subgroups"));
sortSubgroups.setOnAction(event -> viewModel.sortAlphabeticallyRecursive(group));

MenuItem addEntries = new MenuItem(Localization.lang("Add selected entries to this group"));
addEntries.setOnAction(event -> viewModel.addSelectedEntries(group));

MenuItem removeEntries = new MenuItem(Localization.lang("Remove selected entries from this group"));
removeEntries.setOnAction(event -> viewModel.removeSelectedEntries(group));

MenuItem sortAlphabetically = new MenuItem(Localization.lang("Sort all subgroups (recursively)"));
sortAlphabetically.setOnAction(event -> viewModel.sortAlphabeticallyRecursive(group));

menu.getItems().add(editGroup);
removeGroup.getItems().add(removeGroupKeepSubgroups);
removeGroup.getItems().add(removeGroupAndSubgroups);
menu.getItems().add(removeGroup);
menu.getItems().add(new SeparatorMenuItem());
menu.getItems().addAll(addSubgroup, removeSubgroups, removeGroupAndSubgroups, removeGroupKeepSubgroups);
menu.getItems().add(addSubgroup);
menu.getItems().add(removeSubgroups);
menu.getItems().add(sortSubgroups);
menu.getItems().add(new SeparatorMenuItem());
menu.getItems().addAll(addEntries, removeEntries);
menu.getItems().add(new SeparatorMenuItem());
menu.getItems().add(sortAlphabetically);
menu.getItems().add(addEntries);
menu.getItems().add(removeEntries);

// TODO: Disable some actions under certain conditions
// if (group.canBeEdited()) {
Expand Down Expand Up @@ -397,6 +415,19 @@ private void setupClearButtonField(CustomTextField customTextField) {
}
}

private void setNewGroupButtonStyle(TreeTableView<GroupNodeViewModel> groupTree) {
PseudoClass active = PseudoClass.getPseudoClass("active");
PseudoClass inactive = PseudoClass.getPseudoClass("inactive");

if (groupTree.getRoot() != null) {
boolean isActive = groupTree.getExpandedItemCount() <= 10;
addNewGroup.pseudoClassStateChanged(active, isActive);
addNewGroup.pseudoClassStateChanged(inactive, !isActive);
} else {
addNewGroup.pseudoClassStateChanged(active, true);
}
}

private static class DragExpansionHandler {
private static final long DRAG_TIME_BEFORE_EXPANDING_MS = 1000;
private TreeItem<GroupNodeViewModel> draggedItem;
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private void onSelectedGroupChanged(ObservableList<GroupNodeViewModel> newValue)
*/
public void addNewGroupToRoot() {
if (currentDatabase.isPresent()) {
addNewSubgroup(rootGroup.get());
addNewSubgroup(rootGroup.get(), GroupDialogHeader.GROUP);
} else {
dialogService.showWarningDialogAndWait(Localization.lang("Cannot create group"), Localization.lang("Cannot create group. Please create a library first."));
}
Expand Down Expand Up @@ -147,13 +147,15 @@ private void onActiveDatabaseChanged(Optional<BibDatabaseContext> newDatabase) {
/**
* Opens "New Group Dialog" and add the resulting group to the specified group
*/
public void addNewSubgroup(GroupNodeViewModel parent) {

public void addNewSubgroup(GroupNodeViewModel parent, GroupDialogHeader groupDialogHeader) {
currentDatabase.ifPresent(database -> {
Optional<AbstractGroup> newGroup = dialogService.showCustomDialogAndWait(new GroupDialogView(
dialogService,
database,
preferences,
null));
null,
groupDialogHeader));

newGroup.ifPresent(group -> {
parent.addSubgroup(group);
Expand Down Expand Up @@ -184,7 +186,8 @@ public void editGroup(GroupNodeViewModel oldGroup) {
dialogService,
database,
preferences,
oldGroup.getGroupNode().getGroup()));
oldGroup.getGroupNode().getGroup(),
GroupDialogHeader.SUBGROUP));

newGroup.ifPresent(group -> {
// TODO: Keep assignments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ public UndoableAddOrRemoveGroup(GroupTreeNodeViewModel groupsRoot,
public String getPresentationName() {
switch (m_editType) {
case ADD_NODE:
return Localization.lang("add group");
return Localization.lang("Add group");
case REMOVE_NODE_KEEP_CHILDREN:
return Localization.lang("remove group (keep subgroups)");
return Localization.lang("Keep subgroups)");
case REMOVE_NODE_AND_CHILDREN:
return Localization.lang("remove group and subgroups");
return Localization.lang("Also remove subgroups");
default:
break;
}
Expand Down
15 changes: 7 additions & 8 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Added\ string=Added string

All\ entries=All entries

Also\ remove\ subgroups=Also remove subgroups

Always\ reformat\ BIB\ file\ on\ save\ and\ export=Always reformat BIB file on save and export

and=and
Expand Down Expand Up @@ -450,6 +452,8 @@ JabRef\ Version\ (Required\ to\ ensure\ backwards\ compatibility\ with\ Mr.\ DLi
Journal\ abbreviations=Journal abbreviations
Keep\ both=Keep both

Keep\ subgroups=Keep subgroups

Key\ bindings=Key bindings

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

Remove\ group=Remove group

Remove\ group,\ keep\ subgroups=Remove group, keep subgroups

Remove\ group\ "%0"?=Remove group "%0"?

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

remove\ group\ (keep\ subgroups)=remove group (keep subgroups)

remove\ group\ and\ subgroups=remove group and subgroups

Remove\ group\ and\ subgroups=Remove group and subgroups

Remove\ link=Remove link
Expand Down Expand Up @@ -796,6 +794,8 @@ Skipped\ -\ PDF\ does\ not\ exist=Skipped - PDF does not exist

Skipped\ entry.=Skipped entry.

Sort\ subgroups=Sort subgroups

source\ edit=source edit
Special\ name\ formatters=Special name formatters

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

0 comments on commit 9d1c448

Please sign in to comment.