private void actionGotoPage(AjaxRequestTarget aTarget, Form<?> aForm) throws Exception { AnnotatorState state = getModelObject(); JCas jcas = getEditorCas(); List<Sentence> sentences = new ArrayList<>(select(jcas, Sentence.class)); int selectedSentence = gotoPageTextField.getModelObject(); selectedSentence = Math.min(selectedSentence, sentences.size()); gotoPageTextField.setModelObject(selectedSentence); state.setFirstVisibleUnit(sentences.get(selectedSentence - 1)); state.setFocusUnitIndex(selectedSentence); actionRefreshDocument(aTarget); }
private void actionGotoPage(AjaxRequestTarget aTarget, Form<?> aForm) throws Exception { AnnotatorState state = getModelObject(); JCas jcas = getEditorCas(); List<Sentence> sentences = new ArrayList<>(select(jcas, Sentence.class)); int selectedSentence = gotoPageTextField.getModelObject(); selectedSentence = Math.min(selectedSentence, sentences.size()); gotoPageTextField.setModelObject(selectedSentence); state.setFirstVisibleUnit(sentences.get(selectedSentence - 1)); state.setFocusUnitIndex(selectedSentence); actionRefreshDocument(aTarget); }
private void actionGotoPage(AjaxRequestTarget aTarget, Form<?> aForm) throws Exception { AnnotatorState state = getModelObject(); JCas jcas = getEditorCas(); List<Sentence> sentences = new ArrayList<>(select(jcas, Sentence.class)); int selectedSentence = gotoPageTextField.getModelObject(); selectedSentence = Math.min(selectedSentence, sentences.size()); gotoPageTextField.setModelObject(selectedSentence); state.setFirstVisibleUnit(sentences.get(selectedSentence - 1)); state.setFocusUnitIndex(selectedSentence); actionRefreshDocument(aTarget); }
private void updateSentenceNumber(JCas aJCas, int aAddress) { AnnotatorState state = getModelObject(); Sentence sentence = selectByAddr(aJCas, Sentence.class, aAddress); state.setFirstVisibleUnit(sentence); state.setFocusUnitIndex(WebAnnoCasUtil.getSentenceNumber(aJCas, sentence.getBegin())); }
private void updateSentenceNumber(JCas aJCas, int aAddress) { AnnotatorState state = getModelObject(); Sentence sentence = selectByAddr(aJCas, Sentence.class, aAddress); state.setFirstVisibleUnit(sentence); state.setFocusUnitIndex(WebAnnoCasUtil.getSentenceNumber(aJCas, sentence.getBegin())); }
private void actionGotoPage(AjaxRequestTarget aTarget, Form<?> aForm) throws Exception { AnnotatorState state = getModelObject(); JCas editorCas = getEditorCas(); List<Sentence> sentences = new ArrayList<>(select(editorCas, Sentence.class)); int selectedSentence = gotoPageTextField.getModelObject(); selectedSentence = Math.min(selectedSentence, sentences.size()); gotoPageTextField.setModelObject(selectedSentence); state.setFirstVisibleUnit(sentences.get(selectedSentence - 1)); state.setFocusUnitIndex(selectedSentence); SuggestionBuilder builder = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository); curationContainer = builder.buildCurationContainer(state); setCurationSegmentBeginEnd(editorCas); curationContainer.setBratAnnotatorModel(state); update(aTarget); aTarget.add(gotoPageTextField); annotationEditor.requestRender(aTarget); }
private void actionGotoPage(AjaxRequestTarget aTarget, Form<?> aForm) throws Exception { AnnotatorState state = getModelObject(); JCas editorCas = getEditorCas(); List<Sentence> sentences = new ArrayList<>(select(editorCas, Sentence.class)); int selectedSentence = gotoPageTextField.getModelObject(); selectedSentence = Math.min(selectedSentence, sentences.size()); gotoPageTextField.setModelObject(selectedSentence); state.setFirstVisibleUnit(sentences.get(selectedSentence - 1)); state.setFocusUnitIndex(selectedSentence); SuggestionBuilder builder = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository); curationContainer = builder.buildCurationContainer(state); setCurationSegmentBeginEnd(editorCas); curationContainer.setBratAnnotatorModel(state); update(aTarget); aTarget.add(gotoPageTextField); annotationEditor.requestRender(aTarget); }
private void actionGotoPage(AjaxRequestTarget aTarget, Form<?> aForm) throws Exception { AnnotatorState state = getModelObject(); JCas editorCas = getEditorCas(); List<Sentence> sentences = new ArrayList<>(select(editorCas, Sentence.class)); int selectedSentence = gotoPageTextField.getModelObject(); selectedSentence = Math.min(selectedSentence, sentences.size()); gotoPageTextField.setModelObject(selectedSentence); state.setFirstVisibleUnit(sentences.get(selectedSentence - 1)); state.setFocusUnitIndex(selectedSentence); SuggestionBuilder builder = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository); curationContainer = builder.buildCurationContainer(state); setCurationSegmentBeginEnd(editorCas); curationContainer.setBratAnnotatorModel(state); update(aTarget); aTarget.add(gotoPageTextField); annotationEditor.requestRender(aTarget); }
/** * Show the next document if it exists, starting in a certain token position */ @Deprecated public void actionShowSelectedDocumentByTokenPosition(AjaxRequestTarget aTarget, SourceDocument aDocument, int aTokenNumber) throws IOException { actionShowSelectedDocument(aTarget, aDocument); AnnotatorState state = getModelObject(); JCas jCas = getEditorCas(); Collection<Token> tokenCollection = JCasUtil.select(jCas, Token.class); Token[] tokens = tokenCollection.toArray(new Token[tokenCollection.size()]); int sentenceNumber = WebAnnoCasUtil.getSentenceNumber(jCas, tokens[aTokenNumber].getBegin()); Sentence sentence = WebAnnoCasUtil.getSentence(jCas, tokens[aTokenNumber].getBegin()); getGotoPageTextField().setModelObject(sentenceNumber); state.setFirstVisibleUnit(sentence); state.setFocusUnitIndex(sentenceNumber); actionRefreshDocument(aTarget); }
private void actionCompletePreferencesChange(AjaxRequestTarget aTarget) { try { AnnotatorState state = getModelObject(); JCas jCas = getEditorCas(); // The number of visible sentences may have changed - let the state recalculate // the visible sentences Sentence sentence = selectByAddr(jCas, Sentence.class, state.getFirstVisibleUnitAddress()); state.setFirstVisibleUnit(sentence); // The selection of layers may have changed. Update the dropdown detailEditor.getAnnotationFeatureForm().updateLayersDropdown(); AnnotationEditorBase newAnnotationEditor = createAnnotationEditor(); annotationEditor.replaceWith(newAnnotationEditor); annotationEditor = newAnnotationEditor; // Reload all AJAX-enabled children of the page but not the page itself! WicketUtil.refreshPage(aTarget, getPage()); } catch (Exception e) { LOG.info("Error reading CAS: {}", e.getMessage()); error("Error reading CAS " + e.getMessage()); aTarget.addChildren(getPage(), IFeedback.class); } }
private void updateCurationView(final CurationContainer curationContainer, final SourceListView curationViewItem, AjaxRequestTarget aTarget, JCas jCas) { Sentence currentSent = WebAnnoCasUtil.getCurrentSentence(jCas, curationViewItem.getBegin(), curationViewItem.getEnd()); state.setFirstVisibleUnit(WebAnnoCasUtil.findWindowStartCenteringOnSelection(jCas, currentSent, curationViewItem.getBegin(), state.getProject(), state.getDocument(), state.getPreferences().getWindowSize())); curationContainer.setBratAnnotatorModel(state); onChange(aTarget); }
private void updateCurationView(final CurationContainer curationContainer, final SourceListView curationViewItem, AjaxRequestTarget aTarget, JCas jCas) { Sentence currentSent = WebAnnoCasUtil.getCurrentSentence(jCas, curationViewItem.getBegin(), curationViewItem.getEnd()); state.setFirstVisibleUnit(WebAnnoCasUtil.findWindowStartCenteringOnSelection(jCas, currentSent, curationViewItem.getBegin(), state.getProject(), state.getDocument(), state.getPreferences().getWindowSize())); curationContainer.setBratAnnotatorModel(state); onChange(aTarget); }
private void commonUpdate() throws IOException { JCas jCas = curationDocumentService.readCurationCas(state.getDocument()); // Determine the FIRST visible unit final Sentence firstVisibleUnit = selectSentenceAt(jCas, state.getFirstVisibleUnitBegin(), state.getFirstVisibleUnitEnd()); state.setFirstVisibleUnit(firstVisibleUnit); // Determine the LAST visible unit List<Sentence> followingUnits = selectFollowing(jCas, Sentence.class, firstVisibleUnit, state.getPreferences().getWindowSize()); // Check also, when getting the last sentence address in the display window, if this is the // last sentence or the ONLY sentence in the document Sentence lastVisibleUnit = followingUnits.size() == 0 ? firstVisibleUnit : followingUnits.get(followingUnits.size() - 1); curationView.setCurationBegin(firstVisibleUnit.getBegin()); curationView.setCurationEnd(lastVisibleUnit.getEnd()); // Determine the number of the first and last visible unit int ws = state.getPreferences().getWindowSize(); Sentence fs = WebAnnoCasUtil.selectSentenceAt(jCas, state.getFirstVisibleUnitBegin(), state.getFirstVisibleUnitEnd()); Sentence ls = WebAnnoCasUtil.getLastSentenceInDisplayWindow(jCas, getAddr(fs), ws); fSn = WebAnnoCasUtil.getSentenceNumber(jCas, fs.getBegin()); lSn = WebAnnoCasUtil.getSentenceNumber(jCas, ls.getBegin()); }
private void commonUpdate() throws IOException { JCas jCas = curationDocumentService.readCurationCas(state.getDocument()); // Determine the FIRST visible unit final Sentence firstVisibleUnit = selectSentenceAt(jCas, state.getFirstVisibleUnitBegin(), state.getFirstVisibleUnitEnd()); state.setFirstVisibleUnit(firstVisibleUnit); // Determine the LAST visible unit List<Sentence> followingUnits = selectFollowing(jCas, Sentence.class, firstVisibleUnit, state.getPreferences().getWindowSize()); // Check also, when getting the last sentence address in the display window, if this is the // last sentence or the ONLY sentence in the document Sentence lastVisibleUnit = followingUnits.size() == 0 ? firstVisibleUnit : followingUnits.get(followingUnits.size() - 1); curationView.setCurationBegin(firstVisibleUnit.getBegin()); curationView.setCurationEnd(lastVisibleUnit.getEnd()); // Determine the number of the first and last visible unit int ws = state.getPreferences().getWindowSize(); Sentence fs = WebAnnoCasUtil.selectSentenceAt(jCas, state.getFirstVisibleUnitBegin(), state.getFirstVisibleUnitEnd()); Sentence ls = WebAnnoCasUtil.getLastSentenceInDisplayWindow(jCas, getAddr(fs), ws); fSn = WebAnnoCasUtil.getSentenceNumber(jCas, fs.getBegin()); lSn = WebAnnoCasUtil.getSentenceNumber(jCas, ls.getBegin()); }
/** * Show the next document if it exists, starting in a certain begin offset */ public void actionShowSelectedDocument(AjaxRequestTarget aTarget, SourceDocument aDocument, int aBegin, int aEnd) throws IOException { boolean switched = actionShowSelectedDocument(aTarget, aDocument); AnnotatorState state = getModelObject(); // If the document was not switched and the requested offset is already visible on screen, // then there is no need to change the screen contents if (switched || !(state.getWindowBeginOffset() <= aBegin && aEnd <= state.getWindowEndOffset())) { JCas jCas = getEditorCas(); int sentenceNumber = WebAnnoCasUtil.getSentenceNumber(jCas, aBegin); Sentence sentence = WebAnnoCasUtil.getSentence(jCas, aBegin); getGotoPageTextField().setModelObject(sentenceNumber); state.setFirstVisibleUnit(sentence); state.setFocusUnitIndex(sentenceNumber); } actionRefreshDocument(aTarget); }
private void actionCompletePreferencesChange(AjaxRequestTarget aTarget) { try { AnnotatorState state = getModelObject(); JCas editorCas = getEditorCas(); // The number of visible sentences may have changed - let the state recalculate // the visible sentences Sentence sentence = selectByAddr(editorCas, Sentence.class, state.getFirstVisibleUnitAddress()); state.setFirstVisibleUnit(sentence); SuggestionBuilder builder = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository); curationContainer = builder.buildCurationContainer(state); setCurationSegmentBeginEnd(editorCas); curationContainer.setBratAnnotatorModel(state); update(aTarget); aTarget.appendJavaScript( "Wicket.Window.unloadConfirmation = false;window.location.reload()"); // Re-render the whole page because the width of the sidebar may have changed aTarget.add(this); } catch (Exception e) { handleException(aTarget, e); } }
state.setFirstVisibleUnit(sentence);
private void actionCompletePreferencesChange(AjaxRequestTarget aTarget) { AnnotatorState state = CurationPage.this.getModelObject(); // Re-render the whole page because the width of the sidebar may have changed aTarget.add(CurationPage.this); aTarget.add(getOrCreatePositionInfoLabel()); JCas mergeCas = null; try { aTarget.add(getFeedbackPanel()); mergeCas = curationDocumentService.readCurationCas(state.getDocument()); // The number of visible sentences may have changed - let the state recalculate // the visible sentences Sentence sentence = selectByAddr(mergeCas, Sentence.class, state.getFirstVisibleUnitAddress()); state.setFirstVisibleUnit(sentence); curationPanel.updatePanel(aTarget, curationContainer); updatePanel(curationContainer, aTarget); updateSentenceNumber(mergeCas, state.getFirstVisibleUnitAddress()); } catch (Exception e) { handleException(aTarget, e); } }
private void actionCompletePreferencesChange(AjaxRequestTarget aTarget) { AnnotatorState state = CurationPage.this.getModelObject(); // Re-render the whole page because the width of the sidebar may have changed aTarget.add(CurationPage.this); aTarget.add(getOrCreatePositionInfoLabel()); JCas mergeCas = null; try { aTarget.add(getFeedbackPanel()); mergeCas = curationDocumentService.readCurationCas(state.getDocument()); // The number of visible sentences may have changed - let the state recalculate // the visible sentences Sentence sentence = selectByAddr(mergeCas, Sentence.class, state.getFirstVisibleUnitAddress()); state.setFirstVisibleUnit(sentence); curationPanel.updatePanel(aTarget, curationContainer); updatePanel(curationContainer, aTarget); updateSentenceNumber(mergeCas, state.getFirstVisibleUnitAddress()); } catch (Exception e) { handleException(aTarget, e); } }