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

fix for cancel button in linearization view #82

Merged
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 @@ -3,6 +3,7 @@
import com.google.common.collect.ImmutableSet;
import edu.stanford.bmir.protege.web.client.Messages;
import edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceManager;
import edu.stanford.bmir.protege.web.client.hierarchy.HierarchyDescriptor;
import edu.stanford.bmir.protege.web.client.library.dlg.DialogButton;
import edu.stanford.bmir.protege.web.client.library.modal.ModalCloser;
import edu.stanford.bmir.protege.web.client.library.modal.ModalManager;
Expand All @@ -11,7 +12,6 @@
import edu.stanford.bmir.protege.web.shared.hierarchy.ChangeEntityParentsAction;
import edu.stanford.bmir.protege.web.shared.hierarchy.ChangeEntityParentsResult;
import edu.stanford.bmir.protege.web.shared.hierarchy.GetHierarchyParentsAction;
import edu.stanford.bmir.protege.web.shared.hierarchy.HierarchyId;
import edu.stanford.bmir.protege.web.shared.issues.CreateEntityDiscussionThreadAction;
import edu.stanford.bmir.protege.web.shared.project.ProjectId;
import edu.stanford.bmir.protege.web.shared.renderer.GetEntityRenderingAction;
Expand Down Expand Up @@ -42,7 +42,7 @@ public class EditParentsPresenter {
@Nullable
private OWLEntity entity;

private Optional<HierarchyId> hierarchyId = Optional.empty();
private Optional<HierarchyDescriptor> hierarchyDescriptor = Optional.empty();

@Nonnull
private final ModalManager modalManager;
Expand Down Expand Up @@ -78,7 +78,7 @@ public void start(@Nonnull OWLEntity entity) {
dispatch.execute(GetEntityRenderingAction.create(projectId, entity),
result -> view.setOwlEntityData(result.getEntityData()));

hierarchyId.ifPresent(id -> dispatch.execute(GetHierarchyParentsAction.create(projectId, entity, id),
hierarchyDescriptor.ifPresent(id -> dispatch.execute(GetHierarchyParentsAction.create(projectId, entity, hierarchyDescriptor.get()),
result -> view.setEntityParents(result.getParents())));
}

Expand All @@ -87,8 +87,8 @@ public EditParentsView getView() {
return view;
}

public void setHierarchyId(@Nonnull HierarchyId hierarchyId) {
this.hierarchyId = Optional.of(hierarchyId);
public void setHierarchyDescriptor(@Nonnull HierarchyDescriptor hierarchyDescriptor) {
this.hierarchyDescriptor = Optional.of(hierarchyDescriptor);
}

private void handleHierarchyChange(ModalCloser closer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import edu.stanford.bmir.protege.web.client.Messages;
import edu.stanford.bmir.protege.web.client.action.AbstractUiAction;
import edu.stanford.bmir.protege.web.client.hierarchy.ClassHierarchyDescriptor;
import edu.stanford.bmir.protege.web.client.selection.SelectionModel;
import edu.stanford.bmir.protege.web.shared.hierarchy.HierarchyId;
import org.semanticweb.owlapi.model.OWLEntity;

import javax.annotation.Nonnull;
Expand Down Expand Up @@ -33,7 +33,7 @@ public void execute() {
}

private void showDialog(OWLEntity entity) {
editParentsPresenter.setHierarchyId(HierarchyId.CLASS_HIERARCHY);
editParentsPresenter.setHierarchyDescriptor(ClassHierarchyDescriptor.get());
editParentsPresenter.start(entity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.web.bindery.event.shared.EventBus;
import edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceManager;
import edu.stanford.bmir.protege.web.client.hierarchy.ClassHierarchyDescriptor;
import edu.stanford.bmir.protege.web.client.lang.DisplayNameRenderer;
import edu.stanford.bmir.protege.web.client.library.dlg.DialogButton;
import edu.stanford.bmir.protege.web.client.library.msgbox.*;
Expand Down Expand Up @@ -62,11 +63,9 @@ public LinearizationPortletPresenter(@Nonnull SelectionModel selectionModel,

@Override
public void startPortlet(PortletUi portletUi, WebProtegeEventBus eventBus) {

portletUi.setWidget(view.asWidget());
setDisplaySelectedEntityNameAsSubtitle(true);

dispatch.execute(GetLinearizationDefinitionsAction.create(), result -> {
portletUi.setWidget(view.asWidget());
setDisplaySelectedEntityNameAsSubtitle(true);
for (LinearizationDefinition definition : result.getDefinitionList()) {
this.definitionMap.put(definition.getWhoficEntityIri(), definition);
}
Expand Down Expand Up @@ -110,7 +109,7 @@ private void navigateToEntity(Optional<OWLEntity> entityData) {
if (response.getWhoficEntityLinearizationSpecification() != null &&
response.getWhoficEntityLinearizationSpecification().getLinearizationSpecifications() != null) {

dispatch.execute(GetHierarchyParentsAction.create(getProjectId(), entityData.get(), HierarchyId.CLASS_HIERARCHY), result -> {
dispatch.execute(GetHierarchyParentsAction.create(getProjectId(), entityData.get(), ClassHierarchyDescriptor.get()), result -> {
if (result.getParents() != null) {
result.getParents().forEach(parent -> this.entityParentsMap.put(parent.getEntity().toStringID(), parent.getBrowserText()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceManager;
import edu.stanford.bmir.protege.web.client.form.complexcheckbox.*;
import edu.stanford.bmir.protege.web.client.library.text.PlaceholderTextBox;
import edu.stanford.bmir.protege.web.client.progress.*;
import edu.stanford.bmir.protege.web.shared.linearization.*;
import edu.stanford.bmir.protege.web.shared.project.ProjectId;
import org.semanticweb.owlapi.model.IRI;
Expand All @@ -15,12 +16,15 @@
import java.util.logging.*;
import java.util.stream.Collectors;

public class LinearizationPortletViewImpl extends Composite implements LinearizationPortletView {
public class LinearizationPortletViewImpl extends Composite implements LinearizationPortletView, HasBusy {


Logger logger = java.util.logging.Logger.getLogger("LinearizationPortletViewImpl");

private WhoficEntityLinearizationSpecification specification;
@UiField
BusyView busyView;

@UiField
HTMLPanel paneContainer;

Expand Down Expand Up @@ -194,11 +198,11 @@ public boolean isReadOnly() {

private void setEditable() {
if (isReadOnly) {
this.backupRows = new ArrayList<>();
for (LinearizationTableRow row : this.tableRowList) {
this.backupRows.add(row.clone());
row.setEnabled();
}
this.backupRows.clear();
tableRowList.forEach(tableRow -> {
this.backupRows.add(tableRow.clone());
tableRow.setEnabled();
});

this.backupUnspecifiedTitle = this.unspecifiedResidualTitle.getValue();
this.backupOtherSpecifiedTitle = this.otherSpecifiedResidualTitle.getValue();
Expand All @@ -222,11 +226,10 @@ private void setEditable() {

private void setReadOnly() {
if (!isReadOnly) {
this.tableRowList = this.backupRows;
this.tableRowList.clear();
flexTable.removeAllRows();
for (LinearizationTableRow row : this.tableRowList) {
row.setReadOnly();
}
this.backupRows.forEach(backupRow -> this.tableRowList.add(backupRow.clone()));
this.tableRowList.forEach(LinearizationTableRow::setReadOnly);
initializeTableHeader();

orderAndPopulateViewWithRows();
Expand All @@ -238,7 +241,7 @@ private void setReadOnly() {

disableResiduals();
isReadOnly = true;
this.backupRows = new ArrayList<>();
this.backupRows.clear();
toggleSaveButtons();
}

Expand All @@ -250,6 +253,10 @@ private void toggleSaveButtons() {
saveValuesButton.setVisible(!isReadOnly);
}

@Override
public void setBusy(boolean busy) {
this.busyView.setVisible(busy);
}

interface LinearizationPortletViewImplUiBinder extends UiBinder<HTMLPanel, LinearizationPortletViewImpl> {

Expand Down Expand Up @@ -289,6 +296,7 @@ private void initializeTableHeader() {
@Override
public void saveValues() {
if (!isReadOnly) {
setBusy(true);
List<LinearizationSpecification> specifications = this.tableRowList.stream()
.map(LinearizationTableRow::asLinearizationSpecification)
.collect(Collectors.toList());
Expand All @@ -309,16 +317,18 @@ public void saveValues() {
}
dispatch.execute(
SaveEntityLinearizationAction.create(projectId, linearizationSpecification),
this,
(result) -> {
this.backupRows = new ArrayList<>();
this.backupRows.clear();
for (LinearizationTableRow row : this.tableRowList) {
this.backupRows.add(row.clone());
}
this.backupUnspecifiedTitle = this.unspecifiedResidualTitle.getValue();
this.backupOtherSpecifiedTitle = this.otherSpecifiedResidualTitle.getValue();

this.backupSuppressOtherResidualValue = suppressOthersSpecifiedResidual.getValue();

this.backupSuppressUnspecifiedResidualValue = suppressUnspecifiedResidual.getValue();
this.setBusy(false);
}
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
xmlns:custom="urn:import:edu.stanford.bmir.protege.web.client.form.complexcheckbox"
xmlns:progress="urn:import:edu.stanford.bmir.protege.web.client.progress"
xmlns:text="urn:import:edu.stanford.bmir.protege.web.client.library.text">
<ui:style>
.paneContainer {
Expand All @@ -14,7 +15,7 @@
display: flex;
justify-content: end;
width: 97%;
margin:15px;
margin: 15px;
padding: 3px;
}

Expand All @@ -33,22 +34,23 @@
}

.residualsCard {
display:flex;
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);
-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%;
}
.residualsCardBody{

.residualsCardBody {
display: flex;
flex-direction: column;
}

.residualsCardBody div {
}

.residualsCardHeader{
.residualsCardHeader {
font-size: 14px;
color: #fff;
line-height: 1.4;
Expand All @@ -66,8 +68,8 @@
margin-right: 15px;
font-size: 12px;
width: 99%;
border-bottom: 1px solid #f2f2f2;
border-top: 1px solid #f2f2f2;
border-bottom: 1px solid #f2f2f2;
border-top: 1px solid #f2f2f2;
min-height: 35px;
align-items: center;
}
Expand All @@ -82,8 +84,8 @@
.residualValue {
min-width: 40%;
margin-left: 7px;
border: 1px solid #B5B5B5;
padding: 5px!important;
border: 1px solid #B5B5B5;
padding: 5px !important;
}

.residualValue::placeholder {
Expand All @@ -109,15 +111,22 @@
border-radius: 8px;
}

.busyView {
width: 100%;
height: 100%;
}

.titleTextBox {
margin-left: 6px;
font-size : 16px;
font-size: 16px;
}

.cancelButton:hover {
background-color: #E3E3E3;
}
</ui:style>
<g:HTMLPanel ui:field="paneContainer" >
<g:HTMLPanel ui:field="paneContainer">
<progress:BusyViewImpl ui:field="busyView" visible="false" addStyleNames="{style.busyView}"/>
<g:HTMLPanel width="100%">
<g:FlexTable width="97%" height="100%" ui:field="flexTable"/>
<g:HTMLPanel addStyleNames="{style.residualsCard}">
Expand All @@ -127,19 +136,25 @@
<g:HTMLPanel addStyleNames="{style.residualsCardBody}">
<g:HTMLPanel addStyleNames="{style.residualsRow}">
<g:Label addStyleNames="{style.residualLabel}" text="Suppress 'Other Specified' Residuals"/>
<custom:ConfigurableCheckbox ui:field="suppressOthersSpecifiedResidual"></custom:ConfigurableCheckbox>
<custom:ConfigurableCheckbox
ui:field="suppressOthersSpecifiedResidual"></custom:ConfigurableCheckbox>
</g:HTMLPanel>
<g:HTMLPanel addStyleNames="{style.residualsRow}">
<g:Label addStyleNames="{style.residualLabel}" text="Suppress 'Unspecified' Residuals"/>
<custom:ConfigurableCheckbox ui:field="suppressUnspecifiedResidual"></custom:ConfigurableCheckbox>
<custom:ConfigurableCheckbox
ui:field="suppressUnspecifiedResidual"></custom:ConfigurableCheckbox>
</g:HTMLPanel>
<g:HTMLPanel addStyleNames="{style.residualsRow}">
<g:Label addStyleNames="{style.residualLabel}" text="'Other Specified' Residual title"/>
<text:PlaceholderTextBox addStyleNames="{style.residualValue}" ui:field="otherSpecifiedResidualTitle" placeholder="Add the 'Other specified' residual title" />
<g:Label addStyleNames="{style.residualLabel}" text="'Other Specified' Residual title"/>
<text:PlaceholderTextBox addStyleNames="{style.residualValue}"
ui:field="otherSpecifiedResidualTitle"
placeholder="Add the 'Other specified' residual title"/>
</g:HTMLPanel>
<g:HTMLPanel addStyleNames="{style.residualsRow}">
<g:Label addStyleNames="{style.residualLabel}" text="'Unspecified' Residual title"/>
<text:PlaceholderTextBox addStyleNames="{style.residualValue}" ui:field="unspecifiedResidualTitle" placeholder="Add the 'Unspecified' residual title" />
<g:Label addStyleNames="{style.residualLabel}" text="'Unspecified' Residual title"/>
<text:PlaceholderTextBox addStyleNames="{style.residualValue}"
ui:field="unspecifiedResidualTitle"
placeholder="Add the 'Unspecified' residual title"/>
</g:HTMLPanel>
</g:HTMLPanel>
</g:HTMLPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,20 @@ public LinearizationDefinition getLinearizationDefinition() {

public LinearizationTableRow clone() {
LinearizationTableRow clone = new LinearizationTableRow();
clone.linearizationSpecification = linearizationSpecification;
clone.linearizationSpecification = this.asLinearizationSpecification();

clone.linearizationParentSelector = getCopy(linearizationParentSelector);
clone.linearizationParentLabel = getCopy(linearizationParentLabel);
clone.parentSelectionPanel = new HorizontalPanel();
clone.parentSelectionPanel.add(clone.linearizationParentSelector);
clone.parentSelectionPanel.add(clone.linearizationParentLabel);

clone.tableRefresh = this.tableRefresh;
clone.parentIri = this.parentIri;
clone.linearizationDefinition = this.linearizationDefinition;
clone.linearizationDefinitionWidget = new Label(linearizationDefinition.getDisplayLabel());
clone.isPartOfCheckbox = new ConfigurableCheckbox(new LinearizationCheckboxConfig(), linearizationSpecification.getIsIncludedInLinearization());
clone.isGroupingCheckbox = new ConfigurableCheckbox(new LinearizationCheckboxConfig(), linearizationSpecification.getIsGrouping());
clone.isAuxAxChildCheckbox = new ConfigurableCheckbox(new LinearizationCheckboxConfig(), linearizationSpecification.getIsAuxiliaryAxisChild());
clone.isPartOfCheckbox = new ConfigurableCheckbox(new LinearizationCheckboxConfig(), clone.linearizationSpecification.getIsIncludedInLinearization());
clone.isGroupingCheckbox = new ConfigurableCheckbox(new LinearizationCheckboxConfig(), clone.linearizationSpecification.getIsGrouping());
clone.isAuxAxChildCheckbox = new ConfigurableCheckbox(new LinearizationCheckboxConfig(), clone.linearizationSpecification.getIsAuxiliaryAxisChild());

LinearizationComments commentsClone = new LinearizationComments(this.commentsWidget.getText(), linearizationCommentsModal);

Expand Down Expand Up @@ -299,6 +299,8 @@ private ListBox getCopy(ListBox original) {
}
}

copy.addChangeHandler((event) -> this.handleParentSelected());

return copy;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.google.auto.value.AutoValue;
import com.google.common.annotations.GwtCompatible;
import edu.stanford.bmir.protege.web.client.hierarchy.HierarchyDescriptor;
import edu.stanford.bmir.protege.web.shared.dispatch.AbstractHasProjectAction;
import edu.stanford.bmir.protege.web.shared.project.ProjectId;
import org.semanticweb.owlapi.model.OWLEntity;
Expand All @@ -22,8 +23,8 @@ public abstract class GetHierarchyParentsAction extends AbstractHasProjectAction
@JsonCreator
public static GetHierarchyParentsAction create(@JsonProperty("projectId") @Nonnull ProjectId projectId,
@JsonProperty("entity") @Nonnull OWLEntity entity,
@JsonProperty("hierarchyId") @Nonnull HierarchyId hierarchyId) {
return new AutoValue_GetHierarchyParentsAction(projectId, entity, hierarchyId);
@JsonProperty("hierarchyId") @Nonnull HierarchyDescriptor hierarchyDescriptor) {
return new AutoValue_GetHierarchyParentsAction(projectId, entity, hierarchyDescriptor);
}

@Nonnull
Expand All @@ -32,5 +33,5 @@ public static GetHierarchyParentsAction create(@JsonProperty("projectId") @Nonnu

public abstract OWLEntity getEntity();

public abstract HierarchyId getHierarchyId();
public abstract HierarchyDescriptor getHierarchyDescriptor();
}
Loading