Skip to content

Commit

Permalink
Try to fix ioob for selected entries (#10389)
Browse files Browse the repository at this point in the history
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
  • Loading branch information
Siedlerchr and koppor committed Sep 17, 2023
1 parent 70e9eb3 commit a7d3398
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions src/main/java/org/jabref/gui/LibraryTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.jabref.gui.dialogs.AutosaveUiManager;
import org.jabref.gui.entryeditor.EntryEditor;
import org.jabref.gui.importer.actions.OpenDatabaseAction;
import org.jabref.gui.maintable.BibEntryTableViewModel;
import org.jabref.gui.maintable.MainTable;
import org.jabref.gui.maintable.MainTableDataModel;
import org.jabref.gui.undo.CountingUndoManager;
Expand Down Expand Up @@ -344,7 +345,7 @@ public void updateTabTitle(boolean isChanged) {
Path databasePath = file.get();
String fileName = databasePath.getFileName().toString();
tabTitle.append(fileName);
toolTipText.append(databasePath.toAbsolutePath().toString());
toolTipText.append(databasePath.toAbsolutePath());

if (databaseLocation == DatabaseLocation.SHARED) {
tabTitle.append(" \u2013 ");
Expand Down Expand Up @@ -517,15 +518,16 @@ private void createMainTable() {
entryTypesManager,
taskExecutor,
fileUpdateMonitor);

// Add the listener that binds selection to state manager (TODO: should be replaced by proper JavaFX binding as soon as table is implemented in JavaFX)
mainTable.addSelectionListener(listEvent -> stateManager.setSelectedEntries(mainTable.getSelectedEntries()));

// Update entry editor and preview according to selected entries
mainTable.addSelectionListener(event -> mainTable.getSelectedEntries()
.stream()
.findFirst()
.ifPresent(entryEditor::setEntry));
// content binding between StateManager#getselectedEntries and mainTable#getSelectedEntries does not work here as it does not trigger the ActionHelper#needsEntriesSelected checker for the menubar
mainTable.addSelectionListener(event -> {
List<BibEntry> entries = event.getList().stream().map(BibEntryTableViewModel::getEntry).toList();
stateManager.setSelectedEntries(entries);
if (!entries.isEmpty()) {
// Update entry editor and preview according to selected entries
entryEditor.setEntry(entries.get(0));
}
});
}

public void setupMainPanel() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/actions/ActionHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static BooleanExpression isFilePresentForSelectedEntry(StateManager state
Binding<Boolean> fileIsPresent = EasyBind.valueAt(selectedEntries, 0).mapOpt(entry -> {
List<LinkedFile> files = entry.getFiles();

if ((entry.getFiles().size() > 0) && stateManager.getActiveDatabase().isPresent()) {
if ((!entry.getFiles().isEmpty()) && stateManager.getActiveDatabase().isPresent()) {
if (files.get(0).isOnlineLink()) {
return true;
}
Expand Down

0 comments on commit a7d3398

Please sign in to comment.