-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 #10992
Conversation
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 #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 #13
[Fix] Fix Null when copying
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
|
||
public void setContent(List<BibEntry> entries, BibEntryTypesManager entryTypesManager, List<BibtexString> stringConstants) throws IOException { | ||
final ClipboardContent content = new ClipboardContent(); | ||
BibEntryWriter writer = new BibEntryWriter(new FieldWriter(preferencesService.getFieldPreferences()), entryTypesManager); |
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 see a lot of duplicated code with the other method. Please extract the common parts to a common method
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 have extracted the methods as suggested, please check them when convenient, thanks!
On a quick look this already goes in the right direction. Will take a closer look later |
if (checker.combinedValidationValidProperty().get()) { | ||
bibDatabaseContext.getDatabase().addString(stringConstantToAdd); | ||
} else { | ||
dialogService.showErrorDialogAndWait(Localization.lang("Pasted string constant \"%0\" was not added because it is not a valid string constant", stringConstantToAdd.getName())); |
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 have a better idea:
- Make a list with strings constants that were imported/not imported
- Display them at the end of the loop, so the user does not have to click yes/no etc for each string contant
src/main/java/org/jabref/gui/libraryproperties/constants/ConstantsPropertiesViewModel.java
Show resolved
Hide resolved
Some minor changes! |
It would be great if you could address the small changes so this gets merged and we can reduce our open PRs |
I could not push to the original repo, therefore I created a follow up PR #11037 |
We changed the copy and paste function to handle string constants automatically.
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.
Closes #10872
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)