Skip to content

Commit

Permalink
added check on moving from entity.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsilaghi committed Oct 2, 2024
1 parent 8da034d commit d6f7a0f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
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.dlg.DialogButton;
import edu.stanford.bmir.protege.web.client.library.msgbox.MessageBox;
import edu.stanford.bmir.protege.web.client.library.msgbox.MessageStyle;
import edu.stanford.bmir.protege.web.client.portlet.*;
import edu.stanford.bmir.protege.web.client.postcoordination.scaleValuesCard.*;
import edu.stanford.bmir.protege.web.client.selection.SelectionModel;
Expand Down Expand Up @@ -134,19 +136,23 @@ remove the orElseGet() and add back the orElseThrow() when we have proper labels
this.setEditMode(false);
});

view.setSaveButtonHandler((postcoordinationSpec) -> {
postcoordinationSpec.ifPresent(whoficEntityPostCoordinationSpecification ->
dispatch.execute(SaveEntityPostCoordinationAction.create(getProjectId(), whoficEntityPostCoordinationSpecification),
(result) -> {
}
)
);
this.setEditMode(false);
});
view.setSaveButtonHandler(this::saveEntity);

this.setEditMode(false);
}

private void saveEntity(Optional<WhoficEntityPostCoordinationSpecification> specification) {
this.setEditMode(false);

specification.ifPresent(whoficEntityPostCoordinationSpecification ->
dispatch.execute(SaveEntityPostCoordinationAction.create(getProjectId(), whoficEntityPostCoordinationSpecification),
(result) -> {
}
)

);
}

private ScaleValueCardPresenter createScaleValueCardPresenter(PostCoordinationTableAxisLabel axis, PostCoordinationScaleValue scaleValue) {
ScaleValueCardView view = new ScaleValueCardViewImpl();
return new ScaleValueCardPresenter(axis, scaleValue, view, dispatch, getProjectId());
Expand All @@ -158,7 +164,27 @@ protected void handleReloadRequest() {

@Override
protected void handleAfterSetEntity(Optional<OWLEntity> entityData) {
this.entityIri = entityData;
if(this.editMode) {
this.entityIri = entityData;

messageBox.showConfirmBox(MessageStyle.ALERT,
"Save edits before switching?",
"Do you want to save your edits before changing selection?",
DialogButton.YES,
() -> {
saveEntity(view.getTableData());
navigateToEntity(entityData);
},
DialogButton.NO,
() -> navigateToEntity(entityData),
DialogButton.YES);
} else {
navigateToEntity(entityData);
}


}
private void navigateToEntity(Optional<OWLEntity> entityData){
entityData.ifPresent(owlEntity -> dispatch.execute(GetEntityCustomScalesAction.create(owlEntity.getIRI().toString(), getProjectId()),
(result) -> {
postCoordinationCustomScalesList.addAll(result.getWhoficCustomScaleValues().getScaleCustomizations());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ public interface PostCoordinationPortletView extends AcceptsOneWidget, IsWidget,
void setCancelButtonHandler(CancelButtonHandler handler);
void setSaveButtonHandler(SaveButtonHandler handler);
void setEditMode(boolean editMode);

Optional<WhoficEntityPostCoordinationSpecification> getTableData();
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public void setEditMode(boolean editMode) {
editValuesButton.setVisible(!editMode);
}

@Override
public Optional<WhoficEntityPostCoordinationSpecification> getTableData() {
return createEditedSpec();
}

@Override
public void setEditButtonHandler(EditButtonHandler handler) {
this.editButtonHandler = handler;
Expand Down

0 comments on commit d6f7a0f

Please sign in to comment.