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

#4258 - Reset document button for annotators in dynamic assignment mode #4261

Original file line number Diff line number Diff line change
Expand Up @@ -1103,8 +1103,8 @@ public void onSpanCreated(SpanCreatedEvent aEvent)
return;
}

reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget(), aEvent.getLayer(),
aEvent.getDocument());
reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget().orElse(null),
aEvent.getLayer(), aEvent.getDocument());
}

@OnEvent
Expand All @@ -1122,7 +1122,7 @@ public void onRelationCreated(RelationCreatedEvent aEvent)
return;
}

reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget(), aEvent.getLayer(),
reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget().get(), aEvent.getLayer(),
aEvent.getDocument());
}

Expand Down Expand Up @@ -1153,7 +1153,7 @@ public void onFeatureValueUpdated(FeatureValueUpdatedEvent aEvent)
return;
}

reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget(),
reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget().get(),
aEvent.getFeature().getLayer(), aEvent.getDocument());
}

Expand All @@ -1180,7 +1180,7 @@ public void onAnnotationDeleted(SpanDeletedEvent aEvent)
return;
}

reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget(), aEvent.getLayer(),
reactToAnnotationsBeingCreatedOrDeleted(aEvent.getRequestTarget().get(), aEvent.getLayer(),
aEvent.getDocument());
}

Expand Down Expand Up @@ -1381,7 +1381,7 @@ public void onDocumentOpenedEvent(DocumentOpenedEvent aEvent)
// If active learning is not active, update the sidebar in case the session auto-terminated
ActiveLearningUserState alState = alStateModel.getObject();
if (!alState.isSessionActive()) {
aEvent.getRequestTarget().add(alMainContainer);
aEvent.getRequestTarget().ifPresent(target -> target.add(alMainContainer));
return;
}

Expand All @@ -1390,11 +1390,11 @@ public void onDocumentOpenedEvent(DocumentOpenedEvent aEvent)

// Maybe the prediction switch has made a new suggestion available for us to go to
if (alState.getSuggestion().isEmpty()) {
moveToNextSuggestion(aEvent.getRequestTarget());
moveToNextSuggestion(aEvent.getRequestTarget().get());
return;
}

refreshCurrentSuggestionOrMoveToNextSuggestion(aEvent.getRequestTarget());
refreshCurrentSuggestionOrMoveToNextSuggestion(aEvent.getRequestTarget().get());
}

@OnEvent
Expand All @@ -1405,7 +1405,7 @@ public void onPredictionsSwitched(PredictionsSwitchedEvent aEvent)
// If active learning is not active, update the sidebar in case the session auto-terminated
ActiveLearningUserState alState = alStateModel.getObject();
if (!alState.isSessionActive()) {
aEvent.getRequestTarget().add(alMainContainer);
aEvent.getRequestTarget().ifPresent(target -> target.add(alMainContainer));
return;
}

Expand All @@ -1414,11 +1414,11 @@ public void onPredictionsSwitched(PredictionsSwitchedEvent aEvent)

// Maybe the prediction switch has made a new suggestion available for us to go to
if (alState.getSuggestion().isEmpty()) {
moveToNextSuggestion(aEvent.getRequestTarget());
moveToNextSuggestion(aEvent.getRequestTarget().get());
return;
}

refreshCurrentSuggestionOrMoveToNextSuggestion(aEvent.getRequestTarget());
refreshCurrentSuggestionOrMoveToNextSuggestion(aEvent.getRequestTarget().get());
}

private void refreshCurrentSuggestionOrMoveToNextSuggestion(AjaxRequestTarget aTarget)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ private IconType getStateIcon()
@OnEvent
public void sessionStarted(ActiveLearningSessionStartedEvent aEvent)
{
aEvent.getRequestTarget().add(this);
aEvent.getRequestTarget().ifPresent(target -> target.add(this));
}

