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

Improve Automatic Field Editor Dialog #8973

Merged
merged 81 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
376760c
Update README.md
HoussemNasri Mar 24, 2022
d898da1
Merge branch 'JabRef:main' into main
HoussemNasri Mar 31, 2022
752954b
Merge branch 'JabRef:main' into main
HoussemNasri Apr 11, 2022
41b499f
Merge branch 'JabRef:main' into main
HoussemNasri Apr 26, 2022
a63045f
Merge branch 'JabRef:main' into main
HoussemNasri May 7, 2022
0901768
Merge branch 'JabRef:main' into main
HoussemNasri May 8, 2022
5874b4e
Merge remote-tracking branch 'origin/main' into main
HoussemNasri May 30, 2022
3c3fb02
Fix Readme
HoussemNasri Jun 7, 2022
81815fa
Merge branch 'JabRef:main' into main
HoussemNasri Jun 7, 2022
18d95c2
Merge branch 'JabRef:main' into main
HoussemNasri Jun 18, 2022
0e08af3
Merge branch 'JabRef:main' into main
HoussemNasri Jun 20, 2022
2bb0b6c
Merge branch 'JabRef:main' into main
HoussemNasri Jun 23, 2022
d71f93a
Commit
HoussemNasri Jun 23, 2022
57005ce
Merge branch 'JabRef:main' into main
HoussemNasri Jun 23, 2022
fffc86c
Update README.md
HoussemNasri Jun 29, 2022
4f480ba
Merge remote-tracking branch 'origin/main' into main
HoussemNasri Jul 12, 2022
63e09ba
Merge branch 'JabRef:main' into main
HoussemNasri Jul 12, 2022
365e968
Merge remote-tracking branch 'origin/main' into main
HoussemNasri Jul 12, 2022
033b9a2
Revert "Commit"
HoussemNasri Jul 12, 2022
1303d3c
Don't copy field value if it doesn't exist
HoussemNasri Jul 12, 2022
a4b5e3e
Refactor TwoFields tab to make it easier to test
HoussemNasri Jul 12, 2022
fd1006e
Test TwoFieldsViewModel
HoussemNasri Jul 12, 2022
2a1a298
Add more tests for TwoFieldsViewModel
HoussemNasri Jul 12, 2022
a8adb0b
Rename dialog's 'Revert' button to 'Cancel'
HoussemNasri Jul 12, 2022
0879542
Rename 'value' to 'content'
HoussemNasri Jul 12, 2022
675ed00
Make field ComboBox editable
HoussemNasri Jul 13, 2022
2bbb097
Update ComboBox field list when a new field is added
HoussemNasri Jul 13, 2022
ec75377
Rename "Overwrite Non empty fields" to "Overwrite field content"
HoussemNasri Jul 13, 2022
72e9287
Cancel changes when the dialog is closed using the X button
HoussemNasri Jul 13, 2022
120c63c
Revert "Cancel changes when the dialog is closed using the X button"
HoussemNasri Jul 13, 2022
0f9734a
Prevent JavaFX from firing CANCEL_CLOSE event
HoussemNasri Jul 13, 2022
7e58326
Show field display name in ComboBox
HoussemNasri Jul 13, 2022
d2f2b8a
Clear old field list before adding the new list
HoussemNasri Jul 15, 2022
bbe27b0
Rename 'TwoFields' to 'CopyOrMoveFieldContent'
HoussemNasri Jul 15, 2022
a70f750
i18n
HoussemNasri Jul 15, 2022
3a055ee
Rename package to copyormovecontent
HoussemNasri Jul 15, 2022
ccfd331
Make the set of visible fields observable
HoussemNasri Jul 15, 2022
b0accbf
Bind fields ComboBox to visible fields in BibDatabase
HoussemNasri Jul 15, 2022
b012f5d
Checkstyle
HoussemNasri Jul 15, 2022
4d6cd83
Make visibleFields set modifiable
HoussemNasri Jul 15, 2022
e2edbe1
Select first item in the ComboBox after fields set is updated
HoussemNasri Jul 15, 2022
46673e4
Bind RenameFieldTabView's combobox to visible fields set
HoussemNasri Jul 15, 2022
4663df5
Allow users to move or copy content from one field to a NEW field
HoussemNasri Jul 15, 2022
c1f2bf2
Bind CopyOrMoveFieldContentTabView's from/to fields combobox to visib…
HoussemNasri Jul 15, 2022
839454f
Remove the binding between visible fields in BibDatabase and ComboBox…
HoussemNasri Jul 17, 2022
35c3146
Add Standard fields even when visible fields set is empty
HoussemNasri Jul 17, 2022
bad23ae
Make all ComboBox(s) editable
HoussemNasri Jul 17, 2022
8652b58
Pass BibDatabase rather than BibDatabaseContext to field editor tabs
HoussemNasri Jul 17, 2022
b115260
Bind UI to view model and not the other way around
HoussemNasri Jul 17, 2022
e851dc0
Add getSelectedField() to EditFieldContentViewModel
HoussemNasri Jul 17, 2022
5bb34ff
Test EditFieldContentTabViewModel
HoussemNasri Jul 17, 2022
1e9dfc4
Remove System.out.println
HoussemNasri Jul 19, 2022
452d212
Show a notification to indicate the number of affected entries when a…
HoussemNasri Jul 21, 2022
c27b835
Don't register copy edit if the copy action is not performed
HoussemNasri Jul 21, 2022
ed18b44
Show affected rows notification when field values are swapped
HoussemNasri Jul 21, 2022
f9c45f9
Show affected rows notification when field values are set/cleared or …
HoussemNasri Jul 21, 2022
0e8c9a4
Add methods to register/unregister event bus to RenameFieldTabView
HoussemNasri Jul 21, 2022
2522645
Post a notification event when field is renamed or when field value i…
HoussemNasri Jul 21, 2022
0d44a15
Remove Notification Pane's transparent background style
HoussemNasri Jul 21, 2022
f06b212
Display the notification pane for 2 seconds
HoussemNasri Jul 21, 2022
b41033f
Convert AutomaticFieldEditorEvent to a record
HoussemNasri Jul 21, 2022
8011f30
Filter out blank field names
HoussemNasri Jul 21, 2022
e87dc4c
Reuse FIELD_STRING_CONVERTER from CustomEntryTypeDialogViewModel
HoussemNasri Jul 21, 2022
a5c84fa
Disable rename field button when either field ComboBox or new field n…
HoussemNasri Jul 21, 2022
3ceec86
Display an error if new field name has any whitespace characters
HoussemNasri Jul 21, 2022
2146766
Validate user input in EditFieldContentTabView
HoussemNasri Jul 21, 2022
aaa7814
Refactor
HoussemNasri Jul 21, 2022
dd7875d
Validate user input in CopyOrMoveFieldContentTabView
HoussemNasri Jul 21, 2022
cdc88ab
Test RenameFieldViewModel
HoussemNasri Jul 22, 2022
872839f
Convert to field display name as user types text in fromFieldComboBox
HoussemNasri Jul 22, 2022
9016c1a
Update 'containsWhitespace' implementation
HoussemNasri Jul 24, 2022
edc9f3e
Test containsWhitespace
HoussemNasri Jul 24, 2022
f80232a
Increase StringUtil maximum line count to 765
HoussemNasri Jul 24, 2022
96c7ea8
Stop using event bus in EditFieldContentTabView
HoussemNasri Jul 29, 2022
e925826
Stop using event bus in the other tabs
HoussemNasri Jul 29, 2022
d89f691
Delete AutomaticFieldEditorEvent.java
HoussemNasri Jul 29, 2022
1c9f063
Minimize number of constructor arguments
HoussemNasri Jul 29, 2022
e9a7716
Update tests
HoussemNasri Jul 29, 2022
6b86397
Work around exception
koppor Aug 1, 2022
f59c5f5
Fix casing
koppor Aug 1, 2022
f37c5f8
Convert to ParameterizedTests
koppor Aug 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public CopyOrMoveFieldContentTabViewModel(List<BibEntry> selectedEntries, BibDat
toFieldValidator = new FunctionBasedValidator<>(toField, field -> {
if (StringUtil.isBlank(field.getName())) {
return ValidationMessage.error("Field name cannot be empty");
} else if (StringUtil.containsAnyWhitespaceCharacters(field.getName())) {
} else if (StringUtil.containsWhitespace(field.getName())) {
return ValidationMessage.error("Field name cannot have whitespace characters");
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public EditFieldContentViewModel(BibDatabase database, List<BibEntry> selectedEn
fieldValidator = new FunctionBasedValidator<>(selectedField, field -> {
if (StringUtil.isBlank(field.getName())) {
return ValidationMessage.error("Field name cannot be empty");
} else if (StringUtil.containsAnyWhitespaceCharacters(field.getName())) {
} else if (StringUtil.containsWhitespace(field.getName())) {
return ValidationMessage.error("Field name cannot have whitespace characters");
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public RenameFieldViewModel(List<BibEntry> selectedEntries, BibDatabase database
fieldNameValidator = new FunctionBasedValidator<>(newFieldName, fieldName -> {
if (StringUtil.isBlank(fieldName)) {
return ValidationMessage.error("Field name cannot be empty");
} else if (StringUtil.containsAnyWhitespaceCharacters(fieldName)) {
} else if (StringUtil.containsWhitespace(fieldName)) {
return ValidationMessage.error("Field name cannot have whitespace characters");
}
return null;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/model/strings/StringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ public static String quoteStringIfSpaceIsContained(String string) {
* @param s The string to check
* @return {@code True} if the given string does contain at least one whitespace character, {@code False} otherwise
* */
public static boolean containsAnyWhitespaceCharacters(String s) {
return s.matches(".*\s.*");
public static boolean containsWhitespace(String s) {
Copy link
Member

Choose a reason for hiding this comment

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

You now need to adapt the failing architecture test to the new size of the StringUtil class.
PS: I wasn't aware of the String.chars method, that's neat

Copy link
Member Author

Choose a reason for hiding this comment

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

Increased it to 765

return s.chars().anyMatch(Character::isWhitespace);
}
}
16 changes: 16 additions & 0 deletions src/test/java/org/jabref/model/strings/StringUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,20 @@ void testStripAccents() {
assertEquals("aAoeee", StringUtil.stripAccents("åÄöéèë"));
assertEquals("Muhlbach", StringUtil.stripAccents("Mühlbach"));
}

@Test
void testContainsWhitespace() {
assertTrue(StringUtil.containsWhitespace("file url"));
assertTrue(StringUtil.containsWhitespace("file\nurl"));
assertTrue(StringUtil.containsWhitespace("file\r\nurl"));
assertTrue(StringUtil.containsWhitespace("file\rurl"));
assertTrue(StringUtil.containsWhitespace("file\furl"));
assertTrue(StringUtil.containsWhitespace("file_url "));
assertTrue(StringUtil.containsWhitespace("file url\n"));
assertTrue(StringUtil.containsWhitespace(" "));

assertFalse(StringUtil.containsWhitespace("file_url"));
assertFalse(StringUtil.containsWhitespace("PascalCase"));
assertFalse(StringUtil.containsWhitespace(""));
}
}