Skip to content

Commit

Permalink
#3587 - Click on annotation sidebar text to jump
Browse files Browse the repository at this point in the history
- Add scroll command that editor can send to backend to trigger a scroll
- Extend scroll command that backend can sent to editor to finalize a scoll to include an area to highlight
- Make brat briefly highlight the scroll target after a scroll
- Fix scrolling to anywhere beyond the first page in the brat editor
- Rename a few internal functions in the brat code
- Update the package-lock.json files
- Improve style of the annotation sidebar
- Fix annotation sidebar not appearing at all
  • Loading branch information
reckart committed Jan 6, 2023
1 parent 0ef6ae8 commit ad18462
Show file tree
Hide file tree
Showing 40 changed files with 8,552 additions and 3,622 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import de.tudarmstadt.ukp.inception.preferences.Key;
import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState;
import de.tudarmstadt.ukp.inception.rendering.vmodel.VID;
import de.tudarmstadt.ukp.inception.rendering.vmodel.VRange;
import de.tudarmstadt.ukp.inception.schema.AnnotationSchemaService;
import de.tudarmstadt.ukp.inception.schema.adapter.AnnotationException;
import de.tudarmstadt.ukp.inception.schema.adapter.TypeAdapter;
Expand Down Expand Up @@ -272,7 +273,8 @@ public void actionShowSelectedDocument(AjaxRequestTarget aTarget, SourceDocument
AnnotatorState state = getModelObject();

CAS cas = getEditorCas();
state.getPagingStrategy().moveToOffset(state, cas, aBegin, CENTERED);
state.getPagingStrategy().moveToOffset(state, cas, aBegin, new VRange(aBegin, aEnd),
CENTERED);

if (!switched && state.getPagingStrategy() instanceof NoPagingStrategy) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,21 @@
import de.tudarmstadt.ukp.inception.rendering.paging.Unit;
import de.tudarmstadt.ukp.inception.rendering.selection.FocusPosition;
import de.tudarmstadt.ukp.inception.rendering.selection.ScrollToEvent;
import de.tudarmstadt.ukp.inception.rendering.vmodel.VRange;

public abstract class PagingStrategy_ImplBase
implements PagingStrategy
{
private static final long serialVersionUID = 928025483609029306L;

@Override
public void moveToOffset(AnnotatorViewState aState, CAS aCas, int aOffset, FocusPosition aPos)
public void moveToOffset(AnnotatorViewState aState, CAS aCas, int aOffset, VRange aPingRange,
FocusPosition aPos)
{
switch (aPos) {
case TOP: {
aState.setPageBegin(aCas, aOffset);
fireScrollToEvent(aOffset, aPos);
fireScrollToEvent(aOffset, aPingRange, aPos);
break;
}
case CENTERED: {
Expand All @@ -65,15 +67,15 @@ public void moveToOffset(AnnotatorViewState aState, CAS aCas, int aOffset, Focus

aState.setPageBegin(aCas, firstUnit.getBegin());
aState.setFocusUnitIndex(unit.getIndex());
fireScrollToEvent(aOffset, aPos);
fireScrollToEvent(aOffset, aPingRange, aPos);
break;
}
default:
throw new IllegalArgumentException("Unknown focus positon: [" + aPos + "]");
}
}

private void fireScrollToEvent(int aOffset, FocusPosition aPos)
private void fireScrollToEvent(int aOffset, VRange aPingRange, FocusPosition aPos)
{
RequestCycle requestCycle = RequestCycle.get();

Expand All @@ -85,7 +87,7 @@ private void fireScrollToEvent(int aOffset, FocusPosition aPos)
if (handler.isPresent() && handler.get().isPageInstanceCreated()) {
Page page = (Page) handler.get().getPage();
var target = requestCycle.find(AjaxRequestTarget.class).orElse(null);
page.send(page, BREADTH, new ScrollToEvent(target, aOffset, aPos));
page.send(page, BREADTH, new ScrollToEvent(target, aOffset, aPingRange, aPos));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState;
import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorViewState;
import de.tudarmstadt.ukp.inception.rendering.selection.FocusPosition;
import de.tudarmstadt.ukp.inception.rendering.vmodel.VRange;

public interface PagingStrategy
extends Serializable
Expand All @@ -53,7 +54,13 @@ public interface PagingStrategy

Component createPageNavigator(String aId, Page aPage);

void moveToOffset(AnnotatorViewState aState, CAS aCas, int aOffset, FocusPosition aPos);
default void moveToOffset(AnnotatorViewState aState, CAS aCas, int aOffset, FocusPosition aPos)
{
moveToOffset(aState, aCas, aOffset, null, aPos);
}

void moveToOffset(AnnotatorViewState aState, CAS aCas, int aOffset, VRange aPingRange,
FocusPosition aPos);

default void recalculatePage(AnnotatorViewState aState, CAS aCas)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,22 @@

import org.apache.wicket.ajax.AjaxRequestTarget;

import de.tudarmstadt.ukp.inception.rendering.vmodel.VRange;

public class ScrollToEvent
{
private final AjaxRequestTarget requestHandler;
private final int offset;
private final VRange pingRange;
private final FocusPosition position;

public ScrollToEvent(AjaxRequestTarget aRequestHandler, int aOffset, FocusPosition aPos)
public ScrollToEvent(AjaxRequestTarget aRequestHandler, int aOffset, VRange aPingRange,
FocusPosition aPos)
{
requestHandler = aRequestHandler;
offset = aOffset;
position = aPos;
pingRange = aPingRange;
}

public AjaxRequestTarget getRequestHandler()
Expand All @@ -42,6 +47,11 @@ public int getOffset()
return offset;
}

public VRange getPingRange()
{
return pingRange;
}

public FocusPosition getPosition()
{
return position;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ void actionSelectAndJump(AjaxRequestTarget aTarget, AnnotationFS aFS)
void actionJump(AjaxRequestTarget aTarget, AnnotationFS aFS)
throws IOException, AnnotationException;

void actionJump(AjaxRequestTarget aTarget, int aBegin, int aEnd)
throws IOException, AnnotationException;

/**
* Delete currently selected annotation.
*
Expand Down
Loading

0 comments on commit ad18462

Please sign in to comment.