diff --git a/CHANGELOG.md b/CHANGELOG.md index c96ac04290c..df11540ff6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,8 +17,12 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# ### Fixed -- Inherit fields from cross-referenced entries as specified by biblatex [#5045](https://github.com/JabRef/jabref/issues/5045) -- We fixed an issue where it was no longer possible to connect to LibreOffice [#5261](https://github.com/JabRef/jabref/issues/5261) +- Inherit fields from cross-referenced entries as specified by biblatex. [#5045](https://github.com/JabRef/jabref/issues/5045) +- We fixed an issue where it was no longer possible to connect to LibreOffice. [#5261](https://github.com/JabRef/jabref/issues/5261) +- The "All entries group" is no longer shown when no library is open. +- The group panel is now properly updated when switching between libraries (or when closing/opening one). [#3142](https://github.com/JabRef/jabref/issues/3142) +- We fixed an error where the number of matched entries shown in the group pane was not updated correctly. [#4441](https://github.com/JabRef/jabref/issues/4441) +- We fixed an error mentioning "javafx.controls/com.sun.javafx.scene.control" that was thrown when interacting with the toolbar. ### Removed diff --git a/build.gradle b/build.gradle index 9eafaae3208..36124837e1d 100644 --- a/build.gradle +++ b/build.gradle @@ -392,6 +392,7 @@ run { '--add-exports', 'org.controlsfx.controls/impl.org.controlsfx.skin=org.jabref', '--add-opens', 'javafx.controls/javafx.scene.control=org.jabref', '--add-opens', 'org.controlsfx.controls/org.controlsfx.control.textfield=org.jabref', + '--add-opens', 'javafx.controls/com.sun.javafx.scene.control=org.jabref', // Not sure why we need to restate the controlfx exports // Taken from here: https://github.com/controlsfx/controlsfx/blob/9.0.0/build.gradle#L1 "--add-exports", "javafx.graphics/com.sun.javafx.scene=org.controlsfx.controls", diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 371989f91bf..ae00ada1df4 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -163,65 +163,8 @@ public JabRefFrame(Stage mainStage) { this.undoManager = Globals.undoManager; } - public void init() { - sidePaneManager = new SidePaneManager(Globals.prefs, this); - sidePane = sidePaneManager.getPane(); - - tabbedPane = new TabPane(); - tabbedPane.setTabDragPolicy(TabPane.TabDragPolicy.REORDER); - - initLayout(); - - initKeyBindings(); - - initDragAndDrop(); - - //setBounds(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds()); - //WindowLocation pw = new WindowLocation(this, JabRefPreferences.POS_X, JabRefPreferences.POS_Y, JabRefPreferences.SIZE_X, - // JabRefPreferences.SIZE_Y); - //pw.displayWindowAtStoredLocation(); - - /* - * The following state listener makes sure focus is registered with the - * correct database when the user switches tabs. Without this, - * cut/paste/copy operations would some times occur in the wrong tab. - */ - EasyBind.subscribe(tabbedPane.getSelectionModel().selectedItemProperty(), e -> { - if (e == null) { - stateManager.activeDatabaseProperty().setValue(Optional.empty()); - return; - } - - BasePanel currentBasePanel = getCurrentBasePanel(); - if (currentBasePanel == null) { - return; - } - - // Poor-mans binding to global state - stateManager.activeDatabaseProperty().setValue(Optional.of(currentBasePanel.getBibDatabaseContext())); - stateManager.setSelectedEntries(currentBasePanel.getSelectedEntries()); - - // Update search query - String content = ""; - Optional currentSearchQuery = currentBasePanel.getCurrentSearchQuery(); - if (currentSearchQuery.isPresent()) { - content = currentSearchQuery.get().getQuery(); - } - globalSearchBar.setSearchTerm(content); - - // groupSidePane.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(GroupSidePane.class)); - //previewToggle.setSelected(Globals.prefs.getPreviewPreferences().isPreviewPanelEnabled()); - //generalFetcher.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(WebSearchPane.class)); - //openOfficePanel.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(OpenOfficeSidePanel.class)); - - setWindowTitle(); - // Update search autocompleter with information for the correct database: - currentBasePanel.updateSearchManager(); - - currentBasePanel.getUndoManager().postUndoRedoEvent(); - currentBasePanel.getMainTable().requestFocus(); - }); - initShowTrackingNotification(); + private static BasePanel getBasePanel(Tab tab) { + return (BasePanel) tab.getContent(); } public void initDragAndDrop() { @@ -612,6 +555,66 @@ public void showBasePanel(BasePanel bp) { tabbedPane.getSelectionModel().select(getTab(bp)); } + public void init() { + sidePaneManager = new SidePaneManager(Globals.prefs, this); + sidePane = sidePaneManager.getPane(); + + tabbedPane = new TabPane(); + tabbedPane.setTabDragPolicy(TabPane.TabDragPolicy.REORDER); + + initLayout(); + + initKeyBindings(); + + initDragAndDrop(); + + //setBounds(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds()); + //WindowLocation pw = new WindowLocation(this, JabRefPreferences.POS_X, JabRefPreferences.POS_Y, JabRefPreferences.SIZE_X, + // JabRefPreferences.SIZE_Y); + //pw.displayWindowAtStoredLocation(); + + // Bind global state + stateManager.activeDatabaseProperty().bind( + EasyBind.map(tabbedPane.getSelectionModel().selectedItemProperty(), + tab -> Optional.ofNullable(tab).map(JabRefFrame::getBasePanel).map(BasePanel::getBibDatabaseContext))); + /* + * The following state listener makes sure focus is registered with the + * correct database when the user switches tabs. Without this, + * cut/paste/copy operations would some times occur in the wrong tab. + */ + EasyBind.subscribe(tabbedPane.getSelectionModel().selectedItemProperty(), tab -> { + if (tab == null) { + return; + } + + BasePanel newBasePanel = getBasePanel(tab); + + // Poor-mans binding to global state + stateManager.setSelectedEntries(newBasePanel.getSelectedEntries()); + + // Update search query + String content = ""; + Optional currentSearchQuery = newBasePanel.getCurrentSearchQuery(); + if (currentSearchQuery.isPresent()) { + content = currentSearchQuery.get().getQuery(); + } + globalSearchBar.setSearchTerm(content); + + // groupSidePane.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(GroupSidePane.class)); + //previewToggle.setSelected(Globals.prefs.getPreviewPreferences().isPreviewPanelEnabled()); + //generalFetcher.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(WebSearchPane.class)); + //openOfficePanel.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(OpenOfficeSidePanel.class)); + + setWindowTitle(); + // Update search autocompleter with information for the correct database: + newBasePanel.updateSearchManager(); + + newBasePanel.getUndoManager().postUndoRedoEvent(); + newBasePanel.getMainTable().requestFocus(); + }); + initShowTrackingNotification(); + } + /** * Returns the currently viewed BasePanel. */ @@ -619,7 +622,7 @@ public BasePanel getCurrentBasePanel() { if ((tabbedPane == null) || (tabbedPane.getSelectionModel().getSelectedItem() == null)) { return null; } - return (BasePanel) tabbedPane.getSelectionModel().getSelectedItem().getContent(); + return getBasePanel(tabbedPane.getSelectionModel().getSelectedItem()); } /** diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index 62a2a1299dc..c9686d9ab4f 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -6,15 +6,12 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.function.Consumer; import java.util.stream.Collectors; import javax.inject.Inject; import javafx.beans.property.ObjectProperty; -import javafx.collections.ObservableList; import javafx.css.PseudoClass; -import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.ContextMenu; import javafx.scene.control.Control; @@ -84,13 +81,10 @@ public void initialize() { dragExpansionHandler = new DragExpansionHandler(); // Set-up bindings - Consumer> updateSelectedGroups = - (newSelectedGroups) -> newSelectedGroups.forEach(this::selectNode); - BindingsHelper.bindContentBidirectional( groupTree.getSelectionModel().getSelectedItems(), viewModel.selectedGroupsProperty(), - updateSelectedGroups, + (newSelectedGroups) -> newSelectedGroups.forEach(this::selectNode), this::updateSelection ); @@ -104,11 +98,17 @@ public void initialize() { groupTree.rootProperty().bind( EasyBind.map(viewModel.rootGroupProperty(), - group -> new RecursiveTreeItem<>( - group, - GroupNodeViewModel::getChildren, - GroupNodeViewModel::expandedProperty, - viewModel.filterPredicateProperty()))); + group -> { + if (group == null) { + return null; + } else { + return new RecursiveTreeItem<>( + group, + GroupNodeViewModel::getChildren, + GroupNodeViewModel::expandedProperty, + viewModel.filterPredicateProperty()); + } + })); // Icon and group name mainColumn.setCellValueFactory(cellData -> cellData.getValue().valueProperty()); @@ -343,7 +343,8 @@ private ContextMenu createContextMenuForGroup(GroupNodeViewModel group) { return menu; } - public void addNewGroup(ActionEvent actionEvent) { + @FXML + private void addNewGroup() { viewModel.addNewGroupToRoot(); } diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java index bccddf297e5..feb3a90e23a 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java @@ -126,12 +126,12 @@ private void onActiveDatabaseChanged(Optional newDatabase) { .orElse(GroupNodeViewModel.getAllEntriesGroup(newDatabase.get(), stateManager, taskExecutor, localDragboard)); rootGroup.setValue(newRoot); - this.selectedGroups.setAll( + selectedGroups.setAll( stateManager.getSelectedGroup(newDatabase.get()).stream() .map(selectedGroup -> new GroupNodeViewModel(newDatabase.get(), stateManager, taskExecutor, selectedGroup, localDragboard)) .collect(Collectors.toList())); } else { - rootGroup.setValue(GroupNodeViewModel.getAllEntriesGroup(new BibDatabaseContext(), stateManager, taskExecutor, localDragboard)); + rootGroup.setValue(null); } currentDatabase = newDatabase;