@OnEvent
public void sessionStarted(ActiveLearningSessionCompletedEvent aEvent)
{
aEvent.getRequestTarget().add(this);
aEvent.getRequestTarget().ifPresent(target -> target.add(this));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ public static void handleException(Component aComponent, AjaxRequestTarget aTarg
public void onAnnotationDeleted(AnnotationDeletedEvent aEvent)
{
// It could be that a slot filler was deleted - so just in case, we re-render ourself.
aEvent.getRequestTarget().add(this);
aEvent.getRequestTarget().ifPresent(target -> target.add(this));
}

@OnEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,7 @@ public void onTagEvent(TagEvent aEvent)

// If the tag was created in the tagset used by this editor, then we re-render the editor
// to ensure it picks up the new tag
AjaxRequestTarget target = aEvent.getRequestTarget();
if (target != null) {
target.add(this);
}
aEvent.getRequestTarget().ifPresent(target -> target.add(this));
}

@SuppressWarnings("rawtypes")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ tr.even:hover{
.headers,
.headers a:link,
.headers a:visited{
--bs-table-color: var(--bs-light);
--bs-table-bg: #B90F22 !important;
background-color:#B90F22 !important;
color:white !important;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,9 @@ private List<AnnotationListItem> listAnnotations()
@OnEvent
public void onDocumentMetadataEvent(DocumentMetadataEvent aEvent)
{
aEvent.getRequestTarget().add(annotationsContainer);
findParent(AnnotationPageBase.class).actionRefreshDocument(aEvent.getRequestTarget());
aEvent.getRequestTarget().ifPresent(target -> target.add(annotationsContainer));
findParent(AnnotationPageBase.class)
.actionRefreshDocument(aEvent.getRequestTarget().orElse(null));
}

@OnEvent
Expand All @@ -403,7 +404,8 @@ public void onFeatureValueUpdated(FeatureValueUpdatedEvent aEvent)
annotationsContainer.visitChildren(DocumentMetadataAnnotationDetailPanel.class, (c, v) -> {
var detailPanel = (DocumentMetadataAnnotationDetailPanel) c;
if (detailPanel.getModelObject().getId() == vid.getId()) {
aEvent.getRequestTarget().add(detailPanel.findParent(ListItem.class));
aEvent.getRequestTarget()
.ifPresent(target -> target.add(detailPanel.findParent(ListItem.class)));
}
});

Expand All @@ -416,7 +418,8 @@ public void onFeatureValueUpdated(FeatureValueUpdatedEvent aEvent)
// aEvent.getRequestTarget().add(selectedDetailPanel);
// }

findParent(AnnotationPageBase.class).actionRefreshDocument(aEvent.getRequestTarget());
findParent(AnnotationPageBase.class)
.actionRefreshDocument((aEvent.getRequestTarget().orElse(null)));
}

protected static void handleException(Component aComponent, AjaxRequestTarget aTarget,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ public void onDocumentOpened(DocumentOpenedEvent aEvent)
// suggestions that need to be processed (in particular ones that may have been generated
// by the non-trainable recommenders triggered above or from already existing predictions
if (aEvent.getStateBeforeOpening() == AnnotationDocumentState.NEW) {
autoAccept(aEvent.getRequestTarget(), sessionOwner, doc, ON_FIRST_ACCESS);
autoAccept(aEvent.getRequestTarget().orElse(null), sessionOwner, doc, ON_FIRST_ACCESS);
}

// Trigger a training and prediction run if there is no prediction state yet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public AnnotatorState getModelObject()
@OnEvent
public void onPredictionsSwitched(PredictionsSwitchedEvent aEvent)
{
aEvent.getRequestTarget().add(this);
aEvent.getRequestTarget().ifPresent(target -> target.add(this));
}

private void actionShowDetails(AjaxRequestTarget aTarget, Recommender aRecommender)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package de.tudarmstadt.ukp.clarin.webanno.support.wicket.event;

import java.util.Optional;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.request.cycle.RequestCycle;

Expand All @@ -29,8 +31,8 @@ public interface HybridApplicationUIEvent
* @return the request target which can be used to update the UI (if the event was triggered in
* the context of a UI action).
*/
default AjaxRequestTarget getRequestTarget()
default Optional<AjaxRequestTarget> getRequestTarget()
{
return RequestCycle.get().find(AjaxRequestTarget.class).get();
return RequestCycle.get().find(AjaxRequestTarget.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public void onAnnotationEvent(AnnotationEvent aEvent)
return;
}

actionRefreshDocument(aEvent.getRequestTarget());
aEvent.getRequestTarget().ifPresent(this::actionRefreshDocument);
}

/**
Expand All @@ -267,7 +267,7 @@ public void onFeatureValueUpdatedEvent(FeatureValueUpdatedEvent aEvent)
return;
}

actionRefreshDocument(aEvent.getRequestTarget());
actionRefreshDocument(aEvent.getRequestTarget().orElse(null));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1247,11 +1247,11 @@ public void onBulkAnnotationEvent(BulkAnnotationEvent aEvent)

if (!annotationStillExists) {
selection.clear();
refresh(aEvent.getRequestTarget());
aEvent.getRequestTarget().ifPresent(this::refresh);
}
}
catch (Exception e) {
handleException(this, aEvent.getRequestTarget(), e);
handleException(this, aEvent.getRequestTarget().orElse(null), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,7 @@ && getModelObject().getDocument() != null
@OnEvent
public void onAnnotationEvent(AnnotationEvent aEvent)
{
if (aEvent.getRequestTarget() != null) {
actionRefreshDocument(aEvent.getRequestTarget());
}
actionRefreshDocument(aEvent.getRequestTarget().orElse(null));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@

<body>
<wicket:panel>
<div wicket:id="finishDocumentDialog"></div>
<div wicket:id="dialog"></div>
<div class="action-bar-group">
<div class="btn-group">
<button wicket:id="showResetDocumentDialog" class="btn btn-action-bar" type="button" title="Reset document">
<i class="fas fa-recycle"></i>
</button>
<button wicket:id="showFinishDocumentDialog" class="btn btn-action-bar" type="button" wicket:message="title:stateToggle">
<i wicket:id="state"></i>
</button>
Expand Down
Loading