Skip to content

Commit

Permalink
fix the link between the postcoordination table and the scale value c…
Browse files Browse the repository at this point in the history
…ards. now the cards show and disappear properly when enabling a postcoordination axis
  • Loading branch information
soimugeo committed Aug 30, 2024
1 parent 8405a5c commit 3f0d1f6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ create a post PostCoordinationScaleValue also using the scale value from BE if
}

private TableCellChangedHandler handleTableCellChanged() {
return (isOnMultipleRows, checkboxValue, tableAxisIri) -> {
return (isAxisEnabledOnAnyRow, checkboxValue, tableAxisIri) -> {
boolean presenterExists = isScaleValuePresenterCreated(tableAxisIri);
if ((checkboxValue.getValue().equals("ALLOWED") ||
checkboxValue.getValue().equals("REQUIRED")) &&
Expand All @@ -211,7 +211,7 @@ private TableCellChangedHandler handleTableCellChanged() {
} else {
addScaleValueCardPresenter(tableAxisIri);
}
} else if (!isOnMultipleRows &&
} else if (!isAxisEnabledOnAnyRow &&
(!checkboxValue.getValue().equals("ALLOWED") ||
!checkboxValue.getValue().equals("REQUIRED"))) {
if (isCompositeAxis(tableAxisIri)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.google.gwt.uibinder.client.*;
import com.google.gwt.user.client.ui.*;
import edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceManager;
import edu.stanford.bmir.protege.web.client.form.complexcheckbox.CheckboxValue;
import edu.stanford.bmir.protege.web.client.postcoordination.scaleValuesCard.TableCellChangedHandler;
import edu.stanford.bmir.protege.web.shared.linearization.LinearizationDefinition;
import edu.stanford.bmir.protege.web.shared.postcoordination.PostCoordinationTableAxisLabel;
Expand All @@ -31,7 +30,7 @@ public class PostCoordinationPortletViewImpl extends Composite implements PostCo
private final List<PostCoordinationTableRow> tableRows = new ArrayList<>();
private final DispatchServiceManager dispatch;

private TableCellChangedHandler tableCellChanged = (tableRows, checkboxValue, tableAxisLabel) -> {
private TableCellChangedHandler tableCellChanged = (isAxisEnabledOnAnyRow, checkboxValue, tableAxisLabel) -> {
};

private static final PostCoordinationTableResourceBundle.PostCoordinationTableCss style = PostCoordinationTableResourceBundle.INSTANCE.style();
Expand Down Expand Up @@ -109,7 +108,7 @@ private void initializeTableContent() {
PostCoordinationTableCell cell = new PostCoordinationTableCell(linDef, axisLabel, tableRow);
cell.addValueChangeHandler(valueChanged -> {
tableCellChanged.handleTableCellChanged(
isValueSetOnMultipleRowsForAxis(axisLabel, valueChanged.getValue()),
isAxisEnabledOnAnyRow(axisLabel),
valueChanged.getValue(),
cell.getAxisLabel().getPostCoordinationAxis()
);
Expand All @@ -132,13 +131,17 @@ private void initializeTableContent() {
}
}

private boolean isValueSetOnMultipleRowsForAxis(PostCoordinationTableAxisLabel axisLabel, CheckboxValue valueChanged) {
private boolean isAxisEnabledOnAnyRow(PostCoordinationTableAxisLabel axisLabel) {
List<PostCoordinationTableRow> tableRowsWithAxisChecked = this.tableRows.stream()
.filter(tableRow -> tableRow.getCellList()
.stream()
.anyMatch(cell -> cell.getAxisLabel().equals(axisLabel) && cell.getValue().equals(valueChanged.getValue())))
.anyMatch(cell ->
cell.getAxisLabel().equals(axisLabel) &&
(cell.getValue().equals("ALLOWED") || cell.getValue().equals("REQUIRED"))
)
)
.collect(Collectors.toList());
return tableRowsWithAxisChecked.size() > 1;
return tableRowsWithAxisChecked.size() > 0;
}

private void updateTelescopicLinearizations(PostCoordinationTableCell cell) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import edu.stanford.bmir.protege.web.client.form.complexcheckbox.CheckboxValue;

public interface TableCellChangedHandler {
void handleTableCellChanged(boolean isOnMultipleRows, CheckboxValue checkboxValue, String tableAxisIri);
void handleTableCellChanged(boolean isAxisEnabledOnAnyRow, CheckboxValue checkboxValue, String tableAxisIri);
}

0 comments on commit 3f0d1f6

Please sign in to comment.