-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Improve performance of entry editor #2892
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
Conversation
| if (changedFieldSet) { | ||
| // We have added or removed content selectors, update the entry editor | ||
| panel.rebuildAllEntryEditors(); | ||
| // TODO: We have added or removed content selectors, update the entry editor |
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.
What about this TODO? This shouldn't be merged as long as the PR still breaks the feature.
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.
The content selector feature is not yet reimplemented in the new FX entry editor and this PR doesn't change anything in this respect. The purpose of this particular code line was to update the content selectors in the editor if the user changes them. But since content editors are currently not enabled, I can't say which is the best way to reimplement the update functionality.
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.
Ok, I get it. If this is just a false marking by github and the TODOs have been there before, then this can just move forward.
However, we need to be sure that we do not release 4.0 without content selectors. Should we open an issue for this? Or will you keep this in mind and open a PR at some point?
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 this in mind. I plan to implement content selectors along with auto-completion in one of the next PRs (as soon as the big problems are resolved).
lenhard
left a comment
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.
As always, it is quite hard to review this amount of code, so I cannot guarantee that I didn't miss something. Still, I tested it locally and the performance really improves noticeably. Good job :-) It is also good to see that MaterialDesign finally has codes for its Icons.
The problem that I see is that there are quite a few TODOs still in the code and as far as I tested, the content selector feature is gone again (the manage dialog is there, but I don't get them to appear in the GUI).
All of the TODOs need to be fixed before we can think of merging the PR.
|
|
||
| for (String fieldName : fields) { | ||
|
|
||
| // TODO: Reenable/migrate this |
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.
Same here and at a few positions below. This looks like you are removing a few features including content selectors (again)?
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 actually didn't change anything here in this PR (github just marks the whole file as changed since it was renamed).
| // Add autocompleter listener, if required for this field: | ||
| /* | ||
| AutoCompleter<String> autoCompleter = bPanel.getAutoCompleters().get(field); |
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.
Just a note: The auto completer is broken and therefore it is one of the few features that is fine to go.
| import org.jabref.model.entry.EntryType; | ||
|
|
||
| public class OtherFieldsTab extends FieldsEditorTab { | ||
| public OtherFieldsTab(JabRefFrame frame, BasePanel basePanel, EntryType entryType, EntryEditor parent, BibEntry entry) { |
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.
Very minor, but please add a blank between the class declaration and the 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.
done
| */ | ||
| private void setupJTextComponent(JTextComponent textComponent) { | ||
| /* | ||
| // TODO: Set up key bindings and focus listener for the code editor. |
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.
This todo is quite important
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.
Agreed. The entry editor specific key bindings are now activated again and they work as expected. There are still issues with the key bindings, especially when it comes to more global ones - but this is already tracked as #2855.
| } | ||
|
|
||
| // First, remove fields that the user has removed. | ||
| for (Map.Entry<String, String> field : entry.getFieldMap().entrySet()) { |
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.
You could rewrite this to streams, using entrySet().stream()
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.
You mean as entrySet().stream().foreach(...) ? I really like the old-style for loop more when it comes to a complicated body and find foreach only preferable when calling one 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.
No, I thought about directly applying the
internalBibtexFields.isDisplayableField(fieldName) && !newEntry.hasField(fieldName)
as filter option in the stream and then applying anyMatch()
So:
entry.getFieldMap().entrySet().stream().filter(field->InternalBibtexFields.isDisplayableField(field.gett )
https://www.mkyong.com/java8/java-8-filter-a-map-examples/
But now I see it may not make sense
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.
Ah ok, that would be possible yes. Since this is only a slight improvement, I will leave the for-loop for now.
| } | ||
|
|
||
| // Then set all fields that have been set by the user. | ||
| for (Map.Entry<String, String> field : newEntry.getFieldMap().entrySet()) { |
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.
Same as aboe
…ePerformanceEditor
…ePerformanceEditor
* upstream/master: Greek Translation (#2835) Updated JabRef_tr.properties (#2894) Display deprecated fields in single-column layout Improve performance of entry editor (#2892) Improve person names checker (#2876) Fix #2871: all field editors have maximal height and width Fix #2880: NPE when importing in a database without groups Updated Menu_tr.properties (#2884) Updated JabRef_tr.properties (#2883) Updated mysql-connector-java from 5.1.40 -> 5.1.42 Updated java-string-similarity from 0.23 -> 0.24 Add small change to push build again # Conflicts: # external-libraries.txt
This PR improves the performance of the entry editor to a satisfactory level (switching between entries leads to a short flicker of the entry editor but no real delay). Things changed:
Moreover, a bit of the code was refactored (e.g. the creation of the different tabs is extracted from the EntryEditor class to many smaller classes, one for each tab).
gradle localizationUpdate?