diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/form/complexcheckbox/CheckBoxConfig.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/form/complexcheckbox/CheckBoxConfig.java index b584f838b..5946ff54d 100644 --- a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/form/complexcheckbox/CheckBoxConfig.java +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/form/complexcheckbox/CheckBoxConfig.java @@ -18,7 +18,7 @@ protected CheckBoxConfig(CheckboxValue defaultValue, List scrolla this.readOnly = true; } - CheckboxValue getNextValue(CheckboxValue checkboxValue) { + public CheckboxValue getNextValue(CheckboxValue checkboxValue) { int pos = scrollableValues.indexOf(checkboxValue); if(pos >= 0) { if(pos == scrollableValues.size() - 1) { diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/form/complexcheckbox/ConfigurableCheckBoxPresenter.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/form/complexcheckbox/ConfigurableCheckBoxPresenter.java index ffca50b0b..598837a20 100644 --- a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/form/complexcheckbox/ConfigurableCheckBoxPresenter.java +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/form/complexcheckbox/ConfigurableCheckBoxPresenter.java @@ -19,11 +19,11 @@ import static com.google.common.base.Preconditions.checkNotNull; public class ConfigurableCheckBoxPresenter implements HasValue, HasText, HasEnabled, HasReadOnly { - Logger logger = java.util.logging.Logger.getLogger("ConfigurableCheckBoxPresenter"); - @Nonnull private final ConfigurableCheckBoxView view; + private boolean isTouched = false; + private CheckBoxConfig config; @Inject @@ -58,6 +58,7 @@ private void toggleSelected() { } CheckboxValue nextSel = config.getNextValue(view.getValue()); view.setValue(nextSel); + isTouched = true; } @Override @@ -89,6 +90,10 @@ public HandlerRegistration addValueChangeHandler(ValueChangeHandler event) { view.fireEvent(event); diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/form/complexcheckbox/ConfigurableCheckbox.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/form/complexcheckbox/ConfigurableCheckbox.java index 7e25cbbc5..fd69beb73 100644 --- a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/form/complexcheckbox/ConfigurableCheckbox.java +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/form/complexcheckbox/ConfigurableCheckbox.java @@ -16,6 +16,7 @@ public class ConfigurableCheckbox implements IsWidget, HasValue, @Nonnull private final ConfigurableCheckBoxPresenter presenter; + private final CheckBoxConfig checkBoxConfig; public ConfigurableCheckbox(CheckBoxConfig checkBoxConfig, String initialValue) { @@ -35,6 +36,10 @@ public ConfigurableCheckbox(CheckBoxConfig checkBoxConfig, String initialValue) this.setValue(checkboxValue); } + public boolean isTouched() { + return this.presenter.isTouched(); + } + @Override public Widget asWidget() { return container; diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/inject/ClientApplicationModule.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/inject/ClientApplicationModule.java index d9781de63..7fe70fcd4 100644 --- a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/inject/ClientApplicationModule.java +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/inject/ClientApplicationModule.java @@ -94,6 +94,8 @@ import edu.stanford.bmir.protege.web.client.portlet.PortletChooserViewImpl; import edu.stanford.bmir.protege.web.client.portlet.PortletUi; import edu.stanford.bmir.protege.web.client.portlet.PortletUiImpl; +import edu.stanford.bmir.protege.web.client.postcoordination.PostCoordinationPortletView; +import edu.stanford.bmir.protege.web.client.postcoordination.PostCoordinationPortletViewImpl; import edu.stanford.bmir.protege.web.client.primitive.PrimitiveDataEditorImageView; import edu.stanford.bmir.protege.web.client.primitive.PrimitiveDataEditorImageViewImpl; import edu.stanford.bmir.protege.web.client.progress.BusyView; @@ -504,6 +506,11 @@ LinearizationPortletView provideLinearizationPortletView(LinearizationPortletVie return impl; } + @Provides + PostCoordinationPortletView providePostCoordinationPortletView(PostCoordinationPortletViewImpl impl){ + return impl; + } + @Provides LinearizationCommentsView provideLienarizationCommentsView(LinearizationCommentsViewImpl impl){ return impl; diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/linearization/LinearizationPortletViewImpl.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/linearization/LinearizationPortletViewImpl.java index 2c4c33b3b..390c7f032 100644 --- a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/linearization/LinearizationPortletViewImpl.java +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/linearization/LinearizationPortletViewImpl.java @@ -279,11 +279,11 @@ private void addCommentsHeader(String headerText, int column) { private void initializeTableHeader() { addHeaderCell("Linearization", 0); - addCheckboxHeaderCell("Is part of?", 1); - addCheckboxHeaderCell("Is grouping?",2); - addCheckboxHeaderCell("Aux.ax.child?", 3); - addWideHeaderCell("Linearization parent", 4); - addCommentsHeader("Coding notes", 5); + addCheckboxHeaderCell("Is Part Of?", 1); + addCheckboxHeaderCell("Is Grouping?",2); + addCheckboxHeaderCell("Aux.Ax.Child?", 3); + addWideHeaderCell("Linearization Path Parent", 4); + addCommentsHeader("Coding Notes", 5); flexTable.getRowFormatter().addStyleName(0, style.getLinearizationHeader()); } diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationCheckboxConfig.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationCheckboxConfig.java new file mode 100644 index 000000000..b733538df --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationCheckboxConfig.java @@ -0,0 +1,89 @@ +package edu.stanford.bmir.protege.web.client.postcoordination; + +import edu.stanford.bmir.protege.web.client.form.complexcheckbox.CheckBoxConfig; +import edu.stanford.bmir.protege.web.client.form.complexcheckbox.CheckboxValue; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.logging.Logger; + +public class PostCoordinationCheckboxConfig extends CheckBoxConfig { + private final Logger logger = Logger.getLogger("CheckBoxConfig"); + + private final static String CHECK_SVG = " "; + private final static String REQUIRED_SVG = " mandatory-done "; + + private final static String UNKNOWN_SVG = " "; + + private final static String DEFAULT_CHECK_SVG = " "; + private final static String DEFAULT_REQUIRED_SVG = " mandatory-done "; + + private final static String DEFAULT_UNKNOWN_SVG = " "; + + + private CheckboxValue parentValue; + + + public static List AVAILABLE_VALUES_LIST = Arrays.asList(new CheckboxValue(UNKNOWN_SVG, "UNKNOWN"), + new CheckboxValue(CHECK_SVG, "ALLOWED"), + new CheckboxValue(REQUIRED_SVG, "REQUIRED") + ); + + public static List AVAILABLE_DEFAULT_VALUE_LIST = Arrays.asList( + new CheckboxValue(DEFAULT_UNKNOWN_SVG, "DEFAULT_UNKNOWN"), + new CheckboxValue(DEFAULT_CHECK_SVG, "DEFAULT_ALLOWED"), + new CheckboxValue(DEFAULT_REQUIRED_SVG, "DEFAULT_REQUIRED")); + + protected PostCoordinationCheckboxConfig() { + super(new CheckboxValue(UNKNOWN_SVG, "UNKNOWN"), AVAILABLE_VALUES_LIST); + } + + @Override + public CheckboxValue getNextValue(CheckboxValue checkboxValue) { + if(parentValue != null) { + return getNextValueForDerivedClasses(checkboxValue); + } else { + return super.getNextValue(checkboxValue); + } + } + + @Override + public CheckboxValue findValue(String inputValue) { + if(inputValue == null || inputValue.isEmpty()) { + return new CheckboxValue(UNKNOWN_SVG, "UNKNOWN"); + } + List allValues = new ArrayList<>(); + allValues.addAll(AVAILABLE_VALUES_LIST); + allValues.addAll(AVAILABLE_DEFAULT_VALUE_LIST); + + return allValues.stream().filter(value -> value.getValue().equalsIgnoreCase(inputValue)) + .findFirst() + .orElse(new CheckboxValue(UNKNOWN_SVG, "UNKNOWN")); + } + + private CheckboxValue getNextValueForDerivedClasses(CheckboxValue checkboxValue) { + if(checkboxValue.getValue().startsWith("DEFAULT")) { + return AVAILABLE_VALUES_LIST.get(0); + } + + int pos = AVAILABLE_VALUES_LIST.indexOf(checkboxValue); + if(pos >= 0) { + if (pos == AVAILABLE_VALUES_LIST.size()-1) { + return AVAILABLE_DEFAULT_VALUE_LIST.stream().filter(value -> ("DEFAULT_"+parentValue.getValue()).equalsIgnoreCase(value.getValue())) + .findFirst() + .orElseThrow(() -> new RuntimeException("Missing parent")); + } else { + return AVAILABLE_VALUES_LIST.get(pos + 1); + + } + }else { + throw new RuntimeException("Given value " + checkboxValue + " is not in scrollable values "); + } + } + + public void setParentValue(CheckboxValue parentValue) { + this.parentValue = parentValue; + } + +} diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationPortletPresenter.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationPortletPresenter.java new file mode 100644 index 000000000..9226c741e --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationPortletPresenter.java @@ -0,0 +1,107 @@ +package edu.stanford.bmir.protege.web.client.postcoordination; + +import com.google.web.bindery.event.shared.EventBus; +import edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceManager; +import edu.stanford.bmir.protege.web.client.lang.DisplayNameRenderer; +import edu.stanford.bmir.protege.web.client.library.msgbox.MessageBox; +import edu.stanford.bmir.protege.web.client.portlet.AbstractWebProtegePortletPresenter; +import edu.stanford.bmir.protege.web.client.portlet.PortletUi; +import edu.stanford.bmir.protege.web.client.selection.SelectionModel; +import edu.stanford.bmir.protege.web.client.user.LoggedInUserManager; +import edu.stanford.bmir.protege.web.shared.event.WebProtegeEventBus; +import edu.stanford.bmir.protege.web.shared.linearization.GetLinearizationDefinitionsAction; +import edu.stanford.bmir.protege.web.shared.linearization.LinearizationDefinition; +import edu.stanford.bmir.protege.web.shared.postcoordination.GetPostCoordinationTableConfigurationAction; +import edu.stanford.bmir.protege.web.shared.postcoordination.PostCoordinationTableAxisLabel; +import edu.stanford.bmir.protege.web.shared.project.ProjectId; +import edu.stanford.webprotege.shared.annotations.Portlet; +import org.semanticweb.owlapi.model.OWLEntity; + +import javax.annotation.Nonnull; +import javax.inject.Inject; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.logging.Logger; + + +@Portlet(id = "portlets.PostCoordination", + title = "iCat-X Post-Coordinations", + tooltip = "Displays the Post-Coordination configuration on the current entity.") +public class PostCoordinationPortletPresenter extends AbstractWebProtegePortletPresenter { + + private final PostCoordinationPortletView view; + Logger logger = java.util.logging.Logger.getLogger("PostCoordinationPortletPresenter"); + + private DispatchServiceManager dispatch; + private final EventBus eventBus; + + private final LoggedInUserManager loggedInUserManager; + + + private MessageBox messageBox; + + @Inject + public PostCoordinationPortletPresenter(@Nonnull SelectionModel selectionModel, + @Nonnull ProjectId projectId, + @Nonnull DisplayNameRenderer displayNameRenderer, + @Nonnull DispatchServiceManager dispatch, + @Nonnull PostCoordinationPortletView view, + @Nonnull EventBus eventBus, + @Nonnull MessageBox messageBox, + @Nonnull LoggedInUserManager loggedInUserManager) { + super(selectionModel, projectId, displayNameRenderer, dispatch); + this.view = view; + this.messageBox = messageBox; + this.dispatch = dispatch; + this.eventBus = eventBus; + this.loggedInUserManager = loggedInUserManager; + this.view.setProjectId(projectId); + + } + + @Override + public void startPortlet(PortletUi portletUi, WebProtegeEventBus eventBus) { + + portletUi.setWidget(view.asWidget()); + setDisplaySelectedEntityNameAsSubtitle(true); + + dispatch.execute(GetPostCoordinationTableConfigurationAction.create("ICD"), result -> { + Map labels = new HashMap<>(); + for(String availableAxis : result.getTableConfiguration().getPostCoordinationAxes()) { + PostCoordinationTableAxisLabel existingLabel = result.getLabels().stream() + .filter(label -> label.getPostCoordinationAxis().equalsIgnoreCase(availableAxis)) + .findFirst().orElseThrow( () -> new RuntimeException("Couldn't find label for " + availableAxis)); + labels.put(availableAxis, existingLabel); + } + view.setLabels(labels); + + dispatch.execute(GetLinearizationDefinitionsAction.create(), definitionsResult -> { + Map definitionMap = new HashMap<>(); + + for (LinearizationDefinition definition : definitionsResult.getDefinitionList()) { + definitionMap.put(definition.getWhoficEntityIri(), definition); + } + view.setLinearizationDefinitonMap(definitionMap); + view.setPostCoordinationEntity(); + }); + + }); + + + } + + + + @Override + protected void handleReloadRequest() { + + } + + @Override + protected void handleAfterSetEntity(Optional entityData) { + + + } + +} diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationPortletView.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationPortletView.java new file mode 100644 index 000000000..738160ea2 --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationPortletView.java @@ -0,0 +1,20 @@ +package edu.stanford.bmir.protege.web.client.postcoordination; + +import com.google.gwt.user.client.ui.AcceptsOneWidget; +import com.google.gwt.user.client.ui.IsWidget; +import edu.stanford.bmir.protege.web.shared.HasDispose; +import edu.stanford.bmir.protege.web.shared.linearization.LinearizationDefinition; +import edu.stanford.bmir.protege.web.shared.postcoordination.PostCoordinationTableAxisLabel; +import edu.stanford.bmir.protege.web.shared.project.ProjectId; + +import java.util.Map; + +public interface PostCoordinationPortletView extends AcceptsOneWidget, IsWidget, HasDispose { + void setProjectId(ProjectId projectId); + + void setLabels(Map labels); + + void setLinearizationDefinitonMap(Map linearizationDefinitonMap); + + void setPostCoordinationEntity(); +} diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationPortletViewImpl.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationPortletViewImpl.java new file mode 100644 index 000000000..495707c42 --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationPortletViewImpl.java @@ -0,0 +1,177 @@ +package edu.stanford.bmir.protege.web.client.postcoordination; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.*; +import edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceManager; +import edu.stanford.bmir.protege.web.shared.linearization.LinearizationDefinition; +import edu.stanford.bmir.protege.web.shared.postcoordination.PostCoordinationTableAxisLabel; +import edu.stanford.bmir.protege.web.shared.project.ProjectId; + +import javax.inject.Inject; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.logging.Logger; + +public class PostCoordinationPortletViewImpl extends Composite implements PostCoordinationPortletView { + + + @UiField + HTMLPanel paneContainer; + + @UiField + protected FlexTable flexTable; + private Map labels; + private Map definitionMap; + + private List tableRows = new ArrayList<>(); + private final DispatchServiceManager dispatch; + + private static PostCoordinationTableResourceBundle.PostCoordinationTableCss style = PostCoordinationTableResourceBundle.INSTANCE.style(); + + private static PostCoordinationPortletViewImpl.PostCoordinationPortletViewImplUiBinder ourUiBinder = GWT.create(PostCoordinationPortletViewImpl.PostCoordinationPortletViewImplUiBinder.class); + + @Inject + public PostCoordinationPortletViewImpl(DispatchServiceManager dispatch) { + initWidget(ourUiBinder.createAndBindUi(this)); + + this.dispatch = dispatch; + style.ensureInjected(); + } + + @Override + public void setProjectId(ProjectId projectId) { + + } + + @Override + public void setLabels(Map labels) { + this.labels = labels; + } + + @Override + public void setLinearizationDefinitonMap(Map linearizationDefinitonMap) { + this.definitionMap = linearizationDefinitonMap; + } + + @Override + public void setPostCoordinationEntity() { + initializeTableHeader(); + initializeTableContent(); + } + + @Override + public void setWidget(IsWidget w) { + + } + + @Override + public void dispose() { + + } + + private void initializeTableHeader() { + flexTable.setWidget(0, 0, new Label("Linearization / Use")); + flexTable.getCellFormatter().addStyleName(0, 0, style.getHeaderLabel()); + List labelList = new ArrayList<>(this.labels.values()); + for (int i = 0; i < labelList.size(); i++) { + addHeaderCell(labelList.get(i).getTableLabel(), i + 1); + } + flexTable.getCellFormatter().addStyleName(0, 0, style.getPostCoordinationHeader()); + flexTable.setWidget(0, labelList.size() + 1, new Label("Linearization / Use")); + flexTable.getCellFormatter().addStyleName(0, labelList.size() + 1, style.getHeaderLabel()); + flexTable.getCellFormatter().addStyleName(0, labelList.size() + 1, style.getPostCoordinationHeader()); + flexTable.addStyleName(style.getPostCoordinationTable()); + flexTable.getRowFormatter().addStyleName(0, style.getHeaderLabelRow()); + } + + private void initializeTableContent() { + List definitions = new ArrayList<>(this.definitionMap.values()); + for (int i = 0; i < definitions.size(); i++) { + PostCoordinationTableRow tableRow = new PostCoordinationTableRow(definitions.get(i)); + addRowLabel(tableRow.isDerived(), definitions.get(i).getDisplayLabel(), i + 1, 0); + List labelList = new ArrayList<>(this.labels.values()); + for (int j = 0; j < labelList.size(); j++) { + + PostCoordinationTableCell cell = new PostCoordinationTableCell(definitions.get(i), labelList.get(j), tableRow); + cell.addValueChangeHandler(valueChanged -> { + updateTelescopicLinearizations(cell); + }); + flexTable.setWidget(i + 1, j + 1, cell.asWidget()); + tableRow.addCell(cell); + } + addRowLabel(false, definitions.get(i).getDisplayLabel(), i + 1, labelList.size()+1); + + flexTable.getRowFormatter().addStyleName(i+1, style.getCustomRowStyle()); + if( (i + 1) % 2 == 1) { + flexTable.getRowFormatter().addStyleName(i+1, style.getEvenRowStyle()); + } + this.tableRows.add(tableRow); + } + + for(PostCoordinationTableRow tableRow : tableRows) { + tableRow.bindToParentRow(tableRows); + } + } + + private void updateTelescopicLinearizations(PostCoordinationTableCell cell) { + for(PostCoordinationTableRow tableRow: this.tableRows) { + tableRow.updateDerivedCell(cell); + } + } + + private void addRowLabel(boolean isDerived, String label, int row, int column) { + String rowLabelString; + if(isDerived) { + rowLabelString = SVG + label; + } else { + rowLabelString = label; + } + Widget rowLabel = new Label(); + rowLabel.getElement().setInnerHTML(rowLabelString); + rowLabel.addStyleName(style.getRowLabel()); + flexTable.setWidget(row, column, rowLabel); + //flexTable.getCellFormatter().addStyleName(row, column, style.getRowLabel()); + } + + private void addHeaderCell(String label, int position) { + Widget headerCell = new Label(); + headerCell.getElement().setInnerHTML(getHeaderLabelPadded(25, label)); + //headerCell.getElement().setInnerHTML(label); + flexTable.setWidget(0, position, headerCell); + flexTable.getCellFormatter().addStyleName(0, position, style.getPostCoordinationHeader()); + flexTable.getCellFormatter().addStyleName(0, position, style.getRotatedHeader()); + } + + private String getHeaderLabelPadded(int padding, String label) { + + StringBuilder result = new StringBuilder(); + int lastBreak = 0; + + for (int i = padding; i < label.length(); i += padding) { + int spaceIndex = label.lastIndexOf(' ', i); + + if (spaceIndex > lastBreak) { + result.append(label, lastBreak, spaceIndex).append("
"); + lastBreak = spaceIndex + 1; + } else { + result.append(label, lastBreak, i).append("
"); + lastBreak = i; + } + } + + result.append(label.substring(lastBreak)); + + return result.toString(); + } + private static String SVG = "
" + + + " " + + "
"; + + interface PostCoordinationPortletViewImplUiBinder extends UiBinder { + + } +} diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationPortletViewImpl.ui.xml b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationPortletViewImpl.ui.xml new file mode 100644 index 000000000..d3b4b2cce --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationPortletViewImpl.ui.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationTable.css b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationTable.css new file mode 100644 index 000000000..8fa286340 --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationTable.css @@ -0,0 +1,70 @@ + +.postCoordinationHeader { + font-size: 12px; + color: #fff; + line-height: 12px; + vertical-align: middle; + border-left: 1px solid #eee; + border-right: 1px solid #d0d0d0; + color: #fff; + line-height: 1.4; + font-family: "Helvetica Neue", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif; + height: 100px; + max-width: 43px; + overflow: hidden; +} + +.rotatedHeader { +} + +.rotatedHeader div { + transform-origin: left; + transform: rotate(-75deg) translate(-50px,100%); + display: table-cell; + vertical-align: middle; + text-align: start; + text-wrap: wrap; + white-space: nowrap; +} + +.customRowStyle { + border-bottom: 1px solid #f2f2f2; +} + +.evenRowStyle { + background-color: #f2f7f4; +} + + +.headerLabel { + display: flex; + justify-content: center; + align-items: center; + min-height: 120px; + min-width: 13vw; + font-size: 14px; + font-weight: bold; +} + +.headerLabelRow { + background-color: #186cd4; +} + + +.rowLabel { + vertical-align: middle; + display: flex; + margin-left: 5px; + +} + + +.postCoordinationTable { + border-radius: 5px; + overflow: hidden; + -webkit-box-shadow: 0 0 40px 0 rgba(0,0,0,.15); + box-shadow: 0 0 40px 0 rgba(0,0,0,.15); + margin: 15px; + border-collapse: collapse; + padding: 3px; +} \ No newline at end of file diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationTableCell.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationTableCell.java new file mode 100644 index 000000000..6a2d48fba --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationTableCell.java @@ -0,0 +1,69 @@ +package edu.stanford.bmir.protege.web.client.postcoordination; + +import com.google.gwt.event.logical.shared.ValueChangeHandler; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.ui.Widget; +import edu.stanford.bmir.protege.web.client.form.complexcheckbox.CheckboxValue; +import edu.stanford.bmir.protege.web.client.form.complexcheckbox.ConfigurableCheckbox; +import edu.stanford.bmir.protege.web.shared.linearization.LinearizationDefinition; +import edu.stanford.bmir.protege.web.shared.postcoordination.PostCoordinationTableAxisLabel; + +import java.util.logging.Logger; + +public class PostCoordinationTableCell { + private ConfigurableCheckbox configurableCheckbox; + private LinearizationDefinition linearizationDefinition; + + private PostCoordinationCheckboxConfig checkboxConfig; + private PostCoordinationTableAxisLabel axisLabel; + + private PostCoordinationTableRow parentRow; + Logger logger = java.util.logging.Logger.getLogger("PostCoordinationTableCell"); + + public PostCoordinationTableCell(LinearizationDefinition linearizationDefinition, PostCoordinationTableAxisLabel axisLabel, PostCoordinationTableRow parentRow) { + this.checkboxConfig = new PostCoordinationCheckboxConfig(); + configurableCheckbox = new ConfigurableCheckbox(checkboxConfig, "UNKNOWN"); + configurableCheckbox.setReadOnly(false); + configurableCheckbox.setEnabled(true); + + this.linearizationDefinition = linearizationDefinition; + this.axisLabel = axisLabel; + this.parentRow = parentRow; + } + + public Widget asWidget(){ + return configurableCheckbox.asWidget(); + } + + public HandlerRegistration addValueChangeHandler(ValueChangeHandler handler) { + return this.configurableCheckbox.addValueChangeHandler(handler); + } + + public void setValue(String value) { + this.configurableCheckbox.setValue(value); + } + + public boolean isTouched(){ + return configurableCheckbox.isTouched(); + } + + public String getValue() { + return this.configurableCheckbox.getValue().getValue(); + } + + public CheckboxValue getAsCheckboxValue(){ + return this.configurableCheckbox.getValue(); + } + + public LinearizationDefinition getLinearizationDefinition() { + return linearizationDefinition; + } + + public PostCoordinationTableAxisLabel getAxisLabel() { + return axisLabel; + } + + public void setParentValue(CheckboxValue parentValue) { + this.checkboxConfig.setParentValue(parentValue); + } +} diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationTableResourceBundle.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationTableResourceBundle.java new file mode 100644 index 000000000..da8e9fda0 --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationTableResourceBundle.java @@ -0,0 +1,44 @@ +package edu.stanford.bmir.protege.web.client.postcoordination; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.resources.client.ClientBundle; +import com.google.gwt.resources.client.CssResource; + +public interface PostCoordinationTableResourceBundle extends ClientBundle { + + + PostCoordinationTableResourceBundle INSTANCE = GWT.create(PostCoordinationTableResourceBundle.class); + + @Source("PostCoordinationTable.css") + PostCoordinationTableCss style(); + + + + interface PostCoordinationTableCss extends CssResource { + + @ClassName("postCoordinationHeader") + String getPostCoordinationHeader(); + + @ClassName("customRowStyle") + String getCustomRowStyle(); + + @ClassName("headerLabel") + String getHeaderLabel(); + + @ClassName("postCoordinationTable") + String getPostCoordinationTable(); + + @ClassName("rowLabel") + String getRowLabel(); + + @ClassName("rotatedHeader") + String getRotatedHeader(); + @ClassName("headerLabelRow") + String getHeaderLabelRow(); + + @ClassName("evenRowStyle") + String getEvenRowStyle(); + + } + +} diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationTableRow.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationTableRow.java new file mode 100644 index 000000000..70d43bac0 --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationTableRow.java @@ -0,0 +1,65 @@ +package edu.stanford.bmir.protege.web.client.postcoordination; + +import edu.stanford.bmir.protege.web.shared.linearization.LinearizationDefinition; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.logging.Logger; + +public class PostCoordinationTableRow { + + private final LinearizationDefinition linearizationDefinition; + private List cellList = new ArrayList<>(); + + public PostCoordinationTableRow(LinearizationDefinition linearizationDefinition) { + this.linearizationDefinition = linearizationDefinition; + } + + public void addCell(PostCoordinationTableCell cell) { + this.cellList.add(cell); + } + + public void updateDerivedCell(PostCoordinationTableCell changedCell) { + if(isDerived() && linearizationDefinition.getCoreLinId().equalsIgnoreCase(changedCell.getLinearizationDefinition().getId())) { + Optional equivalentCell = this.cellList.stream() + .filter(cell -> cell.getAxisLabel().getPostCoordinationAxis().equalsIgnoreCase(changedCell.getAxisLabel().getPostCoordinationAxis())) + .findFirst(); + equivalentCell.ifPresent(cell -> { + if (!cell.isTouched() || cell.getValue().startsWith("DEFAULT")) { + cell.setParentValue(changedCell.getAsCheckboxValue()); + cell.setValue("DEFAULT_" + changedCell.getValue()); + + } + }); + } + } + public boolean isDerived(){ + return linearizationDefinition.getCoreLinId() != null && !linearizationDefinition.getCoreLinId().isEmpty(); + } + + public void bindToParentRow(List tableRows) { + if(isDerived()) { + PostCoordinationTableRow parentRow = findParentRow(linearizationDefinition.getCoreLinId(), tableRows); + bindCellsToParentCells(parentRow); + } + } + + + + private void bindCellsToParentCells(PostCoordinationTableRow parentRow) { + for(PostCoordinationTableCell parentCell : parentRow.cellList) { + Optional cellToUpload = this.cellList.stream() + .filter(myCell -> myCell.getAxisLabel().getPostCoordinationAxis().equalsIgnoreCase(parentCell.getAxisLabel().getPostCoordinationAxis())) + .findFirst(); + + cellToUpload.ifPresent(cell -> cell.setParentValue(parentCell.getAsCheckboxValue())); + } + } + + PostCoordinationTableRow findParentRow(String parentIRI, List rows) { + return rows.stream().filter(row -> row.linearizationDefinition.getId().equalsIgnoreCase(parentIRI)) + .findFirst() + .orElseThrow(() -> new RuntimeException("Parent not found")); + } +} diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Action.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Action.java index fa66358ef..df223aec8 100644 --- a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Action.java +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Action.java @@ -44,6 +44,7 @@ import edu.stanford.bmir.protege.web.shared.permissions.GetProjectPermissionsAction; import edu.stanford.bmir.protege.web.shared.permissions.RebuildPermissionsAction; import edu.stanford.bmir.protege.web.shared.perspective.*; +import edu.stanford.bmir.protege.web.shared.postcoordination.GetPostCoordinationTableConfigurationAction; import edu.stanford.bmir.protege.web.shared.project.*; import edu.stanford.bmir.protege.web.shared.projectsettings.GetProjectSettingsAction; import edu.stanford.bmir.protege.web.shared.projectsettings.SetProjectSettingsAction; @@ -229,7 +230,8 @@ @Type(value = GetEntityLinearizationAction.class), @Type(value = GetClassAncestorsAction.class), @Type(value = SaveEntityLinearizationAction.class), - @Type(value = GetRenderedOwlEntitiesAction.class) + @Type(value = GetRenderedOwlEntitiesAction.class), + @Type(value = GetPostCoordinationTableConfigurationAction.class) }) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME) public interface Action extends IsSerializable { diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Result.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Result.java index 134c24566..f64a231e6 100644 --- a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Result.java +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Result.java @@ -97,6 +97,7 @@ import edu.stanford.bmir.protege.web.shared.perspective.ResetPerspectivesResult; import edu.stanford.bmir.protege.web.shared.perspective.SetPerspectiveLayoutResult; import edu.stanford.bmir.protege.web.shared.perspective.SetPerspectivesResult; +import edu.stanford.bmir.protege.web.shared.postcoordination.GetPostCoordinationTableConfigurationResult; import edu.stanford.bmir.protege.web.shared.project.CreateNewProjectResult; import edu.stanford.bmir.protege.web.shared.project.GetAvailableProjectsResult; import edu.stanford.bmir.protege.web.shared.project.GetAvailableProjectsWithPermissionResult; @@ -299,7 +300,8 @@ @JsonSubTypes.Type(GetUserInfoResult.class), @JsonSubTypes.Type(SaveEntityLinearizationResult.class), @JsonSubTypes.Type(GetClassAncestorsResult.class), - @JsonSubTypes.Type(GetRenderedOwlEntitiesResult.class) + @JsonSubTypes.Type(GetRenderedOwlEntitiesResult.class), + @JsonSubTypes.Type(GetPostCoordinationTableConfigurationResult.class) }) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME) public interface Result extends IsSerializable { diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/RpcWhiteList.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/RpcWhiteList.java index 2c6af5602..6e372dcf3 100644 --- a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/RpcWhiteList.java +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/RpcWhiteList.java @@ -56,6 +56,10 @@ import edu.stanford.bmir.protege.web.shared.permissions.RebuildPermissionsAction; import edu.stanford.bmir.protege.web.shared.permissions.RebuildPermissionsResult; import edu.stanford.bmir.protege.web.shared.perspective.*; +import edu.stanford.bmir.protege.web.shared.postcoordination.GetPostCoordinationTableConfigurationResult; +import edu.stanford.bmir.protege.web.shared.postcoordination.PostCoordinationCompositeAxis; +import edu.stanford.bmir.protege.web.shared.postcoordination.PostCoordinationTableAxisLabel; +import edu.stanford.bmir.protege.web.shared.postcoordination.PostCoordinationTableConfiguration; import edu.stanford.bmir.protege.web.shared.project.*; import edu.stanford.bmir.protege.web.shared.projectsettings.*; import edu.stanford.bmir.protege.web.shared.renderer.GetEntityHtmlRenderingAction; @@ -1024,6 +1028,14 @@ public class RpcWhiteList implements IsSerializable, Action, Result { GetClassAncestorsResult _GetClassAncestorsResult; AncestorClassHierarchy _AncestorClassHierarchy; + + GetPostCoordinationTableConfigurationResult _GetPostCoordinationTableConfigurationResult; + + PostCoordinationTableConfiguration _PostCoordinationTableConfiguration; + + PostCoordinationTableAxisLabel _PostCoordinationTableAxisLabel; + PostCoordinationCompositeAxis _PostCoordinationCompositeAxis; + public RpcWhiteList() { } } diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/GetPostCoordinationTableConfigurationAction.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/GetPostCoordinationTableConfigurationAction.java new file mode 100644 index 000000000..c7776973c --- /dev/null +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/GetPostCoordinationTableConfigurationAction.java @@ -0,0 +1,18 @@ +package edu.stanford.bmir.protege.web.shared.postcoordination; + +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.google.auto.value.AutoValue; +import com.google.common.annotations.GwtCompatible; +import edu.stanford.bmir.protege.web.shared.dispatch.Action; + +@AutoValue +@GwtCompatible(serializable = true) +@JsonTypeName("webprotege.postcoordination.GetTablePostCoordinationAxis") +public abstract class GetPostCoordinationTableConfigurationAction implements Action { + + public static GetPostCoordinationTableConfigurationAction create(String entityType){ + return new AutoValue_GetPostCoordinationTableConfigurationAction(entityType); + } + + public abstract String getEntityType(); +} diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/GetPostCoordinationTableConfigurationResult.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/GetPostCoordinationTableConfigurationResult.java new file mode 100644 index 000000000..f89b4c8dc --- /dev/null +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/GetPostCoordinationTableConfigurationResult.java @@ -0,0 +1,27 @@ +package edu.stanford.bmir.protege.web.shared.postcoordination; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.google.auto.value.AutoValue; +import com.google.common.annotations.GwtCompatible; +import edu.stanford.bmir.protege.web.shared.dispatch.Result; + +import java.util.List; + + +@AutoValue +@GwtCompatible(serializable = true) +@JsonTypeName("webprotege.postcoordination.GetTablePostCoordinationAxis") +public abstract class GetPostCoordinationTableConfigurationResult implements Result { + + public abstract PostCoordinationTableConfiguration getTableConfiguration(); + + public abstract List getLabels(); + + @JsonCreator + public static GetPostCoordinationTableConfigurationResult create(@JsonProperty("tableConfiguration") PostCoordinationTableConfiguration tableConfiguration, @JsonProperty("labels") List labels) { + return new AutoValue_GetPostCoordinationTableConfigurationResult(tableConfiguration, labels); + } + +} diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/PostCoordinationCompositeAxis.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/PostCoordinationCompositeAxis.java new file mode 100644 index 000000000..c6f8b255d --- /dev/null +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/PostCoordinationCompositeAxis.java @@ -0,0 +1,37 @@ +package edu.stanford.bmir.protege.web.shared.postcoordination; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.annotations.GwtCompatible; +import com.google.gwt.user.client.rpc.IsSerializable; +import edu.stanford.bmir.protege.web.shared.annotations.GwtSerializationConstructor; + +import java.io.Serializable; +import java.util.List; + +@GwtCompatible(serializable = true) +public class PostCoordinationCompositeAxis implements IsSerializable, Serializable { + + private String postCoordinationAxis; + + private List subAxis; + @GwtSerializationConstructor + private PostCoordinationCompositeAxis() { + } + + @JsonCreator + public PostCoordinationCompositeAxis(@JsonProperty("postcoordinationAxis") String postCoordinationAxis, @JsonProperty("replacedBySubaxes") List subAxis) { + this.postCoordinationAxis = postCoordinationAxis; + this.subAxis = subAxis; + } + + @JsonProperty("postcoordinationAxis") + public String getPostCoordinationAxis() { + return postCoordinationAxis; + } + + @JsonProperty("replacedBySubaxes") + public List getSubAxis() { + return subAxis; + } +} diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/PostCoordinationTableAxisLabel.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/PostCoordinationTableAxisLabel.java new file mode 100644 index 000000000..1e79c510c --- /dev/null +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/PostCoordinationTableAxisLabel.java @@ -0,0 +1,47 @@ +package edu.stanford.bmir.protege.web.shared.postcoordination; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.annotations.GwtCompatible; +import com.google.gwt.user.client.rpc.IsSerializable; +import edu.stanford.bmir.protege.web.shared.annotations.GwtSerializationConstructor; + +import java.io.Serializable; + +@GwtCompatible(serializable = true) +public class PostCoordinationTableAxisLabel implements IsSerializable, Serializable { + + private String postCoordinationAxis; + + private String tableLabel; + + private String scaleLabel; + + @GwtSerializationConstructor + private PostCoordinationTableAxisLabel() { + } + + + + @JsonCreator + public PostCoordinationTableAxisLabel(@JsonProperty("postcoordinationAxis") String postCoordinationAxis, @JsonProperty("tableLabel") String tableLabel, @JsonProperty("scaleLabel") String scaleLabel) { + this.postCoordinationAxis = postCoordinationAxis; + this.tableLabel = tableLabel; + this.scaleLabel = scaleLabel; + } + + @JsonProperty("postcoordinationAxis") + public String getPostCoordinationAxis() { + return postCoordinationAxis; + } + + @JsonProperty("tableLabel") + public String getTableLabel() { + return tableLabel; + } + + @JsonProperty("scaleLabel") + public String getScaleLabel() { + return scaleLabel; + } +} diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/PostCoordinationTableConfiguration.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/PostCoordinationTableConfiguration.java new file mode 100644 index 000000000..71615d8d5 --- /dev/null +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/PostCoordinationTableConfiguration.java @@ -0,0 +1,48 @@ +package edu.stanford.bmir.protege.web.shared.postcoordination; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.annotations.GwtCompatible; +import com.google.gwt.user.client.rpc.IsSerializable; +import edu.stanford.bmir.protege.web.shared.annotations.GwtSerializationConstructor; + + +import java.io.Serializable; +import java.util.List; + +@GwtCompatible(serializable = true) +public class PostCoordinationTableConfiguration implements IsSerializable, Serializable { + + private String entityType; + private List postCoordinationAxes; + + private List compositePostCoordinationAxes; + + @GwtSerializationConstructor + private PostCoordinationTableConfiguration() { + } + + + @JsonCreator + public PostCoordinationTableConfiguration(@JsonProperty("entityType") String entityType, @JsonProperty("postcoordinationAxes") List postCoordinationAxes, @JsonProperty("compositePostcoordinationAxes") List compositePostCoordinationAxes) { + this.entityType = entityType; + this.postCoordinationAxes = postCoordinationAxes; + this.compositePostCoordinationAxes = compositePostCoordinationAxes; + } + + + @JsonProperty("entityType") + public String getEntityType() { + return entityType; + } + + @JsonProperty("postcoordinationAxes") + public List getPostCoordinationAxes() { + return postCoordinationAxes; + } + + @JsonProperty("compositePostcoordinationAxes") + public List getCompositePostCoordinationAxes() { + return compositePostCoordinationAxes; + } +}