-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not resize main table columns in search dialog window (#8253)
* Do not resize main table columns in search dialog window Follow up from #8134 Fixes part of #8054 * checkstyle * Refactor and store Search Dialog Column changes * checkstyle * refactor, get rid of duplicate column preferences * fix checkstlye again * Revert reformatting hazard * fix checkstyle * Add a new column type library and check if it exists before adding to search reults * Remove library col from main table... * fix checkstyle * Reverted unnecessary reformatting * fix checkstyle Co-authored-by: Carl Christian Snethlage <cc.snethlage@gmail.com>
- Loading branch information
1 parent
7ec4c7e
commit 69467d3
Showing
13 changed files
with
343 additions
and
155 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/main/java/org/jabref/gui/maintable/AbstractPersistenceVisualStateTable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
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<BibEntryTableViewModel> mainTable; | ||
protected final PreferencesService preferences; | ||
|
||
public AbstractPersistenceVisualStateTable(final TableView<BibEntryTableViewModel> 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. | ||
* override in subclass | ||
*/ | ||
protected abstract void updateColumns(); | ||
|
||
/** | ||
* Stores the SortOrder of 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 in subclass | ||
*/ | ||
protected abstract void updateSortOrder(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/org/jabref/gui/maintable/columns/LibraryColumn.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> { | ||
|
||
public LibraryColumn(MainTableColumnModel model) { | ||
super(model); | ||
|
||
setText(Localization.lang("Library")); | ||
new ValueTableCellFactory<BibEntryTableViewModel, String>().withText(FileUtil::getBaseName) | ||
.install(this); | ||
setCellValueFactory(param -> param.getValue().bibDatabaseContextProperty()); | ||
} | ||
|
||
public LibraryColumn() { | ||
this(new MainTableColumnModel(Type.LIBRARY_NAME)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.