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

Updates to colored group indicator for cited entries #7173

Merged
merged 35 commits into from
Jan 13, 2021

Conversation

k3KAW8Pnf7mkmdSMPHz27
Copy link
Member

@k3KAW8Pnf7mkmdSMPHz27 k3KAW8Pnf7mkmdSMPHz27 commented Dec 8, 2020

Fixes #6394.

An entry can belong to a specific group depending on,

  1. Field or type in the BibEntry
  2. The settings of the specific group

Hence, any changes in a field or type in the BibEntry, or any change in the groups should reevaluation wether or not the entry is still in any given group.

I am not very comfortable with the JavaFX/MVVC structure yet, so I have attempted an approach with as few structural changes as possible.

  • Keep the count "badge" is up-to-date
  • Refresh the selected groups
    • Deal with ConcurrentModificationException
    • Fix performance bottleneck
      • Occurs when switching library and the group is selected
  • Check for potential memory leaks,
    • caused by extending Observable in TexGroup.java (how should the listeners be stored?)
    • dependence on deprecated method GroupTreeNode#setGroup(AbstractGroup newGroup)
    • use of EventBus without unregistering listener
      • Make a WeakInvalidationListener adapter?
  • JabRef believes the .bib file has changed when the .aux file changes
    • Check if the isFilteredOut attribute of BibDatabaseContextChangedEvent is used to prevent saving
      • Add JavaDoc
  • How does the current GroupInvalidationEvent affect the hierarchical group structure? (should it be fired from elsewhere so that only partial recalculations of group colors are necessary)
  • Replace unnecessary adapter class

  • Change in CHANGELOG.md described (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked documentation: Is the information available and up to date? If not created an issue at https://github.com/JabRef/user-documentation/issues or, even better, submitted a pull request to the documentation repository.

Matched groups should update both on changes in the BibEntry and changes
 in groups.
@k3KAW8Pnf7mkmdSMPHz27 k3KAW8Pnf7mkmdSMPHz27 changed the title [WIP] Updates to colored group indicator [WIP] Updates to colored group indicator for cited entries Dec 8, 2020
@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

Would any of the following be more/less valid approaches?

  1. Make TexGroup implement Observable,
  2. Make TexGroup.keysUsedInAux an ObservableSet (I'd argue this seem similar to how BibEntry#getObservables operates)

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

I added a minimum working example of implementing the Observable interface. Any comments/suggestions are welcome (including scratch this approach X) )

@Siedlerchr
Copy link
Member

Thanks for tackling this! It would be interesting to see how it performs with many group (can provide you a test file via mail or so, cause its confidential)

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

I can't observe impactful slowdowns/memory leaks, but there shouldn't be many changes that affects the large database. Most potential memory leaks will only occur when an .aux file is linked.

I have update the description with what I think is left, and commented on a change that can mostly be reverted if performance is an issue. Sorry about the slow going, JavaFX is somewhat new to me.

@DominikVoigt
Copy link
Contributor

Hey there!
Thank you for your contribution.
Seeing that your last commit was pushed 5 days ago,
I want to ask whether you are finished with your work?
Is this PR ready for review :)?

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

k3KAW8Pnf7mkmdSMPHz27 commented Dec 21, 2020

Hey @DominikVoigt . I am sorry but no, I thought I would make a 30 min fix in #7210 but unfortunately it didn't turn out that way o.O
I don't think this is worth reviewing yet, the JabRef believes the .bib file has changed when the .aux file changes bullet item most likely means I am going to have to change/extend the metadata updates which might/might not be ok from JabRef's point-of-view.

@Siedlerchr
Copy link
Member

@k3KAW8Pnf7mkmdSMPHz27 The bib file is changed can be also #5967

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

k3KAW8Pnf7mkmdSMPHz27 commented Dec 21, 2020 via email

@Siedlerchr
Copy link
Member

As a first workaround try disabling autosave.

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

@Siedlerchr at least for now it happens independently of autosave.

The reason why JabRef believes that the database has changed is that I wanted to use GroupUpdatedEvent to notify any listener that a group has changed. GroupUpdatedEvent extends BibDatabaseContextChangedEvent which I guess triggers

@Subscribe
public void listen(BibDatabaseContextChangedEvent event) {
this.changedProperty.setValue(true);
}

among others. (I wanted to view it as a change to the MetaData)
The issue with TexGroup is that it

  1. requires an update without any interaction from the user (it updates on changes in an external file), and
  2. these updates does not need to be saved.

I think it is the only group with these characteristics, hence I don't see it motivated to extend the GroupUpdatedEvent since it seems well established that BibDatabaseContextChangedEvent implies a change that requires saving.

I'll figure something out but I am temporarily a bit stuck 😱

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

Hum... TexGroup has a reference to the MetaData. Is it ok if I its EventBus to post updates instead?

@k3KAW8Pnf7mkmdSMPHz27 k3KAW8Pnf7mkmdSMPHz27 marked this pull request as ready for review December 28, 2020 21:29
@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

It might make sense to make TexGroup observable or to use its FileUpdateMonitor directly in the GroupNodeViewModel.

Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

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

Do you still have open questions or is this already ready for review?

src/main/java/org/jabref/model/groups/TexGroup.java Outdated Show resolved Hide resolved
@calixtus
Copy link
Member

calixtus commented Jan 9, 2021

Hey @k3KAW8Pnf7mkmdSMPHz27 , you didn't change anything on this PR for 5 days. Is this PR ready for review?

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

k3KAW8Pnf7mkmdSMPHz27 commented Jan 9, 2021 via email

@calixtus calixtus added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jan 9, 2021
Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

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

Thanks!

The code looks very good to me. The only problem I see is that the UI-binding already happens in the model class. This should be moved to the gui classes that need such a wrapping.

import org.jabref.architecture.AllowedToUseLogic;
import org.jabref.gui.util.uithreadaware.UiThreadOptionalBinding;
Copy link
Member

Choose a reason for hiding this comment

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

The model and logic packages need to be free of gui stuff. The wrapping on the JavaFX thread should happen right before it is displayed.

Copy link
Member

Choose a reason for hiding this comment

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

@JabRef/developers Our architecture tests don't work anymore?! This is clearly a violation but the tests pass.

@tobiasdiez tobiasdiez added the status: changes required Pull requests that are not yet complete label Jan 9, 2021
Copy link
Member Author

@k3KAW8Pnf7mkmdSMPHz27 k3KAW8Pnf7mkmdSMPHz27 left a comment

Choose a reason for hiding this comment

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

I'd appreciate an opinion on what should create an update of the group color region in the maintable (entry.getObservables()?). Also, should that part of #7325 be addressed in this PR? (the group color region not updating)

@tobiasdiez tobiasdiez removed the status: changes required Pull requests that are not yet complete label Jan 11, 2021
Copy link
Member

@calixtus calixtus left a comment

Choose a reason for hiding this comment

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

Worked myself through the changes. Looks good also to me, so I will merge this PR.
Thanks for your work on this issue!

@calixtus calixtus merged commit 4d8e4f0 into JabRef:master Jan 13, 2021
Siedlerchr added a commit that referenced this pull request Jan 13, 2021
…dtask

