Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement better scaling of main table showing entries #644

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a1a5ccc
Implement better scaling of main table showing entries
koppor Dec 12, 2020
e91bb8d
Fix number
koppor Dec 14, 2020
8f522df
Remove resizeColumnsToFit
koppor Dec 14, 2020
1acd12e
Fix checkstyle
koppor Dec 14, 2020
c8caa13
Merge branch 'master' into fix-967
koppor Dec 17, 2020
f5e2d9f
Add smart resize if content fits into table width
koppor Dec 17, 2020
bcea66c
Address some comments
koppor Dec 18, 2020
6da49b2
WIP
koppor Dec 21, 2020
dfac705
Speedup processResources
koppor Dec 21, 2020
057ae9f
Merge branch 'speedup-process-resources' into fix-967
koppor Dec 21, 2020
8834fb6
Try path without ./ at the beginning
koppor Dec 21, 2020
5b6f0d8
Output java error on console, too
koppor Dec 21, 2020
fd80c30
Use LOGGER instead of System.err
koppor Dec 21, 2020
c64b5e3
Merge branch 'fix-output-with-wrong-jdk-version' into fix-967
koppor Dec 21, 2020
9f56fd5
Merge branch 'speedup-process-resources' into fix-967
koppor Dec 21, 2020
d15e90f
Fix scroll bar still present
koppor Dec 21, 2020
7de21ad
MinWidth to 80
koppor Dec 21, 2020
8c7cd7a
Merge branch 'master' into fix-967
koppor Dec 21, 2020
f7186f3
Merge branch 'fix-967' of github.com:JabRef/jabref into fix-967
koppor Dec 21, 2020
80557f2
WIP (does not work)
koppor Dec 22, 2020
043a0cc
Merge remote-tracking branch 'origin/master' into fix-967
koppor Dec 29, 2020
c3b02e3
Fix ordering in CHANGELOG.md
koppor Dec 29, 2020
fd118a6
WIP
koppor Dec 29, 2020
f0788f6
WIP - "User changed column size in a way that window can contain all …
koppor Dec 29, 2020
a1633a1
Add documentation on implementation idea
koppor Jan 2, 2021
73d5448
Refine description (and change TableColumnBase to TableColumn)
koppor Jan 3, 2021
f75831d
Cases I0 to I3
koppor Jan 3, 2021
c417d7d
First proposal of case names
koppor Jan 3, 2021
496e505
WIP: Reimplement logic according to comments
koppor Jan 6, 2021
466731f
Merge remote-tracking branch 'origin/master' into fix-967
koppor Jan 7, 2021
caf1e23
WIP
koppor Jan 7, 2021
63af8fd
Merge remote-tracking branch 'origin/master' into fix-967
koppor Jan 10, 2021
274e109
Resizing of colomms works
koppor Jan 10, 2021
910c592
Use EPSILON_MARGIN also for "content has fit into table before"
koppor Jan 10, 2021
513c68c
Merge branch 'master' into fix-967
koppor Jan 21, 2021
286e7f9
Merge remote-tracking branch 'upstream/master' into fix-967
calixtus Feb 6, 2021
caf7232
Merge branch 'main' into fix-967
koppor Oct 14, 2021
609f6a2
Merge branch 'main' into fix-967
koppor Oct 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Changed

