Skip to content

Commit

Permalink
added icons for scale values selection mode
Browse files Browse the repository at this point in the history
  • Loading branch information
soimugeo committed Oct 1, 2024
1 parent 2cb7242 commit 2ca7e60
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
package edu.stanford.bmir.protege.web.client.postcoordination.scaleValuesCard;

import com.google.gwt.resources.client.DataResource;

import javax.annotation.Nullable;
import java.util.Optional;

import static edu.stanford.bmir.protege.web.resources.WebProtegeClientBundle.BUNDLE;

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");
NotAllowed(Optional.of(BUNDLE.singleScaleValue()), "In the Coding Tool, this axis allows the selection of multiple values"),
AllowAlways(Optional.of(BUNDLE.multipleScaleValues()),"In the Coding Tool, this axis allows the section of a single value"),
AllowedExceptFromSameBlock(Optional.of(BUNDLE.scaleValueFromSameBlock()),"In the Coding Tool, this axis allows the selection of multiple values, but only one value from each block");

private final String description;
private final String tooltip;

@Nullable
private transient DataResource image;

ScaleAllowMultiValue(Optional<DataResource> image, String tooltip) {
this.tooltip = tooltip;
this.image = image.orElse(null);
}

ScaleAllowMultiValue(String description) {
this.description = description;
public String getTooltip() {
return tooltip;
}

public String getBrowserText() {
return description;
public Optional<DataResource> getImage() {
return Optional.ofNullable(image);
}

public static ScaleAllowMultiValue fromString(String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private void bindView() {

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

dispatchServiceManager.execute(GetRenderedOwlEntitiesAction.create(projectId, new HashSet<>(scaleValue.getValueIris())),
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, String description);
void addHeader(String headerText, ScaleAllowMultiValue scaleAllowMultiValue);

void addRow(String value) ;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,27 @@ public void clearTable() {
}

@Override
public void addHeader(String headerText, String description) {
public void addHeader(String headerText, ScaleAllowMultiValue scaleAllowMultiValue) {
GWT.log("Adding header. Current row count: " + valueTable.getRowCount());

headerHtml = new HTML("<span class=\"" + postCoordinationStyle.toggleIcon() + "\">" + collapseIcon + "</span> " + headerText + spaceSymbol + "<span class=\"" + postCoordinationStyle.scaleValueHeaderDescription() + "\">(" + description + ")</span>");
String imageUri = "";
if (scaleAllowMultiValue.getImage().isPresent()) {
imageUri = scaleAllowMultiValue.getImage().get().getSafeUri().asString();
}
StringBuilder sb = new StringBuilder();
sb.append("<span class=\"")
.append(postCoordinationStyle.toggleIcon())
.append("\">")
.append(collapseIcon)
.append("</span> ")
.append(headerText)
.append(spaceSymbol)
.append("<img src='")
.append(imageUri)
.append("' title='")
.append(scaleAllowMultiValue.getTooltip())
.append("'/>");

headerHtml = new HTML(sb.toString());

valueTable.setWidget(0, 0, headerHtml);
valueTable.getFlexCellFormatter().setColSpan(0, 0, 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,18 @@ public interface WebProtegeClientBundle extends ClientBundle {
@Source("primitive-data.css")
WebProtegePrimitiveDataCss primitiveData();

@Source("single.svg")
@DataResource.MimeType("image/svg+xml")
DataResource singleScaleValue();

@Source("multiple.svg")
@DataResource.MimeType("image/svg+xml")
DataResource multipleScaleValues();

@Source("block.svg")
@DataResource.MimeType("image/svg+xml")
DataResource scaleValueFromSameBlock();

interface WebProtegePrimitiveDataCss extends CssResource {

@ClassName("wp-pd")
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2ca7e60

Please sign in to comment.