Skip to content

Commit

Permalink
added header text for ScaleAllowMultiValue
Browse files Browse the repository at this point in the history
  • Loading branch information
soimugeo committed Aug 28, 2024
1 parent fd7093a commit 9ec7839
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class PostCoordinationPortletPresenter extends AbstractWebProtegePortletP
private final Map<String, ScaleValueCardPresenter> scaleValueCardPresenters = new HashMap<>();

private final Map<String, PostCoordinationTableAxisLabel> labels = new HashMap<>();
private final Map<String, PostCoordinationAxisToGenericScale> genericScale = new HashMap<>();


@Inject
Expand Down Expand Up @@ -65,6 +66,7 @@ public void startPortlet(PortletUi portletUi, WebProtegeEventBus eventBus) {

scaleValueCardPresenters.clear();
labels.clear();
genericScale.clear();


dispatch.execute(GetPostCoordinationTableConfigurationAction.create("ICD"), result -> {
Expand All @@ -77,18 +79,28 @@ public void startPortlet(PortletUi portletUi, WebProtegeEventBus eventBus) {
}
view.setLabels(labels);

/*
ToDo:
populate genericScale using a dispatch request.
*/
Map<String, ScaleValueCardPresenter> axisMapWithValues = labels.values()
.stream()
.collect(Collectors.toMap(
PostCoordinationTableAxisLabel::getPostCoordinationAxis, // Key mapper
tabelAxisLabel -> createScaleValueCardPresenter( // Value mapper
tabelAxisLabel,
new PostCoordinationScaleValue(
tabelAxisLabel.getPostCoordinationAxis(),
tabelAxisLabel.getScaleLabel(),
new ArrayList<>(Arrays.asList("iri1.1", "iri1.2", "iri1.3"))
)
)
PostCoordinationTableAxisLabel::getPostCoordinationAxis,
tabelAxisLabel -> {
PostCoordinationAxisToGenericScale genericScale1 = genericScale.getOrDefault(
tabelAxisLabel.getPostCoordinationAxis(),
new PostCoordinationAxisToGenericScale(tabelAxisLabel.getPostCoordinationAxis(), "", ScaleAllowMultiValue.NotAllowed)
);
return createScaleValueCardPresenter(
tabelAxisLabel,
new PostCoordinationScaleValue(
tabelAxisLabel.getPostCoordinationAxis(),
tabelAxisLabel.getScaleLabel(),
new ArrayList<>(Arrays.asList("iri1.1", "iri1.2", "iri1.3")),
genericScale1)
);
}
));

scaleValueCardPresenters.putAll(axisMapWithValues);
Expand Down Expand Up @@ -130,7 +142,14 @@ public void removeScaleValueCardPresenter(String axisIri) {

private void addScaleValueCardPresenter(String axisIri) {
PostCoordinationTableAxisLabel currentAxisLabels = labels.get(axisIri);
ScaleValueCardPresenter newPresenter = createScaleValueCardPresenter(currentAxisLabels, PostCoordinationScaleValue.createEmpty(axisIri, currentAxisLabels.getScaleLabel()));
PostCoordinationAxisToGenericScale genericScale1 = genericScale.getOrDefault(
axisIri,
new PostCoordinationAxisToGenericScale(axisIri, "", ScaleAllowMultiValue.NotAllowed)
);
ScaleValueCardPresenter newPresenter = createScaleValueCardPresenter(
currentAxisLabels,
PostCoordinationScaleValue.createEmpty(axisIri, currentAxisLabels.getScaleLabel(), genericScale1)
);
scaleValueCardPresenters.put(axisIri, newPresenter);
newPresenter.start(view.getScaleValueCardsView());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,6 @@
max-width: 43px;
overflow: hidden;
}
.scaleValueHeader {
font-size: 14px;
color: #fff;
line-height: 1.4;
background-color: #186cd4;
padding: 10px;
font-weight: bold;
font-family: "Helvetica Neue", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif;
border-top-left-radius: 5px;
border-top-right-radius: 5px
}

.scaleValueRow {
margin-left: 15px;
margin-right: 15px;
font-size: 12px;
width: 99%;
border-bottom: 1px solid #f2f2f2;
border-top: 1px solid #f2f2f2;
min-height: 35px;
align-items: center;
}

.scaleValueCard {
display: flex;
flex-direction: column;
-webkit-box-shadow: 0 0 40px 0 rgba(0, 0, 0, .15);
box-shadow: 0 0 40px 0 rgba(0, 0, 0, .15);
margin: 14px;
width: 97%;
}

.scaleValue-table-button-cell {
width: 30px;
text-align: center;
vertical-align: middle;
}
.scaleValue-table-value-cell {
padding-left: 10px; /* Adjust padding value as needed */
text-align: left; /* Ensure text is aligned to the left */
}

.rotatedHeader {
}
Expand Down Expand Up @@ -107,4 +66,51 @@
margin: 15px;
border-collapse: collapse;
padding: 3px;
}

.scaleValueHeader {
font-size: 14px;
color: #fff;
line-height: 1.4;
background-color: #186cd4;
padding: 10px;
font-weight: bold;
font-family: "Helvetica Neue", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif;
border-top-left-radius: 5px;
border-top-right-radius: 5px
}

.scaleValueRow {
margin-left: 15px;
margin-right: 15px;
font-size: 12px;
width: 99%;
border-bottom: 1px solid #f2f2f2;
border-top: 1px solid #f2f2f2;
min-height: 35px;
align-items: center;
}

.scaleValueCard {
display: flex;
flex-direction: column;
-webkit-box-shadow: 0 0 40px 0 rgba(0, 0, 0, .15);
box-shadow: 0 0 40px 0 rgba(0, 0, 0, .15);
margin: 14px;
width: 97%;
}

.scaleValue-table-button-cell {
width: 30px;
text-align: center;
vertical-align: middle;
}
.scaleValue-table-value-cell {
padding-left: 10px;
text-align: left;
}

.scaleValueHeaderDescription {
font-size: 11px; /* Smaller font size for description */
font-style: italic; /* Italic style for description */
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ interface PostCoordinationTableCss extends CssResource {

@ClassName("scaleValue-table-value-cell")
String scaleValueTableValueCell();

@ClassName("scaleValueHeaderDescription")
String scaleValueHeaderDescription();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package edu.stanford.bmir.protege.web.client.postcoordination.scaleValuesCard;

public class PostCoordinationAxisToGenericScale {
private final String postcoordinationAxis;
private final String genericPostcoordinationScaleTopClass;
private final ScaleAllowMultiValue allowMultiValue;

public PostCoordinationAxisToGenericScale(String postcoordinationAxis,
String genericPostcoordinationScaleTopClass,
ScaleAllowMultiValue allowMultiValue) {
this.postcoordinationAxis = postcoordinationAxis;
this.genericPostcoordinationScaleTopClass = genericPostcoordinationScaleTopClass;
this.allowMultiValue = allowMultiValue;
}

public PostCoordinationAxisToGenericScale create(String postcoordinationAxis,
String genericPostcoordinationScaleTopClass,
ScaleAllowMultiValue allowMultiValue) {
return new PostCoordinationAxisToGenericScale(postcoordinationAxis, genericPostcoordinationScaleTopClass, allowMultiValue);
}

public String getPostcoordinationAxis() {
return postcoordinationAxis;
}

public String getGenericPostcoordinationScaleTopClass() {
return genericPostcoordinationScaleTopClass;
}

public ScaleAllowMultiValue getAllowMultiValue() {
return allowMultiValue;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ public class PostCoordinationScaleValue {
private final String axisIri;
private final String axisLabel;
private final List<String> valueIris;
private final PostCoordinationAxisToGenericScale genericScale;

public PostCoordinationScaleValue(String axisIri, String axisLabel, List<String> valueIris) {
public PostCoordinationScaleValue(String axisIri,
String axisLabel,
List<String> valueIris, PostCoordinationAxisToGenericScale genericScale) {
this.axisIri = axisIri;
this.axisLabel = axisLabel;
this.valueIris = valueIris;
this.genericScale = genericScale;
}

public static PostCoordinationScaleValue createEmpty(String axisIri, String axisLabel){
return new PostCoordinationScaleValue(axisIri, axisLabel, new ArrayList<>());
public static PostCoordinationScaleValue createEmpty(String axisIri,
String axisLabel,
PostCoordinationAxisToGenericScale genericScale) {
return new PostCoordinationScaleValue(axisIri, axisLabel, new ArrayList<>(), genericScale);
}

public String getAxisIri() {
Expand All @@ -29,4 +35,8 @@ public String getAxisLabel() {
public List<String> getValueIris() {
return valueIris;
}

public PostCoordinationAxisToGenericScale getGenericScale(){
return genericScale;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package edu.stanford.bmir.protege.web.client.postcoordination.scaleValuesCard;

public enum ScaleAllowMultiValue {
NotAllowed("This does not allow multiple values"),
AllowAlways("This always allows multiple values"),
AllowedExceptFromSameBlock("This allows multiple values except from the same block");

private final String description;

ScaleAllowMultiValue(String description) {
this.description = description;
}

public String getBrowserTest() {
return description;
}

public static ScaleAllowMultiValue fromString(String value) {
for (ScaleAllowMultiValue scaleAllowMultiValue : ScaleAllowMultiValue.values()) {
if (scaleAllowMultiValue.name().equalsIgnoreCase(value)) {
return scaleAllowMultiValue;
}
}
throw new IllegalArgumentException("Unknown value: " + value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,18 @@ public ScaleValueCardPresenter(PostCoordinationTableAxisLabel postCoordinationAx
this.projectId = projectId;
}

//implement here the pop-up modal for selecting a scale value
private void bindView() {
view.setAddButtonClickHandler(event -> addRow("New Value"));
}

private void initTable() {
view.clearTable();
view.addHeader(postCoordinationAxis.getScaleLabel());
view.addHeader(postCoordinationAxis.getScaleLabel(), scaleValue.getGenericScale().getAllowMultiValue().getBrowserTest());
view.addSelectValueButton();

dispatchServiceManager.execute(GetRenderedOwlEntitiesAction.create(projectId, new HashSet<>(scaleValue.getValueIris())),
result -> {
result.getRenderedEntities().forEach(renderedEntity -> addRow(!renderedEntity.getBrowserText().equals("") ? renderedEntity.getBrowserText() : renderedEntity.getEntity().toStringID()));
}
result -> result.getRenderedEntities().forEach(renderedEntity -> addRow(!renderedEntity.getBrowserText().equals("") ? renderedEntity.getBrowserText() : renderedEntity.getEntity().toStringID()))
);

view.setDeleteValueButtonHandler((value) -> scaleValue.getValueIris().remove(value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public interface ScaleValueCardView extends IsWidget {

void clearTable();

void addHeader(String headerText);
void addHeader(String headerText, String description);

void addRow(String value) ;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ interface ScaleValueCardViewImplUiBinder extends UiBinder<HTMLPanel, ScaleValueC

private static final WebProtegeClientBundle.ButtonsCss buttonCss = WebProtegeClientBundle.BUNDLE.buttons();

private DeleteScaleValueButtonHandler deleteScaleValueButtonHandler = (value) -> {};
private DeleteScaleValueButtonHandler deleteScaleValueButtonHandler = (value) -> {
};

@UiField
FlexTable valueTable;
Expand Down Expand Up @@ -48,12 +49,17 @@ public void clearTable() {
}

@Override
public void addHeader(String headerText) {
public void addHeader(String headerText, String description) {
GWT.log("Adding header. Current row count: " + valueTable.getRowCount());
Label headerLabel = new Label(headerText);
headerLabel.setStyleName(postCoordinationStyle.scaleValueHeader());
valueTable.setWidget(0, 0, headerLabel);

// Combine header text and description using HTML with inline span for description
HTML headerHtml = new HTML(headerText + "<br><span class=\"" + postCoordinationStyle.scaleValueHeaderDescription() + "\">" + description + "</span>");

// Add the combined header HTML to the table cell and apply the scaleValueHeader style to the cell
valueTable.setWidget(0, 0, headerHtml);
valueTable.getFlexCellFormatter().setColSpan(0, 0, 2);
valueTable.getCellFormatter().setStyleName(0, 0, postCoordinationStyle.scaleValueHeader());

GWT.log("Header added. Current row count: " + valueTable.getRowCount());
}

Expand Down Expand Up @@ -89,7 +95,7 @@ private void setRowContents(int rowIndex, String value) {
GWT.log("New row added. Current row count: " + valueTable.getRowCount());
}

public void setDeleteValueButtonHandler(DeleteScaleValueButtonHandler handler){
public void setDeleteValueButtonHandler(DeleteScaleValueButtonHandler handler) {
this.deleteScaleValueButtonHandler = handler;
}

Expand Down

0 comments on commit 9ec7839

Please sign in to comment.