Skip to content

Added Button to Shorten the DOI#13657

Merged
HoussemNasri merged 18 commits into
JabRef:mainfrom
turhantolgaunal:DOIButton
Aug 8, 2025
Merged

Added Button to Shorten the DOI#13657
HoussemNasri merged 18 commits into
JabRef:mainfrom
turhantolgaunal:DOIButton

Conversation

@turhantolgaunal

@turhantolgaunal turhantolgaunal commented Aug 4, 2025

Copy link
Copy Markdown
Contributor

Closes #13639

Created new DOI package for handling DOI data. Created new DOIEditor class and fxml file, moving the logic for DOI from IdentifierEditor. Added an if statement to the FieldEditors to implement the new DOIEditor class.

Steps to take:
-Implement the shorten DOI logic to the button

Steps to test

Open the program and create a new example library.
Double click an entry and click the 'General' tab.
There should be a button that indicates shortening near the DOI field.
Screenshot From 2025-08-05 01-49-23

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • [/] Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (if change is visible to the user)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@Inject private GuiPreferences preferences;
@Inject private UndoManager undoManager;
@Inject private StateManager stateManager;
private Optional<BibEntry> entry = Optional.empty();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entry field is modified directly in bindToEntry method instead of being treated as immutable. Optional should be used for return values, not for fields.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally we should refactor this to be more elegant without the use of an Optional field here. Needs also to be done in ISSNEditor and IdentifierEditor.

But on the other hand we would add null checks on other places or we would add an get function for the entry that returns an optional.

So it's more of an moving the problem to other places

Comment thread jabgui/src/main/java/org/jabref/gui/fieldeditors/identifier/IdentifierEditor.java Outdated
Comment thread jabgui/src/main/java/org/jabref/gui/fieldeditors/identifier/IdentifierEditor.java Outdated
@turhantolgaunal turhantolgaunal marked this pull request as ready for review August 5, 2025 18:59
Comment thread jabgui/src/main/java/org/jabref/gui/fieldeditors/identifier/doi/DoiEditor.java Outdated
Comment thread CHANGELOG.md Outdated
Comment thread jabgui/src/main/java/org/jabref/gui/fieldeditors/identifier/doi/DoiEditor.java Outdated
Comment thread jabgui/src/main/java/org/jabref/gui/fieldeditors/identifier/doi/DoiEditor.java Outdated
turhantolgaunal and others added 5 commits August 6, 2025 18:25
- Add requested notification for successful DOI shortening
- Fix formatting issues in DoiIdentifierEditorViewModel
- Clarify changelog entry as suggested
- Add notification text to JabRef_en.properties
- Change name of the function in DOIEditor to shortenID
- shortenID method in BaseIdentifierEditorViewModel.java now throws an exception for unsupported operation.
-Merged DOIEditor contents to IdentifierEditor
-Added tooltip to the button
- Added sentence to JabRef_en.properties_en
- Changed notification message code to obey UI language rules
- Added canShortenIdentifier boolean to the BaseIdentifierEditorViewModel.java, changed the configure method, added new methods associated with it and changed affected classes.

@palukku palukku left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise looks okay to me

Comment thread jabgui/src/main/java/org/jabref/gui/fieldeditors/identifier/IdentifierEditor.java Outdated
String shortenedDOI = shortenDOIFormatter.format(doi);
entry.setField(field, shortenedDOI);
LOGGER.info("Shortened DOI: {} to {}", doi, shortenedDOI);
dialogService.notify(Localization.lang("Shortened DOI to: %0", shortenedDOI));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should show an alternative message if DOI is already short.

turhantolgaunal and others added 3 commits August 8, 2025 15:32
…entifierEditor.java

Co-authored-by: Philip <37398281+palukku@users.noreply.github.com>
- Added a message for when the DOI is already shortened
@trag-bot

trag-bot Bot commented Aug 8, 2025

Copy link
Copy Markdown

@trag-bot didn't find any issues in the code! ✅✨

@HoussemNasri HoussemNasri added this pull request to the merge queue Aug 8, 2025
Merged via the queue into JabRef:main with commit 7a5ef50 Aug 8, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add button to shorten the DOI

3 participants