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

On clicking on the symbol in the consistency check results table select the respective field #12658

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.stream.Collectors;

import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.collections.ListChangeListener;
import javafx.collections.transformation.FilteredList;
import javafx.fxml.FXML;
import javafx.scene.control.ComboBox;
Expand All @@ -26,6 +25,7 @@
import org.jabref.logic.quality.consistency.ConsistencyMessage;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.entry.field.SpecialField;
import org.jabref.model.entry.field.StandardField;

import com.airhacks.afterburner.views.ViewLoader;
import com.tobiasdiez.easybind.EasyBind;
Expand Down Expand Up @@ -62,13 +62,6 @@ public ConsistencyCheckDialog(LibraryTab libraryTab,
.setAsDialogPane(this);
}

private void onSelectionChanged(ListChangeListener.Change<? extends ConsistencyMessage> change) {
if (change.next()) {
change.getAddedSubList().stream().findFirst().ifPresent(message ->
libraryTab.showAndEdit(message.bibEntry()));
}
}

public ConsistencyCheckDialogViewModel getViewModel() {
return viewModel;
}
Expand All @@ -77,8 +70,6 @@ public ConsistencyCheckDialogViewModel getViewModel() {
public void initialize() {
viewModel = new ConsistencyCheckDialogViewModel(dialogService, preferences, entryTypesManager, result);

tableView.getSelectionModel().getSelectedItems().addListener(this::onSelectionChanged);

entryTypeCombo.getItems().addAll(viewModel.getEntryTypes());
entryTypeCombo.valueProperty().bindBidirectional(viewModel.selectedEntryTypeProperty());
EasyBind.listen(entryTypeCombo.getEditor().textProperty(), observable -> entryTypeCombo.commitValue());
Expand Down Expand Up @@ -124,6 +115,17 @@ protected void updateItem(String item, boolean empty) {
setText(item);
}
);

this.setOnMouseClicked(event -> {
if (!isEmpty()) {
TableColumn<?, ?> clickedColumn = getTableColumn();

ConsistencyMessage selectedMessage = getTableRow().getItem();
Optional<StandardField> field = StandardField.fromName(clickedColumn.getText());

field.ifPresent(standardField -> libraryTab.editEntryAndFocusField(selectedMessage.bibEntry(), standardField));
}
});
}
});

Expand Down
Loading