Implemented title and camel key modifiers#1894
Conversation
d5e5e64 to
f0ae6ee
Compare
| ### Fixed | ||
| - Fixed NullPointerException when opening search result window for an untitled database | ||
| - Fixed #1757: Crash after saving illegal argument in entry editor | ||
| - Fixed[#1663](https://github.com/JabRef/jabref/issues/1663): Better multi-monitor support |
There was a problem hiding this comment.
|
LGTM, just some misisng space in the changelog 👍 |
| @Test | ||
| public void generateKeyTitleTitle() { | ||
| preferences = new BibtexKeyPatternPreferences("", "", false, true, false, pattern); | ||
| DatabaseBibtexKeyPattern bibtexKeyPattern = new DatabaseBibtexKeyPattern(pattern); |
There was a problem hiding this comment.
I think it makes sense to move preferences = ...; DatabaseBibtexKeyPattern bibtexKeyPattern = ... and metadata.setBibtexKeyPattern(bibtexKeyPattern); BibEntry entry = new BibEntry(); entry.setField("title",...)
to the setup method.
There was a problem hiding this comment.
The preferences are different for different tests. There is a standard preferences in setUp, but in this case it is not the standard preferences. Adding set methods which are only used in the tests doesn't seem worthwhile to me.
Regarding entries, yes, one could have one in the preferences with some standard content, and edit as required in the tests.
(This also holds for your similar comment in the other PR, although I noted I used the standard preferences in some test and still redefined them...)
f0ae6ee to
48c1e06
Compare
| this.words.addAll(new TitleParser().parse(title)); | ||
| } | ||
|
|
||
| public List<Word> getWordsReadOnly() { |
There was a problem hiding this comment.
Why not immediately replace getWords with getWordsReadOnly, i.e. just have getWords return Collections.unmodifiableList(words); and skip the introduction of getWordsReadOnly? From what I see this should not break the existing implementations.
There was a problem hiding this comment.
I think it will break it... See @tobiasdiez comment above. The thing is that forEach(Word::toUpperFirst) actually modifies the Title object, which it can't (I think) if Collections.unmodifiableList(words); is returned. On the other hand, I do not really see the use case of Title unless one is allowed to modify the content.
There was a problem hiding this comment.
Ah, I get it. The real problem is that the Word objects are mutable, less that the list is.
However, that means that you can still return Collections.unmodifiableList(words) and execute forEach(Word::toUpperFirst). The unmodifiableList only ensures that the structure of the list will not change (and your lambda does not change it), the objects contained therein can still be modified (which is ugly, but anyway...). Therefore, I would ask you to implement my suggestion and skip the deprecated getter.
There was a problem hiding this comment.
And please add at least a comment in Word that this class should be rewritten to be not mutable.
There was a problem hiding this comment.
Makes sense. I'll add immutable getWords as default and add a comment. On the other hand it is quite convenient that Word mutable. Somehow the whole Title class depends on it as the toString() method really wouldn't make sense if you cannot change any Word in Title. You would just get the same string that you entered and there is no way to convert a stream to a new Title at the moment.
48c1e06 to
5b05180
Compare
|
Added Unmodifiable return from |
| - Entries in the SearchResultDialog are now converted to Unicode | ||
| - Suggestions in the autocomplete (search) are now in Unicode | ||
| - Fixed NullPointerException when opening search result window for an untitled database | ||
| - Fixed entry table traversal with Tab (no column traversal thus no double jump) |
tobiasdiez
left a comment
There was a problem hiding this comment.
Just some small remarks about the code. Can be merged afterwards.
| resultingLabel = resultingLabel.toLowerCase(Locale.ENGLISH); | ||
| } else if ("upper".equals(modifier)) { | ||
| resultingLabel = resultingLabel.toUpperCase(Locale.ENGLISH); | ||
| if ("lower".equals(modifier) || lowerCaseFormatter.getKey().equals(modifier)) { |
There was a problem hiding this comment.
Please refactor the code a bit: first convert the modifier to the corresponding formatter Formatter getFormatterForModifier(string modifier) and then apply it to the label.
|
|
||
| @Test | ||
| public void generateKeyTitleCapitalize() { | ||
| DatabaseBibtexKeyPattern bibtexKeyPattern = new DatabaseBibtexKeyPattern(pattern); |
There was a problem hiding this comment.
The lines DatabaseBibtexKeyPattern bibtexKeyPattern = ... and metadata.setBibtexKeyPattern(bibtexKeyPattern); can be extracted to the setup method.
|
@oscargus Could you follow up so that we can merge? |
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
# Conflicts: # src/test/java/net/sf/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java
...and also all DatabaseBibtexKeyPattern bibtexKeyPattern = new DatabaseBibtexKeyPattern(pattern);
6da74b6 to
45ab7ec
Compare
|
@tobiasdiez Sorry for overlooking your second move comment. I also created The tests are locally OK. The failing test is unrelated to the update. |
|
Yes, looks good now. Thanks @koppor for finishing this PR 😄 |
* upstream/master: Implemented Integrity NoBibtexFieldChecker (#2059) Implemented title and camel key modifiers (#1894) Fix localization task hints (#2031) Result of syncLang.py update Result of syncLang.py update (with manual correction of captial_letters, and The_BibTeX_entry...) Fix "large capitals" to "capital letters" Updated Menu_tr.properties (#2057) Updated jabref_tr.properties (#2056) fix ignore version (#2055) Towards hierarchical keywords (#1950) Fix failing test, replace \uxxx encoded chars with proper UTF8 chars. Import Italian patch
* Implemented title and camel key modifiers * Fixed comments * Added more modifiers * Move bibtexKeyPattern to constructor * Move metadata.setBibtexKeyPattern(bibtexKeyPattern); to @before ...and also all DatabaseBibtexKeyPattern bibtexKeyPattern = new DatabaseBibtexKeyPattern(pattern); * Introduce Formatters.getFormatterForModifier(String)
Implemented #1506