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

Changing entry type does not always work when biblatex source is not shown #5906

Closed
systemoperator opened this issue Feb 2, 2020 · 10 comments · Fixed by #5925
Closed

Changing entry type does not always work when biblatex source is not shown #5906

systemoperator opened this issue Feb 2, 2020 · 10 comments · Fixed by #5925
Labels
bug Confirmed bugs or reports that are very likely to be bugs maintable ui

Comments

@systemoperator
Copy link
Contributor

systemoperator commented Feb 2, 2020

I am using the latest JabRef 5 master build:
Java 13.0.2
on Ubuntu 16.04

The value of the entry type field for an entry in the main table is not updating when changing its type by using the dropdown menu of the entry editor. To differentiate this from issue #5905, one can assume, that in the entry editor the tab "biblatex source" is not/never active.

Steps to reproduce the behavior:

  1. Double click an entry in the main table (with e.g. entry type "Article")
  2. Change entry type via the dropdown menu to a different entry type (e.g. entry type "Misc")
  3. Do "whatever you want", but don't open the tab "biblatex source" in the entry editor.

Observation: Commonly, the entry type will not change in the main table, even if shortly selecting a different entry in the main table and reselecting the edited one. Sometimes temporarily switching to a different opened library helps, but not always.

Contrarily, other fields in the main table will be updated immediately, when their values get changed.


Subsequent observation (now allows viewing the tab "biblatex source"):

  1. Perform steps 1. and 2. as above.
  2. Save library with CTRL+S.
  3. Switch to "biblatex source"

Observation: The library has been modifed (indicated with the star symbol "*"), although no change was conduted.

For both cases, I assume it could be some reference problem.

@systemoperator systemoperator changed the title The value of the entry type field for an entry in the main table is not updating when changing its type by using the dropdown menu Changing entry type does not work when biblatex source is not active Feb 2, 2020
@systemoperator systemoperator changed the title Changing entry type does not work when biblatex source is not active Changing entry type does not work when biblatex source is not shown Feb 2, 2020
@tobiasdiez tobiasdiez added bug Confirmed bugs or reports that are very likely to be bugs maintable ui labels Feb 2, 2020
@tobiasdiez
Copy link
Member

It's only a display issue: if you change the entry type, save and reload the database the change is correctly reflected.

@systemoperator
Copy link
Contributor Author

systemoperator commented Feb 2, 2020

@tobiasdiez On the one hand, I wanted to address the display issues (in the main table and in the tab "biblatex source", where in the source the entry type sometimes does not get updated), on the other hand, I think it is not only a display issue:

Consider the following:

Prerequisite: Make sure, that in Options -> Preferences -> Entry editor -> "Show BibTeX source by default" is NOT ticked.

  1. Double click or click an entry in the main table (with e.g. entry type "Article") to see its entry editor
  2. Change entry type via the dropdown menu to a different entry type (e.g. entry type "Misc")
  3. Save library with CTRL+S.
  4. Switch to "biblatex source"
    Observation: The library shows that it has been modifed (indicated with the star symbol "*"), although no change was conducted after saving it. Furthermore, to be precise, the tab "biblatex source" still shows the original entry type (so not the new one!) in the source text. If this is not ALL the case switch to a tab different than "biblatex source" (e.g. tab "Required fields") and again start from step 2. (using now another, different entry type, so that you can better differentiate them). [Usually, the first "round" is ok, but any further round not. This obviously depends on what one has already done before performing this procedure.]
  5. Optional: Switch to a different tab than "biblatex source"
  6. Again save library with CTRL+S. (-> The modified indicator (*) vanishes.)
  7. Reload library (by closing and reopening it)

Observation: The performed change (namely changing the entry type) has been overwritten to the previous entry type.

This could indicate a reference issue as well. From my perspective, it seems, that the tab "biblatex source" still references to the previous entry (or the changes simply have not been written to the tab "biblatex source") and it "writes back" the contained values, since it is (and must be) quite sensitive to changes.

@Siedlerchr
Copy link
Member

Siedlerchr commented Feb 2, 2020

@calixtus you recently fixed a bug and reused that code editor component. Maybe this is the issue now for the incorrect reference?

That would explain why we did not reuse the control, but recreated every time

@systemoperator systemoperator changed the title Changing entry type does not work when biblatex source is not shown Changing entry type does not always work when biblatex source is not shown Feb 2, 2020
@calixtus
Copy link
Member

calixtus commented Feb 2, 2020

Im going to investigate this tomorrow.

@calixtus
Copy link
Member

calixtus commented Feb 3, 2020

I took a look into the code, it's two bugs: one thing is about the source tab, it easily fixed by adding an InvalidationListener to the typeProperty (fix incoming for issue #5905 ).

The other one, this here, is about displaying the changed entry type in the main table.

@tobiasdiez
Copy link
Member

This bug here could be a simply consequence of the fact that
https://github.com/JabRef/jabref/blob/master/src/main/java/org/jabref/model/entry/BibEntry.java#L940
does not contain type. Thus, changes of the type do not trigger change events (and thus the main table is not updated).

@Siedlerchr
Copy link
Member

I tried the simple fix idea from @tobiasdiez and added entryType to the observables. However, this has only an impact on the PreviewViewer. The observables are only used in the PrevieViewer.
However, I think we need to have a simliar class like FieldCoumn which handles the entry type or maybe we can extend the fieldColumn. I could not find anything related to the entry type in the MainTable. So I guess this explains it. Because entry type is not a field, it's not updated

@tobiasdiez
Copy link
Member

I think I found the problem:
Types are displayed as a normal field column. However,

ObjectBinding[] dependencies = bibtexFields.stream().map(entry::getField).toArray(ObjectBinding[]::new);
return Bindings.createStringBinding(() -> computeText(entry), dependencies);

only includes real fields as dependencies.
public ObjectBinding<String> getFieldBinding(Field field) {
//noinspection unchecked
return Bindings.valueAt(fields, field);
}

The display still works as its done via

content = entry.getResolvedFieldOrAlias(field, database.orElse(null));

and this includes special handling of types
if (InternalField.TYPE_HEADER.equals(field) || InternalField.OBSOLETE_TYPE_HEADER.equals(field)) {
return Optional.of(type.get().getDisplayName());
}

Thus it should be possible to fix this issue by adding a special handling of the type field in

public ObjectBinding<String> getFieldBinding(Field field) {
//noinspection unchecked
return Bindings.valueAt(fields, field);
}

@Siedlerchr
Copy link
Member

Thanks for the hint, adding a check for the entry type in that binding works

@systemoperator
Copy link
Contributor Author

I can confirm, that all problems mentioned within this issue are fixed with this commit. :) One very related issue (where I hoped this would fix it as well) is still open: #5905

Siedlerchr added a commit that referenced this issue Feb 10, 2020
* Fix maintable not updated when changing entry type


Fixes #5906

* fix checkstyle

* use easybind with cast
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bugs or reports that are very likely to be bugs maintable ui
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants