Skip to content

Conversation

@Siedlerchr
Copy link
Member

@Siedlerchr Siedlerchr commented Oct 9, 2021

Fixes part of #8054

Add flag if listeners should be used.

The only drawback is that it's impossible to store the dialog colunn size.
Edit// I thought about a possible way but this is currently not really possible without duplicating all the code

Bildschirmfoto 2021-10-09 um 18 45 00

- [ ] Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)

@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Oct 9, 2021
@Siedlerchr Siedlerchr changed the title Do not resize main table columns in search dialog Do not resize main table columns in search dialog window Oct 9, 2021
@Siedlerchr Siedlerchr removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Oct 9, 2021
@Siedlerchr Siedlerchr marked this pull request as draft October 9, 2021 16:54
@Siedlerchr Siedlerchr marked this pull request as ready for review October 9, 2021 16:56
@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Oct 9, 2021
@calixtus
Copy link
Member

I'm not sure if the binding to the columnmodel is the right place to do this. I'm home tomorrow evening and will take a deeper look.

@calixtus
Copy link
Member

I need some more time to dig into this, sorry, i need to find the connection between the maintable columns and the search table columns. The filters, that will be disabled with this pr are connecting the table with the columnmodel. Somehow this is shared between both, but should not be.

(ObservableValue<SortType>) model.sortTypeProperty(),
value -> this.setSortType(model.sortTypeProperty().getValue()),
value -> model.sortTypeProperty().setValue(this.getSortType()));
if (withListener) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't see anything wrong with setting up the binding...I would say it's the job of the model to save or not save the updated width to the preferences.

Copy link
Member

Choose a reason for hiding this comment

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

Answers just 4 minutes apart. Must have been some kind of though transmission 😁

Copy link
Member

Choose a reason for hiding this comment

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

Storing to the preferences is done in the PersistenceVisualStateTable class, which is only called from the MainTable class. But storing in the preferences is not the cause of the problem.
MainTable and SearchTable are sharing the same MainTableColumnModel, thats why the width is synced. Providing a fresh set of MainTableColumnModels should even make storing the widths of the SearchDialog table possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

But in the end they are stored under the same preferences key and would still overwrite the main table ones, probably after a restart

Copy link
Member

Choose a reason for hiding this comment

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

Let's not do the third step before the first.
Could be solved by injecting a proper subset of prefs or a flag.

But for now let's solve the synced widths problem

@calixtus
Copy link
Member

Problem analysis: The MainTable and the SearchTable share the same MainTableColumnModel. The width of the actual columns is bound to that MainTableColumnModel. Instead of not using listeners in the MainTableColumnModel (which has nothing to do with the actual problem and should not be touched), the SearchDialog should get new MainTableColumnModels, independent of the MainTable. Best way to do this would probably to introduce a flag in the JabRefPreferences to provide a fresh copy of the ColumnPreferences instead of providing the cached version of it.

@calixtus
Copy link
Member

calixtus commented Oct 15, 2021

A new set, because if you share the MainTableColumnModel, you will always have problems again, when you try to manipulate the SearchDialog, which then would always have effect again on the MainTable columns.

@Siedlerchr
Copy link
Member Author

A new set, because if you share the MainTableColumnModel, you will always have problems again, when you try to manipulate the SearchDialog, which then would always have effect again on the MainTable columns.

public List<TableColumn<BibEntryTableViewModel, ?>> createColumns() {
List<TableColumn<BibEntryTableViewModel, ?>> columns = new ArrayList<>();
columnPreferences.getColumns().forEach(column -> {
switch (column.getType()) {

So I think I understood it now. The preferences return the MainTableColumn model for each column, so in this factory wee need to provide a new MainTableColumnModl which has the same columns but is a different object. But I don't know there we should get that new object

@calixtus
Copy link
Member

calixtus commented Oct 16, 2021

Yes. The columnpreferences are cached inside Jabrefpreferences. Should be somewhat easy to command jabrefpreferences to create a fresh set of MainTableColumnModels instead of using the existing one. Maybe it's best to introduce a new method: getSearchDialogColums(), which internally just copies the behaviour of getColumns but without caching. Would leave some space for later improvement (saving the column width of the SearchDialog columns ;-) )

@Siedlerchr Siedlerchr removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Oct 17, 2021
@calixtus calixtus marked this pull request as draft October 25, 2021 20:17
@koppor koppor added this to the v5.4 milestone Nov 14, 2021
Siedlerchr added a commit that referenced this pull request Nov 15, 2021
@Siedlerchr Siedlerchr closed this Nov 15, 2021
@Siedlerchr Siedlerchr deleted the donotmovecols branch November 15, 2021 17:50
Siedlerchr added a commit that referenced this pull request Nov 28, 2021
* Do not resize main table columns in search dialog window

Follow up from #8134
Fixes part of #8054

* checkstyle

* Refactor and store Search Dialog Column changes

* checkstyle

* refactor, get rid of duplicate column preferences

* fix checkstlye again

* Revert reformatting hazard

* fix checkstyle

* Add a new column type library and check if it exists before adding to search reults

* Remove library col from main table...

* fix checkstyle

* Reverted unnecessary reformatting

* fix checkstyle

Co-authored-by: Carl Christian Snethlage <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants