From a396d6c87b110fe5920498ca1cc792935e75ce03 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Mon, 15 Nov 2021 18:49:56 +0100 Subject: [PATCH 01/13] Do not resize main table columns in search dialog window Follow up from #8134 Fixes part of #8054 --- .../maintable/AbstractColumnPreferences.java | 13 ++ .../gui/maintable/ColumnPreferences.java | 4 +- .../org/jabref/gui/maintable/MainTable.java | 1 + .../gui/maintable/MainTableColumnFactory.java | 5 +- .../SearchDialogColumnPreferences.java | 24 ++++ .../jabref/gui/search/SearchResultsTable.java | 3 +- .../jabref/preferences/JabRefPreferences.java | 132 ++++++++++++++++-- .../preferences/PreferencesService.java | 8 ++ 8 files changed, 177 insertions(+), 13 deletions(-) create mode 100644 src/main/java/org/jabref/gui/maintable/AbstractColumnPreferences.java create mode 100644 src/main/java/org/jabref/gui/maintable/SearchDialogColumnPreferences.java diff --git a/src/main/java/org/jabref/gui/maintable/AbstractColumnPreferences.java b/src/main/java/org/jabref/gui/maintable/AbstractColumnPreferences.java new file mode 100644 index 00000000000..01c35b354dc --- /dev/null +++ b/src/main/java/org/jabref/gui/maintable/AbstractColumnPreferences.java @@ -0,0 +1,13 @@ +package org.jabref.gui.maintable; + +import java.util.List; + +public interface AbstractColumnPreferences { + + public static final double DEFAULT_COLUMN_WIDTH = 100; + public static final double ICON_COLUMN_WIDTH = 16 + 12; // add some additional space to improve appearance + + public List getColumns(); + + public List getColumnSortOrder(); +} diff --git a/src/main/java/org/jabref/gui/maintable/ColumnPreferences.java b/src/main/java/org/jabref/gui/maintable/ColumnPreferences.java index d79b3a6857b..45b46278363 100644 --- a/src/main/java/org/jabref/gui/maintable/ColumnPreferences.java +++ b/src/main/java/org/jabref/gui/maintable/ColumnPreferences.java @@ -2,7 +2,7 @@ import java.util.List; -public class ColumnPreferences { +public class ColumnPreferences implements AbstractColumnPreferences { public static final double DEFAULT_COLUMN_WIDTH = 100; public static final double ICON_COLUMN_WIDTH = 16 + 12; // add some additional space to improve appearance @@ -15,10 +15,12 @@ public ColumnPreferences(List columns, List getColumns() { return columns; } + @Override public List getColumnSortOrder() { return columnSortOrder; } diff --git a/src/main/java/org/jabref/gui/maintable/MainTable.java b/src/main/java/org/jabref/gui/maintable/MainTable.java index 130faad49fc..3714669f731 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTable.java +++ b/src/main/java/org/jabref/gui/maintable/MainTable.java @@ -101,6 +101,7 @@ public MainTable(MainTableDataModel model, new MainTableColumnFactory( database, preferencesService, + preferencesService.getColumnPreferences(), externalFileTypes, libraryTab.getUndoManager(), dialogService, diff --git a/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java b/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java index b1295a48fdc..dae244884ea 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java @@ -52,7 +52,7 @@ public class MainTableColumnFactory { private static final Logger LOGGER = LoggerFactory.getLogger(MainTableColumnFactory.class); private final PreferencesService preferencesService; - private final ColumnPreferences columnPreferences; + private final AbstractColumnPreferences columnPreferences; private final ExternalFileTypes externalFileTypes; private final BibDatabaseContext database; private final CellFactory cellFactory; @@ -62,13 +62,14 @@ public class MainTableColumnFactory { public MainTableColumnFactory(BibDatabaseContext database, PreferencesService preferencesService, + AbstractColumnPreferences abstractColumnPrefs, ExternalFileTypes externalFileTypes, UndoManager undoManager, DialogService dialogService, StateManager stateManager) { this.database = Objects.requireNonNull(database); this.preferencesService = Objects.requireNonNull(preferencesService); - this.columnPreferences = preferencesService.getColumnPreferences(); + this.columnPreferences = abstractColumnPrefs; this.externalFileTypes = Objects.requireNonNull(externalFileTypes); this.dialogService = dialogService; this.cellFactory = new CellFactory(externalFileTypes, preferencesService, undoManager); diff --git a/src/main/java/org/jabref/gui/maintable/SearchDialogColumnPreferences.java b/src/main/java/org/jabref/gui/maintable/SearchDialogColumnPreferences.java new file mode 100644 index 00000000000..ca46c7ea02f --- /dev/null +++ b/src/main/java/org/jabref/gui/maintable/SearchDialogColumnPreferences.java @@ -0,0 +1,24 @@ +package org.jabref.gui.maintable; + +import java.util.List; + +public class SearchDialogColumnPreferences implements AbstractColumnPreferences{ + + private final List columns; + private final List columnSortOrder; + + public SearchDialogColumnPreferences(List columns, List columnSortOrder) { + this.columns = columns; + this.columnSortOrder = columnSortOrder; + } + + @Override + public List getColumns() { + return columns; + } + + @Override + public List getColumnSortOrder() { + return columnSortOrder; + } +} diff --git a/src/main/java/org/jabref/gui/search/SearchResultsTable.java b/src/main/java/org/jabref/gui/search/SearchResultsTable.java index 60ba2ad60e4..82b0b88afa2 100644 --- a/src/main/java/org/jabref/gui/search/SearchResultsTable.java +++ b/src/main/java/org/jabref/gui/search/SearchResultsTable.java @@ -33,13 +33,14 @@ public SearchResultsTable(SearchResultsTableDataModel model, this.getColumns().addAll(new MainTableColumnFactory( database, preferencesService, + preferencesService.getSearchDialogColumnPreferences(), externalFileTypes, undoManager, dialogService, stateManager).createColumns()); this.getSortOrder().clear(); - mainTablePreferences.getColumnPreferences().getColumnSortOrder().forEach(columnModel -> + preferencesService.getSearchDialogColumnPreferences().getColumnSortOrder().forEach(columnModel -> this.getColumns().stream() .map(column -> (MainTableColumn) column) .filter(column -> column.getModel().equals(columnModel)) diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 422f39d833a..25797e78b06 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -52,6 +52,7 @@ import org.jabref.gui.maintable.MainTableNameFormatPreferences.AbbreviationStyle; import org.jabref.gui.maintable.MainTableNameFormatPreferences.DisplayStyle; import org.jabref.gui.maintable.MainTablePreferences; +import org.jabref.gui.maintable.SearchDialogColumnPreferences; import org.jabref.gui.mergeentries.MergeEntries; import org.jabref.gui.search.SearchDisplayMode; import org.jabref.gui.sidepane.SidePaneType; @@ -157,7 +158,7 @@ public class JabRefPreferences implements PreferencesService { public static final String REFORMAT_FILE_ON_SAVE_AND_EXPORT = "reformatFileOnSaveAndExport"; public static final String EXPORT_IN_ORIGINAL_ORDER = "exportInOriginalOrder"; public static final String EXPORT_IN_SPECIFIED_ORDER = "exportInSpecifiedOrder"; - + public static final String EXPORT_PRIMARY_SORT_FIELD = "exportPriSort"; public static final String EXPORT_PRIMARY_SORT_DESCENDING = "exportPriDescending"; public static final String EXPORT_SECONDARY_SORT_FIELD = "exportSecSort"; @@ -173,6 +174,11 @@ public class JabRefPreferences implements PreferencesService { public static final String COLUMN_SORT_TYPES = "mainTableColumnSortTypes"; public static final String COLUMN_SORT_ORDER = "mainTableColumnSortOrder"; + public static final String SEARCH_DIALOG_COLUMN_NAMES = "mainTableColumnNames"; + public static final String SEARCH_DIALOG_COLUMN_WIDTHS = "mainTableColumnWidths"; + public static final String SEARCH_DIALOG_COLUMN_SORT_TYPES = "searchDialogColumnSortTypes"; + public static final String SEARCH_DIALOG_COLUMN_SORT_ORDER = "searchDalogColumnSortOrder"; + public static final String SIDE_PANE_COMPONENT_PREFERRED_POSITIONS = "sidePaneComponentPreferredPositions"; public static final String SIDE_PANE_COMPONENT_NAMES = "sidePaneComponentNames"; public static final String XMP_PRIVACY_FILTERS = "xmpPrivacyFilters"; @@ -421,6 +427,10 @@ public class JabRefPreferences implements PreferencesService { private Map> entryEditorTabList; private List mainTableColumns; private List mainTableColumnSortOrder; + + private List searchDialogTableColunns; + private List searchDialogColumnSortOrder; + private Theme globalTheme; private Set customImporters; private String userName; @@ -1826,11 +1836,6 @@ public void storeExternalApplicationsPreferences(ExternalApplicationsPreferences // MainTablePreferences //************************************************************************************************************* - /** - * Creates the GlobalCitationKeyPattern from cache - * - * @return GlobalCitationKeyPattern containing all keys without a parent AbstractKeyPattern - */ private List createMainTableColumns() { if (this.mainTableColumns == null) { updateMainTableColumns(); @@ -1838,9 +1843,6 @@ private List createMainTableColumns() { return this.mainTableColumns; } - /** - * Reloads the GlobalCitationKeyPattern from scratch - */ @Override public void updateMainTableColumns() { List columnNames = getStringList(COLUMN_NAMES); @@ -1988,6 +1990,118 @@ public void storeMainTableNameFormatPreferences(MainTableNameFormatPreferences p putBoolean(NAMES_LAST_ONLY, preferences.getAbbreviationStyle() == AbbreviationStyle.LASTNAME_ONLY); } + //************************************************************************************************************* + // SearchDialogColumnsPreferences + //***********************************************s************************************************************** + + public void updateSearchDialogTableColumns() { + List columnNames = getStringList(SEARCH_DIALOG_COLUMN_NAMES); + + List columnWidths = getStringList(SEARCH_DIALOG_COLUMN_WIDTHS) + .stream() + .map(string -> { + try { + return Double.parseDouble(string); + } catch (NumberFormatException e) { + LOGGER.error("Exception while parsing column widths. Choosing default.", e); + return SearchDialogColumnPreferences.DEFAULT_COLUMN_WIDTH; + } + }) + .collect(Collectors.toList()); + + List columnSortTypes = getStringList(SEARCH_DIALOG_COLUMN_SORT_TYPES) + .stream() + .map(SortType::valueOf) + .collect(Collectors.toList()); + + List columns = new ArrayList<>(); + for (int i = 0; i < columnNames.size(); i++) { + MainTableColumnModel columnModel = MainTableColumnModel.parse(columnNames.get(i)); + + if (i < columnWidths.size()) { + columnModel.widthProperty().setValue(columnWidths.get(i)); + } + + if (i < columnSortTypes.size()) { + columnModel.sortTypeProperty().setValue(columnSortTypes.get(i)); + } + + columns.add(columnModel); + } + + searchDialogTableColunns = columns; + } + + + private List createSearchDialogColumns() { + if (this.searchDialogTableColunns == null) { + updateSearchDialogTableColumns(); + } + return this.searchDialogTableColunns; + } + + /** + * Creates the ColumnSortOrder from cache + * + * @return List containing only the the columns in its proper sort order + */ + private List createSearchDialogColumnSortOrder() { + if (this.searchDialogColumnSortOrder == null) { + updateSearchDialogColumnSortOrder(); + } + return this.searchDialogColumnSortOrder; + } + + + /** + * Reloads the MainTableColumnSortOrder from scratch to cache + */ + private void updateSearchDialogColumnSortOrder() { + List columnsOrdered = new ArrayList<>(); + getStringList(SEARCH_DIALOG_COLUMN_SORT_ORDER).forEach(columnName -> + searchDialogTableColunns.stream().filter(column -> + column.getName().equals(columnName)) + .findFirst() + .ifPresent(columnsOrdered::add)); + + searchDialogColumnSortOrder = columnsOrdered; + } + + @Override + public SearchDialogColumnPreferences getSearchDialogColumnPreferences() { + return new SearchDialogColumnPreferences( + createSearchDialogColumns(), + createSearchDialogColumnSortOrder()); + } + + // TODO is that needed? + /** + * Stores the {@link SearchDialogColumnPreferences} in the preferences + * + * @param columnPreferences the preferences to store + */ + public void storeSearchDialogColumnPreferences(SearchDialogColumnPreferences columnPreferences) { + putStringList(SEARCH_DIALOG_COLUMN_NAMES, columnPreferences.getColumns().stream() + .map(MainTableColumnModel::getName) + .collect(Collectors.toList())); + + List columnWidthsInOrder = new ArrayList<>(); + columnPreferences.getColumns().forEach(column -> columnWidthsInOrder.add(column.widthProperty().getValue().toString())); + putStringList(SEARCH_DIALOG_COLUMN_WIDTHS, columnWidthsInOrder); + + List columnSortTypesInOrder = new ArrayList<>(); + columnPreferences.getColumns().forEach(column -> columnSortTypesInOrder.add(column.sortTypeProperty().getValue().toString())); + putStringList(SEARCH_DIALOG_COLUMN_SORT_TYPES, columnSortTypesInOrder); + + putStringList(SEARCH_DIALOG_COLUMN_SORT_ORDER, columnPreferences + .getColumnSortOrder().stream() + .map(MainTableColumnModel::getName) + .collect(Collectors.toList())); + + // Update cache + searchDialogTableColunns = columnPreferences.getColumns(); + } + //************************************************************************************************************* // AppearancePreferences //************************************************************************************************************* diff --git a/src/main/java/org/jabref/preferences/PreferencesService.java b/src/main/java/org/jabref/preferences/PreferencesService.java index 40448caba9a..22344804324 100644 --- a/src/main/java/org/jabref/preferences/PreferencesService.java +++ b/src/main/java/org/jabref/preferences/PreferencesService.java @@ -15,6 +15,7 @@ import org.jabref.gui.maintable.ColumnPreferences; import org.jabref.gui.maintable.MainTableNameFormatPreferences; import org.jabref.gui.maintable.MainTablePreferences; +import org.jabref.gui.maintable.SearchDialogColumnPreferences; import org.jabref.gui.specialfields.SpecialFieldsPreferences; import org.jabref.gui.util.Theme; import org.jabref.logic.JabRefException; @@ -220,6 +221,12 @@ public interface PreferencesService { void storeMainTableNameFormatPreferences(MainTableNameFormatPreferences preferences); + //************************************************************************************************************* + // SearchDialogColumnPreferences + //************************************************************************************************************* + + SearchDialogColumnPreferences getSearchDialogColumnPreferences(); + //************************************************************************************************************* // AppearancePreferences //************************************************************************************************************* @@ -340,4 +347,5 @@ public interface PreferencesService { void storeIdBasedFetcherForEntryGenerator(String fetcherName); ProtectedTermsPreferences getProtectedTermsPreferences(); + } From dd306db5c0f59d482177658e28c785660a03283a Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Mon, 15 Nov 2021 18:55:59 +0100 Subject: [PATCH 02/13] checkstyle --- .../jabref/gui/maintable/SearchDialogColumnPreferences.java | 2 +- src/main/java/org/jabref/preferences/JabRefPreferences.java | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/maintable/SearchDialogColumnPreferences.java b/src/main/java/org/jabref/gui/maintable/SearchDialogColumnPreferences.java index ca46c7ea02f..9794706715a 100644 --- a/src/main/java/org/jabref/gui/maintable/SearchDialogColumnPreferences.java +++ b/src/main/java/org/jabref/gui/maintable/SearchDialogColumnPreferences.java @@ -2,7 +2,7 @@ import java.util.List; -public class SearchDialogColumnPreferences implements AbstractColumnPreferences{ +public class SearchDialogColumnPreferences implements AbstractColumnPreferences { private final List columns; private final List columnSortOrder; diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 25797e78b06..45d84a98def 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -2032,7 +2032,6 @@ public void updateSearchDialogTableColumns() { searchDialogTableColunns = columns; } - private List createSearchDialogColumns() { if (this.searchDialogTableColunns == null) { updateSearchDialogTableColumns(); @@ -2052,7 +2051,6 @@ private List createSearchDialogColumnSortOrder() { return this.searchDialogColumnSortOrder; } - /** * Reloads the MainTableColumnSortOrder from scratch to cache */ @@ -2074,7 +2072,6 @@ public SearchDialogColumnPreferences getSearchDialogColumnPreferences() { createSearchDialogColumnSortOrder()); } - // TODO is that needed? /** * Stores the {@link SearchDialogColumnPreferences} in the preferences * From 0e307a6ee7bfa618bfa7fef5af753e9a4f8c2fc9 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Fri, 19 Nov 2021 23:32:38 +0100 Subject: [PATCH 03/13] Refactor and store Search Dialog Column changes --- .../AbstractPersistenceVisualStateTable.java | 49 ++++++ .../gui/maintable/MainTableColumnFactory.java | 2 +- .../gui/maintable/MainTableColumnModel.java | 4 +- ...s.java => MainTableColumnPreferences.java} | 4 +- .../gui/maintable/MainTablePreferences.java | 6 +- .../PersistenceVisualStateTable.java | 34 ++--- .../gui/maintable/columns/FileColumn.java | 4 +- .../columns/LinkedIdentifierColumn.java | 4 +- .../maintable/columns/SpecialFieldColumn.java | 4 +- .../preferences/table/TableTabViewModel.java | 6 +- .../jabref/gui/search/SearchResultsTable.java | 4 + ...rchResultsTablePersistenceVisualState.java | 48 ++++++ .../migrations/PreferencesMigrations.java | 6 +- .../jabref/preferences/JabRefPreferences.java | 142 +++++------------- .../preferences/PreferencesService.java | 8 +- 15 files changed, 179 insertions(+), 146 deletions(-) create mode 100644 src/main/java/org/jabref/gui/maintable/AbstractPersistenceVisualStateTable.java rename src/main/java/org/jabref/gui/maintable/{ColumnPreferences.java => MainTableColumnPreferences.java} (76%) create mode 100644 src/main/java/org/jabref/gui/search/SearchResultsTablePersistenceVisualState.java diff --git a/src/main/java/org/jabref/gui/maintable/AbstractPersistenceVisualStateTable.java b/src/main/java/org/jabref/gui/maintable/AbstractPersistenceVisualStateTable.java new file mode 100644 index 00000000000..333ff7b84d3 --- /dev/null +++ b/src/main/java/org/jabref/gui/maintable/AbstractPersistenceVisualStateTable.java @@ -0,0 +1,49 @@ +package org.jabref.gui.maintable; + +import javafx.beans.InvalidationListener; +import javafx.scene.control.TableView; + +import org.jabref.gui.maintable.columns.MainTableColumn; +import org.jabref.preferences.PreferencesService; + +/** + * Keep track of changes made to the columns (reordering, resorting, resizing). + */ +public abstract class AbstractPersistenceVisualStateTable { + + protected final TableView mainTable; + protected final PreferencesService preferences; + + public AbstractPersistenceVisualStateTable(final TableView mainTable, PreferencesService preferences) { + this.mainTable = mainTable; + this.preferences = preferences; + + mainTable.getColumns().addListener((InvalidationListener) obs -> updateColumns()); + mainTable.getSortOrder().addListener((InvalidationListener) obs -> updateSortOrder()); + + // As we store the ColumnModels of the MainTable, we need to add the listener to the ColumnModel properties, + // since the value is bound to the model after the listener to the column itself is called. + mainTable.getColumns().forEach(col -> + ((MainTableColumn) col).getModel().widthProperty().addListener(obs -> updateColumns())); + mainTable.getColumns().forEach(col -> + ((MainTableColumn) col).getModel().sortTypeProperty().addListener(obs -> updateColumns())); + } + + /** + * Stores shown columns, their width and their sortType in preferences. + * By default does nothing, override in subclass + */ + protected void updateColumns() { + // empty + } + + /** + * Stores the SortOrder of the the Table in the preferences. Cannot be combined with updateColumns, because JavaFX + * would provide just an empty list for the sort order on other changes. + * By default does nothing, override in subclass + + */ + protected void updateSortOrder() { + // empty + } +} diff --git a/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java b/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java index dae244884ea..871d50444e6 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java @@ -157,7 +157,7 @@ private TableColumn createIndexColumn(MainTableC Tooltip.install(headerGraphic, new Tooltip(Localization.lang("Group color"))); column.setGraphic(headerGraphic); column.getStyleClass().add(STYLE_ICON_COLUMN); - setExactWidth(column, ColumnPreferences.ICON_COLUMN_WIDTH); + setExactWidth(column, MainTableColumnPreferences.ICON_COLUMN_WIDTH); column.setResizable(false); column.setCellValueFactory(cellData -> cellData.getValue().getMatchedGroups()); new ValueTableCellFactory>() diff --git a/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java b/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java index e82af036482..44ee1301d49 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java @@ -92,9 +92,9 @@ public MainTableColumnModel(Type type, String qualifier) { this.sortTypeProperty.setValue(TableColumn.SortType.ASCENDING); if (Type.ICON_COLUMNS.contains(type)) { - this.widthProperty.setValue(ColumnPreferences.ICON_COLUMN_WIDTH); + this.widthProperty.setValue(MainTableColumnPreferences.ICON_COLUMN_WIDTH); } else { - this.widthProperty.setValue(ColumnPreferences.DEFAULT_COLUMN_WIDTH); + this.widthProperty.setValue(MainTableColumnPreferences.DEFAULT_COLUMN_WIDTH); } } diff --git a/src/main/java/org/jabref/gui/maintable/ColumnPreferences.java b/src/main/java/org/jabref/gui/maintable/MainTableColumnPreferences.java similarity index 76% rename from src/main/java/org/jabref/gui/maintable/ColumnPreferences.java rename to src/main/java/org/jabref/gui/maintable/MainTableColumnPreferences.java index 45b46278363..6249ce3a4e6 100644 --- a/src/main/java/org/jabref/gui/maintable/ColumnPreferences.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableColumnPreferences.java @@ -2,7 +2,7 @@ import java.util.List; -public class ColumnPreferences implements AbstractColumnPreferences { +public class MainTableColumnPreferences implements AbstractColumnPreferences { public static final double DEFAULT_COLUMN_WIDTH = 100; public static final double ICON_COLUMN_WIDTH = 16 + 12; // add some additional space to improve appearance @@ -10,7 +10,7 @@ public class ColumnPreferences implements AbstractColumnPreferences { private final List columns; private final List columnSortOrder; - public ColumnPreferences(List columns, List columnSortOrder) { + public MainTableColumnPreferences(List columns, List columnSortOrder) { this.columns = columns; this.columnSortOrder = columnSortOrder; } diff --git a/src/main/java/org/jabref/gui/maintable/MainTablePreferences.java b/src/main/java/org/jabref/gui/maintable/MainTablePreferences.java index 7698893b9dd..41cd266a8f6 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTablePreferences.java +++ b/src/main/java/org/jabref/gui/maintable/MainTablePreferences.java @@ -1,17 +1,17 @@ package org.jabref.gui.maintable; public class MainTablePreferences { - private final ColumnPreferences columnPreferences; + private final MainTableColumnPreferences columnPreferences; private final boolean resizeColumnsToFit; private final boolean extraFileColumnsEnabled; - public MainTablePreferences(ColumnPreferences columnPreferences, boolean resizeColumnsToFit, boolean extraFileColumnsEnabled) { + public MainTablePreferences(MainTableColumnPreferences columnPreferences, boolean resizeColumnsToFit, boolean extraFileColumnsEnabled) { this.columnPreferences = columnPreferences; this.resizeColumnsToFit = resizeColumnsToFit; this.extraFileColumnsEnabled = extraFileColumnsEnabled; } - public ColumnPreferences getColumnPreferences() { + public MainTableColumnPreferences getColumnPreferences() { return columnPreferences; } diff --git a/src/main/java/org/jabref/gui/maintable/PersistenceVisualStateTable.java b/src/main/java/org/jabref/gui/maintable/PersistenceVisualStateTable.java index 092f5c02820..1b5e6d62339 100644 --- a/src/main/java/org/jabref/gui/maintable/PersistenceVisualStateTable.java +++ b/src/main/java/org/jabref/gui/maintable/PersistenceVisualStateTable.java @@ -2,7 +2,7 @@ import java.util.stream.Collectors; -import javafx.beans.InvalidationListener; +import javafx.scene.control.TableView; import org.jabref.gui.maintable.columns.MainTableColumn; import org.jabref.preferences.PreferencesService; @@ -10,32 +10,20 @@ /** * Keep track of changes made to the columns (reordering, resorting, resizing). */ -public class PersistenceVisualStateTable { +public class PersistenceVisualStateTable extends AbstractPersistenceVisualStateTable { - private final MainTable mainTable; - private final PreferencesService preferences; - - public PersistenceVisualStateTable(final MainTable mainTable, PreferencesService preferences) { - this.mainTable = mainTable; - this.preferences = preferences; - - mainTable.getColumns().addListener((InvalidationListener) obs -> updateColumns()); - mainTable.getSortOrder().addListener((InvalidationListener) obs -> updateSortOrder()); - - // As we store the ColumnModels of the MainTable, we need to add the listener to the ColumnModel properties, - // since the value is bound to the model after the listener to the column itself is called. - mainTable.getColumns().forEach(col -> - ((MainTableColumn) col).getModel().widthProperty().addListener(obs -> updateColumns())); - mainTable.getColumns().forEach(col -> - ((MainTableColumn) col).getModel().sortTypeProperty().addListener(obs -> updateColumns())); + public PersistenceVisualStateTable(final TableView mainTable, PreferencesService preferences) { + super(mainTable, preferences); } /** * Stores shown columns, their width and their sortType in preferences. */ - private void updateColumns() { - preferences.storeColumnPreferences(new ColumnPreferences( + @Override + protected void updateColumns() { + preferences.storeMainTableColumnPreferences(new MainTableColumnPreferences( mainTable.getColumns().stream() + .filter(col -> col instanceof MainTableColumn) .map(column -> ((MainTableColumn) column).getModel()) .collect(Collectors.toList()), preferences.getColumnPreferences().getColumnSortOrder())); @@ -45,10 +33,12 @@ private void updateColumns() { * Stores the SortOrder of the the Table in the preferences. Cannot be combined with updateColumns, because JavaFX * would provide just an empty list for the sort order on other changes. */ - private void updateSortOrder() { - preferences.storeColumnPreferences(new ColumnPreferences( + @Override + protected void updateSortOrder() { + preferences.storeMainTableColumnPreferences(new MainTableColumnPreferences( preferences.getColumnPreferences().getColumns(), mainTable.getSortOrder().stream() + .filter(col -> col instanceof MainTableColumn) .map(column -> ((MainTableColumn) column).getModel()) .collect(Collectors.toList()))); } diff --git a/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java b/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java index c963ed87b23..5b5db8e4195 100644 --- a/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java +++ b/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java @@ -17,7 +17,7 @@ import org.jabref.gui.fieldeditors.LinkedFileViewModel; import org.jabref.gui.icon.IconTheme; import org.jabref.gui.maintable.BibEntryTableViewModel; -import org.jabref.gui.maintable.ColumnPreferences; +import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.maintable.MainTableColumnFactory; import org.jabref.gui.maintable.MainTableColumnModel; import org.jabref.gui.util.ValueTableCellFactory; @@ -106,7 +106,7 @@ public FileColumn(MainTableColumnModel model, private void setCommonSettings() { this.setResizable(false); - MainTableColumnFactory.setExactWidth(this, ColumnPreferences.ICON_COLUMN_WIDTH); + MainTableColumnFactory.setExactWidth(this, MainTableColumnPreferences.ICON_COLUMN_WIDTH); this.getStyleClass().add(MainTableColumnFactory.STYLE_ICON_COLUMN); this.setCellValueFactory(cellData -> cellData.getValue().getLinkedFiles()); } diff --git a/src/main/java/org/jabref/gui/maintable/columns/LinkedIdentifierColumn.java b/src/main/java/org/jabref/gui/maintable/columns/LinkedIdentifierColumn.java index 23970e161b6..2805892a84c 100644 --- a/src/main/java/org/jabref/gui/maintable/columns/LinkedIdentifierColumn.java +++ b/src/main/java/org/jabref/gui/maintable/columns/LinkedIdentifierColumn.java @@ -15,7 +15,7 @@ import org.jabref.gui.icon.IconTheme; import org.jabref.gui.maintable.BibEntryTableViewModel; import org.jabref.gui.maintable.CellFactory; -import org.jabref.gui.maintable.ColumnPreferences; +import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.maintable.MainTableColumnFactory; import org.jabref.gui.maintable.MainTableColumnModel; import org.jabref.gui.maintable.OpenUrlAction; @@ -54,7 +54,7 @@ public LinkedIdentifierColumn(MainTableColumnModel model, Tooltip.install(headerGraphic, new Tooltip(Localization.lang("Linked identifiers"))); this.setGraphic(headerGraphic); this.getStyleClass().add(MainTableColumnFactory.STYLE_ICON_COLUMN); - MainTableColumnFactory.setExactWidth(this, ColumnPreferences.ICON_COLUMN_WIDTH); + MainTableColumnFactory.setExactWidth(this, MainTableColumnPreferences.ICON_COLUMN_WIDTH); this.setResizable(false); this.setCellValueFactory(cellData -> cellData.getValue().getLinkedIdentifiers()); new ValueTableCellFactory>() diff --git a/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java b/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java index 271a7abe4cb..657e6a8ce91 100644 --- a/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java +++ b/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java @@ -12,7 +12,7 @@ import org.jabref.gui.icon.JabRefIcon; import org.jabref.gui.maintable.BibEntryTableViewModel; -import org.jabref.gui.maintable.ColumnPreferences; +import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.maintable.MainTableColumnFactory; import org.jabref.gui.maintable.MainTableColumnModel; import org.jabref.gui.specialfields.SpecialFieldValueViewModel; @@ -58,7 +58,7 @@ public SpecialFieldColumn(MainTableColumnModel model, PreferencesService prefere .withGraphicIfPresent(this::createSpecialRating) .install(this); } else { - MainTableColumnFactory.setExactWidth(this, ColumnPreferences.ICON_COLUMN_WIDTH); + MainTableColumnFactory.setExactWidth(this, MainTableColumnPreferences.ICON_COLUMN_WIDTH); this.setResizable(false); if (specialField.isSingleValueField()) { diff --git a/src/main/java/org/jabref/gui/preferences/table/TableTabViewModel.java b/src/main/java/org/jabref/gui/preferences/table/TableTabViewModel.java index 1ab98f3905b..8464ff16c16 100644 --- a/src/main/java/org/jabref/gui/preferences/table/TableTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/table/TableTabViewModel.java @@ -17,7 +17,7 @@ import org.jabref.gui.DialogService; import org.jabref.gui.externalfiletype.ExternalFileType; import org.jabref.gui.externalfiletype.ExternalFileTypes; -import org.jabref.gui.maintable.ColumnPreferences; +import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.maintable.MainTableColumnModel; import org.jabref.gui.maintable.MainTableNameFormatPreferences; import org.jabref.gui.maintable.MainTablePreferences; @@ -82,7 +82,7 @@ public MainTableColumnModel fromString(String string) { private final DialogService dialogService; private final PreferencesService preferences; - private ColumnPreferences initialColumnPreferences; + private MainTableColumnPreferences initialColumnPreferences; private SpecialFieldsPreferences initialSpecialFieldsPreferences; public TableTabViewModel(DialogService dialogService, PreferencesService preferences) { @@ -243,7 +243,7 @@ public void moveColumnDown() { public void storeSettings() { MainTablePreferences newMainTablePreferences = preferences.getMainTablePreferences(); preferences.storeMainTablePreferences(new MainTablePreferences( - new ColumnPreferences( + new MainTableColumnPreferences( columnsListProperty.getValue(), newMainTablePreferences.getColumnPreferences().getColumnSortOrder()), autoResizeColumnsProperty.getValue(), diff --git a/src/main/java/org/jabref/gui/search/SearchResultsTable.java b/src/main/java/org/jabref/gui/search/SearchResultsTable.java index 82b0b88afa2..689e0395185 100644 --- a/src/main/java/org/jabref/gui/search/SearchResultsTable.java +++ b/src/main/java/org/jabref/gui/search/SearchResultsTable.java @@ -57,6 +57,10 @@ public SearchResultsTable(SearchResultsTableDataModel model, model.getEntriesFilteredAndSorted().comparatorProperty().bind(this.comparatorProperty()); this.getStylesheets().add(MainTable.class.getResource("MainTable.css").toExternalForm()); + + // Store visual state + new SearchResultsTablePersistenceVisualState(this, preferencesService); + database.getDatabase().registerListener(this); } } diff --git a/src/main/java/org/jabref/gui/search/SearchResultsTablePersistenceVisualState.java b/src/main/java/org/jabref/gui/search/SearchResultsTablePersistenceVisualState.java new file mode 100644 index 00000000000..3c75ab5faa9 --- /dev/null +++ b/src/main/java/org/jabref/gui/search/SearchResultsTablePersistenceVisualState.java @@ -0,0 +1,48 @@ +package org.jabref.gui.search; + +import java.util.stream.Collectors; + +import javafx.scene.control.TableView; + +import org.jabref.gui.maintable.AbstractPersistenceVisualStateTable; +import org.jabref.gui.maintable.BibEntryTableViewModel; +import org.jabref.gui.maintable.SearchDialogColumnPreferences; +import org.jabref.gui.maintable.columns.MainTableColumn; +import org.jabref.preferences.PreferencesService; + +/** + * Keep track of changes made to the columns (reordering, resorting, resizing). + */ +public class SearchResultsTablePersistenceVisualState extends AbstractPersistenceVisualStateTable { + + public SearchResultsTablePersistenceVisualState(final TableView mainTable, PreferencesService preferences) { + super(mainTable, preferences); + } + + /** + * Stores shown columns, their width and their sortType in preferences. + */ + @Override + protected void updateColumns() { + preferences.storeSearchDialogColumnPreferences(new SearchDialogColumnPreferences( + mainTable.getColumns().stream() + .filter(col -> col instanceof MainTableColumn) + .map(column -> ((MainTableColumn) column).getModel()) + .collect(Collectors.toList()), + preferences.getSearchDialogColumnPreferences().getColumnSortOrder())); + } + + /** + * Stores the SortOrder of the the Table in the preferences. Cannot be combined with updateColumns, because JavaFX + * would provide just an empty list for the sort order on other changes. + */ + @Override + protected void updateSortOrder() { + preferences.storeSearchDialogColumnPreferences(new SearchDialogColumnPreferences( + preferences.getSearchDialogColumnPreferences().getColumns(), + mainTable.getSortOrder().stream() + .filter(col -> col instanceof MainTableColumn) + .map(column -> ((MainTableColumn) column).getModel()) + .collect(Collectors.toList()))); + } +} diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index 6ff137d6d0f..598985aeeb2 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -15,7 +15,7 @@ import javafx.scene.control.TableColumn; import org.jabref.gui.Globals; -import org.jabref.gui.maintable.ColumnPreferences; +import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.maintable.MainTableColumnModel; import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; import org.jabref.model.entry.field.SpecialField; @@ -341,7 +341,7 @@ static void upgradeColumnPreferences(JabRefPreferences preferences) { try { return Double.parseDouble(string); } catch (NumberFormatException e) { - return ColumnPreferences.DEFAULT_COLUMN_WIDTH; + return MainTableColumnPreferences.DEFAULT_COLUMN_WIDTH; } }) .collect(Collectors.toList()); @@ -357,7 +357,7 @@ static void upgradeColumnPreferences(JabRefPreferences preferences) { for (int i = 0; i < columnNames.size(); i++) { String name = columnNames.get(i); - double columnWidth = ColumnPreferences.DEFAULT_COLUMN_WIDTH; + double columnWidth = MainTableColumnPreferences.DEFAULT_COLUMN_WIDTH; MainTableColumnModel.Type type = SpecialField.fromName(name) .map(field -> MainTableColumnModel.Type.SPECIALFIELD) diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 45d84a98def..16d04a8b06d 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -46,7 +46,8 @@ import org.jabref.gui.groups.GroupViewMode; import org.jabref.gui.groups.GroupsPreferences; import org.jabref.gui.keyboard.KeyBindingRepository; -import org.jabref.gui.maintable.ColumnPreferences; +import org.jabref.gui.maintable.AbstractColumnPreferences; +import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.maintable.MainTableColumnModel; import org.jabref.gui.maintable.MainTableNameFormatPreferences; import org.jabref.gui.maintable.MainTableNameFormatPreferences.AbbreviationStyle; @@ -1838,48 +1839,14 @@ public void storeExternalApplicationsPreferences(ExternalApplicationsPreferences private List createMainTableColumns() { if (this.mainTableColumns == null) { - updateMainTableColumns(); + this.mainTableColumns = updateColumns(COLUMN_NAMES, COLUMN_WIDTHS, COLUMN_SORT_TYPES, MainTableColumnPreferences.DEFAULT_COLUMN_WIDTH); } return this.mainTableColumns; } @Override public void updateMainTableColumns() { - List columnNames = getStringList(COLUMN_NAMES); - - List columnWidths = getStringList(COLUMN_WIDTHS) - .stream() - .map(string -> { - try { - return Double.parseDouble(string); - } catch (NumberFormatException e) { - LOGGER.error("Exception while parsing column widths. Choosing default.", e); - return ColumnPreferences.DEFAULT_COLUMN_WIDTH; - } - }) - .collect(Collectors.toList()); - - List columnSortTypes = getStringList(COLUMN_SORT_TYPES) - .stream() - .map(SortType::valueOf) - .collect(Collectors.toList()); - - List columns = new ArrayList<>(); - for (int i = 0; i < columnNames.size(); i++) { - MainTableColumnModel columnModel = MainTableColumnModel.parse(columnNames.get(i)); - - if (i < columnWidths.size()) { - columnModel.widthProperty().setValue(columnWidths.get(i)); - } - - if (i < columnSortTypes.size()) { - columnModel.sortTypeProperty().setValue(columnSortTypes.get(i)); - } - - columns.add(columnModel); - } - - mainTableColumns = columns; + mainTableColumns = updateColumns(COLUMN_NAMES, COLUMN_WIDTHS, COLUMN_SORT_TYPES, MainTableColumnPreferences.DEFAULT_COLUMN_WIDTH); } /** @@ -1889,28 +1856,14 @@ public void updateMainTableColumns() { */ private List createMainTableColumnSortOrder() { if (this.mainTableColumnSortOrder == null) { - updateColumnSortOrder(); + this.mainTableColumnSortOrder = updateColumnSortOrder(COLUMN_SORT_ORDER, mainTableColumns); } return this.mainTableColumnSortOrder; } - /** - * Reloads the MainTableColumnSortOrder from scratch to cache - */ - private void updateColumnSortOrder() { - List columnsOrdered = new ArrayList<>(); - getStringList(COLUMN_SORT_ORDER).forEach(columnName -> - mainTableColumns.stream().filter(column -> - column.getName().equals(columnName)) - .findFirst() - .ifPresent(columnsOrdered::add)); - - mainTableColumnSortOrder = columnsOrdered; - } - @Override - public ColumnPreferences getColumnPreferences() { - return new ColumnPreferences( + public MainTableColumnPreferences getColumnPreferences() { + return new MainTableColumnPreferences( createMainTableColumns(), createMainTableColumnSortOrder()); } @@ -1921,26 +1874,9 @@ public ColumnPreferences getColumnPreferences() { * @param columnPreferences the preferences to store */ @Override - public void storeColumnPreferences(ColumnPreferences columnPreferences) { - putStringList(COLUMN_NAMES, columnPreferences.getColumns().stream() - .map(MainTableColumnModel::getName) - .collect(Collectors.toList())); - - List columnWidthsInOrder = new ArrayList<>(); - columnPreferences.getColumns().forEach(column -> columnWidthsInOrder.add(column.widthProperty().getValue().toString())); - putStringList(COLUMN_WIDTHS, columnWidthsInOrder); - - List columnSortTypesInOrder = new ArrayList<>(); - columnPreferences.getColumns().forEach(column -> columnSortTypesInOrder.add(column.sortTypeProperty().getValue().toString())); - putStringList(COLUMN_SORT_TYPES, columnSortTypesInOrder); - - putStringList(COLUMN_SORT_ORDER, columnPreferences - .getColumnSortOrder().stream() - .map(MainTableColumnModel::getName) - .collect(Collectors.toList())); - + public void storeMainTableColumnPreferences(MainTableColumnPreferences columnPreferences) { // Update cache - mainTableColumns = columnPreferences.getColumns(); + mainTableColumns = storeColumnPreferences(columnPreferences, COLUMN_NAMES, COLUMN_WIDTHS, COLUMN_SORT_TYPES, COLUMN_SORT_ORDER); } @Override @@ -1952,7 +1888,7 @@ public MainTablePreferences getMainTablePreferences() { @Override public void storeMainTablePreferences(MainTablePreferences mainTablePreferences) { - storeColumnPreferences(mainTablePreferences.getColumnPreferences()); + storeMainTableColumnPreferences(mainTablePreferences.getColumnPreferences()); putBoolean(AUTO_RESIZE_MODE, mainTablePreferences.getResizeColumnsToFit()); putBoolean(EXTRA_FILE_COLUMNS, mainTablePreferences.getExtraFileColumnsEnabled()); } @@ -1991,25 +1927,24 @@ public void storeMainTableNameFormatPreferences(MainTableNameFormatPreferences p } //************************************************************************************************************* - // SearchDialogColumnsPreferences + // Generic Column Handling //***********************************************s************************************************************** - public void updateSearchDialogTableColumns() { - List columnNames = getStringList(SEARCH_DIALOG_COLUMN_NAMES); - - List columnWidths = getStringList(SEARCH_DIALOG_COLUMN_WIDTHS) + public List updateColumns(String columnNamesList, String columnWidthList, String sortTypeList, double defaultWidth) { + List columnNames = getStringList(columnNamesList); //we keep column names + List columnWidths = getStringList(columnWidthList) .stream() .map(string -> { try { return Double.parseDouble(string); } catch (NumberFormatException e) { LOGGER.error("Exception while parsing column widths. Choosing default.", e); - return SearchDialogColumnPreferences.DEFAULT_COLUMN_WIDTH; + return defaultWidth; } }) .collect(Collectors.toList()); - List columnSortTypes = getStringList(SEARCH_DIALOG_COLUMN_SORT_TYPES) + List columnSortTypes = getStringList(sortTypeList) .stream() .map(SortType::valueOf) .collect(Collectors.toList()); @@ -2028,13 +1963,12 @@ public void updateSearchDialogTableColumns() { columns.add(columnModel); } - - searchDialogTableColunns = columns; + return columns; } private List createSearchDialogColumns() { if (this.searchDialogTableColunns == null) { - updateSearchDialogTableColumns(); + this.searchDialogTableColunns = updateColumns(COLUMN_NAMES, SEARCH_DIALOG_COLUMN_WIDTHS, SEARCH_DIALOG_COLUMN_SORT_TYPES, SearchDialogColumnPreferences.DEFAULT_COLUMN_WIDTH); } return this.searchDialogTableColunns; } @@ -2046,23 +1980,24 @@ private List createSearchDialogColumns() { */ private List createSearchDialogColumnSortOrder() { if (this.searchDialogColumnSortOrder == null) { - updateSearchDialogColumnSortOrder(); + this.searchDialogColumnSortOrder = updateColumnSortOrder(SEARCH_DIALOG_COLUMN_SORT_ORDER, searchDialogTableColunns); } return this.searchDialogColumnSortOrder; } /** - * Reloads the MainTableColumnSortOrder from scratch to cache + * Reloads the ColumnSortOrder from scratch + * @return */ - private void updateSearchDialogColumnSortOrder() { + private List updateColumnSortOrder(String sortOrderList, List tableColumns) { List columnsOrdered = new ArrayList<>(); - getStringList(SEARCH_DIALOG_COLUMN_SORT_ORDER).forEach(columnName -> - searchDialogTableColunns.stream().filter(column -> + getStringList(sortOrderList).forEach(columnName -> + tableColumns.stream().filter(column -> column.getName().equals(columnName)) .findFirst() .ifPresent(columnsOrdered::add)); - searchDialogColumnSortOrder = columnsOrdered; + return columnsOrdered; } @Override @@ -2077,26 +2012,31 @@ public SearchDialogColumnPreferences getSearchDialogColumnPreferences() { * * @param columnPreferences the preferences to store */ + @Override public void storeSearchDialogColumnPreferences(SearchDialogColumnPreferences columnPreferences) { - putStringList(SEARCH_DIALOG_COLUMN_NAMES, columnPreferences.getColumns().stream() - .map(MainTableColumnModel::getName) - .collect(Collectors.toList())); + searchDialogTableColunns = storeColumnPreferences(columnPreferences, COLUMN_NAMES, SEARCH_DIALOG_COLUMN_WIDTHS, SEARCH_DIALOG_COLUMN_SORT_TYPES, SEARCH_DIALOG_COLUMN_SORT_ORDER); + } + + private List storeColumnPreferences(AbstractColumnPreferences columnPreferences, String columnNamesList, String columnWidthList, String sortTypeList, String sortOrderList) { + + putStringList(columnNamesList, columnPreferences.getColumns().stream() + .map(MainTableColumnModel::getName) + .collect(Collectors.toList())); List columnWidthsInOrder = new ArrayList<>(); columnPreferences.getColumns().forEach(column -> columnWidthsInOrder.add(column.widthProperty().getValue().toString())); - putStringList(SEARCH_DIALOG_COLUMN_WIDTHS, columnWidthsInOrder); + putStringList(columnWidthList, columnWidthsInOrder); List columnSortTypesInOrder = new ArrayList<>(); columnPreferences.getColumns().forEach(column -> columnSortTypesInOrder.add(column.sortTypeProperty().getValue().toString())); - putStringList(SEARCH_DIALOG_COLUMN_SORT_TYPES, columnSortTypesInOrder); + putStringList(sortTypeList, columnSortTypesInOrder); - putStringList(SEARCH_DIALOG_COLUMN_SORT_ORDER, columnPreferences - .getColumnSortOrder().stream() - .map(MainTableColumnModel::getName) - .collect(Collectors.toList())); + putStringList(sortOrderList, columnPreferences + .getColumnSortOrder().stream() + .map(MainTableColumnModel::getName) + .collect(Collectors.toList())); - // Update cache - searchDialogTableColunns = columnPreferences.getColumns(); + return columnPreferences.getColumns(); } //************************************************************************************************************* diff --git a/src/main/java/org/jabref/preferences/PreferencesService.java b/src/main/java/org/jabref/preferences/PreferencesService.java index 22344804324..23816b80665 100644 --- a/src/main/java/org/jabref/preferences/PreferencesService.java +++ b/src/main/java/org/jabref/preferences/PreferencesService.java @@ -12,7 +12,7 @@ import org.jabref.gui.groups.GroupViewMode; import org.jabref.gui.groups.GroupsPreferences; import org.jabref.gui.keyboard.KeyBindingRepository; -import org.jabref.gui.maintable.ColumnPreferences; +import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.maintable.MainTableNameFormatPreferences; import org.jabref.gui.maintable.MainTablePreferences; import org.jabref.gui.maintable.SearchDialogColumnPreferences; @@ -209,9 +209,9 @@ public interface PreferencesService { void updateMainTableColumns(); - ColumnPreferences getColumnPreferences(); + MainTableColumnPreferences getColumnPreferences(); - void storeColumnPreferences(ColumnPreferences columnPreferences); + void storeMainTableColumnPreferences(MainTableColumnPreferences columnPreferences); MainTablePreferences getMainTablePreferences(); @@ -227,6 +227,8 @@ public interface PreferencesService { SearchDialogColumnPreferences getSearchDialogColumnPreferences(); + void storeSearchDialogColumnPreferences(SearchDialogColumnPreferences columnPreferences); + //************************************************************************************************************* // AppearancePreferences //************************************************************************************************************* From 19d14ea85ff605675ef9b56bfcbe33d8641c062c Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Fri, 19 Nov 2021 23:56:57 +0100 Subject: [PATCH 04/13] checkstyle --- .../org/jabref/gui/maintable/columns/FileColumn.java | 2 +- .../gui/maintable/columns/LinkedIdentifierColumn.java | 4 +--- .../gui/maintable/columns/SpecialFieldColumn.java | 2 +- .../gui/preferences/table/TableTabViewModel.java | 11 +++++------ .../org/jabref/migrations/PreferencesMigrations.java | 2 +- .../org/jabref/preferences/JabRefPreferences.java | 4 ++-- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java b/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java index 5b5db8e4195..555a675b322 100644 --- a/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java +++ b/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java @@ -17,9 +17,9 @@ import org.jabref.gui.fieldeditors.LinkedFileViewModel; import org.jabref.gui.icon.IconTheme; import org.jabref.gui.maintable.BibEntryTableViewModel; -import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.maintable.MainTableColumnFactory; import org.jabref.gui.maintable.MainTableColumnModel; +import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.util.ValueTableCellFactory; import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseContext; diff --git a/src/main/java/org/jabref/gui/maintable/columns/LinkedIdentifierColumn.java b/src/main/java/org/jabref/gui/maintable/columns/LinkedIdentifierColumn.java index 2805892a84c..77885995f0c 100644 --- a/src/main/java/org/jabref/gui/maintable/columns/LinkedIdentifierColumn.java +++ b/src/main/java/org/jabref/gui/maintable/columns/LinkedIdentifierColumn.java @@ -15,9 +15,9 @@ import org.jabref.gui.icon.IconTheme; import org.jabref.gui.maintable.BibEntryTableViewModel; import org.jabref.gui.maintable.CellFactory; -import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.maintable.MainTableColumnFactory; import org.jabref.gui.maintable.MainTableColumnModel; +import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.maintable.OpenUrlAction; import org.jabref.gui.util.ControlHelper; import org.jabref.gui.util.ValueTableCellFactory; @@ -35,7 +35,6 @@ public class LinkedIdentifierColumn extends MainTableColumn> private final CellFactory cellFactory; private final DialogService dialogService; private final PreferencesService preferences; - private final StateManager stateManager; public LinkedIdentifierColumn(MainTableColumnModel model, CellFactory cellFactory, @@ -48,7 +47,6 @@ public LinkedIdentifierColumn(MainTableColumnModel model, this.cellFactory = cellFactory; this.dialogService = dialogService; this.preferences = preferences; - this.stateManager = stateManager; Node headerGraphic = IconTheme.JabRefIcons.WWW.getGraphicNode(); Tooltip.install(headerGraphic, new Tooltip(Localization.lang("Linked identifiers"))); diff --git a/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java b/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java index 657e6a8ce91..9111e108d10 100644 --- a/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java +++ b/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java @@ -12,9 +12,9 @@ import org.jabref.gui.icon.JabRefIcon; import org.jabref.gui.maintable.BibEntryTableViewModel; -import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.maintable.MainTableColumnFactory; import org.jabref.gui.maintable.MainTableColumnModel; +import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.specialfields.SpecialFieldValueViewModel; import org.jabref.gui.specialfields.SpecialFieldViewModel; import org.jabref.gui.specialfields.SpecialFieldsPreferences; diff --git a/src/main/java/org/jabref/gui/preferences/table/TableTabViewModel.java b/src/main/java/org/jabref/gui/preferences/table/TableTabViewModel.java index 8464ff16c16..266fba0878e 100644 --- a/src/main/java/org/jabref/gui/preferences/table/TableTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/table/TableTabViewModel.java @@ -17,9 +17,11 @@ import org.jabref.gui.DialogService; import org.jabref.gui.externalfiletype.ExternalFileType; import org.jabref.gui.externalfiletype.ExternalFileTypes; -import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.maintable.MainTableColumnModel; +import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.maintable.MainTableNameFormatPreferences; +import org.jabref.gui.maintable.MainTableNameFormatPreferences.AbbreviationStyle; +import org.jabref.gui.maintable.MainTableNameFormatPreferences.DisplayStyle; import org.jabref.gui.maintable.MainTablePreferences; import org.jabref.gui.preferences.PreferenceTabViewModel; import org.jabref.gui.specialfields.SpecialFieldsPreferences; @@ -36,9 +38,6 @@ import de.saxsys.mvvmfx.utils.validation.ValidationStatus; import de.saxsys.mvvmfx.utils.validation.Validator; -import static org.jabref.gui.maintable.MainTableNameFormatPreferences.AbbreviationStyle; -import static org.jabref.gui.maintable.MainTableNameFormatPreferences.DisplayStyle; - public class TableTabViewModel implements PreferenceTabViewModel { static StringConverter columnNameStringConverter = new StringConverter<>() { @@ -218,7 +217,7 @@ public void removeColumn(MainTableColumnModel column) { public void moveColumnUp() { MainTableColumnModel selectedColumn = selectedColumnModelProperty.getValue().getSelectedItem(); int row = columnsListProperty.getValue().indexOf(selectedColumn); - if (selectedColumn == null || row < 1) { + if ((selectedColumn == null) || (row < 1)) { return; } @@ -230,7 +229,7 @@ public void moveColumnUp() { public void moveColumnDown() { MainTableColumnModel selectedColumn = selectedColumnModelProperty.getValue().getSelectedItem(); int row = columnsListProperty.getValue().indexOf(selectedColumn); - if (selectedColumn == null || row > columnsListProperty.getValue().size() - 2) { + if ((selectedColumn == null) || (row > (columnsListProperty.getValue().size() - 2))) { return; } diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index 598985aeeb2..b9331effc36 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -15,8 +15,8 @@ import javafx.scene.control.TableColumn; import org.jabref.gui.Globals; -import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.maintable.MainTableColumnModel; +import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; import org.jabref.model.entry.field.SpecialField; import org.jabref.model.entry.field.StandardField; diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 16d04a8b06d..72b054cc403 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -47,8 +47,8 @@ import org.jabref.gui.groups.GroupsPreferences; import org.jabref.gui.keyboard.KeyBindingRepository; import org.jabref.gui.maintable.AbstractColumnPreferences; -import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.maintable.MainTableColumnModel; +import org.jabref.gui.maintable.MainTableColumnPreferences; import org.jabref.gui.maintable.MainTableNameFormatPreferences; import org.jabref.gui.maintable.MainTableNameFormatPreferences.AbbreviationStyle; import org.jabref.gui.maintable.MainTableNameFormatPreferences.DisplayStyle; @@ -1931,7 +1931,7 @@ public void storeMainTableNameFormatPreferences(MainTableNameFormatPreferences p //***********************************************s************************************************************** public List updateColumns(String columnNamesList, String columnWidthList, String sortTypeList, double defaultWidth) { - List columnNames = getStringList(columnNamesList); //we keep column names + List columnNames = getStringList(columnNamesList); List columnWidths = getStringList(columnWidthList) .stream() .map(string -> { From 66555c614bb5dd21d34398aed63d514982b28594 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 20 Nov 2021 19:32:20 +0100 Subject: [PATCH 05/13] refactor, get rid of duplicate column preferences --- .../maintable/AbstractColumnPreferences.java | 13 - ...references.java => ColumnPreferences.java} | 6 +- .../gui/maintable/MainTableColumnFactory.java | 6 +- .../gui/maintable/MainTableColumnModel.java | 4 +- .../gui/maintable/MainTablePreferences.java | 6 +- .../PersistenceVisualStateTable.java | 4 +- .../SearchDialogColumnPreferences.java | 24 - .../gui/maintable/columns/FileColumn.java | 4 +- .../columns/LinkedIdentifierColumn.java | 4 +- .../maintable/columns/SpecialFieldColumn.java | 4 +- .../preferences/table/TableTabViewModel.java | 6 +- ...rchResultsTablePersistenceVisualState.java | 10 +- .../migrations/PreferencesMigrations.java | 6 +- .../jabref/preferences/JabRefPreferences.java | 554 +++++++++--------- .../preferences/PreferencesService.java | 11 +- 15 files changed, 301 insertions(+), 361 deletions(-) delete mode 100644 src/main/java/org/jabref/gui/maintable/AbstractColumnPreferences.java rename src/main/java/org/jabref/gui/maintable/{MainTableColumnPreferences.java => ColumnPreferences.java} (73%) delete mode 100644 src/main/java/org/jabref/gui/maintable/SearchDialogColumnPreferences.java diff --git a/src/main/java/org/jabref/gui/maintable/AbstractColumnPreferences.java b/src/main/java/org/jabref/gui/maintable/AbstractColumnPreferences.java deleted file mode 100644 index 01c35b354dc..00000000000 --- a/src/main/java/org/jabref/gui/maintable/AbstractColumnPreferences.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.jabref.gui.maintable; - -import java.util.List; - -public interface AbstractColumnPreferences { - - public static final double DEFAULT_COLUMN_WIDTH = 100; - public static final double ICON_COLUMN_WIDTH = 16 + 12; // add some additional space to improve appearance - - public List getColumns(); - - public List getColumnSortOrder(); -} diff --git a/src/main/java/org/jabref/gui/maintable/MainTableColumnPreferences.java b/src/main/java/org/jabref/gui/maintable/ColumnPreferences.java similarity index 73% rename from src/main/java/org/jabref/gui/maintable/MainTableColumnPreferences.java rename to src/main/java/org/jabref/gui/maintable/ColumnPreferences.java index 6249ce3a4e6..d79b3a6857b 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableColumnPreferences.java +++ b/src/main/java/org/jabref/gui/maintable/ColumnPreferences.java @@ -2,7 +2,7 @@ import java.util.List; -public class MainTableColumnPreferences implements AbstractColumnPreferences { +public class ColumnPreferences { public static final double DEFAULT_COLUMN_WIDTH = 100; public static final double ICON_COLUMN_WIDTH = 16 + 12; // add some additional space to improve appearance @@ -10,17 +10,15 @@ public class MainTableColumnPreferences implements AbstractColumnPreferences { private final List columns; private final List columnSortOrder; - public MainTableColumnPreferences(List columns, List columnSortOrder) { + public ColumnPreferences(List columns, List columnSortOrder) { this.columns = columns; this.columnSortOrder = columnSortOrder; } - @Override public List getColumns() { return columns; } - @Override public List getColumnSortOrder() { return columnSortOrder; } diff --git a/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java b/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java index 871d50444e6..d80b9f01806 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java @@ -52,7 +52,7 @@ public class MainTableColumnFactory { private static final Logger LOGGER = LoggerFactory.getLogger(MainTableColumnFactory.class); private final PreferencesService preferencesService; - private final AbstractColumnPreferences columnPreferences; + private final ColumnPreferences columnPreferences; private final ExternalFileTypes externalFileTypes; private final BibDatabaseContext database; private final CellFactory cellFactory; @@ -62,7 +62,7 @@ public class MainTableColumnFactory { public MainTableColumnFactory(BibDatabaseContext database, PreferencesService preferencesService, - AbstractColumnPreferences abstractColumnPrefs, + ColumnPreferences abstractColumnPrefs, ExternalFileTypes externalFileTypes, UndoManager undoManager, DialogService dialogService, @@ -157,7 +157,7 @@ private TableColumn createIndexColumn(MainTableC Tooltip.install(headerGraphic, new Tooltip(Localization.lang("Group color"))); column.setGraphic(headerGraphic); column.getStyleClass().add(STYLE_ICON_COLUMN); - setExactWidth(column, MainTableColumnPreferences.ICON_COLUMN_WIDTH); + setExactWidth(column, ColumnPreferences.ICON_COLUMN_WIDTH); column.setResizable(false); column.setCellValueFactory(cellData -> cellData.getValue().getMatchedGroups()); new ValueTableCellFactory>() diff --git a/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java b/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java index 44ee1301d49..e82af036482 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java @@ -92,9 +92,9 @@ public MainTableColumnModel(Type type, String qualifier) { this.sortTypeProperty.setValue(TableColumn.SortType.ASCENDING); if (Type.ICON_COLUMNS.contains(type)) { - this.widthProperty.setValue(MainTableColumnPreferences.ICON_COLUMN_WIDTH); + this.widthProperty.setValue(ColumnPreferences.ICON_COLUMN_WIDTH); } else { - this.widthProperty.setValue(MainTableColumnPreferences.DEFAULT_COLUMN_WIDTH); + this.widthProperty.setValue(ColumnPreferences.DEFAULT_COLUMN_WIDTH); } } diff --git a/src/main/java/org/jabref/gui/maintable/MainTablePreferences.java b/src/main/java/org/jabref/gui/maintable/MainTablePreferences.java index 41cd266a8f6..7698893b9dd 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTablePreferences.java +++ b/src/main/java/org/jabref/gui/maintable/MainTablePreferences.java @@ -1,17 +1,17 @@ package org.jabref.gui.maintable; public class MainTablePreferences { - private final MainTableColumnPreferences columnPreferences; + private final ColumnPreferences columnPreferences; private final boolean resizeColumnsToFit; private final boolean extraFileColumnsEnabled; - public MainTablePreferences(MainTableColumnPreferences columnPreferences, boolean resizeColumnsToFit, boolean extraFileColumnsEnabled) { + public MainTablePreferences(ColumnPreferences columnPreferences, boolean resizeColumnsToFit, boolean extraFileColumnsEnabled) { this.columnPreferences = columnPreferences; this.resizeColumnsToFit = resizeColumnsToFit; this.extraFileColumnsEnabled = extraFileColumnsEnabled; } - public MainTableColumnPreferences getColumnPreferences() { + public ColumnPreferences getColumnPreferences() { return columnPreferences; } diff --git a/src/main/java/org/jabref/gui/maintable/PersistenceVisualStateTable.java b/src/main/java/org/jabref/gui/maintable/PersistenceVisualStateTable.java index 1b5e6d62339..5f53803d35f 100644 --- a/src/main/java/org/jabref/gui/maintable/PersistenceVisualStateTable.java +++ b/src/main/java/org/jabref/gui/maintable/PersistenceVisualStateTable.java @@ -21,7 +21,7 @@ public PersistenceVisualStateTable(final TableView mainT */ @Override protected void updateColumns() { - preferences.storeMainTableColumnPreferences(new MainTableColumnPreferences( + preferences.storeMainTableColumnPreferences(new ColumnPreferences( mainTable.getColumns().stream() .filter(col -> col instanceof MainTableColumn) .map(column -> ((MainTableColumn) column).getModel()) @@ -35,7 +35,7 @@ protected void updateColumns() { */ @Override protected void updateSortOrder() { - preferences.storeMainTableColumnPreferences(new MainTableColumnPreferences( + preferences.storeMainTableColumnPreferences(new ColumnPreferences( preferences.getColumnPreferences().getColumns(), mainTable.getSortOrder().stream() .filter(col -> col instanceof MainTableColumn) diff --git a/src/main/java/org/jabref/gui/maintable/SearchDialogColumnPreferences.java b/src/main/java/org/jabref/gui/maintable/SearchDialogColumnPreferences.java deleted file mode 100644 index 9794706715a..00000000000 --- a/src/main/java/org/jabref/gui/maintable/SearchDialogColumnPreferences.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.jabref.gui.maintable; - -import java.util.List; - -public class SearchDialogColumnPreferences implements AbstractColumnPreferences { - - private final List columns; - private final List columnSortOrder; - - public SearchDialogColumnPreferences(List columns, List columnSortOrder) { - this.columns = columns; - this.columnSortOrder = columnSortOrder; - } - - @Override - public List getColumns() { - return columns; - } - - @Override - public List getColumnSortOrder() { - return columnSortOrder; - } -} diff --git a/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java b/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java index 555a675b322..2e9934eecf3 100644 --- a/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java +++ b/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java @@ -19,7 +19,7 @@ import org.jabref.gui.maintable.BibEntryTableViewModel; import org.jabref.gui.maintable.MainTableColumnFactory; import org.jabref.gui.maintable.MainTableColumnModel; -import org.jabref.gui.maintable.MainTableColumnPreferences; +import org.jabref.gui.maintable.ColumnPreferences; import org.jabref.gui.util.ValueTableCellFactory; import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseContext; @@ -106,7 +106,7 @@ public FileColumn(MainTableColumnModel model, private void setCommonSettings() { this.setResizable(false); - MainTableColumnFactory.setExactWidth(this, MainTableColumnPreferences.ICON_COLUMN_WIDTH); + MainTableColumnFactory.setExactWidth(this, ColumnPreferences.ICON_COLUMN_WIDTH); this.getStyleClass().add(MainTableColumnFactory.STYLE_ICON_COLUMN); this.setCellValueFactory(cellData -> cellData.getValue().getLinkedFiles()); } diff --git a/src/main/java/org/jabref/gui/maintable/columns/LinkedIdentifierColumn.java b/src/main/java/org/jabref/gui/maintable/columns/LinkedIdentifierColumn.java index 77885995f0c..575c146e638 100644 --- a/src/main/java/org/jabref/gui/maintable/columns/LinkedIdentifierColumn.java +++ b/src/main/java/org/jabref/gui/maintable/columns/LinkedIdentifierColumn.java @@ -17,7 +17,7 @@ import org.jabref.gui.maintable.CellFactory; import org.jabref.gui.maintable.MainTableColumnFactory; import org.jabref.gui.maintable.MainTableColumnModel; -import org.jabref.gui.maintable.MainTableColumnPreferences; +import org.jabref.gui.maintable.ColumnPreferences; import org.jabref.gui.maintable.OpenUrlAction; import org.jabref.gui.util.ControlHelper; import org.jabref.gui.util.ValueTableCellFactory; @@ -52,7 +52,7 @@ public LinkedIdentifierColumn(MainTableColumnModel model, Tooltip.install(headerGraphic, new Tooltip(Localization.lang("Linked identifiers"))); this.setGraphic(headerGraphic); this.getStyleClass().add(MainTableColumnFactory.STYLE_ICON_COLUMN); - MainTableColumnFactory.setExactWidth(this, MainTableColumnPreferences.ICON_COLUMN_WIDTH); + MainTableColumnFactory.setExactWidth(this, ColumnPreferences.ICON_COLUMN_WIDTH); this.setResizable(false); this.setCellValueFactory(cellData -> cellData.getValue().getLinkedIdentifiers()); new ValueTableCellFactory>() diff --git a/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java b/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java index 9111e108d10..1e550ed7984 100644 --- a/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java +++ b/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java @@ -14,7 +14,7 @@ import org.jabref.gui.maintable.BibEntryTableViewModel; import org.jabref.gui.maintable.MainTableColumnFactory; import org.jabref.gui.maintable.MainTableColumnModel; -import org.jabref.gui.maintable.MainTableColumnPreferences; +import org.jabref.gui.maintable.ColumnPreferences; import org.jabref.gui.specialfields.SpecialFieldValueViewModel; import org.jabref.gui.specialfields.SpecialFieldViewModel; import org.jabref.gui.specialfields.SpecialFieldsPreferences; @@ -58,7 +58,7 @@ public SpecialFieldColumn(MainTableColumnModel model, PreferencesService prefere .withGraphicIfPresent(this::createSpecialRating) .install(this); } else { - MainTableColumnFactory.setExactWidth(this, MainTableColumnPreferences.ICON_COLUMN_WIDTH); + MainTableColumnFactory.setExactWidth(this, ColumnPreferences.ICON_COLUMN_WIDTH); this.setResizable(false); if (specialField.isSingleValueField()) { diff --git a/src/main/java/org/jabref/gui/preferences/table/TableTabViewModel.java b/src/main/java/org/jabref/gui/preferences/table/TableTabViewModel.java index 266fba0878e..f1390ab27d9 100644 --- a/src/main/java/org/jabref/gui/preferences/table/TableTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/table/TableTabViewModel.java @@ -18,7 +18,7 @@ import org.jabref.gui.externalfiletype.ExternalFileType; import org.jabref.gui.externalfiletype.ExternalFileTypes; import org.jabref.gui.maintable.MainTableColumnModel; -import org.jabref.gui.maintable.MainTableColumnPreferences; +import org.jabref.gui.maintable.ColumnPreferences; import org.jabref.gui.maintable.MainTableNameFormatPreferences; import org.jabref.gui.maintable.MainTableNameFormatPreferences.AbbreviationStyle; import org.jabref.gui.maintable.MainTableNameFormatPreferences.DisplayStyle; @@ -81,7 +81,7 @@ public MainTableColumnModel fromString(String string) { private final DialogService dialogService; private final PreferencesService preferences; - private MainTableColumnPreferences initialColumnPreferences; + private ColumnPreferences initialColumnPreferences; private SpecialFieldsPreferences initialSpecialFieldsPreferences; public TableTabViewModel(DialogService dialogService, PreferencesService preferences) { @@ -242,7 +242,7 @@ public void moveColumnDown() { public void storeSettings() { MainTablePreferences newMainTablePreferences = preferences.getMainTablePreferences(); preferences.storeMainTablePreferences(new MainTablePreferences( - new MainTableColumnPreferences( + new ColumnPreferences( columnsListProperty.getValue(), newMainTablePreferences.getColumnPreferences().getColumnSortOrder()), autoResizeColumnsProperty.getValue(), diff --git a/src/main/java/org/jabref/gui/search/SearchResultsTablePersistenceVisualState.java b/src/main/java/org/jabref/gui/search/SearchResultsTablePersistenceVisualState.java index 3c75ab5faa9..2b5b76b7979 100644 --- a/src/main/java/org/jabref/gui/search/SearchResultsTablePersistenceVisualState.java +++ b/src/main/java/org/jabref/gui/search/SearchResultsTablePersistenceVisualState.java @@ -6,7 +6,7 @@ import org.jabref.gui.maintable.AbstractPersistenceVisualStateTable; import org.jabref.gui.maintable.BibEntryTableViewModel; -import org.jabref.gui.maintable.SearchDialogColumnPreferences; +import org.jabref.gui.maintable.ColumnPreferences; import org.jabref.gui.maintable.columns.MainTableColumn; import org.jabref.preferences.PreferencesService; @@ -15,8 +15,8 @@ */ public class SearchResultsTablePersistenceVisualState extends AbstractPersistenceVisualStateTable { - public SearchResultsTablePersistenceVisualState(final TableView mainTable, PreferencesService preferences) { - super(mainTable, preferences); + public SearchResultsTablePersistenceVisualState(final TableView searchResultsTable, PreferencesService preferences) { + super(searchResultsTable, preferences); } /** @@ -24,7 +24,7 @@ public SearchResultsTablePersistenceVisualState(final TableView col instanceof MainTableColumn) .map(column -> ((MainTableColumn) column).getModel()) @@ -38,7 +38,7 @@ protected void updateColumns() { */ @Override protected void updateSortOrder() { - preferences.storeSearchDialogColumnPreferences(new SearchDialogColumnPreferences( + preferences.storeSearchDialogColumnPreferences(new ColumnPreferences( preferences.getSearchDialogColumnPreferences().getColumns(), mainTable.getSortOrder().stream() .filter(col -> col instanceof MainTableColumn) diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index b9331effc36..ea70b5f60f0 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -16,7 +16,7 @@ import org.jabref.gui.Globals; import org.jabref.gui.maintable.MainTableColumnModel; -import org.jabref.gui.maintable.MainTableColumnPreferences; +import org.jabref.gui.maintable.ColumnPreferences; import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; import org.jabref.model.entry.field.SpecialField; import org.jabref.model.entry.field.StandardField; @@ -341,7 +341,7 @@ static void upgradeColumnPreferences(JabRefPreferences preferences) { try { return Double.parseDouble(string); } catch (NumberFormatException e) { - return MainTableColumnPreferences.DEFAULT_COLUMN_WIDTH; + return ColumnPreferences.DEFAULT_COLUMN_WIDTH; } }) .collect(Collectors.toList()); @@ -357,7 +357,7 @@ static void upgradeColumnPreferences(JabRefPreferences preferences) { for (int i = 0; i < columnNames.size(); i++) { String name = columnNames.get(i); - double columnWidth = MainTableColumnPreferences.DEFAULT_COLUMN_WIDTH; + double columnWidth = ColumnPreferences.DEFAULT_COLUMN_WIDTH; MainTableColumnModel.Type type = SpecialField.fromName(name) .map(field -> MainTableColumnModel.Type.SPECIALFIELD) diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 72b054cc403..e33db5a640e 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -46,14 +46,12 @@ import org.jabref.gui.groups.GroupViewMode; import org.jabref.gui.groups.GroupsPreferences; import org.jabref.gui.keyboard.KeyBindingRepository; -import org.jabref.gui.maintable.AbstractColumnPreferences; import org.jabref.gui.maintable.MainTableColumnModel; -import org.jabref.gui.maintable.MainTableColumnPreferences; +import org.jabref.gui.maintable.ColumnPreferences; import org.jabref.gui.maintable.MainTableNameFormatPreferences; import org.jabref.gui.maintable.MainTableNameFormatPreferences.AbbreviationStyle; import org.jabref.gui.maintable.MainTableNameFormatPreferences.DisplayStyle; import org.jabref.gui.maintable.MainTablePreferences; -import org.jabref.gui.maintable.SearchDialogColumnPreferences; import org.jabref.gui.mergeentries.MergeEntries; import org.jabref.gui.search.SearchDisplayMode; import org.jabref.gui.sidepane.SidePaneType; @@ -175,8 +173,8 @@ public class JabRefPreferences implements PreferencesService { public static final String COLUMN_SORT_TYPES = "mainTableColumnSortTypes"; public static final String COLUMN_SORT_ORDER = "mainTableColumnSortOrder"; - public static final String SEARCH_DIALOG_COLUMN_NAMES = "mainTableColumnNames"; - public static final String SEARCH_DIALOG_COLUMN_WIDTHS = "mainTableColumnWidths"; + public static final String SEARCH_DIALOG_COLUMN_NAMES = "searchDialogColumnNames"; + public static final String SEARCH_DIALOG_COLUMN_WIDTHS = "searchDialogColumnWidths"; public static final String SEARCH_DIALOG_COLUMN_SORT_TYPES = "searchDialogColumnSortTypes"; public static final String SEARCH_DIALOG_COLUMN_SORT_ORDER = "searchDalogColumnSortOrder"; @@ -708,24 +706,24 @@ private JabRefPreferences() { defaults.put(PREVIEW_PANEL_HEIGHT, 0.65); defaults.put(PREVIEW_AS_TAB, Boolean.FALSE); defaults.put(PREVIEW_STYLE, - "" + - "\\bibtextype\\begin{citationkey} (\\citationkey)\\end{citationkey}__NEWLINE__" + - "\\begin{author}

