feat: fetcher from clipboard and auto-select identifier type if valid#13111
Conversation
| // :TODO: Better validation would be nice here, so clipboard text is only copied over if it matches a | ||
| // supported identifier format. |
There was a problem hiding this comment.
Yes - just move it to the isvalid section?`
General thing: The wish is that when JabRef is ready to expect user input, the currently visible text field should contain the clipboard contents and be selected. - Don't know there in the code this is exactly implemented. Currently, it seems to implemented for each tab; but it could also be implemetned after the whole initalization is run - the input text field of the selected tab should be focused.
This could be a good excercise to train Requirements Tracking - see https://devdocs.jabref.org/requirements/ - It could be placed below Focus (https://devdocs.jabref.org/requirements/focus.html) or as a seperate markdown document for the new-entry-dialog.
|
|
||
| @Test | ||
| void detectsValidDOI() { | ||
| Optional<Identifier> result = CompositeIdFetcher.getIdentifier("10.1109/MCOM.2010.5673082"); |
There was a problem hiding this comment.
Better include the tests in org.jabref.logic.importer.fetcher.CompositeIdFetcherTest to have it more closerer to the method.
(Maybe, the whole getIdentifier should move to org.jabref.model.entry.identifier.Identifier as `from(String identifier))
…into fix-for-DeterminedTypeSelected
…into fix-for-DeterminedTypeSelected
|
Hi @koppor, I've implemented the identifier detection and fetcher matching logic in NewEntryView, and relocated the relevant unit tests to CompositeIdFetcherTest as discussed. Regarding your suggestion to move getIdentifier() to Identifier.from(String), I wanted to clarify: do you envision this as a static factory method within the Identifier class? If so, would you prefer this method to return an Optional—to indicate possible failure—or should it return a concrete subclass such as DOI or ISBN based on the input? I'd appreciate your guidance on this before proceeding. Thank you! |
nice!
I need to find the comment again. Maybe, next time, please just put a link to the comment. GitHub is pretty good in deep links.. Reason: I am commenting on dozens of issues and pull requests and don't remember all details. - I did not find the comment, thus, I have to guess.
Just move the method from org.jabref.logic.importer.CompositeIdFetcher to org.jabref.model.entry.identifier.Identifier and rename it from |
|
@lydia-yan Thank you for adressing OpenFastTrace! Looks good. |
| for (IdBasedFetcher fetcher : idFetcher.getItems()) { | ||
| if ((id instanceof DOI && fetcher instanceof DoiFetcher) || | ||
| // Use instanceof for structured check; fallback to name matching since some ISBN fetchers (like IsbnFetcher) don't extend AbstractIsbnFetcher. | ||
| (id instanceof ISBN && (fetcher instanceof AbstractIsbnFetcher || |
There was a problem hiding this comment.
It is enough if you just do an instanceof ISBNFetcher, because it calls the AbstractISBNFetcher under the hood and will try them one after another if no entry is found.
There was a problem hiding this comment.
Thanks! I've updated the condition to use instanceof IsbnFetcher as suggested, and exported the package in module-info.java to resolve visibility issues.
- Moved getIdentifier() from CompositeIdFetcher to Identifier as static factory method 'from(String)' - Updated all call sites to use Identifier.from(...)
…into fix-for-DeterminedTypeSelected
- Replaced string matching with instanceof IsbnFetcher in NewEntryView - Exported isbn fetcher package from jablib to enable module access
…into fix-for-DeterminedTypeSelected
|
@trag-bot didn't find any issues in the code! ✅✨ |
@koppor Thanks! I've moved the method to |
| assertTrue(result.isPresent()); | ||
| assertInstanceOf(ISBN.class, result.get()); | ||
| assertTrue(((ISBN) result.get()).isValid()); |
There was a problem hiding this comment.
I think, in this case, it is OK to "unzip" the Optional checkings.
feat: fetcher from clipboard and auto-select identifier type if valid
Update #13091 #13087
Summary of changes
This PR improves the user experience when creating a new entry by automatically detecting the identifier type (DOI, ISBN, arXiv, RFC, SSRN) from the clipboard content and selecting the appropriate fetcher in the "Enter Identifier" tab.
Changes made:
CompositeIdFetcher.getIdentifier(...)123456789)Unit tests verify identifier detection and validation logic.
UI switching (radio selection and fetcher assignment) was manually verified using valid/invalid identifier clipboard content.
Screenshots
Before (macOS):

Clipboard with
10.1109/MCOM.2010.5673082→ No tab switch, user must manually select typeAfter (macOS):

Clipboard with
10.1109/MCOM.2010.5673082→ Automatically switches and pre-selects to DOIMandatory checks
CHANGELOG.mddescribed in a way that is understandable for the average user (if change is visible to the user)Collaborators
@lydia-yan @yoasaaa @brandon-lau0 @FlyJoanne