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

Change copy-paste function to handle string constants (follow up PR) #11037

Merged
merged 32 commits into from
Mar 18, 2024

Conversation

Siedlerchr
Copy link
Member

@Siedlerchr Siedlerchr commented Mar 17, 2024

We changed the copy and paste function to handle string constants automatically.

When copying a .bib reference, the string constants are added to the clipboard.
When pasting a .bib reference with string constants, these are processed and added to the library database.
    If there are duplicate string constants, the user will be notified (error dialog) and the older string constants will be kept.

This was a quality of life features requested from a user and improves the workflow of the application. However, the user suggested originally to add a separate copy-string-constants option to the UI. We opted instead to add this feature automatically when copying with string constants to make the action more seamless.

Warnings on copy paste with duplicates
grafik

Closes #10872

Mandatory checks

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • 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.

andersblomqvist and others added 20 commits March 1, 2024 13:46
Signed-off-by: Anders Blomqvist <anders@minaemail.se>
Signed-off-by: Anders Blomqvist <anders@minaemail.se>
Currenlty, the clipboard content can be null since the database
does not seem to be updating. This is a sanity check to prevent
the program from adding null to the clipboard.

Link to DD2480-Group1#13
When loading from existing files or libraries, the parser will set
the serilization of the string constant to the correct value. However,
when editing via the GUI, the serilization was not set and a new
string constant list will be created without the serilization.
This result in the serilization being null and when copying with
the clipboard.

Link to DD2480-Group1#13
Add functionality to import string constants in the paste function

Should add functionality to handle colliding string constants.
Should also check that the constants are valid using the
ConstantsItemModel class.
Check that a pasted string constant is valid using the
ConstantsItemModel class.

Add diagnostic messages notifying users when adding a string constant
fails while pasting.
* feat: Add parsed serialized string when cloning
* feat: Add sanity check for null in ClipBoardManager
* closes #15
Add 4 new unit tests, testing the new features added for issue-10872. Specifically the tests are for the `storeSettings` method in the ConstantsPropertiesViewModel.java, and `setContent` in the ClipBaordManager.java.

