-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fix #14821: Hide identifier action buttons when field is empty #14831
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
Merged
subhramit
merged 5 commits into
JabRef:main
from
abhishek9773:fix-issue-14821-identifier-icons
Jan 14, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f8c7ba7
Fix #14821: Hide identifier action buttons when field is empty
abhishek9773 5517761
Fix: safely manage shortenDOIButton visibility and update changelog
abhishek9773 4bbd244
style: fix indentation and clean up Stream imports
abhishek9773 4e1fc3e
style: remove unnecessary blank line in IdentifierEditorTest
abhishek9773 0fd5643
Update CHANGELOG.md
subhramit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| package org.jabref.gui.fieldeditors.identifier; | ||
|
|
||
| import java.util.Optional; | ||
| import java.util.stream.Stream; | ||
|
|
||
| import javax.swing.undo.UndoManager; | ||
|
|
||
|
|
@@ -24,6 +25,7 @@ | |
| import org.jabref.model.entry.BibEntry; | ||
| import org.jabref.model.entry.field.Field; | ||
| import org.jabref.model.entry.field.FieldTextMapper; | ||
| import org.jabref.model.entry.field.StandardField; | ||
|
|
||
| import com.airhacks.afterburner.injection.Injector; | ||
| import com.airhacks.afterburner.views.ViewLoader; | ||
|
|
@@ -91,6 +93,20 @@ public IdentifierEditor(Field field, | |
| textField.initContextMenu(new DefaultMenu(textField), preferences.getKeyBindingRepository()); | ||
|
|
||
| new EditorValidator(preferences).configureValidation(viewModel.getFieldValidator().getValidationStatus(), textField); | ||
|
|
||
| Stream.of(fetchInformationByIdentifierButton, lookupIdentifierButton) | ||
| .forEach(button -> { | ||
| button.visibleProperty().bind(viewModel.textProperty().isNotEmpty()); | ||
| button.managedProperty().bind(button.visibleProperty()); | ||
| }); | ||
|
|
||
| shortenDOIButton.managedProperty().bind(shortenDOIButton.visibleProperty()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code totally overlooked org.jabref.gui.fieldeditors.identifier.BaseIdentifierEditorViewModel#canShortenIdentifier |
||
| if (StandardField.DOI.equals(field)) { | ||
| shortenDOIButton.visibleProperty().bind(viewModel.textProperty().isNotEmpty()); | ||
| } else { | ||
| shortenDOIButton.visibleProperty().unbind(); | ||
| shortenDOIButton.setVisible(false); | ||
| } | ||
| } | ||
|
|
||
| public BaseIdentifierEditorViewModel<?> getViewModel() { | ||
|
|
||
47 changes: 47 additions & 0 deletions
47
jabgui/src/test/java/org/jabref/gui/fieldeditors/identifier/IdentifierEditorTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package org.jabref.gui.fieldeditors.identifier; | ||
|
|
||
| import javafx.scene.Scene; | ||
| import javafx.scene.control.Button; | ||
| import javafx.scene.layout.HBox; | ||
| import javafx.stage.Stage; | ||
|
|
||
| import org.jabref.gui.fieldeditors.EditorTextField; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import org.testfx.api.FxAssert; | ||
| import org.testfx.framework.junit5.ApplicationTest; | ||
| import org.testfx.matcher.base.NodeMatchers; | ||
|
|
||
| class IdentifierEditorTest extends ApplicationTest { | ||
|
|
||
| private Button fetchButton; | ||
| private EditorTextField textField; | ||
|
|
||
| @Override | ||
| public void start(Stage stage) { | ||
| fetchButton = new Button(); | ||
| fetchButton.setId("fetchInformationByIdentifierButton"); | ||
| textField = new EditorTextField(); | ||
| textField.setId("textField"); | ||
| textField.setText(""); | ||
|
|
||
| fetchButton.visibleProperty().bind(textField.textProperty().isNotEmpty()); | ||
| fetchButton.managedProperty().bind(fetchButton.visibleProperty()); | ||
|
|
||
| HBox root = new HBox(textField, fetchButton); | ||
| stage.setScene(new Scene(root, 400, 100)); | ||
| stage.show(); | ||
| } | ||
|
|
||
| @Test | ||
| void fetchButtonTogglesVisibilityBasedOnText() { | ||
| interact(() -> textField.setText("")); | ||
| FxAssert.verifyThat("#fetchInformationByIdentifierButton", NodeMatchers.isInvisible()); | ||
|
|
||
| clickOn(textField).write("10.1001/jama.2017.18444"); | ||
| FxAssert.verifyThat("#fetchInformationByIdentifierButton", NodeMatchers.isVisible()); | ||
|
|
||
| interact(() -> textField.setText("")); | ||
| FxAssert.verifyThat("#fetchInformationByIdentifierButton", NodeMatchers.isInvisible()); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did someone understand what "lookup" means?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I misunderstood the behavior and took the word “hide” literally.
I also understand that “lookup” should work even when there is no DOI, by searching online.
I can change the code to disable instead of hide. Is this what you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the offer. Your past PR needed more than 10 comments of two different maintainers. Still the code did not work. Your code is just hacky - and did not build on existing (!) JavaFX code. Thus, we should save the time of both you and the team. -- In future, please first read around at the code base. The IdentifierEditor is a very nice example to learn about JavaFX bindings and general UI principles in JavaFX. You missed this opportunity.
I already fixed it at #14931.