* upstream/master:
  Update guidelines-for-setting-up-a-local-workspace.md (#7339)
  Updates to colored group indicator for cited entries (#7173)
  Add some special fields as default columns (#7286)
  Add a more descriptive path when Directory cannot be found (#7232)
  Bump antlr4 from 4.9 to 4.9.1 (#7327)
  Bump unirest-java from 3.11.09 to 3.11.10 (#7329)
  Bump mockito-core from 3.6.28 to 3.7.0 (#7328)
  Bump antlr4-runtime from 4.9 to 4.9.1 (#7330)
  Bump gittools/actions from v0.9.7 to v0.9.8 (#7331)
  Update to gradle 6.8 (#7324)
  Link to GitHub contributors in about dialog (#7319)
  Fix snapcraft upload (#7263)
@systemoperator
Copy link
Contributor

systemoperator commented Jan 28, 2021

I have just tried this fix with the current master build on Ubuntu 16.04. Unfortunately, it seems, neither the colored group indicator, nor the badge icon are updated automatically in my situation:

  • Step 1: Build tex file with additional reference. Observations:
    • Counter in badge icon for cited entries is not incremented.
    • Badge icon for cited entries is not highlighted when the bib entry is selected.
    • Colored group indicator for cited entries is not shown for the newly added reference.
  • Step 2: Update group of cited entries: Just edit the group of cited entries and save it again. When a dialogue appears choose, to assign the original group's entries again to this group. Observations:
    • Counter in badge icon for cited entries is now incremented properly.
    • Badge icon for cited entries is now highlighted properly when the bib entry is selected.
    • Colored group indicator for cited entries is still not shown for the newly added reference.
  • Step 3: Close and reopen the bib-file. Observations:
    • Everything is shown as expected.

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

Sorry about that. I am using Texpad with Mac OS X and the group gets updated of the .aux file as I'd expect on JabRef 5.3--2021-01-26--034cf8c.
Could you give me more details on "Step 1" (which application you are using etc.) and I'll try to get a virtual box with Ubuntu up and going in the coming days?

@systemoperator
Copy link
Contributor

I have used a test .tex file with biblatex (see first example in https://www.overleaf.com/learn/latex/bibliography_management_with_biblatex). The library was configured for biblatex in JabRef as well. I have used TeXstudio, but I think it's independent of this, because I have even simply opened the .aux file with some editor and I have directly removed or added entries like \abx@aux@cite{XXX2008}. It seems, that the file monitor does not get triggered properly on a file change, thus, keysUsedInAux will not be cleared and the current group bindings are not invalidated.

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

directly removed or added entries like \abx@aux@cite{XXX2008}. It seems, that the file monitor does not get triggered properly on a file change, thus, keysUsedInAux will not be cleared and the current group bindings are not invalidated.

Yup. Adding/removing entries in that fashion works for me in OS X. I'll look into it. I don't really have a hypothesis for why it doesn't work in Ubuntu (yet)

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

k3KAW8Pnf7mkmdSMPHz27 commented Feb 1, 2021

You are using a local drive? (not remote)

Is it possible your editor is generating a "create event" instead of a "modify event"? (This doesn't have to be the same issue as with TeXstudio)

@systemoperator
Copy link
Contributor

systemoperator commented Feb 1, 2021

Yes, on a local drive. You are right: I have created a small java test program of your provided link.

  • Creating the file "testFile.txt" triggers:

ENTRY_CREATE:testFile.txt

  • Editing the file with the simple text editor Pluma triggers:

ENTRY_CREATE:testFile.txt

If this file is already opened in TeXstudio (and it has been modified within it before), it detects the change and it asks whether the file should be reloaded.

  • Editing the file with TeXstudio triggers:
ENTRY_CREATE:testFile.txt.G29838
ENTRY_MODIFY:testFile.txt.G29838
ENTRY_MODIFY:testFile.txt.G29838
ENTRY_DELETE:testFile.txt.G29838
ENTRY_CREATE:testFile.txt

Apparently, other programs also observe re-ceating files, since I have never had such problems elsewhere before.

  • Editing the file with VS Code triggers:
ENTRY_MODIFY:testFile.txt
ENTRY_MODIFY:testFile.txt

But when building the .pdf file from a .tex file with TeXstudio, 30 modification events are triggered with this java program for the .aux file:

ENTRY_MODIFY:main.aux
// 28 modification entries omitted
ENTRY_MODIFY:main.aux

But still no event gets triggered in JabRef.

The same applies when editing the .aux file with VS Code, which also triggers a modification event with the java test program but not within JabRef.

@systemoperator
Copy link
Contributor

@tobiasdiez @k3KAW8Pnf7mkmdSMPHz27 Do you think, that it would make sense to also observe the ENTRY_CREATE event to make the detection of file-modifications more reliable, since two out of three of my tested editors trigger the ENTRY_CREATE event and other programs apparently also check on this event?

@tobiasdiez
Copy link
Member

Yes, I guess it's a good idea to also listen for entry_create. At least I cannot think of a negative sideeffect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

Main table: Coloured group indicator for cited entries does not show up consistently anymore
6 participants