Skip to content

Conversation

@tobiasdiez
Copy link
Member

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:

  • Tab panel is converted to JavaFX
  • Each tab is initialized only upon focus

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).

  • Change in CHANGELOG.md described
  • Tests created for changes
  • Screenshots added (for bigger UI changes)
  • Manually tested changed features in running JabRef
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)
  • If you changed the localization: Did you run gradle localizationUpdate?

@tobiasdiez tobiasdiez added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jun 6, 2017
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
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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).

Copy link
Member

@lenhard lenhard left a 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
Copy link
Member

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)?

Copy link
Member Author

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);
Copy link
Member

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) {
Copy link
Member

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.

Copy link
Member Author

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.
Copy link
Member

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

Copy link
Member Author

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()) {
Copy link
Member

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()

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

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()) {
Copy link
Member

Choose a reason for hiding this comment

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

Same as aboe

@tobiasdiez tobiasdiez merged commit 52b887d into master Jun 7, 2017
@tobiasdiez tobiasdiez deleted the improvePerformanceEditor branch June 7, 2017 20:14
Siedlerchr added a commit that referenced this pull request Jun 8, 2017
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: entry-editor dev: performance 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.

5 participants