\\format[Authors(LastFirst, FullName,Sep= / ,LastSep= / ),HTMLChars]{\\author}\\end{author}__NEWLINE__" + - "\\begin{editor & !author}

\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & !author}__NEWLINE__" + - "\\begin{title}
\\format[HTMLChars]{\\title} \\end{title}__NEWLINE__" + - "
\\begin{date}\\date\\end{date}\\begin{edition}, \\edition. edition\\end{edition}__NEWLINE__" + - "\\begin{editor & author}

\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & author}__NEWLINE__" + - "\\begin{booktitle}
\\format[HTMLChars]{\\booktitle}\\end{booktitle}__NEWLINE__" + - "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}" + - "\\begin{editor & !author}
\\end{editor & !author}\\begin{!editor}
\\end{!editor}\\begin{journal}
\\format[HTMLChars]{\\journal} \\end{journal} \\begin{volume}, Vol. \\volume\\end{volume}\\begin{series}
\\format[HTMLChars]{\\series}\\end{series}\\begin{number}, No. \\format[HTMLChars]{\\number}\\end{number}__NEWLINE__" + - "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + - "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" + - "\\begin{publisher}
\\format[HTMLChars]{\\publisher}\\end{publisher}\\begin{location}: \\format[HTMLChars]{\\location} \\end{location}__NEWLINE__" + - "\\begin{pages}
p. \\format[FormatPagesForHTML]{\\pages}\\end{pages}__NEWLINE__" + - "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" + - "\\begin{owncitation}

Own citation: \\format[HTMLChars]{\\owncitation} \\end{owncitation}__NEWLINE__" + - "\\begin{comment}

Comment: \\format[HTMLChars]{\\comment}\\end{comment}__NEWLINE__" + - "
__NEWLINE__"); + "" + + "\\bibtextype\\begin{citationkey} (\\citationkey)\\end{citationkey}__NEWLINE__" + + "\\begin{author}

\\format[Authors(LastFirst, FullName,Sep= / ,LastSep= / ),HTMLChars]{\\author}\\end{author}__NEWLINE__" + + "\\begin{editor & !author}

\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & !author}__NEWLINE__" + + "\\begin{title}
\\format[HTMLChars]{\\title} \\end{title}__NEWLINE__" + + "
\\begin{date}\\date\\end{date}\\begin{edition}, \\edition. edition\\end{edition}__NEWLINE__" + + "\\begin{editor & author}

\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & author}__NEWLINE__" + + "\\begin{booktitle}
\\format[HTMLChars]{\\booktitle}\\end{booktitle}__NEWLINE__" + + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}" + + "\\begin{editor & !author}
\\end{editor & !author}\\begin{!editor}
\\end{!editor}\\begin{journal}
\\format[HTMLChars]{\\journal} \\end{journal} \\begin{volume}, Vol. \\volume\\end{volume}\\begin{series}
\\format[HTMLChars]{\\series}\\end{series}\\begin{number}, No. \\format[HTMLChars]{\\number}\\end{number}__NEWLINE__" + + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" + + "\\begin{publisher}
\\format[HTMLChars]{\\publisher}\\end{publisher}\\begin{location}: \\format[HTMLChars]{\\location} \\end{location}__NEWLINE__" + + "\\begin{pages}
p. \\format[FormatPagesForHTML]{\\pages}\\end{pages}__NEWLINE__" + + "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" + + "\\begin{owncitation}

Own citation: \\format[HTMLChars]{\\owncitation} \\end{owncitation}__NEWLINE__" + + "\\begin{comment}

Comment: \\format[HTMLChars]{\\comment}\\end{comment}__NEWLINE__" + + "
__NEWLINE__"); // set default theme defaults.put(FX_THEME, Theme.BASE_CSS); @@ -802,11 +800,11 @@ private static Optional getNextUnit(Reader data) throws IOException { private static void insertDefaultCleanupPreset(Map storage) { EnumSet deactivatedJobs = EnumSet.of( - CleanupPreset.CleanupStep.CLEAN_UP_UPGRADE_EXTERNAL_LINKS, - CleanupPreset.CleanupStep.MOVE_PDF, - CleanupPreset.CleanupStep.RENAME_PDF_ONLY_RELATIVE_PATHS, - CleanupPreset.CleanupStep.CONVERT_TO_BIBLATEX, - CleanupPreset.CleanupStep.CONVERT_TO_BIBTEX); + CleanupPreset.CleanupStep.CLEAN_UP_UPGRADE_EXTERNAL_LINKS, + CleanupPreset.CleanupStep.MOVE_PDF, + CleanupPreset.CleanupStep.RENAME_PDF_ONLY_RELATIVE_PATHS, + CleanupPreset.CleanupStep.CONVERT_TO_BIBLATEX, + CleanupPreset.CleanupStep.CONVERT_TO_BIBTEX); for (CleanupPreset.CleanupStep action : EnumSet.allOf(CleanupPreset.CleanupStep.class)) { storage.put(CLEANUP + action.name(), !deactivatedJobs.contains(action)); @@ -825,7 +823,7 @@ public String getUser() { return userName; } catch (UnknownHostException ex) { LOGGER.error("Hostname not found. Please go to https://docs.jabref.org/ to find possible " + - "problem resolution", ex); + "problem resolution", ex); return get(DEFAULT_OWNER); } } @@ -1075,7 +1073,7 @@ public void exportPreferences(Path file) throws JabRefException { prefs.exportSubtree(os); } catch (BackingStoreException | IOException ex) { throw new JabRefException("Could not export preferences", Localization.lang("Could not export preferences"), - ex); + ex); } } @@ -1091,15 +1089,15 @@ public void importPreferences(Path file) throws JabRefException { Preferences.importPreferences(is); } catch (InvalidPreferencesFormatException | IOException ex) { throw new JabRefException("Could not import preferences", Localization.lang("Could not import preferences"), - ex); + ex); } } @Override public FileLinkPreferences getFileLinkPreferences() { return new FileLinkPreferences( - get(MAIN_FILE_DIRECTORY), // REALLY HERE? - fileDirForDatabase); + get(MAIN_FILE_DIRECTORY), // REALLY HERE? + fileDirForDatabase); } @Override @@ -1110,20 +1108,20 @@ public void storeFileDirforDatabase(List dirs) { @Override public LayoutFormatterPreferences getLayoutFormatterPreferences(JournalAbbreviationRepository repository) { return new LayoutFormatterPreferences( - getNameFormatterPreferences(), - getFileLinkPreferences(), - repository); + getNameFormatterPreferences(), + getFileLinkPreferences(), + repository); } @Override public OpenOfficePreferences getOpenOfficePreferences() { return new OpenOfficePreferences( - get(OO_EXECUTABLE_PATH), - get(OO_PATH), - getBoolean(OO_USE_ALL_OPEN_BASES), - getBoolean(OO_SYNC_WHEN_CITING), - getStringList(OO_EXTERNAL_STYLE_FILES), - get(OO_BIBLIOGRAPHY_STYLE_FILE)); + get(OO_EXECUTABLE_PATH), + get(OO_PATH), + getBoolean(OO_USE_ALL_OPEN_BASES), + getBoolean(OO_SYNC_WHEN_CITING), + getStringList(OO_EXTERNAL_STYLE_FILES), + get(OO_BIBLIOGRAPHY_STYLE_FILE)); } @Override @@ -1155,8 +1153,8 @@ public JournalAbbreviationPreferences getJournalAbbreviationPreferences() { @Override public CleanupPreferences getCleanupPreferences(JournalAbbreviationRepository abbreviationRepository) { return new CleanupPreferences( - getLayoutFormatterPreferences(abbreviationRepository), - getFilePreferences()); + getLayoutFormatterPreferences(abbreviationRepository), + getFilePreferences()); } @Override @@ -1340,12 +1338,12 @@ public GeneralPreferences getGeneralPreferences() { } generalPreferences = new GeneralPreferences( - Charset.forName(get(DEFAULT_ENCODING)), - getBoolean(BIBLATEX_DEFAULT_MODE) ? BibDatabaseMode.BIBLATEX : BibDatabaseMode.BIBTEX, - getBoolean(WARN_ABOUT_DUPLICATES_IN_INSPECTION), - getBoolean(CONFIRM_DELETE), - getBoolean(MEMORY_STICK_MODE), - getBoolean(SHOW_ADVANCED_HINTS)); + Charset.forName(get(DEFAULT_ENCODING)), + getBoolean(BIBLATEX_DEFAULT_MODE) ? BibDatabaseMode.BIBLATEX : BibDatabaseMode.BIBTEX, + getBoolean(WARN_ABOUT_DUPLICATES_IN_INSPECTION), + getBoolean(CONFIRM_DELETE), + getBoolean(MEMORY_STICK_MODE), + getBoolean(SHOW_ADVANCED_HINTS)); EasyBind.listen(generalPreferences.defaultEncodingProperty(), (obs, oldValue, newValue) -> put(DEFAULT_ENCODING, newValue.name())); EasyBind.listen(generalPreferences.defaultBibDatabaseModeProperty(), (obs, oldValue, newValue) -> putBoolean(BIBLATEX_DEFAULT_MODE, (newValue == BibDatabaseMode.BIBLATEX))); @@ -1363,8 +1361,8 @@ public TelemetryPreferences getTelemetryPreferences() { return telemetryPreferences; } telemetryPreferences = new TelemetryPreferences( - getBoolean(COLLECT_TELEMETRY), - !getBoolean(ALREADY_ASKED_TO_COLLECT_TELEMETRY) // mind the ! + getBoolean(COLLECT_TELEMETRY), + !getBoolean(ALREADY_ASKED_TO_COLLECT_TELEMETRY) // mind the ! ); EasyBind.listen(telemetryPreferences.collectTelemetryProperty(), (obs, oldValue, newValue) -> putBoolean(COLLECT_TELEMETRY, newValue)); EasyBind.listen(telemetryPreferences.askToCollectTelemetryProperty(), (obs, oldValue, newValue) -> putBoolean(ALREADY_ASKED_TO_COLLECT_TELEMETRY, !newValue)); @@ -1377,8 +1375,8 @@ public DOIPreferences getDOIPreferences() { return doiPreferences; } doiPreferences = new DOIPreferences( - getBoolean(USE_CUSTOM_DOI_URI), - get(BASE_DOI_URI)); + getBoolean(USE_CUSTOM_DOI_URI), + get(BASE_DOI_URI)); EasyBind.listen(doiPreferences.useCustomProperty(), (obs, oldValue, newValue) -> putBoolean(USE_CUSTOM_DOI_URI, newValue)); EasyBind.listen(doiPreferences.defaultBaseURIProperty(), (obs, oldValue, newValue) -> put(BASE_DOI_URI, newValue)); return doiPreferences; @@ -1390,9 +1388,9 @@ public OwnerPreferences getOwnerPreferences() { return ownerPreferences; } ownerPreferences = new OwnerPreferences( - getBoolean(USE_OWNER), - get(DEFAULT_OWNER), - getBoolean(OVERWRITE_OWNER)); + getBoolean(USE_OWNER), + get(DEFAULT_OWNER), + getBoolean(OVERWRITE_OWNER)); EasyBind.listen(ownerPreferences.useOwnerProperty(), (obs, oldValue, newValue) -> putBoolean(USE_OWNER, newValue)); EasyBind.listen(ownerPreferences.defaultOwnerProperty(), (obs, oldValue, newValue) -> put(DEFAULT_OWNER, newValue)); EasyBind.listen(ownerPreferences.overwriteOwnerProperty(), (obs, oldValue, newValue) -> putBoolean(OVERWRITE_OWNER, newValue)); @@ -1405,11 +1403,11 @@ public TimestampPreferences getTimestampPreferences() { return timestampPreferences; } timestampPreferences = new TimestampPreferences( - getBoolean(ADD_CREATION_DATE), - getBoolean(ADD_MODIFICATION_DATE), - getBoolean(UPDATE_TIMESTAMP), - FieldFactory.parseField(get(TIME_STAMP_FIELD)), - get(TIME_STAMP_FORMAT)); + getBoolean(ADD_CREATION_DATE), + getBoolean(ADD_MODIFICATION_DATE), + getBoolean(UPDATE_TIMESTAMP), + FieldFactory.parseField(get(TIME_STAMP_FIELD)), + get(TIME_STAMP_FORMAT)); EasyBind.listen(timestampPreferences.addCreationDateProperty(), (obs, oldValue, newValue) -> putBoolean(ADD_CREATION_DATE, newValue)); EasyBind.listen(timestampPreferences.addModificationDateProperty(), (obs, oldValue, newValue) -> putBoolean(ADD_MODIFICATION_DATE, newValue)); @@ -1428,10 +1426,10 @@ public Character getKeywordDelimiter() { @Override public GroupsPreferences getGroupsPreferences() { return new GroupsPreferences( - GroupViewMode.valueOf(get(GROUP_INTERSECT_UNION_VIEW_MODE)), - getBoolean(AUTO_ASSIGN_GROUP), - getBoolean(DISPLAY_GROUP_COUNT), - get(KEYWORD_SEPARATOR).charAt(0)); + GroupViewMode.valueOf(get(GROUP_INTERSECT_UNION_VIEW_MODE)), + getBoolean(AUTO_ASSIGN_GROUP), + getBoolean(DISPLAY_GROUP_COUNT), + get(KEYWORD_SEPARATOR).charAt(0)); } @Override @@ -1580,14 +1578,14 @@ public EntryEditorPreferences getEntryEditorPreferences() { } entryEditorPreferences = new EntryEditorPreferences(getEntryEditorTabList(), - getBoolean(AUTO_OPEN_FORM), - getBoolean(SHOW_RECOMMENDATIONS), - getBoolean(ACCEPT_RECOMMENDATIONS), - getBoolean(SHOW_LATEX_CITATIONS), - getBoolean(DEFAULT_SHOW_SOURCE), - getBoolean(VALIDATE_IN_ENTRY_EDITOR), - getBoolean(ALLOW_INTEGER_EDITION_BIBTEX), - getDouble(ENTRY_EDITOR_HEIGHT)); + getBoolean(AUTO_OPEN_FORM), + getBoolean(SHOW_RECOMMENDATIONS), + getBoolean(ACCEPT_RECOMMENDATIONS), + getBoolean(SHOW_LATEX_CITATIONS), + getBoolean(DEFAULT_SHOW_SOURCE), + getBoolean(VALIDATE_IN_ENTRY_EDITOR), + getBoolean(ALLOW_INTEGER_EDITION_BIBTEX), + getDouble(ENTRY_EDITOR_HEIGHT)); EasyBind.listen(entryEditorPreferences.entryEditorTabListProperty(), (obs, oldValue, newValue) -> storeEntryEditorTabList(newValue)); EasyBind.listen(entryEditorPreferences.shouldOpenOnNewEntryProperty(), (obs, oldValue, newValue) -> putBoolean(AUTO_OPEN_FORM, newValue)); @@ -1613,8 +1611,8 @@ public RemotePreferences getRemotePreferences() { } remotePreferences = new RemotePreferences( - getInt(REMOTE_SERVER_PORT), - getBoolean(USE_REMOTE_SERVER)); + getInt(REMOTE_SERVER_PORT), + getBoolean(USE_REMOTE_SERVER)); EasyBind.listen(remotePreferences.portProperty(), (obs, oldValue, newValue) -> putInt(REMOTE_SERVER_PORT, newValue)); EasyBind.listen(remotePreferences.useRemoteServerProperty(), (obs, oldValue, newValue) -> putBoolean(USE_REMOTE_SERVER, newValue)); @@ -1629,12 +1627,12 @@ public ProxyPreferences getProxyPreferences() { } proxyPreferences = new ProxyPreferences( - getBoolean(PROXY_USE), - get(PROXY_HOSTNAME), - get(PROXY_PORT), - getBoolean(PROXY_USE_AUTHENTICATION), - get(PROXY_USERNAME), - get(PROXY_PASSWORD)); + getBoolean(PROXY_USE), + get(PROXY_HOSTNAME), + get(PROXY_PORT), + getBoolean(PROXY_USE_AUTHENTICATION), + get(PROXY_USERNAME), + get(PROXY_PASSWORD)); EasyBind.listen(proxyPreferences.useProxyProperty(), (obs, oldValue, newValue) -> putBoolean(PROXY_USE, newValue)); EasyBind.listen(proxyPreferences.hostnameProperty(), (obs, oldValue, newValue) -> put(PROXY_HOSTNAME, newValue)); @@ -1675,8 +1673,8 @@ public void updateGlobalCitationKeyPattern() { if (keys.length > 0) { for (String key : keys) { this.globalCitationKeyPattern.addCitationKeyPattern( - EntryTypeFactory.parse(key), - preferences.get(key, null)); + EntryTypeFactory.parse(key), + preferences.get(key, null)); } } } catch (BackingStoreException ex) { @@ -1693,7 +1691,7 @@ public void storeGlobalCitationKeyPattern(GlobalCitationKeyPattern pattern) { this.globalCitationKeyPattern = pattern; if ((this.globalCitationKeyPattern.getDefaultValue() == null) - || this.globalCitationKeyPattern.getDefaultValue().isEmpty()) { + || this.globalCitationKeyPattern.getDefaultValue().isEmpty()) { put(DEFAULT_CITATION_KEY_PATTERN, ""); } else { put(DEFAULT_CITATION_KEY_PATTERN, globalCitationKeyPattern.getDefaultValue().get(0)); @@ -1725,8 +1723,7 @@ private void clearCitationKeyPatterns() throws BackingStoreException { @Override public CitationKeyPatternPreferences getCitationKeyPatternPreferences() { - CitationKeyPatternPreferences.KeySuffix keySuffix = - CitationKeyPatternPreferences.KeySuffix.SECOND_WITH_B; + CitationKeyPatternPreferences.KeySuffix keySuffix = CitationKeyPatternPreferences.KeySuffix.SECOND_WITH_B; if (getBoolean(KEY_GEN_ALWAYS_ADD_LETTER)) { keySuffix = CitationKeyPatternPreferences.KeySuffix.ALWAYS; @@ -1735,15 +1732,15 @@ public CitationKeyPatternPreferences getCitationKeyPatternPreferences() { } return new CitationKeyPatternPreferences( - getBoolean(AVOID_OVERWRITING_KEY), - getBoolean(WARN_BEFORE_OVERWRITING_KEY), - getBoolean(GENERATE_KEYS_BEFORE_SAVING), - keySuffix, - get(KEY_PATTERN_REGEX), - get(KEY_PATTERN_REPLACEMENT), - get(UNWANTED_CITATION_KEY_CHARACTERS), - getGlobalCitationKeyPattern(), - getKeywordDelimiter()); + getBoolean(AVOID_OVERWRITING_KEY), + getBoolean(WARN_BEFORE_OVERWRITING_KEY), + getBoolean(GENERATE_KEYS_BEFORE_SAVING), + keySuffix, + get(KEY_PATTERN_REGEX), + get(KEY_PATTERN_REPLACEMENT), + get(UNWANTED_CITATION_KEY_CHARACTERS), + getGlobalCitationKeyPattern(), + getKeywordDelimiter()); } @Override @@ -1789,10 +1786,9 @@ public PushToApplicationPreferences getPushToApplicationPreferences() { applicationCommands.put(PushToApplicationConstants.WIN_EDT, get(PUSH_WINEDT_PATH)); return new PushToApplicationPreferences( - applicationCommands, - get(PUSH_EMACS_ADDITIONAL_PARAMETERS), - get(PUSH_VIM_SERVER) - ); + applicationCommands, + get(PUSH_EMACS_ADDITIONAL_PARAMETERS), + get(PUSH_VIM_SERVER)); } @Override @@ -1811,14 +1807,14 @@ public void storePushToApplicationPreferences(PushToApplicationPreferences prefe @Override public ExternalApplicationsPreferences getExternalApplicationsPreferences() { return new ExternalApplicationsPreferences( - get(EMAIL_SUBJECT), - getBoolean(OPEN_FOLDERS_OF_ATTACHED_FILES), - get(PUSH_TO_APPLICATION), - get(CITE_COMMAND), - !getBoolean(USE_DEFAULT_CONSOLE_APPLICATION), // mind the ! - get(CONSOLE_COMMAND), - !getBoolean(USE_DEFAULT_FILE_BROWSER_APPLICATION), // mind the ! - get(FILE_BROWSER_COMMAND)); + get(EMAIL_SUBJECT), + getBoolean(OPEN_FOLDERS_OF_ATTACHED_FILES), + get(PUSH_TO_APPLICATION), + get(CITE_COMMAND), + !getBoolean(USE_DEFAULT_CONSOLE_APPLICATION), // mind the ! + get(CONSOLE_COMMAND), + !getBoolean(USE_DEFAULT_FILE_BROWSER_APPLICATION), // mind the ! + get(FILE_BROWSER_COMMAND)); } @Override @@ -1839,14 +1835,14 @@ public void storeExternalApplicationsPreferences(ExternalApplicationsPreferences private List createMainTableColumns() { if (this.mainTableColumns == null) { - this.mainTableColumns = updateColumns(COLUMN_NAMES, COLUMN_WIDTHS, COLUMN_SORT_TYPES, MainTableColumnPreferences.DEFAULT_COLUMN_WIDTH); + this.mainTableColumns = updateColumns(COLUMN_NAMES, COLUMN_WIDTHS, COLUMN_SORT_TYPES, ColumnPreferences.DEFAULT_COLUMN_WIDTH); } return this.mainTableColumns; } @Override public void updateMainTableColumns() { - mainTableColumns = updateColumns(COLUMN_NAMES, COLUMN_WIDTHS, COLUMN_SORT_TYPES, MainTableColumnPreferences.DEFAULT_COLUMN_WIDTH); + mainTableColumns = updateColumns(COLUMN_NAMES, COLUMN_WIDTHS, COLUMN_SORT_TYPES, ColumnPreferences.DEFAULT_COLUMN_WIDTH); } /** @@ -1862,10 +1858,10 @@ private List createMainTableColumnSortOrder() { } @Override - public MainTableColumnPreferences getColumnPreferences() { - return new MainTableColumnPreferences( - createMainTableColumns(), - createMainTableColumnSortOrder()); + public ColumnPreferences getColumnPreferences() { + return new ColumnPreferences( + createMainTableColumns(), + createMainTableColumnSortOrder()); } /** @@ -1874,7 +1870,7 @@ public MainTableColumnPreferences getColumnPreferences() { * @param columnPreferences the preferences to store */ @Override - public void storeMainTableColumnPreferences(MainTableColumnPreferences columnPreferences) { + public void storeMainTableColumnPreferences(ColumnPreferences columnPreferences) { // Update cache mainTableColumns = storeColumnPreferences(columnPreferences, COLUMN_NAMES, COLUMN_WIDTHS, COLUMN_SORT_TYPES, COLUMN_SORT_ORDER); } @@ -1882,8 +1878,8 @@ public void storeMainTableColumnPreferences(MainTableColumnPreferences columnPre @Override public MainTablePreferences getMainTablePreferences() { return new MainTablePreferences(getColumnPreferences(), - getBoolean(AUTO_RESIZE_MODE), - getBoolean(EXTRA_FILE_COLUMNS)); + getBoolean(AUTO_RESIZE_MODE), + getBoolean(EXTRA_FILE_COLUMNS)); } @Override @@ -1912,8 +1908,8 @@ public MainTableNameFormatPreferences getMainTableNameFormatPreferences() { } return new MainTableNameFormatPreferences( - displayStyle, - abbreviationStyle); + displayStyle, + abbreviationStyle); } @Override @@ -1933,21 +1929,21 @@ public void storeMainTableNameFormatPreferences(MainTableNameFormatPreferences p public List updateColumns(String columnNamesList, String columnWidthList, String sortTypeList, double defaultWidth) { List columnNames = getStringList(columnNamesList); List columnWidths = getStringList(columnWidthList) - .stream() - .map(string -> { - try { - return Double.parseDouble(string); - } catch (NumberFormatException e) { - LOGGER.error("Exception while parsing column widths. Choosing default.", e); - return defaultWidth; - } - }) - .collect(Collectors.toList()); + .stream() + .map(string -> { + try { + return Double.parseDouble(string); + } catch (NumberFormatException e) { + LOGGER.error("Exception while parsing column widths. Choosing default.", e); + return defaultWidth; + } + }) + .collect(Collectors.toList()); List columnSortTypes = getStringList(sortTypeList) - .stream() - .map(SortType::valueOf) - .collect(Collectors.toList()); + .stream() + .map(SortType::valueOf) + .collect(Collectors.toList()); List columns = new ArrayList<>(); for (int i = 0; i < columnNames.size(); i++) { @@ -1968,7 +1964,7 @@ public List updateColumns(String columnNamesList, String c private List createSearchDialogColumns() { if (this.searchDialogTableColunns == null) { - this.searchDialogTableColunns = updateColumns(COLUMN_NAMES, SEARCH_DIALOG_COLUMN_WIDTHS, SEARCH_DIALOG_COLUMN_SORT_TYPES, SearchDialogColumnPreferences.DEFAULT_COLUMN_WIDTH); + this.searchDialogTableColunns = updateColumns(COLUMN_NAMES, SEARCH_DIALOG_COLUMN_WIDTHS, SEARCH_DIALOG_COLUMN_SORT_TYPES, ColumnPreferences.DEFAULT_COLUMN_WIDTH); } return this.searchDialogTableColunns; } @@ -1989,22 +1985,20 @@ private List createSearchDialogColumnSortOrder() { * Reloads the ColumnSortOrder from scratch * @return */ - private List updateColumnSortOrder(String sortOrderList, List tableColumns) { + private List updateColumnSortOrder(String sortOrderList, List tableColumns) { List columnsOrdered = new ArrayList<>(); - getStringList(sortOrderList).forEach(columnName -> - tableColumns.stream().filter(column -> - column.getName().equals(columnName)) - .findFirst() - .ifPresent(columnsOrdered::add)); + getStringList(sortOrderList).forEach(columnName -> tableColumns.stream().filter(column -> column.getName().equals(columnName)) + .findFirst() + .ifPresent(columnsOrdered::add)); - return columnsOrdered; + return columnsOrdered; } @Override - public SearchDialogColumnPreferences getSearchDialogColumnPreferences() { - return new SearchDialogColumnPreferences( - createSearchDialogColumns(), - createSearchDialogColumnSortOrder()); + public ColumnPreferences getSearchDialogColumnPreferences() { + return new ColumnPreferences( + createSearchDialogColumns(), + createSearchDialogColumnSortOrder()); } /** @@ -2013,15 +2007,15 @@ public SearchDialogColumnPreferences getSearchDialogColumnPreferences() { * @param columnPreferences the preferences to store */ @Override - public void storeSearchDialogColumnPreferences(SearchDialogColumnPreferences columnPreferences) { + public void storeSearchDialogColumnPreferences(ColumnPreferences columnPreferences) { searchDialogTableColunns = storeColumnPreferences(columnPreferences, COLUMN_NAMES, SEARCH_DIALOG_COLUMN_WIDTHS, SEARCH_DIALOG_COLUMN_SORT_TYPES, SEARCH_DIALOG_COLUMN_SORT_ORDER); } - private List storeColumnPreferences(AbstractColumnPreferences columnPreferences, String columnNamesList, String columnWidthList, String sortTypeList, String sortOrderList) { + private List storeColumnPreferences(ColumnPreferences columnPreferences, String columnNamesList, String columnWidthList, String sortTypeList, String sortOrderList) { putStringList(columnNamesList, columnPreferences.getColumns().stream() - .map(MainTableColumnModel::getName) - .collect(Collectors.toList())); + .map(MainTableColumnModel::getName) + .collect(Collectors.toList())); List columnWidthsInOrder = new ArrayList<>(); columnPreferences.getColumns().forEach(column -> columnWidthsInOrder.add(column.widthProperty().getValue().toString())); @@ -2032,9 +2026,9 @@ private List storeColumnPreferences(AbstractColumnPreferen putStringList(sortTypeList, columnSortTypesInOrder); putStringList(sortOrderList, columnPreferences - .getColumnSortOrder().stream() - .map(MainTableColumnModel::getName) - .collect(Collectors.toList())); + .getColumnSortOrder().stream() + .map(MainTableColumnModel::getName) + .collect(Collectors.toList())); return columnPreferences.getColumns(); } @@ -2063,10 +2057,9 @@ public AppearancePreferences getAppearancePreferences() { } appearancePreferences = new AppearancePreferences( - getBoolean(OVERRIDE_DEFAULT_FONT_SIZE), - getInt(MAIN_FONT_SIZE), - getTheme() - ); + getBoolean(OVERRIDE_DEFAULT_FONT_SIZE), + getInt(MAIN_FONT_SIZE), + getTheme()); EasyBind.listen(appearancePreferences.shouldOverrideDefaultFontSizeProperty(), (obs, oldValue, newValue) -> putBoolean(OVERRIDE_DEFAULT_FONT_SIZE, newValue)); EasyBind.listen(appearancePreferences.mainFontSizeProperty(), (obs, oldValue, newValue) -> putInt(MAIN_FONT_SIZE, newValue)); @@ -2082,27 +2075,25 @@ public AppearancePreferences getAppearancePreferences() { @Override public ImportFormatPreferences getImportFormatPreferences() { return new ImportFormatPreferences( - getCustomImportFormats(), - getKeywordDelimiter(), - getCitationKeyPatternPreferences(), - getFieldContentParserPreferences(), - getXmpPreferences(), - getDOIPreferences(), - getSpecialFieldsPreferences().isKeywordSyncEnabled()); + getCustomImportFormats(), + getKeywordDelimiter(), + getCitationKeyPatternPreferences(), + getFieldContentParserPreferences(), + getXmpPreferences(), + getDOIPreferences(), + getSpecialFieldsPreferences().isKeywordSyncEnabled()); } @Override public SaveOrderConfig getExportSaveOrder() { List sortCriteria = List.of( - new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_PRIMARY_SORT_FIELD)), getBoolean(EXPORT_PRIMARY_SORT_DESCENDING)), - new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_SECONDARY_SORT_FIELD)), getBoolean(EXPORT_SECONDARY_SORT_DESCENDING)), - new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_TERTIARY_SORT_FIELD)), getBoolean(EXPORT_TERTIARY_SORT_DESCENDING)) - ); + new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_PRIMARY_SORT_FIELD)), getBoolean(EXPORT_PRIMARY_SORT_DESCENDING)), + new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_SECONDARY_SORT_FIELD)), getBoolean(EXPORT_SECONDARY_SORT_DESCENDING)), + new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_TERTIARY_SORT_FIELD)), getBoolean(EXPORT_TERTIARY_SORT_DESCENDING))); return new SaveOrderConfig( - SaveOrderConfig.OrderType.fromBooleans(getBoolean(EXPORT_IN_SPECIFIED_ORDER), getBoolean(EXPORT_IN_ORIGINAL_ORDER)), - sortCriteria - ); + SaveOrderConfig.OrderType.fromBooleans(getBoolean(EXPORT_IN_SPECIFIED_ORDER), getBoolean(EXPORT_IN_ORIGINAL_ORDER)), + sortCriteria); } @Override @@ -2127,8 +2118,8 @@ private SaveOrderConfig loadTableSaveOrder() { for (var column : sortOrder) { boolean descending = (column.getSortType() == SortType.DESCENDING); config.getSortCriteria().add(new SaveOrderConfig.SortCriterion( - FieldFactory.parseField(column.getQualifier()), - descending)); + FieldFactory.parseField(column.getQualifier()), + descending)); } return config; @@ -2147,21 +2138,21 @@ public SavePreferences getSavePreferencesForExport() { } return getSavePreferences() - .withSaveInOriginalOrder(saveInOriginalOrder) - .withSaveOrder(saveOrder) - .withTakeMetadataSaveOrderInAccount(false); + .withSaveInOriginalOrder(saveInOriginalOrder) + .withSaveOrder(saveOrder) + .withTakeMetadataSaveOrderInAccount(false); } @Override public SavePreferences getSavePreferences() { return new SavePreferences( - false, - null, - SavePreferences.DatabaseSaveType.ALL, - true, - this.getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT), - this.getFieldWriterPreferences(), - getCitationKeyPatternPreferences()); + false, + null, + SavePreferences.DatabaseSaveType.ALL, + true, + this.getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT), + this.getFieldWriterPreferences(), + getCitationKeyPatternPreferences()); } @Override @@ -2177,15 +2168,15 @@ public void storeOpenLastFilesOnStartup(boolean openLastFilesOnStartup) { @Override public FieldContentFormatterPreferences getFieldContentParserPreferences() { return new FieldContentFormatterPreferences( - getStringList(NON_WRAPPABLE_FIELDS).stream().map(FieldFactory::parseField).collect(Collectors.toList())); + getStringList(NON_WRAPPABLE_FIELDS).stream().map(FieldFactory::parseField).collect(Collectors.toList())); } @Override public FieldWriterPreferences getFieldWriterPreferences() { return new FieldWriterPreferences( - getBoolean(RESOLVE_STRINGS_ALL_FIELDS), - getStringList(DO_NOT_RESOLVE_STRINGS_FOR).stream().map(FieldFactory::parseField).collect(Collectors.toList()), - getFieldContentParserPreferences()); + getBoolean(RESOLVE_STRINGS_ALL_FIELDS), + getStringList(DO_NOT_RESOLVE_STRINGS_FOR).stream().map(FieldFactory::parseField).collect(Collectors.toList()), + getFieldContentParserPreferences()); } @Override @@ -2221,13 +2212,12 @@ public FilePreferences getFilePreferences() { } filePreferences = new FilePreferences( - getUser(), - get(MAIN_FILE_DIRECTORY), - getBoolean(STORE_RELATIVE_TO_BIB), - get(IMPORT_FILENAMEPATTERN), - get(IMPORT_FILEDIRPATTERN), - getBoolean(DOWNLOAD_LINKED_FILES) - ); + getUser(), + get(MAIN_FILE_DIRECTORY), + getBoolean(STORE_RELATIVE_TO_BIB), + get(IMPORT_FILENAMEPATTERN), + get(IMPORT_FILEDIRPATTERN), + getBoolean(DOWNLOAD_LINKED_FILES)); EasyBind.listen(filePreferences.mainFileDirectoryProperty(), (obs, oldValue, newValue) -> put(MAIN_FILE_DIRECTORY, filePreferences.getFileDirectory().map(Path::toString).orElse(""))); EasyBind.listen(filePreferences.storeFilesRelativeToBibFileProperty(), (obs, oldValue, newValue) -> putBoolean(STORE_RELATIVE_TO_BIB, newValue)); @@ -2244,8 +2234,7 @@ public AutoLinkPreferences getAutoLinkPreferences() { return autoLinkPreferences; } - AutoLinkPreferences.CitationKeyDependency citationKeyDependency = - AutoLinkPreferences.CitationKeyDependency.START; // default + AutoLinkPreferences.CitationKeyDependency citationKeyDependency = AutoLinkPreferences.CitationKeyDependency.START; // default if (getBoolean(AUTOLINK_EXACT_KEY_ONLY)) { citationKeyDependency = AutoLinkPreferences.CitationKeyDependency.EXACT; } else if (getBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY)) { @@ -2253,28 +2242,28 @@ public AutoLinkPreferences getAutoLinkPreferences() { } autoLinkPreferences = new AutoLinkPreferences( - citationKeyDependency, - get(AUTOLINK_REG_EXP_SEARCH_EXPRESSION_KEY), - getBoolean(ASK_AUTO_NAMING_PDFS_AGAIN), - getKeywordDelimiter()); + citationKeyDependency, + get(AUTOLINK_REG_EXP_SEARCH_EXPRESSION_KEY), + getBoolean(ASK_AUTO_NAMING_PDFS_AGAIN), + getKeywordDelimiter()); EasyBind.listen(autoLinkPreferences.citationKeyDependencyProperty(), (obs, oldValue, newValue) -> { - // Starts bibtex only omitted, as it is not being saved - switch (newValue) { - case START -> { - putBoolean(AUTOLINK_EXACT_KEY_ONLY, false); - putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, false); - } - case EXACT -> { - putBoolean(AUTOLINK_EXACT_KEY_ONLY, true); - putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, false); - } - case REGEX -> { - putBoolean(AUTOLINK_EXACT_KEY_ONLY, false); - putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, true); - } - } - }); + // Starts bibtex only omitted, as it is not being saved + switch (newValue) { + case START -> { + putBoolean(AUTOLINK_EXACT_KEY_ONLY, false); + putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, false); + } + case EXACT -> { + putBoolean(AUTOLINK_EXACT_KEY_ONLY, true); + putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, false); + } + case REGEX -> { + putBoolean(AUTOLINK_EXACT_KEY_ONLY, false); + putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, true); + } + } + }); EasyBind.listen(autoLinkPreferences.askAutoNamingPdfsProperty(), (obs, oldValue, newValue) -> putBoolean(ASK_AUTO_NAMING_PDFS_AGAIN, newValue)); EasyBind.listen(autoLinkPreferences.regularExpressionProperty(), (obs, oldValue, newValue) -> put(AUTOLINK_REG_EXP_SEARCH_EXPRESSION_KEY, newValue)); @@ -2302,14 +2291,14 @@ public ImportExportPreferences getImportExportPreferences() { } importExportPreferences = new ImportExportPreferences( - get(NON_WRAPPABLE_FIELDS), - !getBoolean(RESOLVE_STRINGS_ALL_FIELDS), - getBoolean(RESOLVE_STRINGS_ALL_FIELDS), - get(DO_NOT_RESOLVE_STRINGS_FOR), - getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT), - Path.of(get(IMPORT_WORKING_DIRECTORY)), - get(LAST_USED_EXPORT), - Path.of(get(EXPORT_WORKING_DIRECTORY))); + get(NON_WRAPPABLE_FIELDS), + !getBoolean(RESOLVE_STRINGS_ALL_FIELDS), + getBoolean(RESOLVE_STRINGS_ALL_FIELDS), + get(DO_NOT_RESOLVE_STRINGS_FOR), + getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT), + Path.of(get(IMPORT_WORKING_DIRECTORY)), + get(LAST_USED_EXPORT), + Path.of(get(EXPORT_WORKING_DIRECTORY))); EasyBind.listen(importExportPreferences.nonWrappableFieldsProperty(), (obs, oldValue, newValue) -> put(NON_WRAPPABLE_FIELDS, newValue)); EasyBind.listen(importExportPreferences.resolveStringsForStandardBibtexFieldsProperty(), (obs, oldValue, newValue) -> putBoolean(RESOLVE_STRINGS_ALL_FIELDS, newValue)); @@ -2386,7 +2375,7 @@ public List getCustomExportFormats(JournalAbbreviationReposito filename = formatData.get(EXPORTER_FILENAME_INDEX); extension = formatData.get(EXPORTER_EXTENSION_INDEX); TemplateExporter format = new TemplateExporter(exporterName, filename, extension, - layoutPreferences, savePreferences); + layoutPreferences, savePreferences); format.setCustomExport(true); formats.add(format); i++; @@ -2498,14 +2487,12 @@ public SidePanePreferences getSidePanePreferences() { } sidePanePreferences = new SidePanePreferences( - getVisiblePanes(), - getSidePanePreferredPositions(), - getInt(SELECTED_FETCHER_INDEX)); - - sidePanePreferences.visiblePanes().addListener((InvalidationListener) listener -> - storeVisiblePanes(sidePanePreferences.visiblePanes())); - sidePanePreferences.getPreferredPositions().addListener((InvalidationListener) listener -> - storeSidePanePreferredPositions(sidePanePreferences.getPreferredPositions())); + getVisiblePanes(), + getSidePanePreferredPositions(), + getInt(SELECTED_FETCHER_INDEX)); + + sidePanePreferences.visiblePanes().addListener((InvalidationListener) listener -> storeVisiblePanes(sidePanePreferences.visiblePanes())); + sidePanePreferences.getPreferredPositions().addListener((InvalidationListener) listener -> storeSidePanePreferredPositions(sidePanePreferences.getPreferredPositions())); EasyBind.listen(sidePanePreferences.webSearchFetcherSelectedProperty(), (obs, oldValue, newValue) -> putInt(SELECTED_FETCHER_INDEX, newValue)); return sidePanePreferences; @@ -2577,15 +2564,15 @@ public GuiPreferences getGuiPreferences() { } guiPreferences = new GuiPreferences( - getDouble(POS_X), - getDouble(POS_Y), - getDouble(SIZE_X), - getDouble(SIZE_Y), - getBoolean(WINDOW_MAXIMISED), - getBoolean(OPEN_LAST_EDITED), - getStringList(LAST_EDITED), - Path.of(get(LAST_FOCUSED)), - getDouble(SIDE_PANE_WIDTH)); + getDouble(POS_X), + getDouble(POS_Y), + getDouble(SIZE_X), + getDouble(SIZE_Y), + getBoolean(WINDOW_MAXIMISED), + getBoolean(OPEN_LAST_EDITED), + getStringList(LAST_EDITED), + Path.of(get(LAST_FOCUSED)), + getDouble(SIDE_PANE_WIDTH)); EasyBind.listen(guiPreferences.positionXProperty(), (obs, oldValue, newValue) -> putDouble(POS_X, newValue.doubleValue())); EasyBind.listen(guiPreferences.positionYProperty(), (obs, oldValue, newValue) -> putDouble(POS_Y, newValue.doubleValue())); @@ -2593,8 +2580,7 @@ public GuiPreferences getGuiPreferences() { EasyBind.listen(guiPreferences.sizeYProperty(), (obs, oldValue, newValue) -> putDouble(SIZE_Y, newValue.doubleValue())); EasyBind.listen(guiPreferences.windowMaximisedProperty(), (obs, oldValue, newValue) -> putBoolean(WINDOW_MAXIMISED, newValue)); EasyBind.listen(guiPreferences.openLastEditedProperty(), (obs, oldValue, newValue) -> putBoolean(OPEN_LAST_EDITED, newValue)); - guiPreferences.getLastFilesOpened().addListener((InvalidationListener) change -> - putStringList(LAST_EDITED, guiPreferences.getLastFilesOpened())); + guiPreferences.getLastFilesOpened().addListener((InvalidationListener) change -> putStringList(LAST_EDITED, guiPreferences.getLastFilesOpened())); EasyBind.listen(guiPreferences.lastFocusedFileProperty(), (obs, oldValue, newValue) -> { if (newValue != null) { put(LAST_FOCUSED, newValue.toAbsolutePath().toString()); @@ -2631,19 +2617,19 @@ public SearchPreferences getSearchPreferences() { } searchPreferences = new SearchPreferences( - searchDisplayMode, - getBoolean(SEARCH_CASE_SENSITIVE), - getBoolean(SEARCH_REG_EXP), - getBoolean(SEARCH_FULLTEXT), - getBoolean(SEARCH_KEEP_SEARCH_STRING), - getBoolean(SEARCH_KEEP_GLOBAL_WINDOW_ON_TOP)); + searchDisplayMode, + getBoolean(SEARCH_CASE_SENSITIVE), + getBoolean(SEARCH_REG_EXP), + getBoolean(SEARCH_FULLTEXT), + getBoolean(SEARCH_KEEP_SEARCH_STRING), + getBoolean(SEARCH_KEEP_GLOBAL_WINDOW_ON_TOP)); EasyBind.listen(searchPreferences.searchDisplayModeProperty(), (obs, oldValue, newValue) -> put(SEARCH_DISPLAY_MODE, Objects.requireNonNull(searchPreferences.getSearchDisplayMode()).toString())); searchPreferences.getObservableSearchFlags().addListener((SetChangeListener) c -> { - putBoolean(SEARCH_CASE_SENSITIVE, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.CASE_SENSITIVE)); - putBoolean(SEARCH_REG_EXP, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.REGULAR_EXPRESSION)); - putBoolean(SEARCH_FULLTEXT, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.FULLTEXT)); - putBoolean(SEARCH_KEEP_SEARCH_STRING, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.KEEP_SEARCH_STRING)); + putBoolean(SEARCH_CASE_SENSITIVE, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.CASE_SENSITIVE)); + putBoolean(SEARCH_REG_EXP, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.REGULAR_EXPRESSION)); + putBoolean(SEARCH_FULLTEXT, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.FULLTEXT)); + putBoolean(SEARCH_KEEP_SEARCH_STRING, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.KEEP_SEARCH_STRING)); }); EasyBind.listen(searchPreferences.keepWindowOnTopProperty(), (obs, oldValue, newValue) -> putBoolean(SEARCH_KEEP_GLOBAL_WINDOW_ON_TOP, searchPreferences.shouldKeepWindowOnTop())); @@ -2657,9 +2643,9 @@ public SearchPreferences getSearchPreferences() { @Override public XmpPreferences getXmpPreferences() { return new XmpPreferences( - getBoolean(USE_XMP_PRIVACY_FILTER), - getStringList(XMP_PRIVACY_FILTERS).stream().map(FieldFactory::parseField).collect(Collectors.toSet()), - getKeywordDelimiter()); + getBoolean(USE_XMP_PRIVACY_FILTER), + getStringList(XMP_PRIVACY_FILTERS).stream().map(FieldFactory::parseField).collect(Collectors.toSet()), + getKeywordDelimiter()); } @Override @@ -2671,8 +2657,8 @@ public void storeXmpPreferences(XmpPreferences preferences) { @Override public NameFormatterPreferences getNameFormatterPreferences() { return new NameFormatterPreferences( - getStringList(NAME_FORMATER_KEY), - getStringList(NAME_FORMATTER_VALUE)); + getStringList(NAME_FORMATER_KEY), + getStringList(NAME_FORMATTER_VALUE)); } @Override @@ -2691,11 +2677,11 @@ public AutoCompletePreferences getAutoCompletePreferences() { } return new AutoCompletePreferences( - getBoolean(AUTO_COMPLETE), - AutoCompleteFirstNameMode.parse(get(AUTOCOMPLETER_FIRSTNAME_MODE)), - nameFormat, - getStringList(AUTOCOMPLETER_COMPLETE_FIELDS).stream().map(FieldFactory::parseField).collect(Collectors.toSet()), - getJournalAbbreviationPreferences()); + getBoolean(AUTO_COMPLETE), + AutoCompleteFirstNameMode.parse(get(AUTOCOMPLETER_FIRSTNAME_MODE)), + nameFormat, + getStringList(AUTOCOMPLETER_COMPLETE_FIELDS).stream().map(FieldFactory::parseField).collect(Collectors.toSet()), + getJournalAbbreviationPreferences()); } @Override @@ -2719,9 +2705,9 @@ public void storeAutoCompletePreferences(AutoCompletePreferences preferences) { @Override public SpecialFieldsPreferences getSpecialFieldsPreferences() { return new SpecialFieldsPreferences( - getBoolean(SPECIALFIELDSENABLED), - getBoolean(AUTOSYNCSPECIALFIELDSTOKEYWORDS), - getBoolean(SERIALIZESPECIALFIELDS)); + getBoolean(SPECIALFIELDSENABLED), + getBoolean(AUTOSYNCSPECIALFIELDSTOKEYWORDS), + getBoolean(SERIALIZESPECIALFIELDS)); } @Override @@ -2768,10 +2754,10 @@ public MrDlibPreferences getMrDlibPreferences() { } mrDlibPreferences = new MrDlibPreferences( - getBoolean(ACCEPT_RECOMMENDATIONS), - getBoolean(SEND_LANGUAGE_DATA), - getBoolean(SEND_OS_DATA), - getBoolean(SEND_TIMEZONE_DATA)); + getBoolean(ACCEPT_RECOMMENDATIONS), + getBoolean(SEND_LANGUAGE_DATA), + getBoolean(SEND_OS_DATA), + getBoolean(SEND_TIMEZONE_DATA)); EasyBind.listen(mrDlibPreferences.acceptRecommendationsProperty(), (obs, oldValue, newValue) -> putBoolean(ACCEPT_RECOMMENDATIONS, newValue)); EasyBind.listen(mrDlibPreferences.sendLanguageProperty(), (obs, oldValue, newValue) -> putBoolean(SEND_LANGUAGE_DATA, newValue)); @@ -2798,20 +2784,15 @@ public ProtectedTermsPreferences getProtectedTermsPreferences() { } protectedTermsPreferences = new ProtectedTermsPreferences( - getStringList(PROTECTED_TERMS_ENABLED_INTERNAL), - getStringList(PROTECTED_TERMS_ENABLED_EXTERNAL), - getStringList(PROTECTED_TERMS_DISABLED_INTERNAL), - getStringList(PROTECTED_TERMS_DISABLED_EXTERNAL) - ); + getStringList(PROTECTED_TERMS_ENABLED_INTERNAL), + getStringList(PROTECTED_TERMS_ENABLED_EXTERNAL), + getStringList(PROTECTED_TERMS_DISABLED_INTERNAL), + getStringList(PROTECTED_TERMS_DISABLED_EXTERNAL)); - protectedTermsPreferences.getEnabledExternalTermLists().addListener((InvalidationListener) change -> - putStringList(PROTECTED_TERMS_ENABLED_EXTERNAL, protectedTermsPreferences.getEnabledExternalTermLists())); - protectedTermsPreferences.getDisabledExternalTermLists().addListener((InvalidationListener) change -> - putStringList(PROTECTED_TERMS_DISABLED_EXTERNAL, protectedTermsPreferences.getDisabledExternalTermLists())); - protectedTermsPreferences.getEnabledInternalTermLists().addListener((InvalidationListener) change -> - putStringList(PROTECTED_TERMS_ENABLED_INTERNAL, protectedTermsPreferences.getEnabledInternalTermLists())); - protectedTermsPreferences.getDisabledInternalTermLists().addListener((InvalidationListener) change -> - putStringList(PROTECTED_TERMS_DISABLED_INTERNAL, protectedTermsPreferences.getDisabledInternalTermLists())); + protectedTermsPreferences.getEnabledExternalTermLists().addListener((InvalidationListener) change -> putStringList(PROTECTED_TERMS_ENABLED_EXTERNAL, protectedTermsPreferences.getEnabledExternalTermLists())); + protectedTermsPreferences.getDisabledExternalTermLists().addListener((InvalidationListener) change -> putStringList(PROTECTED_TERMS_DISABLED_EXTERNAL, protectedTermsPreferences.getDisabledExternalTermLists())); + protectedTermsPreferences.getEnabledInternalTermLists().addListener((InvalidationListener) change -> putStringList(PROTECTED_TERMS_ENABLED_INTERNAL, protectedTermsPreferences.getEnabledInternalTermLists())); + protectedTermsPreferences.getDisabledInternalTermLists().addListener((InvalidationListener) change -> putStringList(PROTECTED_TERMS_DISABLED_INTERNAL, protectedTermsPreferences.getDisabledInternalTermLists())); return protectedTermsPreferences; } @@ -2827,11 +2808,10 @@ public ImporterPreferences getImporterPreferences() { } importerPreferences = new ImporterPreferences( - getBoolean(GENERATE_KEY_ON_IMPORT), - getBoolean(GROBID_ENABLED), - getBoolean(GROBID_OPT_OUT), - get(GROBID_URL) - ); + getBoolean(GENERATE_KEY_ON_IMPORT), + getBoolean(GROBID_ENABLED), + getBoolean(GROBID_OPT_OUT), + get(GROBID_URL)); EasyBind.listen(importerPreferences.generateNewKeyOnImportProperty(), (obs, oldValue, newValue) -> putBoolean(GENERATE_KEY_ON_IMPORT, newValue)); EasyBind.listen(importerPreferences.grobidEnabledProperty(), (obs, oldValue, newValue) -> putBoolean(GROBID_ENABLED, newValue)); diff --git a/src/main/java/org/jabref/preferences/PreferencesService.java b/src/main/java/org/jabref/preferences/PreferencesService.java index 23816b80665..a0a66de7c8a 100644 --- a/src/main/java/org/jabref/preferences/PreferencesService.java +++ b/src/main/java/org/jabref/preferences/PreferencesService.java @@ -12,10 +12,9 @@ import org.jabref.gui.groups.GroupViewMode; import org.jabref.gui.groups.GroupsPreferences; import org.jabref.gui.keyboard.KeyBindingRepository; -import org.jabref.gui.maintable.MainTableColumnPreferences; +import org.jabref.gui.maintable.ColumnPreferences; import org.jabref.gui.maintable.MainTableNameFormatPreferences; import org.jabref.gui.maintable.MainTablePreferences; -import org.jabref.gui.maintable.SearchDialogColumnPreferences; import org.jabref.gui.specialfields.SpecialFieldsPreferences; import org.jabref.gui.util.Theme; import org.jabref.logic.JabRefException; @@ -209,9 +208,9 @@ public interface PreferencesService { void updateMainTableColumns(); - MainTableColumnPreferences getColumnPreferences(); + ColumnPreferences getColumnPreferences(); - void storeMainTableColumnPreferences(MainTableColumnPreferences columnPreferences); + void storeMainTableColumnPreferences(ColumnPreferences columnPreferences); MainTablePreferences getMainTablePreferences(); @@ -225,9 +224,9 @@ public interface PreferencesService { // SearchDialogColumnPreferences //************************************************************************************************************* - SearchDialogColumnPreferences getSearchDialogColumnPreferences(); + ColumnPreferences getSearchDialogColumnPreferences(); - void storeSearchDialogColumnPreferences(SearchDialogColumnPreferences columnPreferences); + void storeSearchDialogColumnPreferences(ColumnPreferences columnPreferences); //************************************************************************************************************* // AppearancePreferences From 83dfadf7b910530ce98498a8127bf9456e7b12e1 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 20 Nov 2021 19:41:19 +0100 Subject: [PATCH 06/13] fix checkstlye again --- src/main/java/org/jabref/gui/maintable/columns/FileColumn.java | 2 +- .../jabref/gui/maintable/columns/LinkedIdentifierColumn.java | 2 +- .../org/jabref/gui/maintable/columns/SpecialFieldColumn.java | 2 +- .../org/jabref/gui/preferences/table/TableTabViewModel.java | 2 +- src/main/java/org/jabref/migrations/PreferencesMigrations.java | 2 +- src/main/java/org/jabref/preferences/JabRefPreferences.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java b/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java index 2e9934eecf3..c963ed87b23 100644 --- a/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java +++ b/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java @@ -17,9 +17,9 @@ import org.jabref.gui.fieldeditors.LinkedFileViewModel; import org.jabref.gui.icon.IconTheme; import org.jabref.gui.maintable.BibEntryTableViewModel; +import org.jabref.gui.maintable.ColumnPreferences; import org.jabref.gui.maintable.MainTableColumnFactory; import org.jabref.gui.maintable.MainTableColumnModel; -import org.jabref.gui.maintable.ColumnPreferences; import org.jabref.gui.util.ValueTableCellFactory; import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseContext; diff --git a/src/main/java/org/jabref/gui/maintable/columns/LinkedIdentifierColumn.java b/src/main/java/org/jabref/gui/maintable/columns/LinkedIdentifierColumn.java index 575c146e638..d150bcde358 100644 --- a/src/main/java/org/jabref/gui/maintable/columns/LinkedIdentifierColumn.java +++ b/src/main/java/org/jabref/gui/maintable/columns/LinkedIdentifierColumn.java @@ -15,9 +15,9 @@ import org.jabref.gui.icon.IconTheme; import org.jabref.gui.maintable.BibEntryTableViewModel; import org.jabref.gui.maintable.CellFactory; +import org.jabref.gui.maintable.ColumnPreferences; import org.jabref.gui.maintable.MainTableColumnFactory; import org.jabref.gui.maintable.MainTableColumnModel; -import org.jabref.gui.maintable.ColumnPreferences; import org.jabref.gui.maintable.OpenUrlAction; import org.jabref.gui.util.ControlHelper; import org.jabref.gui.util.ValueTableCellFactory; diff --git a/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java b/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java index 1e550ed7984..271a7abe4cb 100644 --- a/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java +++ b/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java @@ -12,9 +12,9 @@ import org.jabref.gui.icon.JabRefIcon; import org.jabref.gui.maintable.BibEntryTableViewModel; +import org.jabref.gui.maintable.ColumnPreferences; import org.jabref.gui.maintable.MainTableColumnFactory; import org.jabref.gui.maintable.MainTableColumnModel; -import org.jabref.gui.maintable.ColumnPreferences; import org.jabref.gui.specialfields.SpecialFieldValueViewModel; import org.jabref.gui.specialfields.SpecialFieldViewModel; import org.jabref.gui.specialfields.SpecialFieldsPreferences; diff --git a/src/main/java/org/jabref/gui/preferences/table/TableTabViewModel.java b/src/main/java/org/jabref/gui/preferences/table/TableTabViewModel.java index f1390ab27d9..8e3a1300aa9 100644 --- a/src/main/java/org/jabref/gui/preferences/table/TableTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/table/TableTabViewModel.java @@ -17,8 +17,8 @@ import org.jabref.gui.DialogService; import org.jabref.gui.externalfiletype.ExternalFileType; import org.jabref.gui.externalfiletype.ExternalFileTypes; -import org.jabref.gui.maintable.MainTableColumnModel; import org.jabref.gui.maintable.ColumnPreferences; +import org.jabref.gui.maintable.MainTableColumnModel; import org.jabref.gui.maintable.MainTableNameFormatPreferences; import org.jabref.gui.maintable.MainTableNameFormatPreferences.AbbreviationStyle; import org.jabref.gui.maintable.MainTableNameFormatPreferences.DisplayStyle; diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index ea70b5f60f0..6ff137d6d0f 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -15,8 +15,8 @@ import javafx.scene.control.TableColumn; import org.jabref.gui.Globals; -import org.jabref.gui.maintable.MainTableColumnModel; import org.jabref.gui.maintable.ColumnPreferences; +import org.jabref.gui.maintable.MainTableColumnModel; import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern; import org.jabref.model.entry.field.SpecialField; import org.jabref.model.entry.field.StandardField; diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index e33db5a640e..47d785ecd39 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -46,8 +46,8 @@ import org.jabref.gui.groups.GroupViewMode; import org.jabref.gui.groups.GroupsPreferences; import org.jabref.gui.keyboard.KeyBindingRepository; -import org.jabref.gui.maintable.MainTableColumnModel; import org.jabref.gui.maintable.ColumnPreferences; +import org.jabref.gui.maintable.MainTableColumnModel; import org.jabref.gui.maintable.MainTableNameFormatPreferences; import org.jabref.gui.maintable.MainTableNameFormatPreferences.AbbreviationStyle; import org.jabref.gui.maintable.MainTableNameFormatPreferences.DisplayStyle; From c1282f9159e2d1430d19cd71d71d7910a90caf8b Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sun, 21 Nov 2021 18:20:54 +0100 Subject: [PATCH 07/13] Revert reformatting hazard --- .../jabref/preferences/JabRefPreferences.java | 529 +++++++++--------- 1 file changed, 273 insertions(+), 256 deletions(-) diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 47d785ecd39..fa02bf089c8 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -173,8 +173,7 @@ public class JabRefPreferences implements PreferencesService { public static final String COLUMN_SORT_TYPES = "mainTableColumnSortTypes"; public static final String COLUMN_SORT_ORDER = "mainTableColumnSortOrder"; - public static final String SEARCH_DIALOG_COLUMN_NAMES = "searchDialogColumnNames"; - public static final String SEARCH_DIALOG_COLUMN_WIDTHS = "searchDialogColumnWidths"; + public static final String SEARCH_DIALOG_COLUMN_WIDTHS = "searchTableColumnWidths"; public static final String SEARCH_DIALOG_COLUMN_SORT_TYPES = "searchDialogColumnSortTypes"; public static final String SEARCH_DIALOG_COLUMN_SORT_ORDER = "searchDalogColumnSortOrder"; @@ -706,24 +705,24 @@ private JabRefPreferences() { defaults.put(PREVIEW_PANEL_HEIGHT, 0.65); defaults.put(PREVIEW_AS_TAB, Boolean.FALSE); defaults.put(PREVIEW_STYLE, - "" + - "\\bibtextype\\begin{citationkey} (\\citationkey)\\end{citationkey}__NEWLINE__" + - "\\begin{author}

\\format[Authors(LastFirst, FullName,Sep= / ,LastSep= / ),HTMLChars]{\\author}\\end{author}__NEWLINE__" + - "\\begin{editor & !author}

\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & !author}__NEWLINE__" + - "\\begin{title}
\\format[HTMLChars]{\\title} \\end{title}__NEWLINE__" + - "
\\begin{date}\\date\\end{date}\\begin{edition}, \\edition. edition\\end{edition}__NEWLINE__" + - "\\begin{editor & author}

\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & author}__NEWLINE__" + - "\\begin{booktitle}
\\format[HTMLChars]{\\booktitle}\\end{booktitle}__NEWLINE__" + - "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}" + - "\\begin{editor & !author}
\\end{editor & !author}\\begin{!editor}
\\end{!editor}\\begin{journal}
\\format[HTMLChars]{\\journal} \\end{journal} \\begin{volume}, Vol. \\volume\\end{volume}\\begin{series}
\\format[HTMLChars]{\\series}\\end{series}\\begin{number}, No. \\format[HTMLChars]{\\number}\\end{number}__NEWLINE__" + - "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + - "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" + - "\\begin{publisher}
\\format[HTMLChars]{\\publisher}\\end{publisher}\\begin{location}: \\format[HTMLChars]{\\location} \\end{location}__NEWLINE__" + - "\\begin{pages}
p. \\format[FormatPagesForHTML]{\\pages}\\end{pages}__NEWLINE__" + - "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" + - "\\begin{owncitation}

Own citation: \\format[HTMLChars]{\\owncitation} \\end{owncitation}__NEWLINE__" + - "\\begin{comment}

Comment: \\format[HTMLChars]{\\comment}\\end{comment}__NEWLINE__" + - "
__NEWLINE__"); + "" + + "\\bibtextype\\begin{citationkey} (\\citationkey)\\end{citationkey}__NEWLINE__" + + "\\begin{author}

\\format[Authors(LastFirst, FullName,Sep= / ,LastSep= / ),HTMLChars]{\\author}\\end{author}__NEWLINE__" + + "\\begin{editor & !author}

\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & !author}__NEWLINE__" + + "\\begin{title}
\\format[HTMLChars]{\\title} \\end{title}__NEWLINE__" + + "
\\begin{date}\\date\\end{date}\\begin{edition}, \\edition. edition\\end{edition}__NEWLINE__" + + "\\begin{editor & author}

\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & author}__NEWLINE__" + + "\\begin{booktitle}
\\format[HTMLChars]{\\booktitle}\\end{booktitle}__NEWLINE__" + + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}" + + "\\begin{editor & !author}
\\end{editor & !author}\\begin{!editor}
\\end{!editor}\\begin{journal}
\\format[HTMLChars]{\\journal} \\end{journal} \\begin{volume}, Vol. \\volume\\end{volume}\\begin{series}
\\format[HTMLChars]{\\series}\\end{series}\\begin{number}, No. \\format[HTMLChars]{\\number}\\end{number}__NEWLINE__" + + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" + + "\\begin{publisher}
\\format[HTMLChars]{\\publisher}\\end{publisher}\\begin{location}: \\format[HTMLChars]{\\location} \\end{location}__NEWLINE__" + + "\\begin{pages}
p. \\format[FormatPagesForHTML]{\\pages}\\end{pages}__NEWLINE__" + + "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" + + "\\begin{owncitation}

Own citation: \\format[HTMLChars]{\\owncitation} \\end{owncitation}__NEWLINE__" + + "\\begin{comment}

Comment: \\format[HTMLChars]{\\comment}\\end{comment}__NEWLINE__" + + "
__NEWLINE__"); // set default theme defaults.put(FX_THEME, Theme.BASE_CSS); @@ -800,11 +799,11 @@ private static Optional getNextUnit(Reader data) throws IOException { private static void insertDefaultCleanupPreset(Map storage) { EnumSet deactivatedJobs = EnumSet.of( - CleanupPreset.CleanupStep.CLEAN_UP_UPGRADE_EXTERNAL_LINKS, - CleanupPreset.CleanupStep.MOVE_PDF, - CleanupPreset.CleanupStep.RENAME_PDF_ONLY_RELATIVE_PATHS, - CleanupPreset.CleanupStep.CONVERT_TO_BIBLATEX, - CleanupPreset.CleanupStep.CONVERT_TO_BIBTEX); + CleanupPreset.CleanupStep.CLEAN_UP_UPGRADE_EXTERNAL_LINKS, + CleanupPreset.CleanupStep.MOVE_PDF, + CleanupPreset.CleanupStep.RENAME_PDF_ONLY_RELATIVE_PATHS, + CleanupPreset.CleanupStep.CONVERT_TO_BIBLATEX, + CleanupPreset.CleanupStep.CONVERT_TO_BIBTEX); for (CleanupPreset.CleanupStep action : EnumSet.allOf(CleanupPreset.CleanupStep.class)) { storage.put(CLEANUP + action.name(), !deactivatedJobs.contains(action)); @@ -823,7 +822,7 @@ public String getUser() { return userName; } catch (UnknownHostException ex) { LOGGER.error("Hostname not found. Please go to https://docs.jabref.org/ to find possible " + - "problem resolution", ex); + "problem resolution", ex); return get(DEFAULT_OWNER); } } @@ -1073,7 +1072,7 @@ public void exportPreferences(Path file) throws JabRefException { prefs.exportSubtree(os); } catch (BackingStoreException | IOException ex) { throw new JabRefException("Could not export preferences", Localization.lang("Could not export preferences"), - ex); + ex); } } @@ -1089,15 +1088,15 @@ public void importPreferences(Path file) throws JabRefException { Preferences.importPreferences(is); } catch (InvalidPreferencesFormatException | IOException ex) { throw new JabRefException("Could not import preferences", Localization.lang("Could not import preferences"), - ex); + ex); } } @Override public FileLinkPreferences getFileLinkPreferences() { return new FileLinkPreferences( - get(MAIN_FILE_DIRECTORY), // REALLY HERE? - fileDirForDatabase); + get(MAIN_FILE_DIRECTORY), // REALLY HERE? + fileDirForDatabase); } @Override @@ -1108,20 +1107,20 @@ public void storeFileDirforDatabase(List dirs) { @Override public LayoutFormatterPreferences getLayoutFormatterPreferences(JournalAbbreviationRepository repository) { return new LayoutFormatterPreferences( - getNameFormatterPreferences(), - getFileLinkPreferences(), - repository); + getNameFormatterPreferences(), + getFileLinkPreferences(), + repository); } @Override public OpenOfficePreferences getOpenOfficePreferences() { return new OpenOfficePreferences( - get(OO_EXECUTABLE_PATH), - get(OO_PATH), - getBoolean(OO_USE_ALL_OPEN_BASES), - getBoolean(OO_SYNC_WHEN_CITING), - getStringList(OO_EXTERNAL_STYLE_FILES), - get(OO_BIBLIOGRAPHY_STYLE_FILE)); + get(OO_EXECUTABLE_PATH), + get(OO_PATH), + getBoolean(OO_USE_ALL_OPEN_BASES), + getBoolean(OO_SYNC_WHEN_CITING), + getStringList(OO_EXTERNAL_STYLE_FILES), + get(OO_BIBLIOGRAPHY_STYLE_FILE)); } @Override @@ -1153,8 +1152,8 @@ public JournalAbbreviationPreferences getJournalAbbreviationPreferences() { @Override public CleanupPreferences getCleanupPreferences(JournalAbbreviationRepository abbreviationRepository) { return new CleanupPreferences( - getLayoutFormatterPreferences(abbreviationRepository), - getFilePreferences()); + getLayoutFormatterPreferences(abbreviationRepository), + getFilePreferences()); } @Override @@ -1338,12 +1337,12 @@ public GeneralPreferences getGeneralPreferences() { } generalPreferences = new GeneralPreferences( - Charset.forName(get(DEFAULT_ENCODING)), - getBoolean(BIBLATEX_DEFAULT_MODE) ? BibDatabaseMode.BIBLATEX : BibDatabaseMode.BIBTEX, - getBoolean(WARN_ABOUT_DUPLICATES_IN_INSPECTION), - getBoolean(CONFIRM_DELETE), - getBoolean(MEMORY_STICK_MODE), - getBoolean(SHOW_ADVANCED_HINTS)); + Charset.forName(get(DEFAULT_ENCODING)), + getBoolean(BIBLATEX_DEFAULT_MODE) ? BibDatabaseMode.BIBLATEX : BibDatabaseMode.BIBTEX, + getBoolean(WARN_ABOUT_DUPLICATES_IN_INSPECTION), + getBoolean(CONFIRM_DELETE), + getBoolean(MEMORY_STICK_MODE), + getBoolean(SHOW_ADVANCED_HINTS)); EasyBind.listen(generalPreferences.defaultEncodingProperty(), (obs, oldValue, newValue) -> put(DEFAULT_ENCODING, newValue.name())); EasyBind.listen(generalPreferences.defaultBibDatabaseModeProperty(), (obs, oldValue, newValue) -> putBoolean(BIBLATEX_DEFAULT_MODE, (newValue == BibDatabaseMode.BIBLATEX))); @@ -1361,8 +1360,8 @@ public TelemetryPreferences getTelemetryPreferences() { return telemetryPreferences; } telemetryPreferences = new TelemetryPreferences( - getBoolean(COLLECT_TELEMETRY), - !getBoolean(ALREADY_ASKED_TO_COLLECT_TELEMETRY) // mind the ! + getBoolean(COLLECT_TELEMETRY), + !getBoolean(ALREADY_ASKED_TO_COLLECT_TELEMETRY) // mind the ! ); EasyBind.listen(telemetryPreferences.collectTelemetryProperty(), (obs, oldValue, newValue) -> putBoolean(COLLECT_TELEMETRY, newValue)); EasyBind.listen(telemetryPreferences.askToCollectTelemetryProperty(), (obs, oldValue, newValue) -> putBoolean(ALREADY_ASKED_TO_COLLECT_TELEMETRY, !newValue)); @@ -1375,8 +1374,8 @@ public DOIPreferences getDOIPreferences() { return doiPreferences; } doiPreferences = new DOIPreferences( - getBoolean(USE_CUSTOM_DOI_URI), - get(BASE_DOI_URI)); + getBoolean(USE_CUSTOM_DOI_URI), + get(BASE_DOI_URI)); EasyBind.listen(doiPreferences.useCustomProperty(), (obs, oldValue, newValue) -> putBoolean(USE_CUSTOM_DOI_URI, newValue)); EasyBind.listen(doiPreferences.defaultBaseURIProperty(), (obs, oldValue, newValue) -> put(BASE_DOI_URI, newValue)); return doiPreferences; @@ -1388,9 +1387,9 @@ public OwnerPreferences getOwnerPreferences() { return ownerPreferences; } ownerPreferences = new OwnerPreferences( - getBoolean(USE_OWNER), - get(DEFAULT_OWNER), - getBoolean(OVERWRITE_OWNER)); + getBoolean(USE_OWNER), + get(DEFAULT_OWNER), + getBoolean(OVERWRITE_OWNER)); EasyBind.listen(ownerPreferences.useOwnerProperty(), (obs, oldValue, newValue) -> putBoolean(USE_OWNER, newValue)); EasyBind.listen(ownerPreferences.defaultOwnerProperty(), (obs, oldValue, newValue) -> put(DEFAULT_OWNER, newValue)); EasyBind.listen(ownerPreferences.overwriteOwnerProperty(), (obs, oldValue, newValue) -> putBoolean(OVERWRITE_OWNER, newValue)); @@ -1403,11 +1402,11 @@ public TimestampPreferences getTimestampPreferences() { return timestampPreferences; } timestampPreferences = new TimestampPreferences( - getBoolean(ADD_CREATION_DATE), - getBoolean(ADD_MODIFICATION_DATE), - getBoolean(UPDATE_TIMESTAMP), - FieldFactory.parseField(get(TIME_STAMP_FIELD)), - get(TIME_STAMP_FORMAT)); + getBoolean(ADD_CREATION_DATE), + getBoolean(ADD_MODIFICATION_DATE), + getBoolean(UPDATE_TIMESTAMP), + FieldFactory.parseField(get(TIME_STAMP_FIELD)), + get(TIME_STAMP_FORMAT)); EasyBind.listen(timestampPreferences.addCreationDateProperty(), (obs, oldValue, newValue) -> putBoolean(ADD_CREATION_DATE, newValue)); EasyBind.listen(timestampPreferences.addModificationDateProperty(), (obs, oldValue, newValue) -> putBoolean(ADD_MODIFICATION_DATE, newValue)); @@ -1426,10 +1425,10 @@ public Character getKeywordDelimiter() { @Override public GroupsPreferences getGroupsPreferences() { return new GroupsPreferences( - GroupViewMode.valueOf(get(GROUP_INTERSECT_UNION_VIEW_MODE)), - getBoolean(AUTO_ASSIGN_GROUP), - getBoolean(DISPLAY_GROUP_COUNT), - get(KEYWORD_SEPARATOR).charAt(0)); + GroupViewMode.valueOf(get(GROUP_INTERSECT_UNION_VIEW_MODE)), + getBoolean(AUTO_ASSIGN_GROUP), + getBoolean(DISPLAY_GROUP_COUNT), + get(KEYWORD_SEPARATOR).charAt(0)); } @Override @@ -1578,14 +1577,14 @@ public EntryEditorPreferences getEntryEditorPreferences() { } entryEditorPreferences = new EntryEditorPreferences(getEntryEditorTabList(), - getBoolean(AUTO_OPEN_FORM), - getBoolean(SHOW_RECOMMENDATIONS), - getBoolean(ACCEPT_RECOMMENDATIONS), - getBoolean(SHOW_LATEX_CITATIONS), - getBoolean(DEFAULT_SHOW_SOURCE), - getBoolean(VALIDATE_IN_ENTRY_EDITOR), - getBoolean(ALLOW_INTEGER_EDITION_BIBTEX), - getDouble(ENTRY_EDITOR_HEIGHT)); + getBoolean(AUTO_OPEN_FORM), + getBoolean(SHOW_RECOMMENDATIONS), + getBoolean(ACCEPT_RECOMMENDATIONS), + getBoolean(SHOW_LATEX_CITATIONS), + getBoolean(DEFAULT_SHOW_SOURCE), + getBoolean(VALIDATE_IN_ENTRY_EDITOR), + getBoolean(ALLOW_INTEGER_EDITION_BIBTEX), + getDouble(ENTRY_EDITOR_HEIGHT)); EasyBind.listen(entryEditorPreferences.entryEditorTabListProperty(), (obs, oldValue, newValue) -> storeEntryEditorTabList(newValue)); EasyBind.listen(entryEditorPreferences.shouldOpenOnNewEntryProperty(), (obs, oldValue, newValue) -> putBoolean(AUTO_OPEN_FORM, newValue)); @@ -1611,8 +1610,8 @@ public RemotePreferences getRemotePreferences() { } remotePreferences = new RemotePreferences( - getInt(REMOTE_SERVER_PORT), - getBoolean(USE_REMOTE_SERVER)); + getInt(REMOTE_SERVER_PORT), + getBoolean(USE_REMOTE_SERVER)); EasyBind.listen(remotePreferences.portProperty(), (obs, oldValue, newValue) -> putInt(REMOTE_SERVER_PORT, newValue)); EasyBind.listen(remotePreferences.useRemoteServerProperty(), (obs, oldValue, newValue) -> putBoolean(USE_REMOTE_SERVER, newValue)); @@ -1627,12 +1626,12 @@ public ProxyPreferences getProxyPreferences() { } proxyPreferences = new ProxyPreferences( - getBoolean(PROXY_USE), - get(PROXY_HOSTNAME), - get(PROXY_PORT), - getBoolean(PROXY_USE_AUTHENTICATION), - get(PROXY_USERNAME), - get(PROXY_PASSWORD)); + getBoolean(PROXY_USE), + get(PROXY_HOSTNAME), + get(PROXY_PORT), + getBoolean(PROXY_USE_AUTHENTICATION), + get(PROXY_USERNAME), + get(PROXY_PASSWORD)); EasyBind.listen(proxyPreferences.useProxyProperty(), (obs, oldValue, newValue) -> putBoolean(PROXY_USE, newValue)); EasyBind.listen(proxyPreferences.hostnameProperty(), (obs, oldValue, newValue) -> put(PROXY_HOSTNAME, newValue)); @@ -1673,8 +1672,8 @@ public void updateGlobalCitationKeyPattern() { if (keys.length > 0) { for (String key : keys) { this.globalCitationKeyPattern.addCitationKeyPattern( - EntryTypeFactory.parse(key), - preferences.get(key, null)); + EntryTypeFactory.parse(key), + preferences.get(key, null)); } } } catch (BackingStoreException ex) { @@ -1691,7 +1690,7 @@ public void storeGlobalCitationKeyPattern(GlobalCitationKeyPattern pattern) { this.globalCitationKeyPattern = pattern; if ((this.globalCitationKeyPattern.getDefaultValue() == null) - || this.globalCitationKeyPattern.getDefaultValue().isEmpty()) { + || this.globalCitationKeyPattern.getDefaultValue().isEmpty()) { put(DEFAULT_CITATION_KEY_PATTERN, ""); } else { put(DEFAULT_CITATION_KEY_PATTERN, globalCitationKeyPattern.getDefaultValue().get(0)); @@ -1723,7 +1722,8 @@ private void clearCitationKeyPatterns() throws BackingStoreException { @Override public CitationKeyPatternPreferences getCitationKeyPatternPreferences() { - CitationKeyPatternPreferences.KeySuffix keySuffix = CitationKeyPatternPreferences.KeySuffix.SECOND_WITH_B; + CitationKeyPatternPreferences.KeySuffix keySuffix = + CitationKeyPatternPreferences.KeySuffix.SECOND_WITH_B; if (getBoolean(KEY_GEN_ALWAYS_ADD_LETTER)) { keySuffix = CitationKeyPatternPreferences.KeySuffix.ALWAYS; @@ -1732,15 +1732,15 @@ public CitationKeyPatternPreferences getCitationKeyPatternPreferences() { } return new CitationKeyPatternPreferences( - getBoolean(AVOID_OVERWRITING_KEY), - getBoolean(WARN_BEFORE_OVERWRITING_KEY), - getBoolean(GENERATE_KEYS_BEFORE_SAVING), - keySuffix, - get(KEY_PATTERN_REGEX), - get(KEY_PATTERN_REPLACEMENT), - get(UNWANTED_CITATION_KEY_CHARACTERS), - getGlobalCitationKeyPattern(), - getKeywordDelimiter()); + getBoolean(AVOID_OVERWRITING_KEY), + getBoolean(WARN_BEFORE_OVERWRITING_KEY), + getBoolean(GENERATE_KEYS_BEFORE_SAVING), + keySuffix, + get(KEY_PATTERN_REGEX), + get(KEY_PATTERN_REPLACEMENT), + get(UNWANTED_CITATION_KEY_CHARACTERS), + getGlobalCitationKeyPattern(), + getKeywordDelimiter()); } @Override @@ -1786,9 +1786,10 @@ public PushToApplicationPreferences getPushToApplicationPreferences() { applicationCommands.put(PushToApplicationConstants.WIN_EDT, get(PUSH_WINEDT_PATH)); return new PushToApplicationPreferences( - applicationCommands, - get(PUSH_EMACS_ADDITIONAL_PARAMETERS), - get(PUSH_VIM_SERVER)); + applicationCommands, + get(PUSH_EMACS_ADDITIONAL_PARAMETERS), + get(PUSH_VIM_SERVER) + ); } @Override @@ -1807,14 +1808,14 @@ public void storePushToApplicationPreferences(PushToApplicationPreferences prefe @Override public ExternalApplicationsPreferences getExternalApplicationsPreferences() { return new ExternalApplicationsPreferences( - get(EMAIL_SUBJECT), - getBoolean(OPEN_FOLDERS_OF_ATTACHED_FILES), - get(PUSH_TO_APPLICATION), - get(CITE_COMMAND), - !getBoolean(USE_DEFAULT_CONSOLE_APPLICATION), // mind the ! - get(CONSOLE_COMMAND), - !getBoolean(USE_DEFAULT_FILE_BROWSER_APPLICATION), // mind the ! - get(FILE_BROWSER_COMMAND)); + get(EMAIL_SUBJECT), + getBoolean(OPEN_FOLDERS_OF_ATTACHED_FILES), + get(PUSH_TO_APPLICATION), + get(CITE_COMMAND), + !getBoolean(USE_DEFAULT_CONSOLE_APPLICATION), // mind the ! + get(CONSOLE_COMMAND), + !getBoolean(USE_DEFAULT_FILE_BROWSER_APPLICATION), // mind the ! + get(FILE_BROWSER_COMMAND)); } @Override @@ -1860,8 +1861,8 @@ private List createMainTableColumnSortOrder() { @Override public ColumnPreferences getColumnPreferences() { return new ColumnPreferences( - createMainTableColumns(), - createMainTableColumnSortOrder()); + createMainTableColumns(), + createMainTableColumnSortOrder()); } /** @@ -1878,8 +1879,8 @@ public void storeMainTableColumnPreferences(ColumnPreferences columnPreferences) @Override public MainTablePreferences getMainTablePreferences() { return new MainTablePreferences(getColumnPreferences(), - getBoolean(AUTO_RESIZE_MODE), - getBoolean(EXTRA_FILE_COLUMNS)); + getBoolean(AUTO_RESIZE_MODE), + getBoolean(EXTRA_FILE_COLUMNS)); } @Override @@ -1908,8 +1909,8 @@ public MainTableNameFormatPreferences getMainTableNameFormatPreferences() { } return new MainTableNameFormatPreferences( - displayStyle, - abbreviationStyle); + displayStyle, + abbreviationStyle); } @Override @@ -1929,21 +1930,21 @@ public void storeMainTableNameFormatPreferences(MainTableNameFormatPreferences p public List updateColumns(String columnNamesList, String columnWidthList, String sortTypeList, double defaultWidth) { List columnNames = getStringList(columnNamesList); List columnWidths = getStringList(columnWidthList) - .stream() - .map(string -> { - try { - return Double.parseDouble(string); - } catch (NumberFormatException e) { - LOGGER.error("Exception while parsing column widths. Choosing default.", e); - return defaultWidth; - } - }) - .collect(Collectors.toList()); + .stream() + .map(string -> { + try { + return Double.parseDouble(string); + } catch (NumberFormatException e) { + LOGGER.error("Exception while parsing column widths. Choosing default.", e); + return defaultWidth; + } + }) + .collect(Collectors.toList()); List columnSortTypes = getStringList(sortTypeList) - .stream() - .map(SortType::valueOf) - .collect(Collectors.toList()); + .stream() + .map(SortType::valueOf) + .collect(Collectors.toList()); List columns = new ArrayList<>(); for (int i = 0; i < columnNames.size(); i++) { @@ -1985,20 +1986,22 @@ private List createSearchDialogColumnSortOrder() { * Reloads the ColumnSortOrder from scratch * @return */ - private List updateColumnSortOrder(String sortOrderList, List tableColumns) { + private List updateColumnSortOrder(String sortOrderList, List tableColumns) { List columnsOrdered = new ArrayList<>(); - getStringList(sortOrderList).forEach(columnName -> tableColumns.stream().filter(column -> column.getName().equals(columnName)) - .findFirst() - .ifPresent(columnsOrdered::add)); + getStringList(sortOrderList).forEach(columnName -> + tableColumns.stream().filter(column -> + column.getName().equals(columnName)) + .findFirst() + .ifPresent(columnsOrdered::add)); - return columnsOrdered; + return columnsOrdered; } @Override public ColumnPreferences getSearchDialogColumnPreferences() { return new ColumnPreferences( - createSearchDialogColumns(), - createSearchDialogColumnSortOrder()); + createSearchDialogColumns(), + createSearchDialogColumnSortOrder()); } /** @@ -2014,8 +2017,8 @@ public void storeSearchDialogColumnPreferences(ColumnPreferences columnPreferenc private List storeColumnPreferences(ColumnPreferences columnPreferences, String columnNamesList, String columnWidthList, String sortTypeList, String sortOrderList) { putStringList(columnNamesList, columnPreferences.getColumns().stream() - .map(MainTableColumnModel::getName) - .collect(Collectors.toList())); + .map(MainTableColumnModel::getName) + .collect(Collectors.toList())); List columnWidthsInOrder = new ArrayList<>(); columnPreferences.getColumns().forEach(column -> columnWidthsInOrder.add(column.widthProperty().getValue().toString())); @@ -2026,9 +2029,9 @@ private List storeColumnPreferences(ColumnPreferences colu putStringList(sortTypeList, columnSortTypesInOrder); putStringList(sortOrderList, columnPreferences - .getColumnSortOrder().stream() - .map(MainTableColumnModel::getName) - .collect(Collectors.toList())); + .getColumnSortOrder().stream() + .map(MainTableColumnModel::getName) + .collect(Collectors.toList())); return columnPreferences.getColumns(); } @@ -2057,9 +2060,10 @@ public AppearancePreferences getAppearancePreferences() { } appearancePreferences = new AppearancePreferences( - getBoolean(OVERRIDE_DEFAULT_FONT_SIZE), - getInt(MAIN_FONT_SIZE), - getTheme()); + getBoolean(OVERRIDE_DEFAULT_FONT_SIZE), + getInt(MAIN_FONT_SIZE), + getTheme() + ); EasyBind.listen(appearancePreferences.shouldOverrideDefaultFontSizeProperty(), (obs, oldValue, newValue) -> putBoolean(OVERRIDE_DEFAULT_FONT_SIZE, newValue)); EasyBind.listen(appearancePreferences.mainFontSizeProperty(), (obs, oldValue, newValue) -> putInt(MAIN_FONT_SIZE, newValue)); @@ -2075,25 +2079,27 @@ public AppearancePreferences getAppearancePreferences() { @Override public ImportFormatPreferences getImportFormatPreferences() { return new ImportFormatPreferences( - getCustomImportFormats(), - getKeywordDelimiter(), - getCitationKeyPatternPreferences(), - getFieldContentParserPreferences(), - getXmpPreferences(), - getDOIPreferences(), - getSpecialFieldsPreferences().isKeywordSyncEnabled()); + getCustomImportFormats(), + getKeywordDelimiter(), + getCitationKeyPatternPreferences(), + getFieldContentParserPreferences(), + getXmpPreferences(), + getDOIPreferences(), + getSpecialFieldsPreferences().isKeywordSyncEnabled()); } @Override public SaveOrderConfig getExportSaveOrder() { List sortCriteria = List.of( - new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_PRIMARY_SORT_FIELD)), getBoolean(EXPORT_PRIMARY_SORT_DESCENDING)), - new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_SECONDARY_SORT_FIELD)), getBoolean(EXPORT_SECONDARY_SORT_DESCENDING)), - new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_TERTIARY_SORT_FIELD)), getBoolean(EXPORT_TERTIARY_SORT_DESCENDING))); + new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_PRIMARY_SORT_FIELD)), getBoolean(EXPORT_PRIMARY_SORT_DESCENDING)), + new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_SECONDARY_SORT_FIELD)), getBoolean(EXPORT_SECONDARY_SORT_DESCENDING)), + new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_TERTIARY_SORT_FIELD)), getBoolean(EXPORT_TERTIARY_SORT_DESCENDING)) + ); return new SaveOrderConfig( - SaveOrderConfig.OrderType.fromBooleans(getBoolean(EXPORT_IN_SPECIFIED_ORDER), getBoolean(EXPORT_IN_ORIGINAL_ORDER)), - sortCriteria); + SaveOrderConfig.OrderType.fromBooleans(getBoolean(EXPORT_IN_SPECIFIED_ORDER), getBoolean(EXPORT_IN_ORIGINAL_ORDER)), + sortCriteria + ); } @Override @@ -2118,8 +2124,8 @@ private SaveOrderConfig loadTableSaveOrder() { for (var column : sortOrder) { boolean descending = (column.getSortType() == SortType.DESCENDING); config.getSortCriteria().add(new SaveOrderConfig.SortCriterion( - FieldFactory.parseField(column.getQualifier()), - descending)); + FieldFactory.parseField(column.getQualifier()), + descending)); } return config; @@ -2138,21 +2144,21 @@ public SavePreferences getSavePreferencesForExport() { } return getSavePreferences() - .withSaveInOriginalOrder(saveInOriginalOrder) - .withSaveOrder(saveOrder) - .withTakeMetadataSaveOrderInAccount(false); + .withSaveInOriginalOrder(saveInOriginalOrder) + .withSaveOrder(saveOrder) + .withTakeMetadataSaveOrderInAccount(false); } @Override public SavePreferences getSavePreferences() { return new SavePreferences( - false, - null, - SavePreferences.DatabaseSaveType.ALL, - true, - this.getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT), - this.getFieldWriterPreferences(), - getCitationKeyPatternPreferences()); + false, + null, + SavePreferences.DatabaseSaveType.ALL, + true, + this.getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT), + this.getFieldWriterPreferences(), + getCitationKeyPatternPreferences()); } @Override @@ -2168,15 +2174,15 @@ public void storeOpenLastFilesOnStartup(boolean openLastFilesOnStartup) { @Override public FieldContentFormatterPreferences getFieldContentParserPreferences() { return new FieldContentFormatterPreferences( - getStringList(NON_WRAPPABLE_FIELDS).stream().map(FieldFactory::parseField).collect(Collectors.toList())); + getStringList(NON_WRAPPABLE_FIELDS).stream().map(FieldFactory::parseField).collect(Collectors.toList())); } @Override public FieldWriterPreferences getFieldWriterPreferences() { return new FieldWriterPreferences( - getBoolean(RESOLVE_STRINGS_ALL_FIELDS), - getStringList(DO_NOT_RESOLVE_STRINGS_FOR).stream().map(FieldFactory::parseField).collect(Collectors.toList()), - getFieldContentParserPreferences()); + getBoolean(RESOLVE_STRINGS_ALL_FIELDS), + getStringList(DO_NOT_RESOLVE_STRINGS_FOR).stream().map(FieldFactory::parseField).collect(Collectors.toList()), + getFieldContentParserPreferences()); } @Override @@ -2212,12 +2218,13 @@ public FilePreferences getFilePreferences() { } filePreferences = new FilePreferences( - getUser(), - get(MAIN_FILE_DIRECTORY), - getBoolean(STORE_RELATIVE_TO_BIB), - get(IMPORT_FILENAMEPATTERN), - get(IMPORT_FILEDIRPATTERN), - getBoolean(DOWNLOAD_LINKED_FILES)); + getUser(), + get(MAIN_FILE_DIRECTORY), + getBoolean(STORE_RELATIVE_TO_BIB), + get(IMPORT_FILENAMEPATTERN), + get(IMPORT_FILEDIRPATTERN), + getBoolean(DOWNLOAD_LINKED_FILES) + ); EasyBind.listen(filePreferences.mainFileDirectoryProperty(), (obs, oldValue, newValue) -> put(MAIN_FILE_DIRECTORY, filePreferences.getFileDirectory().map(Path::toString).orElse(""))); EasyBind.listen(filePreferences.storeFilesRelativeToBibFileProperty(), (obs, oldValue, newValue) -> putBoolean(STORE_RELATIVE_TO_BIB, newValue)); @@ -2234,7 +2241,8 @@ public AutoLinkPreferences getAutoLinkPreferences() { return autoLinkPreferences; } - AutoLinkPreferences.CitationKeyDependency citationKeyDependency = AutoLinkPreferences.CitationKeyDependency.START; // default + AutoLinkPreferences.CitationKeyDependency citationKeyDependency = + AutoLinkPreferences.CitationKeyDependency.START; // default if (getBoolean(AUTOLINK_EXACT_KEY_ONLY)) { citationKeyDependency = AutoLinkPreferences.CitationKeyDependency.EXACT; } else if (getBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY)) { @@ -2242,28 +2250,28 @@ public AutoLinkPreferences getAutoLinkPreferences() { } autoLinkPreferences = new AutoLinkPreferences( - citationKeyDependency, - get(AUTOLINK_REG_EXP_SEARCH_EXPRESSION_KEY), - getBoolean(ASK_AUTO_NAMING_PDFS_AGAIN), - getKeywordDelimiter()); + citationKeyDependency, + get(AUTOLINK_REG_EXP_SEARCH_EXPRESSION_KEY), + getBoolean(ASK_AUTO_NAMING_PDFS_AGAIN), + getKeywordDelimiter()); EasyBind.listen(autoLinkPreferences.citationKeyDependencyProperty(), (obs, oldValue, newValue) -> { - // Starts bibtex only omitted, as it is not being saved - switch (newValue) { - case START -> { - putBoolean(AUTOLINK_EXACT_KEY_ONLY, false); - putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, false); - } - case EXACT -> { - putBoolean(AUTOLINK_EXACT_KEY_ONLY, true); - putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, false); - } - case REGEX -> { - putBoolean(AUTOLINK_EXACT_KEY_ONLY, false); - putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, true); - } - } - }); + // Starts bibtex only omitted, as it is not being saved + switch (newValue) { + case START -> { + putBoolean(AUTOLINK_EXACT_KEY_ONLY, false); + putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, false); + } + case EXACT -> { + putBoolean(AUTOLINK_EXACT_KEY_ONLY, true); + putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, false); + } + case REGEX -> { + putBoolean(AUTOLINK_EXACT_KEY_ONLY, false); + putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, true); + } + } + }); EasyBind.listen(autoLinkPreferences.askAutoNamingPdfsProperty(), (obs, oldValue, newValue) -> putBoolean(ASK_AUTO_NAMING_PDFS_AGAIN, newValue)); EasyBind.listen(autoLinkPreferences.regularExpressionProperty(), (obs, oldValue, newValue) -> put(AUTOLINK_REG_EXP_SEARCH_EXPRESSION_KEY, newValue)); @@ -2291,14 +2299,14 @@ public ImportExportPreferences getImportExportPreferences() { } importExportPreferences = new ImportExportPreferences( - get(NON_WRAPPABLE_FIELDS), - !getBoolean(RESOLVE_STRINGS_ALL_FIELDS), - getBoolean(RESOLVE_STRINGS_ALL_FIELDS), - get(DO_NOT_RESOLVE_STRINGS_FOR), - getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT), - Path.of(get(IMPORT_WORKING_DIRECTORY)), - get(LAST_USED_EXPORT), - Path.of(get(EXPORT_WORKING_DIRECTORY))); + get(NON_WRAPPABLE_FIELDS), + !getBoolean(RESOLVE_STRINGS_ALL_FIELDS), + getBoolean(RESOLVE_STRINGS_ALL_FIELDS), + get(DO_NOT_RESOLVE_STRINGS_FOR), + getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT), + Path.of(get(IMPORT_WORKING_DIRECTORY)), + get(LAST_USED_EXPORT), + Path.of(get(EXPORT_WORKING_DIRECTORY))); EasyBind.listen(importExportPreferences.nonWrappableFieldsProperty(), (obs, oldValue, newValue) -> put(NON_WRAPPABLE_FIELDS, newValue)); EasyBind.listen(importExportPreferences.resolveStringsForStandardBibtexFieldsProperty(), (obs, oldValue, newValue) -> putBoolean(RESOLVE_STRINGS_ALL_FIELDS, newValue)); @@ -2375,7 +2383,7 @@ public List getCustomExportFormats(JournalAbbreviationReposito filename = formatData.get(EXPORTER_FILENAME_INDEX); extension = formatData.get(EXPORTER_EXTENSION_INDEX); TemplateExporter format = new TemplateExporter(exporterName, filename, extension, - layoutPreferences, savePreferences); + layoutPreferences, savePreferences); format.setCustomExport(true); formats.add(format); i++; @@ -2487,12 +2495,14 @@ public SidePanePreferences getSidePanePreferences() { } sidePanePreferences = new SidePanePreferences( - getVisiblePanes(), - getSidePanePreferredPositions(), - getInt(SELECTED_FETCHER_INDEX)); - - sidePanePreferences.visiblePanes().addListener((InvalidationListener) listener -> storeVisiblePanes(sidePanePreferences.visiblePanes())); - sidePanePreferences.getPreferredPositions().addListener((InvalidationListener) listener -> storeSidePanePreferredPositions(sidePanePreferences.getPreferredPositions())); + getVisiblePanes(), + getSidePanePreferredPositions(), + getInt(SELECTED_FETCHER_INDEX)); + + sidePanePreferences.visiblePanes().addListener((InvalidationListener) listener -> + storeVisiblePanes(sidePanePreferences.visiblePanes())); + sidePanePreferences.getPreferredPositions().addListener((InvalidationListener) listener -> + storeSidePanePreferredPositions(sidePanePreferences.getPreferredPositions())); EasyBind.listen(sidePanePreferences.webSearchFetcherSelectedProperty(), (obs, oldValue, newValue) -> putInt(SELECTED_FETCHER_INDEX, newValue)); return sidePanePreferences; @@ -2564,15 +2574,15 @@ public GuiPreferences getGuiPreferences() { } guiPreferences = new GuiPreferences( - getDouble(POS_X), - getDouble(POS_Y), - getDouble(SIZE_X), - getDouble(SIZE_Y), - getBoolean(WINDOW_MAXIMISED), - getBoolean(OPEN_LAST_EDITED), - getStringList(LAST_EDITED), - Path.of(get(LAST_FOCUSED)), - getDouble(SIDE_PANE_WIDTH)); + getDouble(POS_X), + getDouble(POS_Y), + getDouble(SIZE_X), + getDouble(SIZE_Y), + getBoolean(WINDOW_MAXIMISED), + getBoolean(OPEN_LAST_EDITED), + getStringList(LAST_EDITED), + Path.of(get(LAST_FOCUSED)), + getDouble(SIDE_PANE_WIDTH)); EasyBind.listen(guiPreferences.positionXProperty(), (obs, oldValue, newValue) -> putDouble(POS_X, newValue.doubleValue())); EasyBind.listen(guiPreferences.positionYProperty(), (obs, oldValue, newValue) -> putDouble(POS_Y, newValue.doubleValue())); @@ -2580,7 +2590,8 @@ public GuiPreferences getGuiPreferences() { EasyBind.listen(guiPreferences.sizeYProperty(), (obs, oldValue, newValue) -> putDouble(SIZE_Y, newValue.doubleValue())); EasyBind.listen(guiPreferences.windowMaximisedProperty(), (obs, oldValue, newValue) -> putBoolean(WINDOW_MAXIMISED, newValue)); EasyBind.listen(guiPreferences.openLastEditedProperty(), (obs, oldValue, newValue) -> putBoolean(OPEN_LAST_EDITED, newValue)); - guiPreferences.getLastFilesOpened().addListener((InvalidationListener) change -> putStringList(LAST_EDITED, guiPreferences.getLastFilesOpened())); + guiPreferences.getLastFilesOpened().addListener((InvalidationListener) change -> + putStringList(LAST_EDITED, guiPreferences.getLastFilesOpened())); EasyBind.listen(guiPreferences.lastFocusedFileProperty(), (obs, oldValue, newValue) -> { if (newValue != null) { put(LAST_FOCUSED, newValue.toAbsolutePath().toString()); @@ -2617,19 +2628,19 @@ public SearchPreferences getSearchPreferences() { } searchPreferences = new SearchPreferences( - searchDisplayMode, - getBoolean(SEARCH_CASE_SENSITIVE), - getBoolean(SEARCH_REG_EXP), - getBoolean(SEARCH_FULLTEXT), - getBoolean(SEARCH_KEEP_SEARCH_STRING), - getBoolean(SEARCH_KEEP_GLOBAL_WINDOW_ON_TOP)); + searchDisplayMode, + getBoolean(SEARCH_CASE_SENSITIVE), + getBoolean(SEARCH_REG_EXP), + getBoolean(SEARCH_FULLTEXT), + getBoolean(SEARCH_KEEP_SEARCH_STRING), + getBoolean(SEARCH_KEEP_GLOBAL_WINDOW_ON_TOP)); EasyBind.listen(searchPreferences.searchDisplayModeProperty(), (obs, oldValue, newValue) -> put(SEARCH_DISPLAY_MODE, Objects.requireNonNull(searchPreferences.getSearchDisplayMode()).toString())); searchPreferences.getObservableSearchFlags().addListener((SetChangeListener) c -> { - putBoolean(SEARCH_CASE_SENSITIVE, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.CASE_SENSITIVE)); - putBoolean(SEARCH_REG_EXP, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.REGULAR_EXPRESSION)); - putBoolean(SEARCH_FULLTEXT, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.FULLTEXT)); - putBoolean(SEARCH_KEEP_SEARCH_STRING, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.KEEP_SEARCH_STRING)); + putBoolean(SEARCH_CASE_SENSITIVE, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.CASE_SENSITIVE)); + putBoolean(SEARCH_REG_EXP, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.REGULAR_EXPRESSION)); + putBoolean(SEARCH_FULLTEXT, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.FULLTEXT)); + putBoolean(SEARCH_KEEP_SEARCH_STRING, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.KEEP_SEARCH_STRING)); }); EasyBind.listen(searchPreferences.keepWindowOnTopProperty(), (obs, oldValue, newValue) -> putBoolean(SEARCH_KEEP_GLOBAL_WINDOW_ON_TOP, searchPreferences.shouldKeepWindowOnTop())); @@ -2643,9 +2654,9 @@ public SearchPreferences getSearchPreferences() { @Override public XmpPreferences getXmpPreferences() { return new XmpPreferences( - getBoolean(USE_XMP_PRIVACY_FILTER), - getStringList(XMP_PRIVACY_FILTERS).stream().map(FieldFactory::parseField).collect(Collectors.toSet()), - getKeywordDelimiter()); + getBoolean(USE_XMP_PRIVACY_FILTER), + getStringList(XMP_PRIVACY_FILTERS).stream().map(FieldFactory::parseField).collect(Collectors.toSet()), + getKeywordDelimiter()); } @Override @@ -2657,8 +2668,8 @@ public void storeXmpPreferences(XmpPreferences preferences) { @Override public NameFormatterPreferences getNameFormatterPreferences() { return new NameFormatterPreferences( - getStringList(NAME_FORMATER_KEY), - getStringList(NAME_FORMATTER_VALUE)); + getStringList(NAME_FORMATER_KEY), + getStringList(NAME_FORMATTER_VALUE)); } @Override @@ -2677,11 +2688,11 @@ public AutoCompletePreferences getAutoCompletePreferences() { } return new AutoCompletePreferences( - getBoolean(AUTO_COMPLETE), - AutoCompleteFirstNameMode.parse(get(AUTOCOMPLETER_FIRSTNAME_MODE)), - nameFormat, - getStringList(AUTOCOMPLETER_COMPLETE_FIELDS).stream().map(FieldFactory::parseField).collect(Collectors.toSet()), - getJournalAbbreviationPreferences()); + getBoolean(AUTO_COMPLETE), + AutoCompleteFirstNameMode.parse(get(AUTOCOMPLETER_FIRSTNAME_MODE)), + nameFormat, + getStringList(AUTOCOMPLETER_COMPLETE_FIELDS).stream().map(FieldFactory::parseField).collect(Collectors.toSet()), + getJournalAbbreviationPreferences()); } @Override @@ -2705,9 +2716,9 @@ public void storeAutoCompletePreferences(AutoCompletePreferences preferences) { @Override public SpecialFieldsPreferences getSpecialFieldsPreferences() { return new SpecialFieldsPreferences( - getBoolean(SPECIALFIELDSENABLED), - getBoolean(AUTOSYNCSPECIALFIELDSTOKEYWORDS), - getBoolean(SERIALIZESPECIALFIELDS)); + getBoolean(SPECIALFIELDSENABLED), + getBoolean(AUTOSYNCSPECIALFIELDSTOKEYWORDS), + getBoolean(SERIALIZESPECIALFIELDS)); } @Override @@ -2754,10 +2765,10 @@ public MrDlibPreferences getMrDlibPreferences() { } mrDlibPreferences = new MrDlibPreferences( - getBoolean(ACCEPT_RECOMMENDATIONS), - getBoolean(SEND_LANGUAGE_DATA), - getBoolean(SEND_OS_DATA), - getBoolean(SEND_TIMEZONE_DATA)); + getBoolean(ACCEPT_RECOMMENDATIONS), + getBoolean(SEND_LANGUAGE_DATA), + getBoolean(SEND_OS_DATA), + getBoolean(SEND_TIMEZONE_DATA)); EasyBind.listen(mrDlibPreferences.acceptRecommendationsProperty(), (obs, oldValue, newValue) -> putBoolean(ACCEPT_RECOMMENDATIONS, newValue)); EasyBind.listen(mrDlibPreferences.sendLanguageProperty(), (obs, oldValue, newValue) -> putBoolean(SEND_LANGUAGE_DATA, newValue)); @@ -2784,15 +2795,20 @@ public ProtectedTermsPreferences getProtectedTermsPreferences() { } protectedTermsPreferences = new ProtectedTermsPreferences( - getStringList(PROTECTED_TERMS_ENABLED_INTERNAL), - getStringList(PROTECTED_TERMS_ENABLED_EXTERNAL), - getStringList(PROTECTED_TERMS_DISABLED_INTERNAL), - getStringList(PROTECTED_TERMS_DISABLED_EXTERNAL)); + getStringList(PROTECTED_TERMS_ENABLED_INTERNAL), + getStringList(PROTECTED_TERMS_ENABLED_EXTERNAL), + getStringList(PROTECTED_TERMS_DISABLED_INTERNAL), + getStringList(PROTECTED_TERMS_DISABLED_EXTERNAL) + ); - protectedTermsPreferences.getEnabledExternalTermLists().addListener((InvalidationListener) change -> putStringList(PROTECTED_TERMS_ENABLED_EXTERNAL, protectedTermsPreferences.getEnabledExternalTermLists())); - protectedTermsPreferences.getDisabledExternalTermLists().addListener((InvalidationListener) change -> putStringList(PROTECTED_TERMS_DISABLED_EXTERNAL, protectedTermsPreferences.getDisabledExternalTermLists())); - protectedTermsPreferences.getEnabledInternalTermLists().addListener((InvalidationListener) change -> putStringList(PROTECTED_TERMS_ENABLED_INTERNAL, protectedTermsPreferences.getEnabledInternalTermLists())); - protectedTermsPreferences.getDisabledInternalTermLists().addListener((InvalidationListener) change -> putStringList(PROTECTED_TERMS_DISABLED_INTERNAL, protectedTermsPreferences.getDisabledInternalTermLists())); + protectedTermsPreferences.getEnabledExternalTermLists().addListener((InvalidationListener) change -> + putStringList(PROTECTED_TERMS_ENABLED_EXTERNAL, protectedTermsPreferences.getEnabledExternalTermLists())); + protectedTermsPreferences.getDisabledExternalTermLists().addListener((InvalidationListener) change -> + putStringList(PROTECTED_TERMS_DISABLED_EXTERNAL, protectedTermsPreferences.getDisabledExternalTermLists())); + protectedTermsPreferences.getEnabledInternalTermLists().addListener((InvalidationListener) change -> + putStringList(PROTECTED_TERMS_ENABLED_INTERNAL, protectedTermsPreferences.getEnabledInternalTermLists())); + protectedTermsPreferences.getDisabledInternalTermLists().addListener((InvalidationListener) change -> + putStringList(PROTECTED_TERMS_DISABLED_INTERNAL, protectedTermsPreferences.getDisabledInternalTermLists())); return protectedTermsPreferences; } @@ -2808,10 +2824,11 @@ public ImporterPreferences getImporterPreferences() { } importerPreferences = new ImporterPreferences( - getBoolean(GENERATE_KEY_ON_IMPORT), - getBoolean(GROBID_ENABLED), - getBoolean(GROBID_OPT_OUT), - get(GROBID_URL)); + getBoolean(GENERATE_KEY_ON_IMPORT), + getBoolean(GROBID_ENABLED), + getBoolean(GROBID_OPT_OUT), + get(GROBID_URL) + ); EasyBind.listen(importerPreferences.generateNewKeyOnImportProperty(), (obs, oldValue, newValue) -> putBoolean(GENERATE_KEY_ON_IMPORT, newValue)); EasyBind.listen(importerPreferences.grobidEnabledProperty(), (obs, oldValue, newValue) -> putBoolean(GROBID_ENABLED, newValue)); From 445242913681ed352a771f733cf356398c77ac58 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Mon, 22 Nov 2021 19:57:31 +0100 Subject: [PATCH 08/13] fix checkstyle --- src/main/java/org/jabref/preferences/JabRefPreferences.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 8fc26ccb304..543cb257620 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -1970,7 +1970,7 @@ private List createSearchDialogColumnSortOrder() { * Reloads the ColumnSortOrder from scratch * @return */ - private List updateColumnSortOrder(String sortOrderList, List tableColumns) { + private List updateColumnSortOrder(String sortOrderList, List tableColumns) { List columnsOrdered = new ArrayList<>(); getStringList(sortOrderList).forEach(columnName -> tableColumns.stream().filter(column -> From a67399cba0dd927461c976263c77a8ee7bd17dd0 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Fri, 26 Nov 2021 00:13:22 +0100 Subject: [PATCH 09/13] Add a new column type library and check if it exists before adding to search reults --- .../AbstractPersistenceVisualStateTable.java | 15 +- .../gui/maintable/MainTableColumnFactory.java | 11 + .../gui/maintable/MainTableColumnModel.java | 3 +- .../gui/maintable/columns/LibraryColumn.java | 25 + .../gui/search/GlobalSearchResultDialog.java | 15 +- .../jabref/gui/search/SearchResultsTable.java | 25 +- .../jabref/preferences/JabRefPreferences.java | 524 +++++++++--------- 7 files changed, 316 insertions(+), 302 deletions(-) create mode 100644 src/main/java/org/jabref/gui/maintable/columns/LibraryColumn.java diff --git a/src/main/java/org/jabref/gui/maintable/AbstractPersistenceVisualStateTable.java b/src/main/java/org/jabref/gui/maintable/AbstractPersistenceVisualStateTable.java index 333ff7b84d3..89b36995de0 100644 --- a/src/main/java/org/jabref/gui/maintable/AbstractPersistenceVisualStateTable.java +++ b/src/main/java/org/jabref/gui/maintable/AbstractPersistenceVisualStateTable.java @@ -31,19 +31,14 @@ public AbstractPersistenceVisualStateTable(final TableView> createExtraFileCol preferencesService, columnModel.getQualifier()); } + + /** + * Create library column containing the Filename of the library's bib file + */ + private TableColumn createLibraryColumn(MainTableColumnModel columnModel) { + return new LibraryColumn(columnModel); + } } diff --git a/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java b/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java index e82af036482..5ff872c1426 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java @@ -36,7 +36,8 @@ public enum Type { GROUPS("groups", Localization.lang("Groups")), LINKED_IDENTIFIER("linked_id", Localization.lang("Linked identifiers")), NORMALFIELD("field"), - SPECIALFIELD("special", Localization.lang("Special")); + SPECIALFIELD("special", Localization.lang("Special")), + LIBRARY_NAME("library", Localization.lang("Library")); public static final EnumSet ICON_COLUMNS = EnumSet.of(EXTRAFILE, FILES, GROUPS, LINKED_IDENTIFIER); diff --git a/src/main/java/org/jabref/gui/maintable/columns/LibraryColumn.java b/src/main/java/org/jabref/gui/maintable/columns/LibraryColumn.java new file mode 100644 index 00000000000..1fafd9c3b14 --- /dev/null +++ b/src/main/java/org/jabref/gui/maintable/columns/LibraryColumn.java @@ -0,0 +1,25 @@ +package org.jabref.gui.maintable.columns; + +import org.jabref.gui.maintable.BibEntryTableViewModel; +import org.jabref.gui.maintable.MainTableColumnModel; +import org.jabref.gui.maintable.MainTableColumnModel.Type; +import org.jabref.gui.util.ValueTableCellFactory; +import org.jabref.logic.l10n.Localization; +import org.jabref.logic.util.io.FileUtil; + +public class LibraryColumn extends MainTableColumn { + + public LibraryColumn(MainTableColumnModel model) { + super(model); + + setText(Localization.lang("Library")); + new ValueTableCellFactory().withText(FileUtil::getBaseName) + .install(this); + setCellValueFactory(param -> param.getValue().bibDatabaseContextProperty()); + } + + public LibraryColumn() { + this(new MainTableColumnModel(Type.LIBRARY_NAME)); + } + +} diff --git a/src/main/java/org/jabref/gui/search/GlobalSearchResultDialog.java b/src/main/java/org/jabref/gui/search/GlobalSearchResultDialog.java index 87388f6a93a..721f8417109 100644 --- a/src/main/java/org/jabref/gui/search/GlobalSearchResultDialog.java +++ b/src/main/java/org/jabref/gui/search/GlobalSearchResultDialog.java @@ -5,7 +5,6 @@ import javafx.fxml.FXML; import javafx.scene.control.SplitPane; -import javafx.scene.control.TableColumn; import javafx.scene.control.ToggleButton; import javafx.stage.Modality; import javafx.stage.Stage; @@ -14,17 +13,16 @@ import org.jabref.gui.StateManager; import org.jabref.gui.externalfiletype.ExternalFileTypes; import org.jabref.gui.icon.IconTheme; -import org.jabref.gui.maintable.BibEntryTableViewModel; +import org.jabref.gui.maintable.MainTableColumnModel; +import org.jabref.gui.maintable.columns.MainTableColumn; import org.jabref.gui.maintable.columns.SpecialFieldColumn; import org.jabref.gui.preview.PreviewViewer; import org.jabref.gui.util.BaseDialog; -import org.jabref.gui.util.ValueTableCellFactory; -import org.jabref.logic.l10n.Localization; -import org.jabref.logic.util.io.FileUtil; import org.jabref.preferences.PreferencesService; import com.airhacks.afterburner.views.ViewLoader; import com.tobiasdiez.easybind.EasyBind; +import scala.collection.parallel.ParIterableLike.Min; public class GlobalSearchResultDialog extends BaseDialog { @@ -58,14 +56,9 @@ private void initialize() { previewViewer.setTheme(preferencesService.getTheme()); previewViewer.setLayout(preferencesService.getPreviewPreferences().getCurrentPreviewStyle()); - TableColumn fieldColumn = new TableColumn<>(Localization.lang("Library")); - new ValueTableCellFactory().withText(FileUtil::getBaseName) - .install(fieldColumn); - fieldColumn.setCellValueFactory(param -> param.getValue().bibDatabaseContextProperty()); - SearchResultsTableDataModel model = new SearchResultsTableDataModel(viewModel.getSearchDatabaseContext(), preferencesService, stateManager); SearchResultsTable resultsTable = new SearchResultsTable(model, viewModel.getSearchDatabaseContext(), preferencesService, undoManager, dialogService, stateManager, externalFileTypes); - resultsTable.getColumns().add(0, fieldColumn); + resultsTable.getColumns().removeIf(col -> col instanceof SpecialFieldColumn); resultsTable.getSelectionModel().selectFirst(); resultsTable.getSelectionModel().selectedItemProperty().addListener((obs, old, newValue) -> { diff --git a/src/main/java/org/jabref/gui/search/SearchResultsTable.java b/src/main/java/org/jabref/gui/search/SearchResultsTable.java index 689e0395185..09083921f7a 100644 --- a/src/main/java/org/jabref/gui/search/SearchResultsTable.java +++ b/src/main/java/org/jabref/gui/search/SearchResultsTable.java @@ -1,8 +1,11 @@ package org.jabref.gui.search; +import java.util.List; + import javax.swing.undo.UndoManager; import javafx.scene.control.SelectionMode; +import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import org.jabref.gui.DialogService; @@ -13,6 +16,7 @@ import org.jabref.gui.maintable.MainTableColumnFactory; import org.jabref.gui.maintable.MainTablePreferences; import org.jabref.gui.maintable.SmartConstrainedResizePolicy; +import org.jabref.gui.maintable.columns.LibraryColumn; import org.jabref.gui.maintable.columns.MainTableColumn; import org.jabref.model.database.BibDatabaseContext; import org.jabref.preferences.PreferencesService; @@ -30,14 +34,19 @@ public SearchResultsTable(SearchResultsTableDataModel model, MainTablePreferences mainTablePreferences = preferencesService.getMainTablePreferences(); - this.getColumns().addAll(new MainTableColumnFactory( - database, - preferencesService, - preferencesService.getSearchDialogColumnPreferences(), - externalFileTypes, - undoManager, - dialogService, - stateManager).createColumns()); + List> allCols = new MainTableColumnFactory( + database, + preferencesService, + preferencesService.getSearchDialogColumnPreferences(), + externalFileTypes, + undoManager, + dialogService, + stateManager).createColumns(); + + if (!allCols.stream().anyMatch(col -> col instanceof LibraryColumn)) { + allCols.add(0, new LibraryColumn()); + } + this.getColumns().addAll(allCols); this.getSortOrder().clear(); preferencesService.getSearchDialogColumnPreferences().getColumnSortOrder().forEach(columnModel -> diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 543cb257620..3af0ea6d8e3 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -703,24 +703,24 @@ private JabRefPreferences() { defaults.put(PREVIEW_PANEL_HEIGHT, 0.65); defaults.put(PREVIEW_AS_TAB, Boolean.FALSE); defaults.put(PREVIEW_STYLE, - "" + - "\\bibtextype\\begin{citationkey} (\\citationkey)\\end{citationkey}__NEWLINE__" + - "\\begin{author}

\\format[Authors(LastFirst, FullName,Sep= / ,LastSep= / ),HTMLChars]{\\author}\\end{author}__NEWLINE__" + - "\\begin{editor & !author}

\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & !author}__NEWLINE__" + - "\\begin{title}
\\format[HTMLChars]{\\title} \\end{title}__NEWLINE__" + - "
\\begin{date}\\date\\end{date}\\begin{edition}, \\edition. edition\\end{edition}__NEWLINE__" + - "\\begin{editor & author}

\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & author}__NEWLINE__" + - "\\begin{booktitle}
\\format[HTMLChars]{\\booktitle}\\end{booktitle}__NEWLINE__" + - "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}" + - "\\begin{editor & !author}
\\end{editor & !author}\\begin{!editor}
\\end{!editor}\\begin{journal}
\\format[HTMLChars]{\\journal} \\end{journal} \\begin{volume}, Vol. \\volume\\end{volume}\\begin{series}
\\format[HTMLChars]{\\series}\\end{series}\\begin{number}, No. \\format[HTMLChars]{\\number}\\end{number}__NEWLINE__" + - "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + - "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" + - "\\begin{publisher}
\\format[HTMLChars]{\\publisher}\\end{publisher}\\begin{location}: \\format[HTMLChars]{\\location} \\end{location}__NEWLINE__" + - "\\begin{pages}
p. \\format[FormatPagesForHTML]{\\pages}\\end{pages}__NEWLINE__" + - "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" + - "\\begin{owncitation}

Own citation: \\format[HTMLChars]{\\owncitation} \\end{owncitation}__NEWLINE__" + - "\\begin{comment}

Comment: \\format[HTMLChars]{\\comment}\\end{comment}__NEWLINE__" + - "
__NEWLINE__"); + "" + + "\\bibtextype\\begin{citationkey} (\\citationkey)\\end{citationkey}__NEWLINE__" + + "\\begin{author}

\\format[Authors(LastFirst, FullName,Sep= / ,LastSep= / ),HTMLChars]{\\author}\\end{author}__NEWLINE__" + + "\\begin{editor & !author}

\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & !author}__NEWLINE__" + + "\\begin{title}
\\format[HTMLChars]{\\title} \\end{title}__NEWLINE__" + + "
\\begin{date}\\date\\end{date}\\begin{edition}, \\edition. edition\\end{edition}__NEWLINE__" + + "\\begin{editor & author}

\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & author}__NEWLINE__" + + "\\begin{booktitle}
\\format[HTMLChars]{\\booktitle}\\end{booktitle}__NEWLINE__" + + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}" + + "\\begin{editor & !author}
\\end{editor & !author}\\begin{!editor}
\\end{!editor}\\begin{journal}
\\format[HTMLChars]{\\journal} \\end{journal} \\begin{volume}, Vol. \\volume\\end{volume}\\begin{series}
\\format[HTMLChars]{\\series}\\end{series}\\begin{number}, No. \\format[HTMLChars]{\\number}\\end{number}__NEWLINE__" + + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" + + "\\begin{publisher}
\\format[HTMLChars]{\\publisher}\\end{publisher}\\begin{location}: \\format[HTMLChars]{\\location} \\end{location}__NEWLINE__" + + "\\begin{pages}
p. \\format[FormatPagesForHTML]{\\pages}\\end{pages}__NEWLINE__" + + "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" + + "\\begin{owncitation}

Own citation: \\format[HTMLChars]{\\owncitation} \\end{owncitation}__NEWLINE__" + + "\\begin{comment}

Comment: \\format[HTMLChars]{\\comment}\\end{comment}__NEWLINE__" + + "
__NEWLINE__"); // set default theme defaults.put(FX_THEME, Theme.BASE_CSS); @@ -797,11 +797,11 @@ private static Optional getNextUnit(Reader data) throws IOException { private static void insertDefaultCleanupPreset(Map storage) { EnumSet deactivatedJobs = EnumSet.of( - CleanupPreset.CleanupStep.CLEAN_UP_UPGRADE_EXTERNAL_LINKS, - CleanupPreset.CleanupStep.MOVE_PDF, - CleanupPreset.CleanupStep.RENAME_PDF_ONLY_RELATIVE_PATHS, - CleanupPreset.CleanupStep.CONVERT_TO_BIBLATEX, - CleanupPreset.CleanupStep.CONVERT_TO_BIBTEX); + CleanupPreset.CleanupStep.CLEAN_UP_UPGRADE_EXTERNAL_LINKS, + CleanupPreset.CleanupStep.MOVE_PDF, + CleanupPreset.CleanupStep.RENAME_PDF_ONLY_RELATIVE_PATHS, + CleanupPreset.CleanupStep.CONVERT_TO_BIBLATEX, + CleanupPreset.CleanupStep.CONVERT_TO_BIBTEX); for (CleanupPreset.CleanupStep action : EnumSet.allOf(CleanupPreset.CleanupStep.class)) { storage.put(CLEANUP + action.name(), !deactivatedJobs.contains(action)); @@ -1054,7 +1054,7 @@ public void exportPreferences(Path file) throws JabRefException { prefs.exportSubtree(os); } catch (BackingStoreException | IOException ex) { throw new JabRefException("Could not export preferences", Localization.lang("Could not export preferences"), - ex); + ex); } } @@ -1070,15 +1070,15 @@ public void importPreferences(Path file) throws JabRefException { Preferences.importPreferences(is); } catch (InvalidPreferencesFormatException | IOException ex) { throw new JabRefException("Could not import preferences", Localization.lang("Could not import preferences"), - ex); + ex); } } @Override public FileLinkPreferences getFileLinkPreferences() { return new FileLinkPreferences( - get(MAIN_FILE_DIRECTORY), // REALLY HERE? - fileDirForDatabase); + get(MAIN_FILE_DIRECTORY), // REALLY HERE? + fileDirForDatabase); } @Override @@ -1089,20 +1089,20 @@ public void storeFileDirforDatabase(List dirs) { @Override public LayoutFormatterPreferences getLayoutFormatterPreferences(JournalAbbreviationRepository repository) { return new LayoutFormatterPreferences( - getNameFormatterPreferences(), - getFileLinkPreferences(), - repository); + getNameFormatterPreferences(), + getFileLinkPreferences(), + repository); } @Override public OpenOfficePreferences getOpenOfficePreferences() { return new OpenOfficePreferences( - get(OO_EXECUTABLE_PATH), - get(OO_PATH), - getBoolean(OO_USE_ALL_OPEN_BASES), - getBoolean(OO_SYNC_WHEN_CITING), - getStringList(OO_EXTERNAL_STYLE_FILES), - get(OO_BIBLIOGRAPHY_STYLE_FILE)); + get(OO_EXECUTABLE_PATH), + get(OO_PATH), + getBoolean(OO_USE_ALL_OPEN_BASES), + getBoolean(OO_SYNC_WHEN_CITING), + getStringList(OO_EXTERNAL_STYLE_FILES), + get(OO_BIBLIOGRAPHY_STYLE_FILE)); } @Override @@ -1136,8 +1136,8 @@ public JournalAbbreviationPreferences getJournalAbbreviationPreferences() { @Override public CleanupPreferences getCleanupPreferences(JournalAbbreviationRepository abbreviationRepository) { return new CleanupPreferences( - getLayoutFormatterPreferences(abbreviationRepository), - getFilePreferences()); + getLayoutFormatterPreferences(abbreviationRepository), + getFilePreferences()); } @Override @@ -1321,12 +1321,12 @@ public GeneralPreferences getGeneralPreferences() { } generalPreferences = new GeneralPreferences( - Charset.forName(get(DEFAULT_ENCODING)), - getBoolean(BIBLATEX_DEFAULT_MODE) ? BibDatabaseMode.BIBLATEX : BibDatabaseMode.BIBTEX, - getBoolean(WARN_ABOUT_DUPLICATES_IN_INSPECTION), - getBoolean(CONFIRM_DELETE), - getBoolean(MEMORY_STICK_MODE), - getBoolean(SHOW_ADVANCED_HINTS)); + Charset.forName(get(DEFAULT_ENCODING)), + getBoolean(BIBLATEX_DEFAULT_MODE) ? BibDatabaseMode.BIBLATEX : BibDatabaseMode.BIBTEX, + getBoolean(WARN_ABOUT_DUPLICATES_IN_INSPECTION), + getBoolean(CONFIRM_DELETE), + getBoolean(MEMORY_STICK_MODE), + getBoolean(SHOW_ADVANCED_HINTS)); EasyBind.listen(generalPreferences.defaultEncodingProperty(), (obs, oldValue, newValue) -> put(DEFAULT_ENCODING, newValue.name())); EasyBind.listen(generalPreferences.defaultBibDatabaseModeProperty(), (obs, oldValue, newValue) -> putBoolean(BIBLATEX_DEFAULT_MODE, (newValue == BibDatabaseMode.BIBLATEX))); @@ -1344,8 +1344,8 @@ public TelemetryPreferences getTelemetryPreferences() { return telemetryPreferences; } telemetryPreferences = new TelemetryPreferences( - getBoolean(COLLECT_TELEMETRY), - !getBoolean(ALREADY_ASKED_TO_COLLECT_TELEMETRY) // mind the ! + getBoolean(COLLECT_TELEMETRY), + !getBoolean(ALREADY_ASKED_TO_COLLECT_TELEMETRY) // mind the ! ); EasyBind.listen(telemetryPreferences.collectTelemetryProperty(), (obs, oldValue, newValue) -> putBoolean(COLLECT_TELEMETRY, newValue)); EasyBind.listen(telemetryPreferences.askToCollectTelemetryProperty(), (obs, oldValue, newValue) -> putBoolean(ALREADY_ASKED_TO_COLLECT_TELEMETRY, !newValue)); @@ -1358,8 +1358,8 @@ public DOIPreferences getDOIPreferences() { return doiPreferences; } doiPreferences = new DOIPreferences( - getBoolean(USE_CUSTOM_DOI_URI), - get(BASE_DOI_URI)); + getBoolean(USE_CUSTOM_DOI_URI), + get(BASE_DOI_URI)); EasyBind.listen(doiPreferences.useCustomProperty(), (obs, oldValue, newValue) -> putBoolean(USE_CUSTOM_DOI_URI, newValue)); EasyBind.listen(doiPreferences.defaultBaseURIProperty(), (obs, oldValue, newValue) -> put(BASE_DOI_URI, newValue)); return doiPreferences; @@ -1371,9 +1371,9 @@ public OwnerPreferences getOwnerPreferences() { return ownerPreferences; } ownerPreferences = new OwnerPreferences( - getBoolean(USE_OWNER), - get(DEFAULT_OWNER), - getBoolean(OVERWRITE_OWNER)); + getBoolean(USE_OWNER), + get(DEFAULT_OWNER), + getBoolean(OVERWRITE_OWNER)); EasyBind.listen(ownerPreferences.useOwnerProperty(), (obs, oldValue, newValue) -> putBoolean(USE_OWNER, newValue)); EasyBind.listen(ownerPreferences.defaultOwnerProperty(), (obs, oldValue, newValue) -> put(DEFAULT_OWNER, newValue)); EasyBind.listen(ownerPreferences.overwriteOwnerProperty(), (obs, oldValue, newValue) -> putBoolean(OVERWRITE_OWNER, newValue)); @@ -1386,11 +1386,11 @@ public TimestampPreferences getTimestampPreferences() { return timestampPreferences; } timestampPreferences = new TimestampPreferences( - getBoolean(ADD_CREATION_DATE), - getBoolean(ADD_MODIFICATION_DATE), - getBoolean(UPDATE_TIMESTAMP), - FieldFactory.parseField(get(TIME_STAMP_FIELD)), - get(TIME_STAMP_FORMAT)); + getBoolean(ADD_CREATION_DATE), + getBoolean(ADD_MODIFICATION_DATE), + getBoolean(UPDATE_TIMESTAMP), + FieldFactory.parseField(get(TIME_STAMP_FIELD)), + get(TIME_STAMP_FORMAT)); EasyBind.listen(timestampPreferences.addCreationDateProperty(), (obs, oldValue, newValue) -> putBoolean(ADD_CREATION_DATE, newValue)); EasyBind.listen(timestampPreferences.addModificationDateProperty(), (obs, oldValue, newValue) -> putBoolean(ADD_MODIFICATION_DATE, newValue)); @@ -1409,10 +1409,10 @@ public Character getKeywordDelimiter() { @Override public GroupsPreferences getGroupsPreferences() { return new GroupsPreferences( - GroupViewMode.valueOf(get(GROUP_INTERSECT_UNION_VIEW_MODE)), - getBoolean(AUTO_ASSIGN_GROUP), - getBoolean(DISPLAY_GROUP_COUNT), - get(KEYWORD_SEPARATOR).charAt(0)); + GroupViewMode.valueOf(get(GROUP_INTERSECT_UNION_VIEW_MODE)), + getBoolean(AUTO_ASSIGN_GROUP), + getBoolean(DISPLAY_GROUP_COUNT), + get(KEYWORD_SEPARATOR).charAt(0)); } @Override @@ -1561,14 +1561,14 @@ public EntryEditorPreferences getEntryEditorPreferences() { } entryEditorPreferences = new EntryEditorPreferences(getEntryEditorTabList(), - getBoolean(AUTO_OPEN_FORM), - getBoolean(SHOW_RECOMMENDATIONS), - getBoolean(ACCEPT_RECOMMENDATIONS), - getBoolean(SHOW_LATEX_CITATIONS), - getBoolean(DEFAULT_SHOW_SOURCE), - getBoolean(VALIDATE_IN_ENTRY_EDITOR), - getBoolean(ALLOW_INTEGER_EDITION_BIBTEX), - getDouble(ENTRY_EDITOR_HEIGHT)); + getBoolean(AUTO_OPEN_FORM), + getBoolean(SHOW_RECOMMENDATIONS), + getBoolean(ACCEPT_RECOMMENDATIONS), + getBoolean(SHOW_LATEX_CITATIONS), + getBoolean(DEFAULT_SHOW_SOURCE), + getBoolean(VALIDATE_IN_ENTRY_EDITOR), + getBoolean(ALLOW_INTEGER_EDITION_BIBTEX), + getDouble(ENTRY_EDITOR_HEIGHT)); EasyBind.listen(entryEditorPreferences.entryEditorTabListProperty(), (obs, oldValue, newValue) -> storeEntryEditorTabList(newValue)); EasyBind.listen(entryEditorPreferences.shouldOpenOnNewEntryProperty(), (obs, oldValue, newValue) -> putBoolean(AUTO_OPEN_FORM, newValue)); @@ -1594,8 +1594,8 @@ public RemotePreferences getRemotePreferences() { } remotePreferences = new RemotePreferences( - getInt(REMOTE_SERVER_PORT), - getBoolean(USE_REMOTE_SERVER)); + getInt(REMOTE_SERVER_PORT), + getBoolean(USE_REMOTE_SERVER)); EasyBind.listen(remotePreferences.portProperty(), (obs, oldValue, newValue) -> putInt(REMOTE_SERVER_PORT, newValue)); EasyBind.listen(remotePreferences.useRemoteServerProperty(), (obs, oldValue, newValue) -> putBoolean(USE_REMOTE_SERVER, newValue)); @@ -1610,12 +1610,12 @@ public ProxyPreferences getProxyPreferences() { } proxyPreferences = new ProxyPreferences( - getBoolean(PROXY_USE), - get(PROXY_HOSTNAME), - get(PROXY_PORT), - getBoolean(PROXY_USE_AUTHENTICATION), - get(PROXY_USERNAME), - get(PROXY_PASSWORD)); + getBoolean(PROXY_USE), + get(PROXY_HOSTNAME), + get(PROXY_PORT), + getBoolean(PROXY_USE_AUTHENTICATION), + get(PROXY_USERNAME), + get(PROXY_PASSWORD)); EasyBind.listen(proxyPreferences.useProxyProperty(), (obs, oldValue, newValue) -> putBoolean(PROXY_USE, newValue)); EasyBind.listen(proxyPreferences.hostnameProperty(), (obs, oldValue, newValue) -> put(PROXY_HOSTNAME, newValue)); @@ -1656,8 +1656,8 @@ public void updateGlobalCitationKeyPattern() { if (keys.length > 0) { for (String key : keys) { this.globalCitationKeyPattern.addCitationKeyPattern( - EntryTypeFactory.parse(key), - preferences.get(key, null)); + EntryTypeFactory.parse(key), + preferences.get(key, null)); } } } catch (BackingStoreException ex) { @@ -1674,7 +1674,7 @@ public void storeGlobalCitationKeyPattern(GlobalCitationKeyPattern pattern) { this.globalCitationKeyPattern = pattern; if ((this.globalCitationKeyPattern.getDefaultValue() == null) - || this.globalCitationKeyPattern.getDefaultValue().isEmpty()) { + || this.globalCitationKeyPattern.getDefaultValue().isEmpty()) { put(DEFAULT_CITATION_KEY_PATTERN, ""); } else { put(DEFAULT_CITATION_KEY_PATTERN, globalCitationKeyPattern.getDefaultValue().get(0)); @@ -1706,8 +1706,7 @@ private void clearCitationKeyPatterns() throws BackingStoreException { @Override public CitationKeyPatternPreferences getCitationKeyPatternPreferences() { - CitationKeyPatternPreferences.KeySuffix keySuffix = - CitationKeyPatternPreferences.KeySuffix.SECOND_WITH_B; + CitationKeyPatternPreferences.KeySuffix keySuffix = CitationKeyPatternPreferences.KeySuffix.SECOND_WITH_B; if (getBoolean(KEY_GEN_ALWAYS_ADD_LETTER)) { keySuffix = CitationKeyPatternPreferences.KeySuffix.ALWAYS; @@ -1716,15 +1715,15 @@ public CitationKeyPatternPreferences getCitationKeyPatternPreferences() { } return new CitationKeyPatternPreferences( - getBoolean(AVOID_OVERWRITING_KEY), - getBoolean(WARN_BEFORE_OVERWRITING_KEY), - getBoolean(GENERATE_KEYS_BEFORE_SAVING), - keySuffix, - get(KEY_PATTERN_REGEX), - get(KEY_PATTERN_REPLACEMENT), - get(UNWANTED_CITATION_KEY_CHARACTERS), - getGlobalCitationKeyPattern(), - getKeywordDelimiter()); + getBoolean(AVOID_OVERWRITING_KEY), + getBoolean(WARN_BEFORE_OVERWRITING_KEY), + getBoolean(GENERATE_KEYS_BEFORE_SAVING), + keySuffix, + get(KEY_PATTERN_REGEX), + get(KEY_PATTERN_REPLACEMENT), + get(UNWANTED_CITATION_KEY_CHARACTERS), + getGlobalCitationKeyPattern(), + getKeywordDelimiter()); } @Override @@ -1770,10 +1769,9 @@ public PushToApplicationPreferences getPushToApplicationPreferences() { applicationCommands.put(PushToApplicationConstants.WIN_EDT, get(PUSH_WINEDT_PATH)); return new PushToApplicationPreferences( - applicationCommands, - get(PUSH_EMACS_ADDITIONAL_PARAMETERS), - get(PUSH_VIM_SERVER) - ); + applicationCommands, + get(PUSH_EMACS_ADDITIONAL_PARAMETERS), + get(PUSH_VIM_SERVER)); } @Override @@ -1792,14 +1790,14 @@ public void storePushToApplicationPreferences(PushToApplicationPreferences prefe @Override public ExternalApplicationsPreferences getExternalApplicationsPreferences() { return new ExternalApplicationsPreferences( - get(EMAIL_SUBJECT), - getBoolean(OPEN_FOLDERS_OF_ATTACHED_FILES), - get(PUSH_TO_APPLICATION), - get(CITE_COMMAND), - !getBoolean(USE_DEFAULT_CONSOLE_APPLICATION), // mind the ! - get(CONSOLE_COMMAND), - !getBoolean(USE_DEFAULT_FILE_BROWSER_APPLICATION), // mind the ! - get(FILE_BROWSER_COMMAND)); + get(EMAIL_SUBJECT), + getBoolean(OPEN_FOLDERS_OF_ATTACHED_FILES), + get(PUSH_TO_APPLICATION), + get(CITE_COMMAND), + !getBoolean(USE_DEFAULT_CONSOLE_APPLICATION), // mind the ! + get(CONSOLE_COMMAND), + !getBoolean(USE_DEFAULT_FILE_BROWSER_APPLICATION), // mind the ! + get(FILE_BROWSER_COMMAND)); } @Override @@ -1845,8 +1843,8 @@ private List createMainTableColumnSortOrder() { @Override public ColumnPreferences getColumnPreferences() { return new ColumnPreferences( - createMainTableColumns(), - createMainTableColumnSortOrder()); + createMainTableColumns(), + createMainTableColumnSortOrder()); } /** @@ -1863,8 +1861,8 @@ public void storeMainTableColumnPreferences(ColumnPreferences columnPreferences) @Override public MainTablePreferences getMainTablePreferences() { return new MainTablePreferences(getColumnPreferences(), - getBoolean(AUTO_RESIZE_MODE), - getBoolean(EXTRA_FILE_COLUMNS)); + getBoolean(AUTO_RESIZE_MODE), + getBoolean(EXTRA_FILE_COLUMNS)); } @Override @@ -1893,8 +1891,8 @@ public MainTableNameFormatPreferences getMainTableNameFormatPreferences() { } return new MainTableNameFormatPreferences( - displayStyle, - abbreviationStyle); + displayStyle, + abbreviationStyle); } @Override @@ -1914,21 +1912,21 @@ public void storeMainTableNameFormatPreferences(MainTableNameFormatPreferences p public List updateColumns(String columnNamesList, String columnWidthList, String sortTypeList, double defaultWidth) { List columnNames = getStringList(columnNamesList); List columnWidths = getStringList(columnWidthList) - .stream() - .map(string -> { - try { - return Double.parseDouble(string); - } catch (NumberFormatException e) { - LOGGER.error("Exception while parsing column widths. Choosing default.", e); - return defaultWidth; - } - }) - .collect(Collectors.toList()); + .stream() + .map(string -> { + try { + return Double.parseDouble(string); + } catch (NumberFormatException e) { + LOGGER.error("Exception while parsing column widths. Choosing default.", e); + return defaultWidth; + } + }) + .collect(Collectors.toList()); List columnSortTypes = getStringList(sortTypeList) - .stream() - .map(SortType::valueOf) - .collect(Collectors.toList()); + .stream() + .map(SortType::valueOf) + .collect(Collectors.toList()); List columns = new ArrayList<>(); for (int i = 0; i < columnNames.size(); i++) { @@ -1972,20 +1970,18 @@ private List createSearchDialogColumnSortOrder() { */ private List updateColumnSortOrder(String sortOrderList, List tableColumns) { List columnsOrdered = new ArrayList<>(); - getStringList(sortOrderList).forEach(columnName -> - tableColumns.stream().filter(column -> - column.getName().equals(columnName)) - .findFirst() - .ifPresent(columnsOrdered::add)); + getStringList(sortOrderList).forEach(columnName -> tableColumns.stream().filter(column -> column.getName().equals(columnName)) + .findFirst() + .ifPresent(columnsOrdered::add)); - return columnsOrdered; + return columnsOrdered; } @Override public ColumnPreferences getSearchDialogColumnPreferences() { return new ColumnPreferences( - createSearchDialogColumns(), - createSearchDialogColumnSortOrder()); + createSearchDialogColumns(), + createSearchDialogColumnSortOrder()); } /** @@ -2001,8 +1997,8 @@ public void storeSearchDialogColumnPreferences(ColumnPreferences columnPreferenc private List storeColumnPreferences(ColumnPreferences columnPreferences, String columnNamesList, String columnWidthList, String sortTypeList, String sortOrderList) { putStringList(columnNamesList, columnPreferences.getColumns().stream() - .map(MainTableColumnModel::getName) - .collect(Collectors.toList())); + .map(MainTableColumnModel::getName) + .collect(Collectors.toList())); List columnWidthsInOrder = new ArrayList<>(); columnPreferences.getColumns().forEach(column -> columnWidthsInOrder.add(column.widthProperty().getValue().toString())); @@ -2013,9 +2009,9 @@ private List storeColumnPreferences(ColumnPreferences colu putStringList(sortTypeList, columnSortTypesInOrder); putStringList(sortOrderList, columnPreferences - .getColumnSortOrder().stream() - .map(MainTableColumnModel::getName) - .collect(Collectors.toList())); + .getColumnSortOrder().stream() + .map(MainTableColumnModel::getName) + .collect(Collectors.toList())); return columnPreferences.getColumns(); } @@ -2044,10 +2040,9 @@ public AppearancePreferences getAppearancePreferences() { } appearancePreferences = new AppearancePreferences( - getBoolean(OVERRIDE_DEFAULT_FONT_SIZE), - getInt(MAIN_FONT_SIZE), - getTheme() - ); + getBoolean(OVERRIDE_DEFAULT_FONT_SIZE), + getInt(MAIN_FONT_SIZE), + getTheme()); EasyBind.listen(appearancePreferences.shouldOverrideDefaultFontSizeProperty(), (obs, oldValue, newValue) -> putBoolean(OVERRIDE_DEFAULT_FONT_SIZE, newValue)); EasyBind.listen(appearancePreferences.mainFontSizeProperty(), (obs, oldValue, newValue) -> putInt(MAIN_FONT_SIZE, newValue)); @@ -2063,26 +2058,24 @@ public AppearancePreferences getAppearancePreferences() { @Override public ImportFormatPreferences getImportFormatPreferences() { return new ImportFormatPreferences( - getCustomImportFormats(), - getKeywordDelimiter(), - getCitationKeyPatternPreferences(), - getFieldContentParserPreferences(), - getXmpPreferences(), - getDOIPreferences()); + getCustomImportFormats(), + getKeywordDelimiter(), + getCitationKeyPatternPreferences(), + getFieldContentParserPreferences(), + getXmpPreferences(), + getDOIPreferences()); } @Override public SaveOrderConfig getExportSaveOrder() { List sortCriteria = List.of( - new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_PRIMARY_SORT_FIELD)), getBoolean(EXPORT_PRIMARY_SORT_DESCENDING)), - new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_SECONDARY_SORT_FIELD)), getBoolean(EXPORT_SECONDARY_SORT_DESCENDING)), - new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_TERTIARY_SORT_FIELD)), getBoolean(EXPORT_TERTIARY_SORT_DESCENDING)) - ); + new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_PRIMARY_SORT_FIELD)), getBoolean(EXPORT_PRIMARY_SORT_DESCENDING)), + new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_SECONDARY_SORT_FIELD)), getBoolean(EXPORT_SECONDARY_SORT_DESCENDING)), + new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_TERTIARY_SORT_FIELD)), getBoolean(EXPORT_TERTIARY_SORT_DESCENDING))); return new SaveOrderConfig( - SaveOrderConfig.OrderType.fromBooleans(getBoolean(EXPORT_IN_SPECIFIED_ORDER), getBoolean(EXPORT_IN_ORIGINAL_ORDER)), - sortCriteria - ); + SaveOrderConfig.OrderType.fromBooleans(getBoolean(EXPORT_IN_SPECIFIED_ORDER), getBoolean(EXPORT_IN_ORIGINAL_ORDER)), + sortCriteria); } @Override @@ -2107,8 +2100,8 @@ private SaveOrderConfig loadTableSaveOrder() { for (var column : sortOrder) { boolean descending = (column.getSortType() == SortType.DESCENDING); config.getSortCriteria().add(new SaveOrderConfig.SortCriterion( - FieldFactory.parseField(column.getQualifier()), - descending)); + FieldFactory.parseField(column.getQualifier()), + descending)); } return config; @@ -2127,21 +2120,21 @@ public SavePreferences getSavePreferencesForExport() { } return getSavePreferences() - .withSaveInOriginalOrder(saveInOriginalOrder) - .withSaveOrder(saveOrder) - .withTakeMetadataSaveOrderInAccount(false); + .withSaveInOriginalOrder(saveInOriginalOrder) + .withSaveOrder(saveOrder) + .withTakeMetadataSaveOrderInAccount(false); } @Override public SavePreferences getSavePreferences() { return new SavePreferences( - false, - null, - SavePreferences.DatabaseSaveType.ALL, - true, - this.getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT), - this.getFieldWriterPreferences(), - getCitationKeyPatternPreferences()); + false, + null, + SavePreferences.DatabaseSaveType.ALL, + true, + this.getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT), + this.getFieldWriterPreferences(), + getCitationKeyPatternPreferences()); } @Override @@ -2157,15 +2150,15 @@ public void storeOpenLastFilesOnStartup(boolean openLastFilesOnStartup) { @Override public FieldContentFormatterPreferences getFieldContentParserPreferences() { return new FieldContentFormatterPreferences( - getStringList(NON_WRAPPABLE_FIELDS).stream().map(FieldFactory::parseField).collect(Collectors.toList())); + getStringList(NON_WRAPPABLE_FIELDS).stream().map(FieldFactory::parseField).collect(Collectors.toList())); } @Override public FieldWriterPreferences getFieldWriterPreferences() { return new FieldWriterPreferences( - getBoolean(RESOLVE_STRINGS_ALL_FIELDS), - getStringList(DO_NOT_RESOLVE_STRINGS_FOR).stream().map(FieldFactory::parseField).collect(Collectors.toList()), - getFieldContentParserPreferences()); + getBoolean(RESOLVE_STRINGS_ALL_FIELDS), + getStringList(DO_NOT_RESOLVE_STRINGS_FOR).stream().map(FieldFactory::parseField).collect(Collectors.toList()), + getFieldContentParserPreferences()); } @Override @@ -2191,14 +2184,13 @@ public FilePreferences getFilePreferences() { } filePreferences = new FilePreferences( - getUser(), - get(MAIN_FILE_DIRECTORY), - getBoolean(STORE_RELATIVE_TO_BIB), - get(IMPORT_FILENAMEPATTERN), - get(IMPORT_FILEDIRPATTERN), - getBoolean(DOWNLOAD_LINKED_FILES), - Path.of(get(WORKING_DIRECTORY)) - ); + getUser(), + get(MAIN_FILE_DIRECTORY), + getBoolean(STORE_RELATIVE_TO_BIB), + get(IMPORT_FILENAMEPATTERN), + get(IMPORT_FILEDIRPATTERN), + getBoolean(DOWNLOAD_LINKED_FILES), + Path.of(get(WORKING_DIRECTORY))); EasyBind.listen(filePreferences.mainFileDirectoryProperty(), (obs, oldValue, newValue) -> put(MAIN_FILE_DIRECTORY, filePreferences.getFileDirectory().map(Path::toString).orElse(""))); EasyBind.listen(filePreferences.storeFilesRelativeToBibFileProperty(), (obs, oldValue, newValue) -> putBoolean(STORE_RELATIVE_TO_BIB, newValue)); @@ -2220,7 +2212,7 @@ private String getUser() { return userName; } catch (UnknownHostException ex) { LOGGER.error("Hostname not found. Please go to https://docs.jabref.org/ to find possible " + - "problem resolution", ex); + "problem resolution", ex); return get(DEFAULT_OWNER); } } @@ -2231,8 +2223,7 @@ public AutoLinkPreferences getAutoLinkPreferences() { return autoLinkPreferences; } - AutoLinkPreferences.CitationKeyDependency citationKeyDependency = - AutoLinkPreferences.CitationKeyDependency.START; // default + AutoLinkPreferences.CitationKeyDependency citationKeyDependency = AutoLinkPreferences.CitationKeyDependency.START; // default if (getBoolean(AUTOLINK_EXACT_KEY_ONLY)) { citationKeyDependency = AutoLinkPreferences.CitationKeyDependency.EXACT; } else if (getBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY)) { @@ -2240,28 +2231,28 @@ public AutoLinkPreferences getAutoLinkPreferences() { } autoLinkPreferences = new AutoLinkPreferences( - citationKeyDependency, - get(AUTOLINK_REG_EXP_SEARCH_EXPRESSION_KEY), - getBoolean(ASK_AUTO_NAMING_PDFS_AGAIN), - getKeywordDelimiter()); + citationKeyDependency, + get(AUTOLINK_REG_EXP_SEARCH_EXPRESSION_KEY), + getBoolean(ASK_AUTO_NAMING_PDFS_AGAIN), + getKeywordDelimiter()); EasyBind.listen(autoLinkPreferences.citationKeyDependencyProperty(), (obs, oldValue, newValue) -> { - // Starts bibtex only omitted, as it is not being saved - switch (newValue) { - case START -> { - putBoolean(AUTOLINK_EXACT_KEY_ONLY, false); - putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, false); - } - case EXACT -> { - putBoolean(AUTOLINK_EXACT_KEY_ONLY, true); - putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, false); - } - case REGEX -> { - putBoolean(AUTOLINK_EXACT_KEY_ONLY, false); - putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, true); - } - } - }); + // Starts bibtex only omitted, as it is not being saved + switch (newValue) { + case START -> { + putBoolean(AUTOLINK_EXACT_KEY_ONLY, false); + putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, false); + } + case EXACT -> { + putBoolean(AUTOLINK_EXACT_KEY_ONLY, true); + putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, false); + } + case REGEX -> { + putBoolean(AUTOLINK_EXACT_KEY_ONLY, false); + putBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY, true); + } + } + }); EasyBind.listen(autoLinkPreferences.askAutoNamingPdfsProperty(), (obs, oldValue, newValue) -> putBoolean(ASK_AUTO_NAMING_PDFS_AGAIN, newValue)); EasyBind.listen(autoLinkPreferences.regularExpressionProperty(), (obs, oldValue, newValue) -> put(AUTOLINK_REG_EXP_SEARCH_EXPRESSION_KEY, newValue)); @@ -2289,14 +2280,14 @@ public ImportExportPreferences getImportExportPreferences() { } importExportPreferences = new ImportExportPreferences( - get(NON_WRAPPABLE_FIELDS), - !getBoolean(RESOLVE_STRINGS_ALL_FIELDS), - getBoolean(RESOLVE_STRINGS_ALL_FIELDS), - get(DO_NOT_RESOLVE_STRINGS_FOR), - getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT), - Path.of(get(IMPORT_WORKING_DIRECTORY)), - get(LAST_USED_EXPORT), - Path.of(get(EXPORT_WORKING_DIRECTORY))); + get(NON_WRAPPABLE_FIELDS), + !getBoolean(RESOLVE_STRINGS_ALL_FIELDS), + getBoolean(RESOLVE_STRINGS_ALL_FIELDS), + get(DO_NOT_RESOLVE_STRINGS_FOR), + getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT), + Path.of(get(IMPORT_WORKING_DIRECTORY)), + get(LAST_USED_EXPORT), + Path.of(get(EXPORT_WORKING_DIRECTORY))); EasyBind.listen(importExportPreferences.nonWrappableFieldsProperty(), (obs, oldValue, newValue) -> put(NON_WRAPPABLE_FIELDS, newValue)); EasyBind.listen(importExportPreferences.resolveStringsForStandardBibtexFieldsProperty(), (obs, oldValue, newValue) -> putBoolean(RESOLVE_STRINGS_ALL_FIELDS, newValue)); @@ -2373,7 +2364,7 @@ public List getCustomExportFormats(JournalAbbreviationReposito filename = formatData.get(EXPORTER_FILENAME_INDEX); extension = formatData.get(EXPORTER_EXTENSION_INDEX); TemplateExporter format = new TemplateExporter(exporterName, filename, extension, - layoutPreferences, savePreferences); + layoutPreferences, savePreferences); format.setCustomExport(true); formats.add(format); i++; @@ -2485,14 +2476,12 @@ public SidePanePreferences getSidePanePreferences() { } sidePanePreferences = new SidePanePreferences( - getVisiblePanes(), - getSidePanePreferredPositions(), - getInt(SELECTED_FETCHER_INDEX)); - - sidePanePreferences.visiblePanes().addListener((InvalidationListener) listener -> - storeVisiblePanes(sidePanePreferences.visiblePanes())); - sidePanePreferences.getPreferredPositions().addListener((InvalidationListener) listener -> - storeSidePanePreferredPositions(sidePanePreferences.getPreferredPositions())); + getVisiblePanes(), + getSidePanePreferredPositions(), + getInt(SELECTED_FETCHER_INDEX)); + + sidePanePreferences.visiblePanes().addListener((InvalidationListener) listener -> storeVisiblePanes(sidePanePreferences.visiblePanes())); + sidePanePreferences.getPreferredPositions().addListener((InvalidationListener) listener -> storeSidePanePreferredPositions(sidePanePreferences.getPreferredPositions())); EasyBind.listen(sidePanePreferences.webSearchFetcherSelectedProperty(), (obs, oldValue, newValue) -> putInt(SELECTED_FETCHER_INDEX, newValue)); return sidePanePreferences; @@ -2564,15 +2553,15 @@ public GuiPreferences getGuiPreferences() { } guiPreferences = new GuiPreferences( - getDouble(POS_X), - getDouble(POS_Y), - getDouble(SIZE_X), - getDouble(SIZE_Y), - getBoolean(WINDOW_MAXIMISED), - getBoolean(OPEN_LAST_EDITED), - getStringList(LAST_EDITED), - Path.of(get(LAST_FOCUSED)), - getDouble(SIDE_PANE_WIDTH)); + getDouble(POS_X), + getDouble(POS_Y), + getDouble(SIZE_X), + getDouble(SIZE_Y), + getBoolean(WINDOW_MAXIMISED), + getBoolean(OPEN_LAST_EDITED), + getStringList(LAST_EDITED), + Path.of(get(LAST_FOCUSED)), + getDouble(SIDE_PANE_WIDTH)); EasyBind.listen(guiPreferences.positionXProperty(), (obs, oldValue, newValue) -> putDouble(POS_X, newValue.doubleValue())); EasyBind.listen(guiPreferences.positionYProperty(), (obs, oldValue, newValue) -> putDouble(POS_Y, newValue.doubleValue())); @@ -2580,8 +2569,7 @@ public GuiPreferences getGuiPreferences() { EasyBind.listen(guiPreferences.sizeYProperty(), (obs, oldValue, newValue) -> putDouble(SIZE_Y, newValue.doubleValue())); EasyBind.listen(guiPreferences.windowMaximisedProperty(), (obs, oldValue, newValue) -> putBoolean(WINDOW_MAXIMISED, newValue)); EasyBind.listen(guiPreferences.openLastEditedProperty(), (obs, oldValue, newValue) -> putBoolean(OPEN_LAST_EDITED, newValue)); - guiPreferences.getLastFilesOpened().addListener((InvalidationListener) change -> - putStringList(LAST_EDITED, guiPreferences.getLastFilesOpened())); + guiPreferences.getLastFilesOpened().addListener((InvalidationListener) change -> putStringList(LAST_EDITED, guiPreferences.getLastFilesOpened())); EasyBind.listen(guiPreferences.lastFocusedFileProperty(), (obs, oldValue, newValue) -> { if (newValue != null) { put(LAST_FOCUSED, newValue.toAbsolutePath().toString()); @@ -2618,19 +2606,19 @@ public SearchPreferences getSearchPreferences() { } searchPreferences = new SearchPreferences( - searchDisplayMode, - getBoolean(SEARCH_CASE_SENSITIVE), - getBoolean(SEARCH_REG_EXP), - getBoolean(SEARCH_FULLTEXT), - getBoolean(SEARCH_KEEP_SEARCH_STRING), - getBoolean(SEARCH_KEEP_GLOBAL_WINDOW_ON_TOP)); + searchDisplayMode, + getBoolean(SEARCH_CASE_SENSITIVE), + getBoolean(SEARCH_REG_EXP), + getBoolean(SEARCH_FULLTEXT), + getBoolean(SEARCH_KEEP_SEARCH_STRING), + getBoolean(SEARCH_KEEP_GLOBAL_WINDOW_ON_TOP)); EasyBind.listen(searchPreferences.searchDisplayModeProperty(), (obs, oldValue, newValue) -> put(SEARCH_DISPLAY_MODE, Objects.requireNonNull(searchPreferences.getSearchDisplayMode()).toString())); searchPreferences.getObservableSearchFlags().addListener((SetChangeListener) c -> { - putBoolean(SEARCH_CASE_SENSITIVE, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.CASE_SENSITIVE)); - putBoolean(SEARCH_REG_EXP, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.REGULAR_EXPRESSION)); - putBoolean(SEARCH_FULLTEXT, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.FULLTEXT)); - putBoolean(SEARCH_KEEP_SEARCH_STRING, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.KEEP_SEARCH_STRING)); + putBoolean(SEARCH_CASE_SENSITIVE, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.CASE_SENSITIVE)); + putBoolean(SEARCH_REG_EXP, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.REGULAR_EXPRESSION)); + putBoolean(SEARCH_FULLTEXT, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.FULLTEXT)); + putBoolean(SEARCH_KEEP_SEARCH_STRING, searchPreferences.getObservableSearchFlags().contains(SearchRules.SearchFlags.KEEP_SEARCH_STRING)); }); EasyBind.listen(searchPreferences.keepWindowOnTopProperty(), (obs, oldValue, newValue) -> putBoolean(SEARCH_KEEP_GLOBAL_WINDOW_ON_TOP, searchPreferences.shouldKeepWindowOnTop())); @@ -2644,9 +2632,9 @@ public SearchPreferences getSearchPreferences() { @Override public XmpPreferences getXmpPreferences() { return new XmpPreferences( - getBoolean(USE_XMP_PRIVACY_FILTER), - getStringList(XMP_PRIVACY_FILTERS).stream().map(FieldFactory::parseField).collect(Collectors.toSet()), - getKeywordDelimiter()); + getBoolean(USE_XMP_PRIVACY_FILTER), + getStringList(XMP_PRIVACY_FILTERS).stream().map(FieldFactory::parseField).collect(Collectors.toSet()), + getKeywordDelimiter()); } @Override @@ -2662,13 +2650,11 @@ public NameFormatterPreferences getNameFormatterPreferences() { } nameFormatterPreferences = new NameFormatterPreferences( - getStringList(NAME_FORMATER_KEY), - getStringList(NAME_FORMATTER_VALUE)); + getStringList(NAME_FORMATER_KEY), + getStringList(NAME_FORMATTER_VALUE)); - nameFormatterPreferences.getNameFormatterKey().addListener((InvalidationListener) change -> - putStringList(NAME_FORMATER_KEY, nameFormatterPreferences.getNameFormatterKey())); - nameFormatterPreferences.getNameFormatterValue().addListener((InvalidationListener) change -> - putStringList(NAME_FORMATTER_VALUE, nameFormatterPreferences.getNameFormatterValue())); + nameFormatterPreferences.getNameFormatterKey().addListener((InvalidationListener) change -> putStringList(NAME_FORMATER_KEY, nameFormatterPreferences.getNameFormatterKey())); + nameFormatterPreferences.getNameFormatterValue().addListener((InvalidationListener) change -> putStringList(NAME_FORMATTER_VALUE, nameFormatterPreferences.getNameFormatterValue())); return nameFormatterPreferences; } @@ -2683,11 +2669,11 @@ public AutoCompletePreferences getAutoCompletePreferences() { } return new AutoCompletePreferences( - getBoolean(AUTO_COMPLETE), - AutoCompleteFirstNameMode.parse(get(AUTOCOMPLETER_FIRSTNAME_MODE)), - nameFormat, - getStringList(AUTOCOMPLETER_COMPLETE_FIELDS).stream().map(FieldFactory::parseField).collect(Collectors.toSet()), - getJournalAbbreviationPreferences()); + getBoolean(AUTO_COMPLETE), + AutoCompleteFirstNameMode.parse(get(AUTOCOMPLETER_FIRSTNAME_MODE)), + nameFormat, + getStringList(AUTOCOMPLETER_COMPLETE_FIELDS).stream().map(FieldFactory::parseField).collect(Collectors.toSet()), + getJournalAbbreviationPreferences()); } @Override @@ -2758,10 +2744,10 @@ public MrDlibPreferences getMrDlibPreferences() { } mrDlibPreferences = new MrDlibPreferences( - getBoolean(ACCEPT_RECOMMENDATIONS), - getBoolean(SEND_LANGUAGE_DATA), - getBoolean(SEND_OS_DATA), - getBoolean(SEND_TIMEZONE_DATA)); + getBoolean(ACCEPT_RECOMMENDATIONS), + getBoolean(SEND_LANGUAGE_DATA), + getBoolean(SEND_OS_DATA), + getBoolean(SEND_TIMEZONE_DATA)); EasyBind.listen(mrDlibPreferences.acceptRecommendationsProperty(), (obs, oldValue, newValue) -> putBoolean(ACCEPT_RECOMMENDATIONS, newValue)); EasyBind.listen(mrDlibPreferences.sendLanguageProperty(), (obs, oldValue, newValue) -> putBoolean(SEND_LANGUAGE_DATA, newValue)); @@ -2788,20 +2774,15 @@ public ProtectedTermsPreferences getProtectedTermsPreferences() { } protectedTermsPreferences = new ProtectedTermsPreferences( - getStringList(PROTECTED_TERMS_ENABLED_INTERNAL), - getStringList(PROTECTED_TERMS_ENABLED_EXTERNAL), - getStringList(PROTECTED_TERMS_DISABLED_INTERNAL), - getStringList(PROTECTED_TERMS_DISABLED_EXTERNAL) - ); + getStringList(PROTECTED_TERMS_ENABLED_INTERNAL), + getStringList(PROTECTED_TERMS_ENABLED_EXTERNAL), + getStringList(PROTECTED_TERMS_DISABLED_INTERNAL), + getStringList(PROTECTED_TERMS_DISABLED_EXTERNAL)); - protectedTermsPreferences.getEnabledExternalTermLists().addListener((InvalidationListener) change -> - putStringList(PROTECTED_TERMS_ENABLED_EXTERNAL, protectedTermsPreferences.getEnabledExternalTermLists())); - protectedTermsPreferences.getDisabledExternalTermLists().addListener((InvalidationListener) change -> - putStringList(PROTECTED_TERMS_DISABLED_EXTERNAL, protectedTermsPreferences.getDisabledExternalTermLists())); - protectedTermsPreferences.getEnabledInternalTermLists().addListener((InvalidationListener) change -> - putStringList(PROTECTED_TERMS_ENABLED_INTERNAL, protectedTermsPreferences.getEnabledInternalTermLists())); - protectedTermsPreferences.getDisabledInternalTermLists().addListener((InvalidationListener) change -> - putStringList(PROTECTED_TERMS_DISABLED_INTERNAL, protectedTermsPreferences.getDisabledInternalTermLists())); + protectedTermsPreferences.getEnabledExternalTermLists().addListener((InvalidationListener) change -> putStringList(PROTECTED_TERMS_ENABLED_EXTERNAL, protectedTermsPreferences.getEnabledExternalTermLists())); + protectedTermsPreferences.getDisabledExternalTermLists().addListener((InvalidationListener) change -> putStringList(PROTECTED_TERMS_DISABLED_EXTERNAL, protectedTermsPreferences.getDisabledExternalTermLists())); + protectedTermsPreferences.getEnabledInternalTermLists().addListener((InvalidationListener) change -> putStringList(PROTECTED_TERMS_ENABLED_INTERNAL, protectedTermsPreferences.getEnabledInternalTermLists())); + protectedTermsPreferences.getDisabledInternalTermLists().addListener((InvalidationListener) change -> putStringList(PROTECTED_TERMS_DISABLED_INTERNAL, protectedTermsPreferences.getDisabledInternalTermLists())); return protectedTermsPreferences; } @@ -2817,11 +2798,10 @@ public ImporterPreferences getImporterPreferences() { } importerPreferences = new ImporterPreferences( - getBoolean(GENERATE_KEY_ON_IMPORT), - getBoolean(GROBID_ENABLED), - getBoolean(GROBID_OPT_OUT), - get(GROBID_URL) - ); + getBoolean(GENERATE_KEY_ON_IMPORT), + getBoolean(GROBID_ENABLED), + getBoolean(GROBID_OPT_OUT), + get(GROBID_URL)); EasyBind.listen(importerPreferences.generateNewKeyOnImportProperty(), (obs, oldValue, newValue) -> putBoolean(GENERATE_KEY_ON_IMPORT, newValue)); EasyBind.listen(importerPreferences.grobidEnabledProperty(), (obs, oldValue, newValue) -> putBoolean(GROBID_ENABLED, newValue)); From de38fcc8837684b632935529c7f16fbd8c0c5e2e Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Fri, 26 Nov 2021 00:29:16 +0100 Subject: [PATCH 10/13] Remove library col from main table... --- src/main/java/org/jabref/gui/maintable/MainTable.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/jabref/gui/maintable/MainTable.java b/src/main/java/org/jabref/gui/maintable/MainTable.java index 3714669f731..6c4d1ac56a1 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTable.java +++ b/src/main/java/org/jabref/gui/maintable/MainTable.java @@ -35,6 +35,7 @@ import org.jabref.gui.externalfiletype.ExternalFileTypes; import org.jabref.gui.keyboard.KeyBinding; import org.jabref.gui.keyboard.KeyBindingRepository; +import org.jabref.gui.maintable.columns.LibraryColumn; import org.jabref.gui.maintable.columns.MainTableColumn; import org.jabref.gui.util.ControlHelper; import org.jabref.gui.util.CustomLocalDragboard; @@ -107,6 +108,8 @@ public MainTable(MainTableDataModel model, dialogService, stateManager).createColumns()); + this.getColumns().removeIf(col -> col instanceof LibraryColumn); + new ViewModelTableRowFactory() .withOnMouseClickedEvent((entry, event) -> { if (event.getClickCount() == 2) { From e741a30b548b74e5994fd72a4b9f913859a06095 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Fri, 26 Nov 2021 00:30:06 +0100 Subject: [PATCH 11/13] fix checkstyle --- .../java/org/jabref/gui/search/GlobalSearchResultDialog.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/org/jabref/gui/search/GlobalSearchResultDialog.java b/src/main/java/org/jabref/gui/search/GlobalSearchResultDialog.java index 721f8417109..5787897b98c 100644 --- a/src/main/java/org/jabref/gui/search/GlobalSearchResultDialog.java +++ b/src/main/java/org/jabref/gui/search/GlobalSearchResultDialog.java @@ -13,8 +13,6 @@ import org.jabref.gui.StateManager; import org.jabref.gui.externalfiletype.ExternalFileTypes; import org.jabref.gui.icon.IconTheme; -import org.jabref.gui.maintable.MainTableColumnModel; -import org.jabref.gui.maintable.columns.MainTableColumn; import org.jabref.gui.maintable.columns.SpecialFieldColumn; import org.jabref.gui.preview.PreviewViewer; import org.jabref.gui.util.BaseDialog; @@ -22,7 +20,6 @@ import com.airhacks.afterburner.views.ViewLoader; import com.tobiasdiez.easybind.EasyBind; -import scala.collection.parallel.ParIterableLike.Min; public class GlobalSearchResultDialog extends BaseDialog { From 2e2715ac07feb55a4c9e61d199d23cc34f411994 Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage Date: Sun, 28 Nov 2021 18:29:54 +0100 Subject: [PATCH 12/13] Reverted unnecessary reformatting --- .../jabref/preferences/JabRefPreferences.java | 454 +++++++++--------- 1 file changed, 240 insertions(+), 214 deletions(-) diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 3af0ea6d8e3..6399c5cc13b 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -703,24 +703,24 @@ private JabRefPreferences() { defaults.put(PREVIEW_PANEL_HEIGHT, 0.65); defaults.put(PREVIEW_AS_TAB, Boolean.FALSE); defaults.put(PREVIEW_STYLE, - "" + - "\\bibtextype\\begin{citationkey} (\\citationkey)\\end{citationkey}__NEWLINE__" + - "\\begin{author}

\\format[Authors(LastFirst, FullName,Sep= / ,LastSep= / ),HTMLChars]{\\author}\\end{author}__NEWLINE__" + - "\\begin{editor & !author}

\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & !author}__NEWLINE__" + - "\\begin{title}
\\format[HTMLChars]{\\title} \\end{title}__NEWLINE__" + - "
\\begin{date}\\date\\end{date}\\begin{edition}, \\edition. edition\\end{edition}__NEWLINE__" + - "\\begin{editor & author}

\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & author}__NEWLINE__" + - "\\begin{booktitle}
\\format[HTMLChars]{\\booktitle}\\end{booktitle}__NEWLINE__" + - "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}" + - "\\begin{editor & !author}
\\end{editor & !author}\\begin{!editor}
\\end{!editor}\\begin{journal}
\\format[HTMLChars]{\\journal} \\end{journal} \\begin{volume}, Vol. \\volume\\end{volume}\\begin{series}
\\format[HTMLChars]{\\series}\\end{series}\\begin{number}, No. \\format[HTMLChars]{\\number}\\end{number}__NEWLINE__" + - "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + - "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" + - "\\begin{publisher}
\\format[HTMLChars]{\\publisher}\\end{publisher}\\begin{location}: \\format[HTMLChars]{\\location} \\end{location}__NEWLINE__" + - "\\begin{pages}
p. \\format[FormatPagesForHTML]{\\pages}\\end{pages}__NEWLINE__" + - "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" + - "\\begin{owncitation}

Own citation: \\format[HTMLChars]{\\owncitation} \\end{owncitation}__NEWLINE__" + - "\\begin{comment}

Comment: \\format[HTMLChars]{\\comment}\\end{comment}__NEWLINE__" + - "
__NEWLINE__"); + "" + + "\\bibtextype\\begin{citationkey} (\\citationkey)\\end{citationkey}__NEWLINE__" + + "\\begin{author}

\\format[Authors(LastFirst, FullName,Sep= / ,LastSep= / ),HTMLChars]{\\author}\\end{author}__NEWLINE__" + + "\\begin{editor & !author}

\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & !author}__NEWLINE__" + + "\\begin{title}
\\format[HTMLChars]{\\title} \\end{title}__NEWLINE__" + + "
\\begin{date}\\date\\end{date}\\begin{edition}, \\edition. edition\\end{edition}__NEWLINE__" + + "\\begin{editor & author}

\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & author}__NEWLINE__" + + "\\begin{booktitle}
\\format[HTMLChars]{\\booktitle}\\end{booktitle}__NEWLINE__" + + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}" + + "\\begin{editor & !author}
\\end{editor & !author}\\begin{!editor}
\\end{!editor}\\begin{journal}
\\format[HTMLChars]{\\journal} \\end{journal} \\begin{volume}, Vol. \\volume\\end{volume}\\begin{series}
\\format[HTMLChars]{\\series}\\end{series}\\begin{number}, No. \\format[HTMLChars]{\\number}\\end{number}__NEWLINE__" + + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" + + "\\begin{publisher}
\\format[HTMLChars]{\\publisher}\\end{publisher}\\begin{location}: \\format[HTMLChars]{\\location} \\end{location}__NEWLINE__" + + "\\begin{pages}
p. \\format[FormatPagesForHTML]{\\pages}\\end{pages}__NEWLINE__" + + "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" + + "\\begin{owncitation}

Own citation: \\format[HTMLChars]{\\owncitation} \\end{owncitation}__NEWLINE__" + + "\\begin{comment}

