Verified Owner
Top Description Fields Constructors Methods
org.jabref.gui.maintable

pack-priv Class ColumnPreferencesApplier

extends Object
Class Inheritance
Annotations
@NullMarked
Imports
java.util.ArrayList, .List, .Optional, java.util.stream.Collectors, javafx.beans.value.ChangeListener, javafx.collections.ListChangeListener, javafx.scene.control.TableColumn, .TableView, org.jabref.gui.maintable.columns.MainTableColumn, org.jspecify.annotations.NullMarked

Applies the column preferences (columns, sort order, resize policy) to the main table: initially and whenever they change, e.g., in the preferences dialog.

This is the preferences-to-table direction. The opposite direction is ColumnPreferencesRecorder. Both directions compare columns by ColumnPreferencesRecorder#toPersistedModels(List). Each change is applied with a single setAll, so that the write-back of the table equals the preferences and ends the round trip.

All main tables share the same preferences. Hence, reordering, adding, removing or sorting columns in one library tab is applied to the main tables of all other open library tabs as well. This is intended: the column preferences are global, so all tables show the state that will be restored at the next start.

New columns are created from the model instances held by the preferences. Resized widths are persisted only because table and preferences share these instances (see ColumnPreferences).

Field Summary

Modifier and TypeField and Description
private final MainTableColumnFactory
private final ListChangeListener<MainTableColumnModel>
private final MainTablePreferences
private final ChangeListener<Boolean>
private final ListChangeListener<MainTableColumnModel>
private final TableView<BibEntryTableViewModel>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private void
private void
applyResizePolicy(boolean resizeColumnsToFit)

pack-priv void
pack-priv void
bind()

Creates the columns, applies the resize policy and follows later changes of the preferences.

private static List<MainTableColumnModel>
private Optional<TableColumn<BibEntryTableViewModel, ?>>
private Optional<TableColumn<BibEntryTableViewModel, ?>>
pack-priv void
unbind()

The preferences outlive the table, so the listeners have to be removed when the library tab closes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

columnFactoryback to summary
private final MainTableColumnFactory columnFactory
columnsListenerback to summary
private final ListChangeListener<MainTableColumnModel> columnsListener
mainTablePreferencesback to summary
private final MainTablePreferences mainTablePreferences
resizeColumnsListenerback to summary
private final ChangeListener<Boolean> resizeColumnsListener
sortOrderListenerback to summary
private final ListChangeListener<MainTableColumnModel> sortOrderListener
tableback to summary
private final TableView<BibEntryTableViewModel> table

Constructor Detail

ColumnPreferencesApplierback to summary
pack-priv ColumnPreferencesApplier(TableView<BibEntryTableViewModel> table, MainTableColumnFactory columnFactory, MainTablePreferences mainTablePreferences)

Method Detail

applyColumnsback to summary
private void applyColumns()
applyResizePolicyback to summary
private void applyResizePolicy(boolean resizeColumnsToFit)
applySortOrderback to summary
pack-priv void applySortOrder()
bindback to summary
pack-priv void bind()

Creates the columns, applies the resize policy and follows later changes of the preferences.

The initial sort order is not applied here, because sorting a large library is expensive. The caller decides when to call applySortOrder().

configuredback to summary
private static List<MainTableColumnModel> configured(List<MainTableColumnModel> models)
findColumnback to summary
private Optional<TableColumn<BibEntryTableViewModel, ?>> findColumn(MainTableColumnModel model)
findMatchCategoryColumnback to summary
private Optional<TableColumn<BibEntryTableViewModel, ?>> findMatchCategoryColumn()
unbindback to summary
pack-priv void unbind()

The preferences outlive the table, so the listeners have to be removed when the library tab closes.