Closes #6
* upstream/main: (26 commits)
  Speed up failure reporting (#11030)
  Importing of BibDesk Groups and Linked Files (#10968)
  Convert RemoveBracesFormatterTest to @ParameterizedTest (#11033)
  Update teaching.md
  Remove non-existing recipe (#11029)
  Update CSL styles (#11031)
  Clean up defintions of entry types (#11013)
  Fix log file path on Windows (#11028)
  Change to rolling logs (#11023)
  chore: remove repetitive words (#11015)
  Fix test names (#11014)
  Remove obsolete "Comments" tab configuration (#11011)
  Fix "Other fields" tab respecting custom tabs (#11012)
  [WIP] Extract PDF References (#10437)
  Fixed jump to entry from crossref (#11009)
  fix suggestion provider for crossref field (#10962)
  Use SequencedSet for required and optional fields (#11007)
  Bump io.github.classgraph:classgraph from 4.8.165 to 4.8.168 (#11005)
  Bump org.glassfish.hk2:hk2-api from 3.0.6 to 3.1.0 (#11006)
  Bump org.apache.logging.log4j:log4j-to-slf4j from 2.23.0 to 2.23.1 (#11003)
  ...

# Conflicts:
#	src/main/resources/csl-styles
@Siedlerchr
Copy link
Member Author

TODO: Clipbaord tests
org.jabref.gui.ClipBoardManagerTest

Test Check that the ClipBoardManager can set a bibentry as its content from the clipboard FAILED

java.lang.NullPointerException: Cannot invoke "java.util.SequencedSet.stream()" because the return value of "org.jabref.model.entry.BibEntryType.getRequiredFields()" is null

Test Check that the ClipBoardManager can handle a bibentry with string constants correctly from the clipboard FAILED

java.lang.NullPointerException: Cannot invoke "java.util.SequencedSet.stream()" because the return value of "org.jabref.model.entry.BibEntryType.getRequiredFields()" is null

@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Mar 17, 2024
CHANGELOG.md Outdated
@@ -47,6 +48,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We enhanced the dialog for adding new fields in the content selector with a selection box containing a list of standard fields. [#10912](https://github.com/JabRef/jabref/pull/10912)
- We store the citation relations in an LRU cache to avoid bloating the memory and out-of-memory exceptions. [#10958](https://github.com/JabRef/jabref/issues/10958)
- Keywords filed are now displayed as tags. [#10910](https://github.com/JabRef/jabref/pull/10910)
- When pasting, string constants are automatically added to the library database, while referenced constants are added to the clipboard during copying. [#10872](https://github.com/JabRef/jabref/issues/10872)
Copy link
Member

Choose a reason for hiding this comment

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

Why two entries in the changelog?

Copy link
Member Author

Choose a reason for hiding this comment

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

One for changed behavior and one for new feature

Copy link
Contributor

github-actions bot commented Mar 18, 2024

The build for this PR is no longer available. Please visit https://builds.jabref.org/main/ for the latest build.

@koppor koppor disabled auto-merge March 18, 2024 10:44
Copy link
Member

@calixtus calixtus left a comment

Choose a reason for hiding this comment

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

LGTM
Follow up would be adding the shift key as modifier to paste without constants. 😝

@calixtus calixtus added this pull request to the merge queue Mar 18, 2024
Merged via the queue into main with commit d792923 Mar 18, 2024
21 checks passed
@calixtus calixtus deleted the fix-for-issue-10872 branch March 18, 2024 11:10
@Siedlerchr
Copy link
Member Author

We opted instead to add this feature automatically when copying with string constants to make the action more seamless.

Siedlerchr added a commit to ror3d/jabref that referenced this pull request Mar 18, 2024
…link

* upstream/main:
  Bump org.apache.pdfbox:fontbox from 3.0.1 to 3.0.2 (JabRef#11042)
  Bump com.dlsc.gemsfx:gemsfx from 2.2.0 to 2.4.0 (JabRef#11044)
  Bump org.apache.pdfbox:xmpbox from 3.0.1 to 3.0.2 (JabRef#11041)
  Bump com.googlecode.plist:dd-plist from 1.23 to 1.28 (JabRef#11040)
  Bump gittools/actions from 0.13.4 to 1.1.1 (JabRef#11039)
  Change copy-paste function to handle string constants (follow up PR) (JabRef#11037)
  Fixes Zotero file handling for absolute paths (JabRef#11038)
  Speed up failure reporting (JabRef#11030)
  Importing of BibDesk Groups and Linked Files (JabRef#10968)
  Convert RemoveBracesFormatterTest to @ParameterizedTest (JabRef#11033)
  Update teaching.md
  Remove non-existing recipe (JabRef#11029)
  Update CSL styles (JabRef#11031)
  Clean up defintions of entry types (JabRef#11013)
  Fix log file path on Windows (JabRef#11028)
  Change to rolling logs (JabRef#11023)
  chore: remove repetitive words (JabRef#11015)
  Fix test names (JabRef#11014)
Siedlerchr added a commit to Anirudhxx/jabref that referenced this pull request Mar 18, 2024
* upstream/main: (40 commits)
  Improve citation relations (JabRef#11016)
  Keep enclosing braces of authors (JabRef#11034)
  Bump org.apache.pdfbox:fontbox from 3.0.1 to 3.0.2 (JabRef#11042)
  Bump com.dlsc.gemsfx:gemsfx from 2.2.0 to 2.4.0 (JabRef#11044)
  Bump org.apache.pdfbox:xmpbox from 3.0.1 to 3.0.2 (JabRef#11041)
  Bump com.googlecode.plist:dd-plist from 1.23 to 1.28 (JabRef#11040)
  Bump gittools/actions from 0.13.4 to 1.1.1 (JabRef#11039)
  Change copy-paste function to handle string constants (follow up PR) (JabRef#11037)
  Fixes Zotero file handling for absolute paths (JabRef#11038)
  Speed up failure reporting (JabRef#11030)
  Importing of BibDesk Groups and Linked Files (JabRef#10968)
  Convert RemoveBracesFormatterTest to @ParameterizedTest (JabRef#11033)
  Update teaching.md
  Remove non-existing recipe (JabRef#11029)
  Update CSL styles (JabRef#11031)
  Clean up defintions of entry types (JabRef#11013)
  Fix log file path on Windows (JabRef#11028)
  Change to rolling logs (JabRef#11023)
  chore: remove repetitive words (JabRef#11015)
  Fix test names (JabRef#11014)
  ...
github-merge-queue bot pushed a commit that referenced this pull request Mar 21, 2024
* issue #10993 - feat: added ability to parse preferred-citation field to CffImporter

* issue #10993 - feat: added all fields of JabRef/CITATION.cff to CffImporter

* issue #10993 - feat: rewrote CffExporter to parse Software, Dataset types and authors names correctly

* issue #10993 - feat: added keywords and unknown fields support

* issue #10993 - feat: added round-trip test

* issue #10993 - doc: updated CHANGELOG.md

* Convert RemoveBracesFormatterTest to @ParameterizedTest (#11033)

* Convert to @ParameterizedTest

* Convert to csvsource

---------

Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>

* Importing of BibDesk Groups and Linked Files (#10968)

* Add test to check parsing of BibDesk Static Groups

* Add test to check parsing of BibDesk Static Groups

* Change isExpanded attribute to false in expected groups

* remove extra blank line

* Add tests to check parsing of BibDesk Smart and mixed groups

* Add parsing of BibDesk Files

* Attempts at plist

* Now parses bdsk-file and shows it as a file in JabRef

* Add test for parsing a bdsk-file field

* Fix formatting

* Add dd-plist library to documentation

---------

Co-authored-by: Tian0602 <646432316@qq.com>

* Add creation of static JabRef group from a BibDesk file

* Creates an empty ExplicitGroup from BibDesk comment

* Adds citations to new groups
modifies group creations to support multiple groups in the same BibDeskFile

* Fix requested changes
Refactor imports since they did not match with main
Add safety check in addBibDeskGroupEntriesToJabRefGroups

---------

Co-authored-by: Filippa Nilsson <filnils@kth.se>

* Refactor newline to match main branch

Co-authored-by: Filippa Nilsson <filnils@kth.se>

* Add changes to CHANGELOG.md

* Reformat indentation to match previous

* Revert external libraries

Adjust groups serializing

* checkstyle and optional magic

* fix

* fix tests

* fix

* fix dangling do

* better group tree metadata setting

* merge group trees, prevent duplicate group assignment in entry
Add new BibDesk group

Fix IOB for change listeing

* fix tests, and extract constant

* return early

* fixtest and checkstyle

---------

Co-authored-by: Anna Maartensson <120831475+annamaartensson@users.noreply.github.com>
Co-authored-by: Tian0602 <646432316@qq.com>
Co-authored-by: LottaJohnsson <35195355+LottaJohnsson@users.noreply.github.com>
Co-authored-by: Filippa Nilsson <filnils@kth.se>
Co-authored-by: Filippa Nilsson <75281470+filippanilsson@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
Co-authored-by: Siedlerchr <siedlerkiller@gmail.com>

* Speed up failure reporting (#11030)

* Fixes Zotero file handling for absolute paths (#11038)

* Fixes Zotero file handling for absolute paths

Fixes #10959

* checkstyle mimiimm

* fix changelog

* cannot fix

* Change copy-paste function to handle string constants (follow up PR) (#11037)

* [Copy] Include string constants in copy (#11)

Signed-off-by: Anders Blomqvist <anders@minaemail.se>

* [Copy] New method for serializing string constants (#12)

Signed-off-by: Anders Blomqvist <anders@minaemail.se>

* Add a sanity check for null for clipboard content

Currenlty, the clipboard content can be null since the database
does not seem to be updating. This is a sanity check to prevent
the program from adding null to the clipboard.

Link to DD2480-Group1#13

* [Fix] Add parsed serilization when save settings

When loading from existing files or libraries, the parser will set
the serilization of the string constant to the correct value. However,
when editing via the GUI, the serilization was not set and a new
string constant list will be created without the serilization.
This result in the serilization being null and when copying with
the clipboard.

Link to DD2480-Group1#13

* feat: import string constants when pasting #9

Add functionality to import string constants in the paste function

Should add functionality to handle colliding string constants.
Should also check that the constants are valid using the
ConstantsItemModel class.

* feat: Add string constant validity checker and dialog messages #9

Check that a pasted string constant is valid using the
ConstantsItemModel class.

Add diagnostic messages notifying users when adding a string constant
fails while pasting.

* [Copy] Copy referenced constant strings to clipboard  (#16)

* feat: Add parsed serialized string when cloning
* feat: Add sanity check for null in ClipBoardManager
* closes #15

* feat: new unit tests

Add 4 new unit tests, testing the new features added for issue-10872. Specifically the tests are for the `storeSettings` method in the ConstantsPropertiesViewModel.java, and `setContent` in the ClipBaordManager.java.

Closes #6

* Update CHANGELOG with copy and paste function

* Fix Checkstyle failing by reformat the code

* Fix OpenRewrite failing by running rewriteRun

* Refactor by extract methods in setContent

* collet failures

* changelog and use os.newline

* checkstyle

* use real bibentrytypes manager

* Fix CHANGELOG.md

* Swap if branches

* Code cleanup

* Use List for getUsedStringValues

* Fix submodule

* Collection is better

* Fix csl-styles

* Remove empty line

* Group BibTeX string l10n together

---------

Signed-off-by: Anders Blomqvist <anders@minaemail.se>
Co-authored-by: Anders Blomqvist <anders@minaemail.se>
Co-authored-by: ZOU Hetai <33616271+JXNCTED@users.noreply.github.com>
Co-authored-by: Hannes Stig <hannes.a.stig@gmail.com>
Co-authored-by: Elliot <elliot.darth@gmail.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>

* Bump gittools/actions from 0.13.4 to 1.1.1 (#11039)

Bumps [gittools/actions](https://github.com/gittools/actions) from 0.13.4 to 1.1.1.
- [Release notes](https://github.com/gittools/actions/releases)
- [Commits](GitTools/actions@v0.13.4...v1.1.1)

---
updated-dependencies:
- dependency-name: gittools/actions
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump com.googlecode.plist:dd-plist from 1.23 to 1.28 (#11040)

Bumps [com.googlecode.plist:dd-plist](https://github.com/3breadt/dd-plist) from 1.23 to 1.28.
- [Release notes](https://github.com/3breadt/dd-plist/releases)
- [Commits](3breadt/dd-plist@dd-plist-1.23...v1.28.0)

---
updated-dependencies:
- dependency-name: com.googlecode.plist:dd-plist
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump org.apache.pdfbox:xmpbox from 3.0.1 to 3.0.2 (#11041)

Bumps org.apache.pdfbox:xmpbox from 3.0.1 to 3.0.2.

---
updated-dependencies:
- dependency-name: org.apache.pdfbox:xmpbox
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump com.dlsc.gemsfx:gemsfx from 2.2.0 to 2.4.0 (#11044)

Bumps [com.dlsc.gemsfx:gemsfx](https://github.com/dlsc-software-consulting-gmbh/GemsFX) from 2.2.0 to 2.4.0.
- [Release notes](https://github.com/dlsc-software-consulting-gmbh/GemsFX/releases)
- [Changelog](https://github.com/dlsc-software-consulting-gmbh/GemsFX/blob/master/CHANGELOG.md)
- [Commits](dlsc-software-consulting-gmbh/GemsFX@v2.2.0...v2.4.0)

---
updated-dependencies:
- dependency-name: com.dlsc.gemsfx:gemsfx
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump org.apache.pdfbox:fontbox from 3.0.1 to 3.0.2 (#11042)

Bumps org.apache.pdfbox:fontbox from 3.0.1 to 3.0.2.

---
updated-dependencies:
- dependency-name: org.apache.pdfbox:fontbox
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Keep enclosing braces of authors (#11034)

* Add test cases

* Add test cases

* Keep braces for last part

* Refine method description

* Adapt test to new braces keeping

* Add CHANGELOG.md entry

* Adapt tests

* More edge cases

* Minor code beautification

* Simplify code

* Fix braces removing

* Extract static fields, refactor code

* Fix removal of {} for export

* Re-add Objects.requireNonNull

* Fix typo

* Re-add NPE throwing

* Rename to modern terms

* Consistent initialization

* Improve citation relations (#11016)

* Collect DOI and publication type from semantich scholar to be able to expand the information of the new entries later by search through DOI

* Include abstract in the request. This lets the GUI show the abstract since that was implemented already.
Refactor api request string since most of it is shared

* Add button to open the relation paper's DOI URL.
Fix DOI for some ArXiv entries.

* Don't show the open link button if there is no link to open.

* Make field value null error a bit more useful

* Include SemanticScholar url in the request and use it as the URL field.

* Add changes to changelog

* Change tooltip text to an existing, more informative one

* Run rewriter to fix pull request

* improve url optional handling

---------

Co-authored-by: Siedlerchr <siedlerkiller@gmail.com>

* issue #10993 - doc: updated CHANGELOG.md

* fix: fixed unit tests not passing due to name changes in Author interface (#10995)

* feat: changed CFFExporter to use YAML library snakeyaml instead (#10995)

* feat: added support for references and ALL possible CFF fields in importer (#10995)

* fix: added requested changes (#10995)

+ updated CHANGELOG.md
+ removed useless comments
+ refactored both CffImporter and CffExporter to use more specific methods
+ used a BiMap to avoid repeating mappings between CffImporter and CffExporter
+ copied entryMap in exporter to avoid side-effects

* fix: task rewriteDryRun fixed to pass by removing test in BibEntryTest

* refactor: deleted useless methods in CffImporter (#10995)

* doc: added decision MADR document for cff export (#10995)

* feat: add a cites or related relationship between imported entries in CffImporter (#10995)

* doc: updated MADR decision document for cff export to pass markdownlint (#10995)

* fix: fixed round-trip test to use mock citatioKeyPatternPreferences correctly (#10995)

* fix: fixed MADR document for CFF export decision to pass Jekyll CI check (#10995)

* fix: fixed requested changes (#10995)

+ fixed typo in CHANGELOG.md
+ tested multiline abstract in CFFImporter

* feat: finished CFFExporter logic and crafted working round-trip test (#10995)

* fix: fixed typos in MADR decision doc for CFF export and refactore ImportFormatReader signature (#10995)

* Some code beautification

* Use existing method getEntryLinkList

* Use getEntryLinkList

* Use JabRef's Date class for parsing

---------

Signed-off-by: Anders Blomqvist <anders@minaemail.se>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
Co-authored-by: Emil Hultcrantz <90456354+Frequinzy@users.noreply.github.com>
Co-authored-by: Anna Maartensson <120831475+annamaartensson@users.noreply.github.com>
Co-authored-by: Tian0602 <646432316@qq.com>
Co-authored-by: LottaJohnsson <35195355+LottaJohnsson@users.noreply.github.com>
Co-authored-by: Filippa Nilsson <filnils@kth.se>
Co-authored-by: Filippa Nilsson <75281470+filippanilsson@users.noreply.github.com>
Co-authored-by: Siedlerchr <siedlerkiller@gmail.com>
Co-authored-by: Anders Blomqvist <anders@minaemail.se>
Co-authored-by: ZOU Hetai <33616271+JXNCTED@users.noreply.github.com>
Co-authored-by: Hannes Stig <hannes.a.stig@gmail.com>
Co-authored-by: Elliot <elliot.darth@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Roc <1844478+ror3d@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replacing String Constants During Copy-Paste
7 participants