Comment: \\format[HTMLChars]{\\comment}\\end{comment}__NEWLINE__" + + "
__NEWLINE__"); // set default theme defaults.put(FX_THEME, Theme.BASE_CSS); @@ -797,11 +797,11 @@ private static Optional getNextUnit(Reader data) throws IOException { private static void insertDefaultCleanupPreset(Map storage) { EnumSet deactivatedJobs = EnumSet.of( - CleanupPreset.CleanupStep.CLEAN_UP_UPGRADE_EXTERNAL_LINKS, - CleanupPreset.CleanupStep.MOVE_PDF, - CleanupPreset.CleanupStep.RENAME_PDF_ONLY_RELATIVE_PATHS, - CleanupPreset.CleanupStep.CONVERT_TO_BIBLATEX, - CleanupPreset.CleanupStep.CONVERT_TO_BIBTEX); + CleanupPreset.CleanupStep.CLEAN_UP_UPGRADE_EXTERNAL_LINKS, + CleanupPreset.CleanupStep.MOVE_PDF, + CleanupPreset.CleanupStep.RENAME_PDF_ONLY_RELATIVE_PATHS, + CleanupPreset.CleanupStep.CONVERT_TO_BIBLATEX, + CleanupPreset.CleanupStep.CONVERT_TO_BIBTEX); for (CleanupPreset.CleanupStep action : EnumSet.allOf(CleanupPreset.CleanupStep.class)) { storage.put(CLEANUP + action.name(), !deactivatedJobs.contains(action)); @@ -1053,8 +1053,10 @@ public void exportPreferences(Path file) throws JabRefException { try (OutputStream os = Files.newOutputStream(file)) { prefs.exportSubtree(os); } catch (BackingStoreException | IOException ex) { - throw new JabRefException("Could not export preferences", Localization.lang("Could not export preferences"), - ex); + throw new JabRefException( + "Could not export preferences", + Localization.lang("Could not export preferences"), + ex); } } @@ -1062,23 +1064,26 @@ public void exportPreferences(Path file) throws JabRefException { * Imports Preferences from an XML file. * * @param file Path of file to import from - * @throws JabRefException thrown if importing the preferences failed due to an InvalidPreferencesFormatException or an IOException + * @throws JabRefException thrown if importing the preferences failed due to an InvalidPreferencesFormatException or + * an IOException */ @Override public void importPreferences(Path file) throws JabRefException { try (InputStream is = Files.newInputStream(file)) { Preferences.importPreferences(is); } catch (InvalidPreferencesFormatException | IOException ex) { - throw new JabRefException("Could not import preferences", Localization.lang("Could not import preferences"), - ex); + throw new JabRefException( + "Could not import preferences", + Localization.lang("Could not import preferences"), + ex); } } @Override public FileLinkPreferences getFileLinkPreferences() { return new FileLinkPreferences( - get(MAIN_FILE_DIRECTORY), // REALLY HERE? - fileDirForDatabase); + get(MAIN_FILE_DIRECTORY), // REALLY HERE? + fileDirForDatabase); } @Override @@ -1089,20 +1094,20 @@ public void storeFileDirforDatabase(List dirs) { @Override public LayoutFormatterPreferences getLayoutFormatterPreferences(JournalAbbreviationRepository repository) { return new LayoutFormatterPreferences( - getNameFormatterPreferences(), - getFileLinkPreferences(), - repository); + getNameFormatterPreferences(), + getFileLinkPreferences(), + repository); } @Override public OpenOfficePreferences getOpenOfficePreferences() { return new OpenOfficePreferences( - get(OO_EXECUTABLE_PATH), - get(OO_PATH), - getBoolean(OO_USE_ALL_OPEN_BASES), - getBoolean(OO_SYNC_WHEN_CITING), - getStringList(OO_EXTERNAL_STYLE_FILES), - get(OO_BIBLIOGRAPHY_STYLE_FILE)); + get(OO_EXECUTABLE_PATH), + get(OO_PATH), + getBoolean(OO_USE_ALL_OPEN_BASES), + getBoolean(OO_SYNC_WHEN_CITING), + getStringList(OO_EXTERNAL_STYLE_FILES), + get(OO_BIBLIOGRAPHY_STYLE_FILE)); } @Override @@ -1136,8 +1141,8 @@ public JournalAbbreviationPreferences getJournalAbbreviationPreferences() { @Override public CleanupPreferences getCleanupPreferences(JournalAbbreviationRepository abbreviationRepository) { return new CleanupPreferences( - getLayoutFormatterPreferences(abbreviationRepository), - getFilePreferences()); + getLayoutFormatterPreferences(abbreviationRepository), + getFilePreferences()); } @Override @@ -1321,12 +1326,12 @@ public GeneralPreferences getGeneralPreferences() { } generalPreferences = new GeneralPreferences( - Charset.forName(get(DEFAULT_ENCODING)), - getBoolean(BIBLATEX_DEFAULT_MODE) ? BibDatabaseMode.BIBLATEX : BibDatabaseMode.BIBTEX, - getBoolean(WARN_ABOUT_DUPLICATES_IN_INSPECTION), - getBoolean(CONFIRM_DELETE), - getBoolean(MEMORY_STICK_MODE), - getBoolean(SHOW_ADVANCED_HINTS)); + Charset.forName(get(DEFAULT_ENCODING)), + getBoolean(BIBLATEX_DEFAULT_MODE) ? BibDatabaseMode.BIBLATEX : BibDatabaseMode.BIBTEX, + getBoolean(WARN_ABOUT_DUPLICATES_IN_INSPECTION), + getBoolean(CONFIRM_DELETE), + getBoolean(MEMORY_STICK_MODE), + getBoolean(SHOW_ADVANCED_HINTS)); EasyBind.listen(generalPreferences.defaultEncodingProperty(), (obs, oldValue, newValue) -> put(DEFAULT_ENCODING, newValue.name())); EasyBind.listen(generalPreferences.defaultBibDatabaseModeProperty(), (obs, oldValue, newValue) -> putBoolean(BIBLATEX_DEFAULT_MODE, (newValue == BibDatabaseMode.BIBLATEX))); @@ -1344,8 +1349,8 @@ public TelemetryPreferences getTelemetryPreferences() { return telemetryPreferences; } telemetryPreferences = new TelemetryPreferences( - getBoolean(COLLECT_TELEMETRY), - !getBoolean(ALREADY_ASKED_TO_COLLECT_TELEMETRY) // mind the ! + getBoolean(COLLECT_TELEMETRY), + !getBoolean(ALREADY_ASKED_TO_COLLECT_TELEMETRY) // mind the ! ); EasyBind.listen(telemetryPreferences.collectTelemetryProperty(), (obs, oldValue, newValue) -> putBoolean(COLLECT_TELEMETRY, newValue)); EasyBind.listen(telemetryPreferences.askToCollectTelemetryProperty(), (obs, oldValue, newValue) -> putBoolean(ALREADY_ASKED_TO_COLLECT_TELEMETRY, !newValue)); @@ -1358,8 +1363,8 @@ public DOIPreferences getDOIPreferences() { return doiPreferences; } doiPreferences = new DOIPreferences( - getBoolean(USE_CUSTOM_DOI_URI), - get(BASE_DOI_URI)); + getBoolean(USE_CUSTOM_DOI_URI), + get(BASE_DOI_URI)); EasyBind.listen(doiPreferences.useCustomProperty(), (obs, oldValue, newValue) -> putBoolean(USE_CUSTOM_DOI_URI, newValue)); EasyBind.listen(doiPreferences.defaultBaseURIProperty(), (obs, oldValue, newValue) -> put(BASE_DOI_URI, newValue)); return doiPreferences; @@ -1371,9 +1376,9 @@ public OwnerPreferences getOwnerPreferences() { return ownerPreferences; } ownerPreferences = new OwnerPreferences( - getBoolean(USE_OWNER), - get(DEFAULT_OWNER), - getBoolean(OVERWRITE_OWNER)); + getBoolean(USE_OWNER), + get(DEFAULT_OWNER), + getBoolean(OVERWRITE_OWNER)); EasyBind.listen(ownerPreferences.useOwnerProperty(), (obs, oldValue, newValue) -> putBoolean(USE_OWNER, newValue)); EasyBind.listen(ownerPreferences.defaultOwnerProperty(), (obs, oldValue, newValue) -> put(DEFAULT_OWNER, newValue)); EasyBind.listen(ownerPreferences.overwriteOwnerProperty(), (obs, oldValue, newValue) -> putBoolean(OVERWRITE_OWNER, newValue)); @@ -1386,11 +1391,11 @@ public TimestampPreferences getTimestampPreferences() { return timestampPreferences; } timestampPreferences = new TimestampPreferences( - getBoolean(ADD_CREATION_DATE), - getBoolean(ADD_MODIFICATION_DATE), - getBoolean(UPDATE_TIMESTAMP), - FieldFactory.parseField(get(TIME_STAMP_FIELD)), - get(TIME_STAMP_FORMAT)); + getBoolean(ADD_CREATION_DATE), + getBoolean(ADD_MODIFICATION_DATE), + getBoolean(UPDATE_TIMESTAMP), + FieldFactory.parseField(get(TIME_STAMP_FIELD)), + get(TIME_STAMP_FORMAT)); EasyBind.listen(timestampPreferences.addCreationDateProperty(), (obs, oldValue, newValue) -> putBoolean(ADD_CREATION_DATE, newValue)); EasyBind.listen(timestampPreferences.addModificationDateProperty(), (obs, oldValue, newValue) -> putBoolean(ADD_MODIFICATION_DATE, newValue)); @@ -1409,10 +1414,10 @@ public Character getKeywordDelimiter() { @Override public GroupsPreferences getGroupsPreferences() { return new GroupsPreferences( - GroupViewMode.valueOf(get(GROUP_INTERSECT_UNION_VIEW_MODE)), - getBoolean(AUTO_ASSIGN_GROUP), - getBoolean(DISPLAY_GROUP_COUNT), - get(KEYWORD_SEPARATOR).charAt(0)); + GroupViewMode.valueOf(get(GROUP_INTERSECT_UNION_VIEW_MODE)), + getBoolean(AUTO_ASSIGN_GROUP), + getBoolean(DISPLAY_GROUP_COUNT), + get(KEYWORD_SEPARATOR).charAt(0)); } @Override @@ -1561,14 +1566,14 @@ public EntryEditorPreferences getEntryEditorPreferences() { } entryEditorPreferences = new EntryEditorPreferences(getEntryEditorTabList(), - getBoolean(AUTO_OPEN_FORM), - getBoolean(SHOW_RECOMMENDATIONS), - getBoolean(ACCEPT_RECOMMENDATIONS), - getBoolean(SHOW_LATEX_CITATIONS), - getBoolean(DEFAULT_SHOW_SOURCE), - getBoolean(VALIDATE_IN_ENTRY_EDITOR), - getBoolean(ALLOW_INTEGER_EDITION_BIBTEX), - getDouble(ENTRY_EDITOR_HEIGHT)); + getBoolean(AUTO_OPEN_FORM), + getBoolean(SHOW_RECOMMENDATIONS), + getBoolean(ACCEPT_RECOMMENDATIONS), + getBoolean(SHOW_LATEX_CITATIONS), + getBoolean(DEFAULT_SHOW_SOURCE), + getBoolean(VALIDATE_IN_ENTRY_EDITOR), + getBoolean(ALLOW_INTEGER_EDITION_BIBTEX), + getDouble(ENTRY_EDITOR_HEIGHT)); EasyBind.listen(entryEditorPreferences.entryEditorTabListProperty(), (obs, oldValue, newValue) -> storeEntryEditorTabList(newValue)); EasyBind.listen(entryEditorPreferences.shouldOpenOnNewEntryProperty(), (obs, oldValue, newValue) -> putBoolean(AUTO_OPEN_FORM, newValue)); @@ -1594,8 +1599,8 @@ public RemotePreferences getRemotePreferences() { } remotePreferences = new RemotePreferences( - getInt(REMOTE_SERVER_PORT), - getBoolean(USE_REMOTE_SERVER)); + getInt(REMOTE_SERVER_PORT), + getBoolean(USE_REMOTE_SERVER)); EasyBind.listen(remotePreferences.portProperty(), (obs, oldValue, newValue) -> putInt(REMOTE_SERVER_PORT, newValue)); EasyBind.listen(remotePreferences.useRemoteServerProperty(), (obs, oldValue, newValue) -> putBoolean(USE_REMOTE_SERVER, newValue)); @@ -1610,12 +1615,12 @@ public ProxyPreferences getProxyPreferences() { } proxyPreferences = new ProxyPreferences( - getBoolean(PROXY_USE), - get(PROXY_HOSTNAME), - get(PROXY_PORT), - getBoolean(PROXY_USE_AUTHENTICATION), - get(PROXY_USERNAME), - get(PROXY_PASSWORD)); + getBoolean(PROXY_USE), + get(PROXY_HOSTNAME), + get(PROXY_PORT), + getBoolean(PROXY_USE_AUTHENTICATION), + get(PROXY_USERNAME), + get(PROXY_PASSWORD)); EasyBind.listen(proxyPreferences.useProxyProperty(), (obs, oldValue, newValue) -> putBoolean(PROXY_USE, newValue)); EasyBind.listen(proxyPreferences.hostnameProperty(), (obs, oldValue, newValue) -> put(PROXY_HOSTNAME, newValue)); @@ -1656,8 +1661,8 @@ public void updateGlobalCitationKeyPattern() { if (keys.length > 0) { for (String key : keys) { this.globalCitationKeyPattern.addCitationKeyPattern( - EntryTypeFactory.parse(key), - preferences.get(key, null)); + EntryTypeFactory.parse(key), + preferences.get(key, null)); } } } catch (BackingStoreException ex) { @@ -1674,7 +1679,7 @@ public void storeGlobalCitationKeyPattern(GlobalCitationKeyPattern pattern) { this.globalCitationKeyPattern = pattern; if ((this.globalCitationKeyPattern.getDefaultValue() == null) - || this.globalCitationKeyPattern.getDefaultValue().isEmpty()) { + || this.globalCitationKeyPattern.getDefaultValue().isEmpty()) { put(DEFAULT_CITATION_KEY_PATTERN, ""); } else { put(DEFAULT_CITATION_KEY_PATTERN, globalCitationKeyPattern.getDefaultValue().get(0)); @@ -1706,7 +1711,8 @@ private void clearCitationKeyPatterns() throws BackingStoreException { @Override public CitationKeyPatternPreferences getCitationKeyPatternPreferences() { - CitationKeyPatternPreferences.KeySuffix keySuffix = CitationKeyPatternPreferences.KeySuffix.SECOND_WITH_B; + CitationKeyPatternPreferences.KeySuffix keySuffix = + CitationKeyPatternPreferences.KeySuffix.SECOND_WITH_B; if (getBoolean(KEY_GEN_ALWAYS_ADD_LETTER)) { keySuffix = CitationKeyPatternPreferences.KeySuffix.ALWAYS; @@ -1715,15 +1721,15 @@ public CitationKeyPatternPreferences getCitationKeyPatternPreferences() { } return new CitationKeyPatternPreferences( - getBoolean(AVOID_OVERWRITING_KEY), - getBoolean(WARN_BEFORE_OVERWRITING_KEY), - getBoolean(GENERATE_KEYS_BEFORE_SAVING), - keySuffix, - get(KEY_PATTERN_REGEX), - get(KEY_PATTERN_REPLACEMENT), - get(UNWANTED_CITATION_KEY_CHARACTERS), - getGlobalCitationKeyPattern(), - getKeywordDelimiter()); + getBoolean(AVOID_OVERWRITING_KEY), + getBoolean(WARN_BEFORE_OVERWRITING_KEY), + getBoolean(GENERATE_KEYS_BEFORE_SAVING), + keySuffix, + get(KEY_PATTERN_REGEX), + get(KEY_PATTERN_REPLACEMENT), + get(UNWANTED_CITATION_KEY_CHARACTERS), + getGlobalCitationKeyPattern(), + getKeywordDelimiter()); } @Override @@ -1769,9 +1775,10 @@ public PushToApplicationPreferences getPushToApplicationPreferences() { applicationCommands.put(PushToApplicationConstants.WIN_EDT, get(PUSH_WINEDT_PATH)); return new PushToApplicationPreferences( - applicationCommands, - get(PUSH_EMACS_ADDITIONAL_PARAMETERS), - get(PUSH_VIM_SERVER)); + applicationCommands, + get(PUSH_EMACS_ADDITIONAL_PARAMETERS), + get(PUSH_VIM_SERVER) + ); } @Override @@ -1790,14 +1797,14 @@ public void storePushToApplicationPreferences(PushToApplicationPreferences prefe @Override public ExternalApplicationsPreferences getExternalApplicationsPreferences() { return new ExternalApplicationsPreferences( - get(EMAIL_SUBJECT), - getBoolean(OPEN_FOLDERS_OF_ATTACHED_FILES), - get(PUSH_TO_APPLICATION), - get(CITE_COMMAND), - !getBoolean(USE_DEFAULT_CONSOLE_APPLICATION), // mind the ! - get(CONSOLE_COMMAND), - !getBoolean(USE_DEFAULT_FILE_BROWSER_APPLICATION), // mind the ! - get(FILE_BROWSER_COMMAND)); + get(EMAIL_SUBJECT), + getBoolean(OPEN_FOLDERS_OF_ATTACHED_FILES), + get(PUSH_TO_APPLICATION), + get(CITE_COMMAND), + !getBoolean(USE_DEFAULT_CONSOLE_APPLICATION), // mind the ! + get(CONSOLE_COMMAND), + !getBoolean(USE_DEFAULT_FILE_BROWSER_APPLICATION), // mind the ! + get(FILE_BROWSER_COMMAND)); } @Override @@ -1843,8 +1850,8 @@ private List createMainTableColumnSortOrder() { @Override public ColumnPreferences getColumnPreferences() { return new ColumnPreferences( - createMainTableColumns(), - createMainTableColumnSortOrder()); + createMainTableColumns(), + createMainTableColumnSortOrder()); } /** @@ -1861,8 +1868,8 @@ public void storeMainTableColumnPreferences(ColumnPreferences columnPreferences) @Override public MainTablePreferences getMainTablePreferences() { return new MainTablePreferences(getColumnPreferences(), - getBoolean(AUTO_RESIZE_MODE), - getBoolean(EXTRA_FILE_COLUMNS)); + getBoolean(AUTO_RESIZE_MODE), + getBoolean(EXTRA_FILE_COLUMNS)); } @Override @@ -1891,8 +1898,8 @@ public MainTableNameFormatPreferences getMainTableNameFormatPreferences() { } return new MainTableNameFormatPreferences( - displayStyle, - abbreviationStyle); + displayStyle, + abbreviationStyle); } @Override @@ -1966,7 +1973,6 @@ private List createSearchDialogColumnSortOrder() { /** * Reloads the ColumnSortOrder from scratch - * @return */ private List updateColumnSortOrder(String sortOrderList, List tableColumns) { List columnsOrdered = new ArrayList<>(); @@ -1985,7 +1991,7 @@ public ColumnPreferences getSearchDialogColumnPreferences() { } /** - * Stores the {@link SearchDialogColumnPreferences} in the preferences + * Stores the {@link JabRefPreferences::SearchDialogColumnPreferences} in the preferences * * @param columnPreferences the preferences to store */ @@ -2040,9 +2046,10 @@ public AppearancePreferences getAppearancePreferences() { } appearancePreferences = new AppearancePreferences( - getBoolean(OVERRIDE_DEFAULT_FONT_SIZE), - getInt(MAIN_FONT_SIZE), - getTheme()); + getBoolean(OVERRIDE_DEFAULT_FONT_SIZE), + getInt(MAIN_FONT_SIZE), + getTheme() + ); EasyBind.listen(appearancePreferences.shouldOverrideDefaultFontSizeProperty(), (obs, oldValue, newValue) -> putBoolean(OVERRIDE_DEFAULT_FONT_SIZE, newValue)); EasyBind.listen(appearancePreferences.mainFontSizeProperty(), (obs, oldValue, newValue) -> putInt(MAIN_FONT_SIZE, newValue)); @@ -2058,24 +2065,26 @@ public AppearancePreferences getAppearancePreferences() { @Override public ImportFormatPreferences getImportFormatPreferences() { return new ImportFormatPreferences( - getCustomImportFormats(), - getKeywordDelimiter(), - getCitationKeyPatternPreferences(), - getFieldContentParserPreferences(), - getXmpPreferences(), - getDOIPreferences()); + getCustomImportFormats(), + getKeywordDelimiter(), + getCitationKeyPatternPreferences(), + getFieldContentParserPreferences(), + getXmpPreferences(), + getDOIPreferences()); } @Override public SaveOrderConfig getExportSaveOrder() { List sortCriteria = List.of( - new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_PRIMARY_SORT_FIELD)), getBoolean(EXPORT_PRIMARY_SORT_DESCENDING)), - new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_SECONDARY_SORT_FIELD)), getBoolean(EXPORT_SECONDARY_SORT_DESCENDING)), - new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_TERTIARY_SORT_FIELD)), getBoolean(EXPORT_TERTIARY_SORT_DESCENDING))); + new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_PRIMARY_SORT_FIELD)), getBoolean(EXPORT_PRIMARY_SORT_DESCENDING)), + new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_SECONDARY_SORT_FIELD)), getBoolean(EXPORT_SECONDARY_SORT_DESCENDING)), + new SaveOrderConfig.SortCriterion(FieldFactory.parseField(get(EXPORT_TERTIARY_SORT_FIELD)), getBoolean(EXPORT_TERTIARY_SORT_DESCENDING)) + ); return new SaveOrderConfig( - SaveOrderConfig.OrderType.fromBooleans(getBoolean(EXPORT_IN_SPECIFIED_ORDER), getBoolean(EXPORT_IN_ORIGINAL_ORDER)), - sortCriteria); + SaveOrderConfig.OrderType.fromBooleans(getBoolean(EXPORT_IN_SPECIFIED_ORDER), getBoolean(EXPORT_IN_ORIGINAL_ORDER)), + sortCriteria + ); } @Override @@ -2100,8 +2109,8 @@ private SaveOrderConfig loadTableSaveOrder() { for (var column : sortOrder) { boolean descending = (column.getSortType() == SortType.DESCENDING); config.getSortCriteria().add(new SaveOrderConfig.SortCriterion( - FieldFactory.parseField(column.getQualifier()), - descending)); + FieldFactory.parseField(column.getQualifier()), + descending)); } return config; @@ -2120,21 +2129,21 @@ public SavePreferences getSavePreferencesForExport() { } return getSavePreferences() - .withSaveInOriginalOrder(saveInOriginalOrder) - .withSaveOrder(saveOrder) - .withTakeMetadataSaveOrderInAccount(false); + .withSaveInOriginalOrder(saveInOriginalOrder) + .withSaveOrder(saveOrder) + .withTakeMetadataSaveOrderInAccount(false); } @Override public SavePreferences getSavePreferences() { return new SavePreferences( - false, - null, - SavePreferences.DatabaseSaveType.ALL, - true, - this.getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT), - this.getFieldWriterPreferences(), - getCitationKeyPatternPreferences()); + false, + null, + SavePreferences.DatabaseSaveType.ALL, + true, + this.getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT), + this.getFieldWriterPreferences(), + getCitationKeyPatternPreferences()); } @Override @@ -2150,15 +2159,15 @@ public void storeOpenLastFilesOnStartup(boolean openLastFilesOnStartup) { @Override public FieldContentFormatterPreferences getFieldContentParserPreferences() { return new FieldContentFormatterPreferences( - getStringList(NON_WRAPPABLE_FIELDS).stream().map(FieldFactory::parseField).collect(Collectors.toList())); + getStringList(NON_WRAPPABLE_FIELDS).stream().map(FieldFactory::parseField).collect(Collectors.toList())); } @Override public FieldWriterPreferences getFieldWriterPreferences() { return new FieldWriterPreferences( - getBoolean(RESOLVE_STRINGS_ALL_FIELDS), - getStringList(DO_NOT_RESOLVE_STRINGS_FOR).stream().map(FieldFactory::parseField).collect(Collectors.toList()), - getFieldContentParserPreferences()); + getBoolean(RESOLVE_STRINGS_ALL_FIELDS), + getStringList(DO_NOT_RESOLVE_STRINGS_FOR).stream().map(FieldFactory::parseField).collect(Collectors.toList()), + getFieldContentParserPreferences()); } @Override @@ -2184,13 +2193,14 @@ public FilePreferences getFilePreferences() { } filePreferences = new FilePreferences( - getUser(), - get(MAIN_FILE_DIRECTORY), - getBoolean(STORE_RELATIVE_TO_BIB), - get(IMPORT_FILENAMEPATTERN), - get(IMPORT_FILEDIRPATTERN), - getBoolean(DOWNLOAD_LINKED_FILES), - Path.of(get(WORKING_DIRECTORY))); + getUser(), + get(MAIN_FILE_DIRECTORY), + getBoolean(STORE_RELATIVE_TO_BIB), + get(IMPORT_FILENAMEPATTERN), + get(IMPORT_FILEDIRPATTERN), + getBoolean(DOWNLOAD_LINKED_FILES), + Path.of(get(WORKING_DIRECTORY)) + ); EasyBind.listen(filePreferences.mainFileDirectoryProperty(), (obs, oldValue, newValue) -> put(MAIN_FILE_DIRECTORY, filePreferences.getFileDirectory().map(Path::toString).orElse(""))); EasyBind.listen(filePreferences.storeFilesRelativeToBibFileProperty(), (obs, oldValue, newValue) -> putBoolean(STORE_RELATIVE_TO_BIB, newValue)); @@ -2212,7 +2222,7 @@ private String getUser() { return userName; } catch (UnknownHostException ex) { LOGGER.error("Hostname not found. Please go to https://docs.jabref.org/ to find possible " + - "problem resolution", ex); + "problem resolution", ex); return get(DEFAULT_OWNER); } } @@ -2223,7 +2233,8 @@ public AutoLinkPreferences getAutoLinkPreferences() { return autoLinkPreferences; } - AutoLinkPreferences.CitationKeyDependency citationKeyDependency = AutoLinkPreferences.CitationKeyDependency.START; // default + AutoLinkPreferences.CitationKeyDependency citationKeyDependency = + AutoLinkPreferences.CitationKeyDependency.START; // default if (getBoolean(AUTOLINK_EXACT_KEY_ONLY)) { citationKeyDependency = AutoLinkPreferences.CitationKeyDependency.EXACT; } else if (getBoolean(AUTOLINK_USE_REG_EXP_SEARCH_KEY)) { @@ -2231,10 +2242,10 @@ public AutoLinkPreferences getAutoLinkPreferences() { } autoLinkPreferences = new AutoLinkPreferences( - citationKeyDependency, - get(AUTOLINK_REG_EXP_SEARCH_EXPRESSION_KEY), - getBoolean(ASK_AUTO_NAMING_PDFS_AGAIN), - getKeywordDelimiter()); + citationKeyDependency, + get(AUTOLINK_REG_EXP_SEARCH_EXPRESSION_KEY), + getBoolean(ASK_AUTO_NAMING_PDFS_AGAIN), + getKeywordDelimiter()); EasyBind.listen(autoLinkPreferences.citationKeyDependencyProperty(), (obs, oldValue, newValue) -> { // Starts bibtex only omitted, as it is not being saved @@ -2280,14 +2291,14 @@ public ImportExportPreferences getImportExportPreferences() { } importExportPreferences = new ImportExportPreferences( - get(NON_WRAPPABLE_FIELDS), - !getBoolean(RESOLVE_STRINGS_ALL_FIELDS), - getBoolean(RESOLVE_STRINGS_ALL_FIELDS), - get(DO_NOT_RESOLVE_STRINGS_FOR), - getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT), - Path.of(get(IMPORT_WORKING_DIRECTORY)), - get(LAST_USED_EXPORT), - Path.of(get(EXPORT_WORKING_DIRECTORY))); + get(NON_WRAPPABLE_FIELDS), + !getBoolean(RESOLVE_STRINGS_ALL_FIELDS), + getBoolean(RESOLVE_STRINGS_ALL_FIELDS), + get(DO_NOT_RESOLVE_STRINGS_FOR), + getBoolean(REFORMAT_FILE_ON_SAVE_AND_EXPORT), + Path.of(get(IMPORT_WORKING_DIRECTORY)), + get(LAST_USED_EXPORT), + Path.of(get(EXPORT_WORKING_DIRECTORY))); EasyBind.listen(importExportPreferences.nonWrappableFieldsProperty(), (obs, oldValue, newValue) -> put(NON_WRAPPABLE_FIELDS, newValue)); EasyBind.listen(importExportPreferences.resolveStringsForStandardBibtexFieldsProperty(), (obs, oldValue, newValue) -> putBoolean(RESOLVE_STRINGS_ALL_FIELDS, newValue)); @@ -2363,8 +2374,12 @@ public List getCustomExportFormats(JournalAbbreviationReposito exporterName = formatData.get(EXPORTER_NAME_INDEX); filename = formatData.get(EXPORTER_FILENAME_INDEX); extension = formatData.get(EXPORTER_EXTENSION_INDEX); - TemplateExporter format = new TemplateExporter(exporterName, filename, extension, - layoutPreferences, savePreferences); + TemplateExporter format = new TemplateExporter( + exporterName, + filename, + extension, + layoutPreferences, + savePreferences); format.setCustomExport(true); formats.add(format); i++; @@ -2476,12 +2491,14 @@ public SidePanePreferences getSidePanePreferences() { } sidePanePreferences = new SidePanePreferences( - getVisiblePanes(), - getSidePanePreferredPositions(), - getInt(SELECTED_FETCHER_INDEX)); - - sidePanePreferences.visiblePanes().addListener((InvalidationListener) listener -> storeVisiblePanes(sidePanePreferences.visiblePanes())); - sidePanePreferences.getPreferredPositions().addListener((InvalidationListener) listener -> storeSidePanePreferredPositions(sidePanePreferences.getPreferredPositions())); + getVisiblePanes(), + getSidePanePreferredPositions(), + getInt(SELECTED_FETCHER_INDEX)); + + sidePanePreferences.visiblePanes().addListener((InvalidationListener) listener -> + storeVisiblePanes(sidePanePreferences.visiblePanes())); + sidePanePreferences.getPreferredPositions().addListener((InvalidationListener) listener -> + storeSidePanePreferredPositions(sidePanePreferences.getPreferredPositions())); EasyBind.listen(sidePanePreferences.webSearchFetcherSelectedProperty(), (obs, oldValue, newValue) -> putInt(SELECTED_FETCHER_INDEX, newValue)); return sidePanePreferences; @@ -2553,15 +2570,15 @@ public GuiPreferences getGuiPreferences() { } guiPreferences = new GuiPreferences( - getDouble(POS_X), - getDouble(POS_Y), - getDouble(SIZE_X), - getDouble(SIZE_Y), - getBoolean(WINDOW_MAXIMISED), - getBoolean(OPEN_LAST_EDITED), - getStringList(LAST_EDITED), - Path.of(get(LAST_FOCUSED)), - getDouble(SIDE_PANE_WIDTH)); + getDouble(POS_X), + getDouble(POS_Y), + getDouble(SIZE_X), + getDouble(SIZE_Y), + getBoolean(WINDOW_MAXIMISED), + getBoolean(OPEN_LAST_EDITED), + getStringList(LAST_EDITED), + Path.of(get(LAST_FOCUSED)), + getDouble(SIDE_PANE_WIDTH)); EasyBind.listen(guiPreferences.positionXProperty(), (obs, oldValue, newValue) -> putDouble(POS_X, newValue.doubleValue())); EasyBind.listen(guiPreferences.positionYProperty(), (obs, oldValue, newValue) -> putDouble(POS_Y, newValue.doubleValue())); @@ -2569,7 +2586,8 @@ public GuiPreferences getGuiPreferences() { EasyBind.listen(guiPreferences.sizeYProperty(), (obs, oldValue, newValue) -> putDouble(SIZE_Y, newValue.doubleValue())); EasyBind.listen(guiPreferences.windowMaximisedProperty(), (obs, oldValue, newValue) -> putBoolean(WINDOW_MAXIMISED, newValue)); EasyBind.listen(guiPreferences.openLastEditedProperty(), (obs, oldValue, newValue) -> putBoolean(OPEN_LAST_EDITED, newValue)); - guiPreferences.getLastFilesOpened().addListener((InvalidationListener) change -> putStringList(LAST_EDITED, guiPreferences.getLastFilesOpened())); + guiPreferences.getLastFilesOpened().addListener((InvalidationListener) change -> + putStringList(LAST_EDITED, guiPreferences.getLastFilesOpened())); EasyBind.listen(guiPreferences.lastFocusedFileProperty(), (obs, oldValue, newValue) -> { if (newValue != null) { put(LAST_FOCUSED, newValue.toAbsolutePath().toString()); @@ -2606,12 +2624,12 @@ public SearchPreferences getSearchPreferences() { } searchPreferences = new SearchPreferences( - searchDisplayMode, - getBoolean(SEARCH_CASE_SENSITIVE), - getBoolean(SEARCH_REG_EXP), - getBoolean(SEARCH_FULLTEXT), - getBoolean(SEARCH_KEEP_SEARCH_STRING), - getBoolean(SEARCH_KEEP_GLOBAL_WINDOW_ON_TOP)); + searchDisplayMode, + getBoolean(SEARCH_CASE_SENSITIVE), + getBoolean(SEARCH_REG_EXP), + getBoolean(SEARCH_FULLTEXT), + getBoolean(SEARCH_KEEP_SEARCH_STRING), + getBoolean(SEARCH_KEEP_GLOBAL_WINDOW_ON_TOP)); EasyBind.listen(searchPreferences.searchDisplayModeProperty(), (obs, oldValue, newValue) -> put(SEARCH_DISPLAY_MODE, Objects.requireNonNull(searchPreferences.getSearchDisplayMode()).toString())); searchPreferences.getObservableSearchFlags().addListener((SetChangeListener) c -> { @@ -2632,9 +2650,9 @@ public SearchPreferences getSearchPreferences() { @Override public XmpPreferences getXmpPreferences() { return new XmpPreferences( - getBoolean(USE_XMP_PRIVACY_FILTER), - getStringList(XMP_PRIVACY_FILTERS).stream().map(FieldFactory::parseField).collect(Collectors.toSet()), - getKeywordDelimiter()); + getBoolean(USE_XMP_PRIVACY_FILTER), + getStringList(XMP_PRIVACY_FILTERS).stream().map(FieldFactory::parseField).collect(Collectors.toSet()), + getKeywordDelimiter()); } @Override @@ -2650,11 +2668,13 @@ public NameFormatterPreferences getNameFormatterPreferences() { } nameFormatterPreferences = new NameFormatterPreferences( - getStringList(NAME_FORMATER_KEY), - getStringList(NAME_FORMATTER_VALUE)); + getStringList(NAME_FORMATER_KEY), + getStringList(NAME_FORMATTER_VALUE)); - nameFormatterPreferences.getNameFormatterKey().addListener((InvalidationListener) change -> putStringList(NAME_FORMATER_KEY, nameFormatterPreferences.getNameFormatterKey())); - nameFormatterPreferences.getNameFormatterValue().addListener((InvalidationListener) change -> putStringList(NAME_FORMATTER_VALUE, nameFormatterPreferences.getNameFormatterValue())); + nameFormatterPreferences.getNameFormatterKey().addListener((InvalidationListener) change -> + putStringList(NAME_FORMATER_KEY, nameFormatterPreferences.getNameFormatterKey())); + nameFormatterPreferences.getNameFormatterValue().addListener((InvalidationListener) change -> + putStringList(NAME_FORMATTER_VALUE, nameFormatterPreferences.getNameFormatterValue())); return nameFormatterPreferences; } @@ -2669,11 +2689,11 @@ public AutoCompletePreferences getAutoCompletePreferences() { } return new AutoCompletePreferences( - getBoolean(AUTO_COMPLETE), - AutoCompleteFirstNameMode.parse(get(AUTOCOMPLETER_FIRSTNAME_MODE)), - nameFormat, - getStringList(AUTOCOMPLETER_COMPLETE_FIELDS).stream().map(FieldFactory::parseField).collect(Collectors.toSet()), - getJournalAbbreviationPreferences()); + getBoolean(AUTO_COMPLETE), + AutoCompleteFirstNameMode.parse(get(AUTOCOMPLETER_FIRSTNAME_MODE)), + nameFormat, + getStringList(AUTOCOMPLETER_COMPLETE_FIELDS).stream().map(FieldFactory::parseField).collect(Collectors.toSet()), + getJournalAbbreviationPreferences()); } @Override @@ -2744,10 +2764,10 @@ public MrDlibPreferences getMrDlibPreferences() { } mrDlibPreferences = new MrDlibPreferences( - getBoolean(ACCEPT_RECOMMENDATIONS), - getBoolean(SEND_LANGUAGE_DATA), - getBoolean(SEND_OS_DATA), - getBoolean(SEND_TIMEZONE_DATA)); + getBoolean(ACCEPT_RECOMMENDATIONS), + getBoolean(SEND_LANGUAGE_DATA), + getBoolean(SEND_OS_DATA), + getBoolean(SEND_TIMEZONE_DATA)); EasyBind.listen(mrDlibPreferences.acceptRecommendationsProperty(), (obs, oldValue, newValue) -> putBoolean(ACCEPT_RECOMMENDATIONS, newValue)); EasyBind.listen(mrDlibPreferences.sendLanguageProperty(), (obs, oldValue, newValue) -> putBoolean(SEND_LANGUAGE_DATA, newValue)); @@ -2774,15 +2794,20 @@ public ProtectedTermsPreferences getProtectedTermsPreferences() { } protectedTermsPreferences = new ProtectedTermsPreferences( - getStringList(PROTECTED_TERMS_ENABLED_INTERNAL), - getStringList(PROTECTED_TERMS_ENABLED_EXTERNAL), - getStringList(PROTECTED_TERMS_DISABLED_INTERNAL), - getStringList(PROTECTED_TERMS_DISABLED_EXTERNAL)); + getStringList(PROTECTED_TERMS_ENABLED_INTERNAL), + getStringList(PROTECTED_TERMS_ENABLED_EXTERNAL), + getStringList(PROTECTED_TERMS_DISABLED_INTERNAL), + getStringList(PROTECTED_TERMS_DISABLED_EXTERNAL) + ); - protectedTermsPreferences.getEnabledExternalTermLists().addListener((InvalidationListener) change -> putStringList(PROTECTED_TERMS_ENABLED_EXTERNAL, protectedTermsPreferences.getEnabledExternalTermLists())); - protectedTermsPreferences.getDisabledExternalTermLists().addListener((InvalidationListener) change -> putStringList(PROTECTED_TERMS_DISABLED_EXTERNAL, protectedTermsPreferences.getDisabledExternalTermLists())); - protectedTermsPreferences.getEnabledInternalTermLists().addListener((InvalidationListener) change -> putStringList(PROTECTED_TERMS_ENABLED_INTERNAL, protectedTermsPreferences.getEnabledInternalTermLists())); - protectedTermsPreferences.getDisabledInternalTermLists().addListener((InvalidationListener) change -> putStringList(PROTECTED_TERMS_DISABLED_INTERNAL, protectedTermsPreferences.getDisabledInternalTermLists())); + protectedTermsPreferences.getEnabledExternalTermLists().addListener((InvalidationListener) change -> + putStringList(PROTECTED_TERMS_ENABLED_EXTERNAL, protectedTermsPreferences.getEnabledExternalTermLists())); + protectedTermsPreferences.getDisabledExternalTermLists().addListener((InvalidationListener) change -> + putStringList(PROTECTED_TERMS_DISABLED_EXTERNAL, protectedTermsPreferences.getDisabledExternalTermLists())); + protectedTermsPreferences.getEnabledInternalTermLists().addListener((InvalidationListener) change -> + putStringList(PROTECTED_TERMS_ENABLED_INTERNAL, protectedTermsPreferences.getEnabledInternalTermLists())); + protectedTermsPreferences.getDisabledInternalTermLists().addListener((InvalidationListener) change -> + putStringList(PROTECTED_TERMS_DISABLED_INTERNAL, protectedTermsPreferences.getDisabledInternalTermLists())); return protectedTermsPreferences; } @@ -2798,10 +2823,11 @@ public ImporterPreferences getImporterPreferences() { } importerPreferences = new ImporterPreferences( - getBoolean(GENERATE_KEY_ON_IMPORT), - getBoolean(GROBID_ENABLED), - getBoolean(GROBID_OPT_OUT), - get(GROBID_URL)); + getBoolean(GENERATE_KEY_ON_IMPORT), + getBoolean(GROBID_ENABLED), + getBoolean(GROBID_OPT_OUT), + get(GROBID_URL) + ); EasyBind.listen(importerPreferences.generateNewKeyOnImportProperty(), (obs, oldValue, newValue) -> putBoolean(GENERATE_KEY_ON_IMPORT, newValue)); EasyBind.listen(importerPreferences.grobidEnabledProperty(), (obs, oldValue, newValue) -> putBoolean(GROBID_ENABLED, newValue)); From f01f16fbc19c377f06630ff9675acdbe5a9aeb49 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sun, 28 Nov 2021 20:21:17 +0100 Subject: [PATCH 13/13] fix checkstyle --- src/main/java/org/jabref/preferences/JabRefPreferences.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 6399c5cc13b..295d3f137a1 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -1991,7 +1991,7 @@ public ColumnPreferences getSearchDialogColumnPreferences() { } /** - * Stores the {@link JabRefPreferences::SearchDialogColumnPreferences} in the preferences + * Stores the {@link ColumnPreferences} in the preferences * * @param columnPreferences the preferences to store */