- We changed the resize behavior of table columns to have smart fit into the table if there is enough space. [#967](https://github.com/JabRef/jabref/issues/967)
- The export to MS Office XML now exports the author field as `Inventor` if the bibtex entry type is `patent` [#7830](https://github.com/JabRef/jabref/issues/7830)
- We changed the EndNote importer to import the field `label` to the corresponding bibtex field `endnote-label` [forum#2734](https://discourse.jabref.org/t/importing-endnote-label-field-to-jabref-from-xml-file/2734)
- The keywords added via "Manage content selectors" are now displayed in alphabetical order. [#3791](https://github.com/JabRef/jabref/issues/3791)
Expand Down Expand Up @@ -304,6 +305,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We changed the way JabRef displays the title of a tab and of the window. [4161](https://github.com/JabRef/jabref/issues/4161)
- We changed connect timeouts for server requests to 30 seconds in general and 5 seconds for GROBID server (special) and improved user notifications on connection issues. [7026](https://github.com/JabRef/jabref/pull/7026)
- We changed the order of the library tab context menu items. [#7171](https://github.com/JabRef/jabref/issues/7171)
- We renamed "Show extra columns" to "Show dedicated file columns". [#7181](https://github.com/JabRef/jabref/pull/7181)
- We changed the way linked files are opened on Linux to use the native openFile method, compatible with confined packages. [7037](https://github.com/JabRef/jabref/pull/7037)
- We refined the entry preview to show the full names of authors and editors, to list the editor only if no author is present, have the year earlier. [#7083](https://github.com/JabRef/jabref/issues/7083)

Expand Down
12 changes: 11 additions & 1 deletion src/main/java/org/jabref/gui/maintable/ColumnPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@

public class ColumnPreferences {

public static final double DEFAULT_COLUMN_MIN_WIDTH = 80;
public static final double DEFAULT_COLUMN_WIDTH = 100;
public static final double ICON_COLUMN_WIDTH = 16 + 12; // add some additional space to improve appearance

private final List<MainTableColumnModel> columns;

private final List<MainTableColumnModel> columnSortOrder;

public ColumnPreferences(List<MainTableColumnModel> columns, List<MainTableColumnModel> columnSortOrder) {
private final boolean dedicatedFileColumnsEnabled;

public ColumnPreferences(List<MainTableColumnModel> columns, List<MainTableColumnModel> columnSortOrder, boolean dedicatedFileColumnsEnabled) {
this.columns = columns;
this.columnSortOrder = columnSortOrder;
this.dedicatedFileColumnsEnabled = dedicatedFileColumnsEnabled;
}

public List<MainTableColumnModel> getColumns() {
Expand All @@ -22,4 +27,9 @@ public List<MainTableColumnModel> getColumns() {
public List<MainTableColumnModel> getColumnSortOrder() {
return columnSortOrder;
}

public boolean isDedicatedFileColumnsEnabled() {
return dedicatedFileColumnsEnabled;
}

}
11 changes: 4 additions & 7 deletions src/main/java/org/jabref/gui/maintable/MainTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public MainTable(MainTableDataModel model,
this.database = Objects.requireNonNull(database);
this.model = model;
UndoManager undoManager = libraryTab.getUndoManager();
MainTablePreferences mainTablePreferences = preferencesService.getMainTablePreferences();
ColumnPreferences columnPreferences = preferencesService.getColumnPreferences();

importHandler = new ImportHandler(
database, externalFileTypes,
Expand Down Expand Up @@ -141,17 +141,14 @@ public MainTable(MainTableDataModel model,
}
}
*/

mainTablePreferences.getColumnPreferences().getColumnSortOrder().forEach(columnModel ->
columnPreferences.getColumnSortOrder().forEach(columnModel ->
this.getColumns().stream()
.map(column -> (MainTableColumn<?>) column)
.filter(column -> column.getModel().equals(columnModel))
.findFirst()
.ifPresent(column -> this.getSortOrder().add(column)));

if (mainTablePreferences.getResizeColumnsToFit()) {
this.setColumnResizePolicy(new SmartConstrainedResizePolicy());
}
this.setColumnResizePolicy(new SmartConstrainedResizePolicy());

this.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

Expand Down Expand Up @@ -344,7 +341,7 @@ private void handleOnDragDetected(TableRow<BibEntryTableViewModel> row, BibEntry

List<BibEntry> entries = getSelectionModel().getSelectedItems().stream().map(BibEntryTableViewModel::getEntry).collect(Collectors.toList());

// The following is necesary to initiate the drag and drop in javafx, although we don't need the contents
// The following is necessary to initiate the drag and drop in javafx, although we don't need the contents
// It doesn't work without
ClipboardContent content = new ClipboardContent();
Dragboard dragboard = startDragAndDrop(TransferMode.MOVE);
Expand Down
19 changes: 16 additions & 3 deletions src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
import org.jabref.model.entry.LinkedFile;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.FieldFactory;
import org.jabref.model.entry.field.InternalField;
import org.jabref.model.entry.field.SpecialField;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.groups.AbstractGroup;
import org.jabref.model.util.OptionalUtil;
import org.jabref.preferences.PreferencesService;
Expand Down Expand Up @@ -80,7 +82,6 @@ public MainTableColumnFactory(BibDatabaseContext database,
List<TableColumn<BibEntryTableViewModel, ?>> columns = new ArrayList<>();

columnPreferences.getColumns().forEach(column -> {

switch (column.getType()) {
case INDEX:
columns.add(createIndexColumn(column));
Expand Down Expand Up @@ -113,7 +114,19 @@ public MainTableColumnFactory(BibDatabaseContext database,
default:
case NORMALFIELD:
if (!column.getQualifier().isBlank()) {
columns.add(createFieldColumn(column));
TableColumn<BibEntryTableViewModel, ?> fieldColumn = createFieldColumn(column);
columns.add(fieldColumn);
fieldColumn.setPrefWidth(ColumnPreferences.DEFAULT_COLUMN_WIDTH);
if (column.getQualifier().equalsIgnoreCase(StandardField.YEAR.getName())) {
// 60 is chosen, because of the optimal width of a four digit number
fieldColumn.setPrefWidth(60);
} else if (column.getQualifier().equalsIgnoreCase(InternalField.TYPE_HEADER.getName())) {
// 90 is chosen, because of the optimal width of the entry type
fieldColumn.setPrefWidth(90);
} else {
fieldColumn.setMinWidth(ColumnPreferences.DEFAULT_COLUMN_MIN_WIDTH);
fieldColumn.setPrefWidth(ColumnPreferences.DEFAULT_COLUMN_WIDTH);
}
}
break;
}
Expand All @@ -129,7 +142,7 @@ public static void setExactWidth(TableColumn<?, ?> column, double width) {
}

/**
* Creates a column with a continous number
* Creates a column with a continuous number
*/
private TableColumn<BibEntryTableViewModel, String> createIndexColumn(MainTableColumnModel columnModel) {
TableColumn<BibEntryTableViewModel, String> column = new MainTableColumn<>(columnModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ public Type getType() {
return typeProperty.getValue();
}

/**
* Returns the field name of the column (e.g., year)
*/
public String getQualifier() {
return qualifierProperty.getValue();
}
Expand Down
25 changes: 0 additions & 25 deletions src/main/java/org/jabref/gui/maintable/MainTablePreferences.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,20 @@ private void updateColumns() {
mainTable.getColumns().stream()
.map(column -> ((MainTableColumn<?>) column).getModel())
.collect(Collectors.toList()),
preferences.getColumnPreferences().getColumnSortOrder()));
preferences.getColumnPreferences().getColumnSortOrder(),
preferences.getColumnPreferences().isDedicatedFileColumnsEnabled()));
}

/**
* Stores the SortOrder of the the Table in the preferences. Cannot be combined with updateColumns, because JavaFX
* 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.
*/
private void updateSortOrder() {
preferences.storeColumnPreferences(new ColumnPreferences(
preferences.getColumnPreferences().getColumns(),
mainTable.getSortOrder().stream()
.map(column -> ((MainTableColumn<?>) column).getModel())
.collect(Collectors.toList())));
preferences.getColumnPreferences().getColumns(),
mainTable.getSortOrder().stream()
.map(column -> ((MainTableColumn<?>) column).getModel())
.collect(Collectors.toList()),
preferences.getColumnPreferences().isDedicatedFileColumnsEnabled()));
}
}
Loading