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

Moved position of add group button to HBox in groups panel UI #9329

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We moved the preferences option "Warn about duplicates on import" option from the tab "File" to the tab "Import and Export". [koppor#570](https://github.com/koppor/jabref/issues/570)
- When JabRef encounters `% Encoding: UTF-8` header, it is kept during writing (and not removed). [#8964](https://github.com/JabRef/jabref/pull/8964)
- We replace characters which cannot be decoded using the specified encoding by a (probably another) valid character. This happens if JabRef detects the wrong charset (e.g., UTF-8 instead of Windows 1252). One can use the [Integrity Check](https://docs.jabref.org/finding-sorting-and-cleaning-entries/checkintegrity) to find those characters.
- We moved the "add group" button from the bottom of the groups UI panel to the horizontal row of icon buttons at the top [koppor#529](https://github.com/koppor/jabref/issues/529)

### Fixed

Expand Down
8 changes: 8 additions & 0 deletions src/main/java/org/jabref/gui/groups/GroupModeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ public GroupModeViewModel(GroupViewMode mode) {
this.mode = mode;
}

public Node getAddGroupGraphic() {
return JabRefIcons.ADD.getGraphicNode();
}

public Tooltip getAddGroupTooltip() {
return new Tooltip(Localization.lang("Add group"));
}

public Node getUnionIntersectionGraphic() {
if (mode == GroupViewMode.UNION) {
return JabRefIcons.GROUP_UNION.getGraphicNode();
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/org/jabref/gui/groups/GroupTreeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public class GroupTreeView extends BorderPane {
private TreeTableColumn<GroupNodeViewModel, GroupNodeViewModel> numberColumn;
private TreeTableColumn<GroupNodeViewModel, GroupNodeViewModel> expansionNodeColumn;
private CustomTextField searchField;
private Button addNewGroup;

private final StateManager stateManager;
private final DialogService dialogService;
Expand Down Expand Up @@ -133,17 +132,6 @@ private void createNodes() {
this.setCenter(groupTree);

mainColumn.prefWidthProperty().bind(groupTree.widthProperty().subtract(60d).subtract(15));

addNewGroup = new Button(Localization.lang("Add group"));
addNewGroup.setId("addNewGroup");
addNewGroup.setMaxWidth(Double.MAX_VALUE);
HBox.setHgrow(addNewGroup, Priority.ALWAYS);
addNewGroup.setTooltip(new Tooltip(Localization.lang("New group")));
addNewGroup.setOnAction(event -> addNewGroup());

HBox groupBar = new HBox(addNewGroup);
groupBar.setId("groupBar");
this.setBottom(groupBar);
}

private void initialize() {
Expand Down Expand Up @@ -469,10 +457,6 @@ private ContextMenu createContextMenuForGroup(GroupNodeViewModel group) {
return menu;
}

private void addNewGroup() {
viewModel.addNewGroupToRoot();
}

/**
* Workaround taken from https://github.com/controlsfx/controlsfx/issues/330
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,64 @@
import javafx.scene.control.Button;

import org.jabref.gui.DialogService;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.groups.GroupModeViewModel;
import org.jabref.gui.groups.GroupTreeViewModel;
import org.jabref.gui.groups.GroupViewMode;
import org.jabref.gui.groups.GroupsPreferences;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.l10n.Localization;

import com.tobiasdiez.easybind.EasyBind;
import org.jabref.preferences.PreferencesService;

public class GroupsSidePaneComponent extends SidePaneComponent {
private final GroupsPreferences groupsPreferences;
private final DialogService dialogService;

private final GroupTreeViewModel viewModel;
private final Button intersectionUnionToggle = IconTheme.JabRefIcons.GROUP_INTERSECTION.asButton();

private final Button addGroup = IconTheme.JabRefIcons.ADD.asButton();

public GroupsSidePaneComponent(SimpleCommand closeCommand,
SimpleCommand moveUpCommand,
SimpleCommand moveDownCommand,
SidePaneContentFactory contentFactory,
GroupsPreferences groupsPreferences,
TaskExecutor taskExecutor,
StateManager stateManager,
PreferencesService preferencesService,
DialogService dialogService) {
super(SidePaneType.GROUPS, closeCommand, moveUpCommand, moveDownCommand, contentFactory);
this.groupsPreferences = groupsPreferences;
this.dialogService = dialogService;
this.viewModel = new GroupTreeViewModel(stateManager, dialogService, preferencesService, taskExecutor, stateManager.getLocalDragboard());
setupAddGroupButton();
setupIntersectionUnionToggle();

EasyBind.subscribe(groupsPreferences.groupViewModeProperty(), mode -> {
GroupModeViewModel modeViewModel = new GroupModeViewModel(mode);
addGroup.setGraphic(modeViewModel.getAddGroupGraphic());
addGroup.setTooltip(modeViewModel.getAddGroupTooltip());
intersectionUnionToggle.setGraphic(modeViewModel.getUnionIntersectionGraphic());
intersectionUnionToggle.setTooltip(modeViewModel.getUnionIntersectionTooltip());
});
}

private void setupAddGroupButton() {
addExtraButtonToHeader(addGroup, 0);
addGroup.setOnAction(event -> addNewGroup());
}

private void addNewGroup() {
viewModel.addNewGroupToRoot();
}

private void setupIntersectionUnionToggle() {
addExtraButtonToHeader(intersectionUnionToggle, 0);
addExtraButtonToHeader(intersectionUnionToggle, 1);
intersectionUnionToggle.setOnAction(event -> new ToggleUnionIntersectionAction().execute());
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/gui/sidepane/SidePaneViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class SidePaneViewModel extends AbstractViewModel {
private final StateManager stateManager;
private final SidePaneContentFactory sidePaneContentFactory;
private final DialogService dialogService;
private final TaskExecutor taskExecutor;

public SidePaneViewModel(PreferencesService preferencesService,
StateManager stateManager,
Expand All @@ -41,6 +42,7 @@ public SidePaneViewModel(PreferencesService preferencesService,
UndoManager undoManager) {
this.preferencesService = preferencesService;
this.stateManager = stateManager;
this.taskExecutor = taskExecutor;
this.dialogService = dialogService;
this.sidePaneContentFactory = new SidePaneContentFactory(
preferencesService,
Expand Down Expand Up @@ -71,6 +73,9 @@ protected SidePaneComponent getSidePaneComponent(SidePaneType pane) {
new MoveDownAction(pane),
sidePaneContentFactory,
preferencesService.getGroupsPreferences(),
taskExecutor,
stateManager,
preferencesService,
dialogService);
case WEB_SEARCH, OPEN_OFFICE -> new SidePaneComponent(pane,
new ClosePaneAction(pane),
Expand Down