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

Fixed jump to entry from crossref #11009

Merged
merged 6 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed an issue where the `CommentsTab` was not properly formatted when the `defaultOwner` contained capital or special letters. [#10870](https://github.com/JabRef/jabref/issues/10870)
- We fixed an issue where the `File -> Close library` menu item was not disabled when no library was open. [#10948](https://github.com/JabRef/jabref/issues/10948)
- We fixed an issue where the Document Viewer would show the PDF in only half the window when maximized. [#10934](https://github.com/JabRef/jabref/issues/10934)
- Clicking on the crossref and related tags in the entry editor jumps to the linked entry. [#5484](https://github.com/JabRef/jabref/issues/5484) [#9369](https://github.com/JabRef/jabref/issues/9369)

### Removed

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,11 @@ public void init() {
EasyBind.subscribe(tabbedPane.getSelectionModel().selectedItemProperty(), selectedTab -> {
if (selectedTab instanceof LibraryTab libraryTab) {
stateManager.setActiveDatabase(libraryTab.getBibDatabaseContext());
stateManager.activeTabProperty().set(Optional.of(libraryTab));
} else if (selectedTab == null) {
// All databases are closed
stateManager.setActiveDatabase(null);
stateManager.activeTabProperty().set(Optional.empty());
}
});

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/LibraryTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,9 @@ private void setDatabaseContext(BibDatabaseContext bibDatabaseContext) {
return;
}
if (tabPane.getSelectionModel().selectedItemProperty().get().equals(this)) {
LOGGER.debug("This case should not happen.");
LOGGER.warn("This case should not happen.");
stateManager.setActiveDatabase(bibDatabaseContext);
stateManager.activeTabProperty().set(Optional.of(this));
}

// Remove existing dummy BibDatabaseContext and add correct BibDatabaseContext from ParserResult to trigger changes in the openDatabases list in the stateManager
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/gui/StateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class StateManager {
private final CustomLocalDragboard localDragboard = new CustomLocalDragboard();
private final ObservableList<BibDatabaseContext> openDatabases = FXCollections.observableArrayList();
private final OptionalObjectProperty<BibDatabaseContext> activeDatabase = OptionalObjectProperty.empty();
private final OptionalObjectProperty<LibraryTab> activeTab = OptionalObjectProperty.empty();
private final ReadOnlyListWrapper<GroupTreeNode> activeGroups = new ReadOnlyListWrapper<>(FXCollections.observableArrayList());
private final ObservableList<BibEntry> selectedEntries = FXCollections.observableArrayList();
private final ObservableMap<BibDatabaseContext, ObservableList<GroupTreeNode>> selectedGroups = FXCollections.observableHashMap();
Expand Down Expand Up @@ -91,6 +92,10 @@ public OptionalObjectProperty<BibDatabaseContext> activeDatabaseProperty() {
return activeDatabase;
}

public OptionalObjectProperty<LibraryTab> activeTabProperty() {
return activeTab;
}

public OptionalObjectProperty<SearchQuery> activeSearchQueryProperty() {
return activeSearchQuery;
}
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ public static FieldEditorFX getForField(final Field field,
} else {
return new OptionEditor<>(new TypeEditorViewModel(field, suggestionProvider, fieldCheckers, undoManager));
}
} else if (fieldProperties.contains(FieldProperty.SINGLE_ENTRY_LINK)) {
return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers);
} else if (fieldProperties.contains(FieldProperty.MULTIPLE_ENTRY_LINK)) {
} else if (fieldProperties.contains(FieldProperty.SINGLE_ENTRY_LINK) || fieldProperties.contains(FieldProperty.MULTIPLE_ENTRY_LINK)) {
return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers);
} else if (fieldProperties.contains(FieldProperty.PERSON_NAMES)) {
return new PersonsEditor(field, suggestionProvider, preferences, fieldCheckers, isMultiLine, undoManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.jabref.gui.ClipBoardManager;
import org.jabref.gui.DialogService;
import org.jabref.gui.JabRefDialogService;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.actions.StandardActions;
Expand Down Expand Up @@ -47,6 +48,7 @@ public class LinkedEntriesEditor extends HBox implements FieldEditorFX {
@Inject private ClipBoardManager clipBoardManager;
@Inject private KeyBindingRepository keyBindingRepository;
@Inject private UndoManager undoManager;
@Inject private StateManager stateManager;

private final LinkedEntriesEditorViewModel viewModel;

Expand All @@ -55,7 +57,7 @@ public LinkedEntriesEditor(Field field, BibDatabaseContext databaseContext, Sugg
.root(this)
.load();

this.viewModel = new LinkedEntriesEditorViewModel(field, suggestionProvider, databaseContext, fieldCheckers, undoManager);
this.viewModel = new LinkedEntriesEditorViewModel(field, suggestionProvider, databaseContext, fieldCheckers, undoManager, stateManager);

entryLinkField.setCellFactory(new ViewModelListCellFactory<ParsedEntryLink>().withText(ParsedEntryLink::getKey));
entryLinkField.setSuggestionProvider(request -> viewModel.getSuggestions(request.getUserText()));
Expand All @@ -79,7 +81,7 @@ private Node createTag(ParsedEntryLink entryLink) {
tagLabel.getGraphic().setOnMouseClicked(event -> entryLinkField.removeTags(entryLink));
tagLabel.setContentDisplay(ContentDisplay.RIGHT);
tagLabel.setOnMouseClicked(event -> {
if (event.getClickCount() == 2 && event.getButton().equals(MouseButton.PRIMARY)) {
if ((event.getClickCount() == 2 || event.isControlDown()) && event.getButton().equals(MouseButton.PRIMARY)) {
viewModel.jumpToEntry(entryLink);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import javafx.collections.FXCollections;
import javafx.util.StringConverter;

import org.jabref.gui.StateManager;
import org.jabref.gui.autocompleter.SuggestionProvider;
import org.jabref.gui.util.BindingsHelper;
import org.jabref.logic.integrity.FieldCheckers;
Expand All @@ -25,12 +26,19 @@ public class LinkedEntriesEditorViewModel extends AbstractEditorViewModel {
private final BibDatabaseContext databaseContext;
private final SuggestionProvider<?> suggestionProvider;
private final ListProperty<ParsedEntryLink> linkedEntries;

public LinkedEntriesEditorViewModel(Field field, SuggestionProvider<?> suggestionProvider, BibDatabaseContext databaseContext, FieldCheckers fieldCheckers, UndoManager undoManager) {
private final StateManager stateManager;

public LinkedEntriesEditorViewModel(Field field,
SuggestionProvider<?> suggestionProvider,
BibDatabaseContext databaseContext,
FieldCheckers fieldCheckers,
UndoManager undoManager,
StateManager stateManager) {
super(field, suggestionProvider, fieldCheckers, undoManager);

this.databaseContext = databaseContext;
this.suggestionProvider = suggestionProvider;
this.stateManager = stateManager;

linkedEntries = new SimpleListProperty<>(FXCollections.observableArrayList());
BindingsHelper.bindContentBidirectional(
Expand Down Expand Up @@ -80,13 +88,7 @@ public List<ParsedEntryLink> getSuggestions(String request) {
}

public void jumpToEntry(ParsedEntryLink parsedEntryLink) {
// TODO: Implement jump to entry - The implementation can be based on <a href="org.jabref.gui.JabRefFrame.jumpToEntry">JabRefFrame.jumpToEntry</a>
// TODO: Add toolitp for tag: Localization.lang("Jump to entry")
// This feature was removed while converting the linked entries editor to JavaFX
// Right now there is no nice way to re-implement it as we have no good interface to control the focus of the main table
// (except directly using the JabRefFrame class as below)
// parsedEntryLink.getLinkedEntry().ifPresent(
// e -> frame.getCurrentBasePanel().highlightEntry(e)
// );
parsedEntryLink.getLinkedEntry().ifPresent(entry ->
stateManager.activeTabProperty().get().ifPresent(tab -> tab.clearAndSelect(entry)));
}
}
1 change: 0 additions & 1 deletion src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1926,7 +1926,6 @@ Group\ view\ mode\ set\ to\ union=Group view mode set to union
Open\ file\ %0=Open file %0
Toggle\ intersection=Toggle intersection
Toggle\ union=Toggle union
Jump\ to\ entry=Jump to entry
The\ group\ name\ contains\ the\ keyword\ separator\ "%0"\ and\ thus\ probably\ does\ not\ work\ as\ expected.=The group name contains the keyword separator "%0" and thus probably does not work as expected.
Blog=Blog

Expand Down