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

Fix sort order in main table not stored #6898

Merged
merged 2 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where the `.sav` file was not deleted upon exiting JabRef. [#6109](https://github.com/JabRef/jabref/issues/6109)
- We fixed a linked identifier icon inconsistency. [#6705](https://github.com/JabRef/jabref/issues/6705)
- We fixed the wrong behavior that font size changes are not reflected in dialogs. [#6039](https://github.com/JabRef/jabref/issues/6039)
- We fixed an issue where the sort order of the entry table was reset after a restart of JabRef [#6898](https://github.com/JabRef/jabref/pull/6898)

### Removed

Expand Down
15 changes: 14 additions & 1 deletion src/main/java/org/jabref/gui/maintable/MainTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,20 @@ public MainTable(MainTableDataModel model,
.install(this);

this.getSortOrder().clear();
mainTablePreferences.getColumnPreferences().getColumnSortOrder().forEach(columnModel ->

/* KEEP for debugging purposes
for (var colModel : mainTablePreferences.getColumnPreferences().getColumnSortOrder()) {
for (var col : this.getColumns()) {
var tablecColModel = ((MainTableColumn<?>) col).getModel();
if (tablecColModel.equals(colModel)) {
LOGGER.debug("Adding sort order for col {} ", col);
this.getSortOrder().add(col);
break;
}
}
}
*/
mainTablePreferences.getColumnPreferences().getColumnSortOrder().forEach(columnModel ->
this.getColumns().stream()
.map(column -> (MainTableColumn<?>) column)
.filter(column -> column.getModel().equals(columnModel))
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public String getName() {

public String getDisplayName() {
if ((Type.ICON_COLUMNS.contains(typeProperty.getValue()) && qualifierProperty.getValue().isBlank())
|| typeProperty.getValue() == Type.INDEX) {
|| (typeProperty.getValue() == Type.INDEX)) {
return typeProperty.getValue().getDisplayName();
} else {
return FieldsUtil.getNameWithType(FieldFactory.parseField(qualifierProperty.getValue()));
Expand All @@ -165,23 +165,25 @@ public ObjectProperty<TableColumn.SortType> sortTypeProperty() {
return sortTypeProperty;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}

if (o == null || getClass() != o.getClass()) {
if ((o == null) || (getClass() != o.getClass())) {
return false;
}

MainTableColumnModel that = (MainTableColumnModel) o;

if (typeProperty != that.typeProperty) {
if (typeProperty.getValue() != that.typeProperty.getValue()) {
return false;
}
return Objects.equals(qualifierProperty, that.qualifierProperty);
return Objects.equals(qualifierProperty.getValue(), that.qualifierProperty.getValue());
}

@Override
public int hashCode() {
return Objects.hash(typeProperty.getValue(), qualifierProperty.getValue());
}
Expand All @@ -199,9 +201,9 @@ public static MainTableColumnModel parse(String rawColumnName) {
Type type = Type.fromString(splittedName[0]);
String qualifier = "";

if (type == Type.NORMALFIELD
|| type == Type.SPECIALFIELD
|| type == Type.EXTRAFILE) {
if ((type == Type.NORMALFIELD)
|| (type == Type.SPECIALFIELD)
|| (type == Type.EXTRAFILE)) {
if (splittedName.length == 1) {
qualifier = splittedName[0]; // By default the rawColumnName is parsed as NORMALFIELD
} else {
Expand Down