private void updateCurationView( final CurationContainer curationContainer, final SourceListView curationViewItem, AjaxRequestTarget aTarget, JCas jCas) { int currentSentAddress = BratAjaxCasUtil.getCurrentSentence( jCas, curationViewItem.getBegin(), curationViewItem.getEnd()) .getAddress(); bModel.setSentenceAddress( BratAjaxCasUtil.getSentenceBeginAddress( jCas, currentSentAddress, curationViewItem.getBegin(), bModel.getProject(), bModel.getDocument(), bModel.getPreferences().getWindowSize())); Sentence sentence = selectByAddr(jCas, Sentence.class, bModel.getSentenceAddress()); bModel.setSentenceBeginOffset(sentence.getBegin()); bModel.setSentenceEndOffset(sentence.getEnd()); Sentence firstSentence = selectSentenceAt(jCas, bModel.getSentenceBeginOffset(), bModel.getSentenceEndOffset()); int lastAddressInPage = getLastSentenceAddressInDisplayWindow( jCas, getAddr(firstSentence), bModel.getPreferences().getWindowSize()); // the last sentence address in the display window Sentence lastSentenceInPage = (Sentence) selectByAddr(jCas, FeatureStructure.class, lastAddressInPage); bModel.setFSN(BratAjaxCasUtil.getSentenceNumber(jCas, firstSentence.getBegin())); bModel.setLSN(BratAjaxCasUtil.getSentenceNumber(jCas, lastSentenceInPage.getBegin())); curationContainer.setBratAnnotatorModel(bModel); onChange(aTarget); }
public AutomationPage() { bModel = new BratAnnotatorModel(); bModel.setMode(Mode.AUTOMATION); LinkedList<CurationUserSegmentForAnnotationDocument> sentences = new LinkedList<CurationUserSegmentForAnnotationDocument>(); CurationUserSegmentForAnnotationDocument curationUserSegmentForAnnotationDocument = new CurationUserSegmentForAnnotationDocument(); if (bModel.getDocument() != null) { curationUserSegmentForAnnotationDocument.setAnnotationSelectionByUsernameAndAddress( annotationSelectionByUsernameAndAddress); curationUserSegmentForAnnotationDocument.setBratAnnotatorModel(bModel); sentences.add(curationUserSegmentForAnnotationDocument); } automateView = new SuggestionViewPanel( "automateView", new Model<LinkedList<CurationUserSegmentForAnnotationDocument>>(sentences)) { private static final long serialVersionUID = 2583509126979792202L; @Override public void onChange(AjaxRequestTarget aTarget) { try { // update begin/end of the curationsegment based on bratAnnotatorModel changes // (like sentence change in auto-scroll mode,.... aTarget.addChildren(getPage(), FeedbackPanel.class); curationContainer.setBratAnnotatorModel(bModel); setCurationSegmentBeginEnd(); CuratorUtil.updatePanel( aTarget, this, curationContainer, mergeVisualizer, repository, annotationSelectionByUsernameAndAddress, curationSegment, annotationService, userRepository); } catch (UIMAException e) { error(ExceptionUtils.getRootCause(e)); } catch (ClassNotFoundException e) { error(e.getMessage()); } catch (IOException e) { error(e.getMessage()); } catch (BratAnnotationException e) { error(e.getMessage()); } mergeVisualizer.bratRenderLater(aTarget); aTarget.add(numberOfPages); update(aTarget); } }; automateView.setOutputMarkupId(true); add(automateView); annotationDetailEditorPanel = new AnnotationDetailEditorPanel( "annotationDetailEditorPanel", new Model<BratAnnotatorModel>(bModel)) { private static final long serialVersionUID = 2857345299480098279L; @Override protected void onChange(AjaxRequestTarget aTarget, BratAnnotatorModel aBModel) { aTarget.addChildren(getPage(), FeedbackPanel.class); try { mergeVisualizer.bratRender(aTarget, getCas(aBModel)); } catch (UIMAException | ClassNotFoundException | IOException e) { LOG.info("Error reading CAS " + e.getMessage()); error("Error reading CAS " + e.getMessage()); return; } mergeVisualizer.bratRenderHighlight(aTarget, aBModel.getSelection().getAnnotation()); mergeVisualizer.onChange(aTarget, aBModel); mergeVisualizer.onAnnotate( aTarget, aBModel, aBModel.getSelection().getBegin(), aBModel.getSelection().getEnd()); if (!aBModel.getSelection().isAnnotate()) { mergeVisualizer.onDelete( aTarget, aBModel, aBModel.getSelection().getBegin(), aBModel.getSelection().getEnd()); } } }; annotationDetailEditorPanel.setOutputMarkupId(true); add(annotationDetailEditorPanel); mergeVisualizer = new BratAnnotator( "mergeView", new Model<BratAnnotatorModel>(bModel), annotationDetailEditorPanel) { private static final long serialVersionUID = 7279648231521710155L; @Override public void onChange(AjaxRequestTarget aTarget, BratAnnotatorModel aBratAnnotatorModel) { try { aTarget.addChildren(getPage(), FeedbackPanel.class); // info(bratAnnotatorModel.getMessage()); aTarget.addChildren(getPage(), FeedbackPanel.class); bModel = aBratAnnotatorModel; SuggestionBuilder builder = new SuggestionBuilder(repository, annotationService, userRepository); curationContainer = builder.buildCurationContainer(bModel); setCurationSegmentBeginEnd(); curationContainer.setBratAnnotatorModel(bModel); CuratorUtil.updatePanel( aTarget, automateView, curationContainer, this, repository, annotationSelectionByUsernameAndAddress, curationSegment, annotationService, userRepository); aTarget.add(automateView); aTarget.add(numberOfPages); } catch (UIMAException e) { error(ExceptionUtils.getRootCause(e)); } catch (ClassNotFoundException e) { error(e.getMessage()); } catch (IOException e) { error(e.getMessage()); } catch (BratAnnotationException e) { error(e.getMessage()); } update(aTarget); } @Override public void onAnnotate( AjaxRequestTarget aTarget, BratAnnotatorModel aBratAnnotatorModel, int aStart, int aEnd) { MiraTemplate template; Set<AnnotationFeature> features = bModel.getRememberedSpanFeatures().keySet(); AnnotationFeature autoFeature = null; for (AnnotationFeature feature : features) { autoFeature = feature; break; } try { template = automationService.getMiraTemplate(autoFeature); if (!template.isAnnotateAndPredict()) { return; } /* * Tag tag = annotationService.getTag(bratAnnotatorModel * .getRememberedSpanFeatures().get(autoFeature), autoFeature.getTagset()); */ AutomationUtil.repeateAnnotation( bModel, repository, userRepository, annotationService, automationService, aStart, aEnd, autoFeature); } catch (UIMAException e) { error(ExceptionUtils.getRootCause(e)); } catch (ClassNotFoundException e) { error(e.getMessage()); } catch (IOException e) { error(e.getMessage()); } catch (BratAnnotationException e) { error(e.getMessage()); } catch (NoResultException e) { // no automation layer is configured yet. template = null; return; } update(aTarget); } @Override public void onDelete( AjaxRequestTarget aTarget, BratAnnotatorModel aBratAnnotatorModel, int aStart, int aEnd) { MiraTemplate template; Set<AnnotationFeature> features = bModel.getRememberedSpanFeatures().keySet(); AnnotationFeature autoFeature = null; for (AnnotationFeature feature : features) { autoFeature = feature; break; } if (autoFeature == null) { return; } try { template = automationService.getMiraTemplate(autoFeature); if (!template.isAnnotateAndPredict()) { return; } /* * Tag tag = annotationService.getTag(bratAnnotatorModel * .getRememberedSpanFeatures().get(autoFeature), autoFeature.getTagset()); */ AutomationUtil.deleteAnnotation( bModel, repository, annotationService, automationService, userRepository, aStart, aEnd, autoFeature); } catch (UIMAException e) { error(ExceptionUtils.getRootCause(e)); } catch (ClassNotFoundException e) { error(e.getMessage()); } catch (IOException e) { error(e.getMessage()); } catch (BratAnnotationException e) { error(e.getMessage()); } catch (NoResultException e) { // no automation layer is configured yet. template = null; return; } update(aTarget); } }; // reset sentenceAddress and lastSentenceAddress to the orginal once mergeVisualizer.setOutputMarkupId(true); add(mergeVisualizer); curationContainer = new CurationContainer(); curationContainer.setBratAnnotatorModel(bModel); add( documentNamePanel = new DocumentNamePanel("documentNamePanel", new Model<BratAnnotatorModel>(bModel))); add( numberOfPages = (Label) new Label( "numberOfPages", new LoadableDetachableModel<String>() { private static final long serialVersionUID = 891566759811286173L; @Override protected String load() { if (bModel.getDocument() != null) { JCas mergeJCas = null; try { mergeJCas = repository.readCorrectionCas(bModel.getDocument()); totalNumberOfSentence = getNumberOfPages(mergeJCas); // If only one page, start displaying from sentence 1 /* * if (totalNumberOfSentence == 1) { * bratAnnotatorModel.setSentenceAddress(bratAnnotatorModel * .getFirstSentenceAddress()); } */ int address = getAddr( selectSentenceAt( mergeJCas, bModel.getSentenceBeginOffset(), bModel.getSentenceEndOffset())); sentenceNumber = getFirstSentenceNumber(mergeJCas, address); int firstSentenceNumber = sentenceNumber + 1; int lastSentenceNumber; if (firstSentenceNumber + bModel.getPreferences().getWindowSize() - 1 < totalNumberOfSentence) { lastSentenceNumber = firstSentenceNumber + bModel.getPreferences().getWindowSize() - 1; } else { lastSentenceNumber = totalNumberOfSentence; } return "showing " + firstSentenceNumber + "-" + lastSentenceNumber + " of " + totalNumberOfSentence + " sentences"; } catch (UIMAException e) { return ""; } catch (DataRetrievalFailureException e) { return ""; } catch (ClassNotFoundException e) { return ""; } catch (FileNotFoundException e) { return ""; } catch (IOException e) { return ""; } } else { return ""; // no document yet selected } } }) .setOutputMarkupId(true)); final ModalWindow openDocumentsModal; add(openDocumentsModal = new ModalWindow("openDocumentsModal")); openDocumentsModal.setOutputMarkupId(true); openDocumentsModal.setInitialWidth(500); openDocumentsModal.setInitialHeight(300); openDocumentsModal.setResizable(true); openDocumentsModal.setWidthUnit("px"); openDocumentsModal.setHeightUnit("px"); openDocumentsModal.setTitle("Open document"); add( new AjaxLink<Void>("showOpenDocumentModal") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget aTarget) { openDocumentsModal.setContent( new OpenModalWindowPanel( openDocumentsModal.getContentId(), bModel, openDocumentsModal, Mode.AUTOMATION)); openDocumentsModal.setWindowClosedCallback( new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = -1746088901018629567L; @Override public void onClose(AjaxRequestTarget target) { if (bModel.getDocument() == null) { setResponsePage(WelcomePage.class); return; } try { target.addChildren(getPage(), FeedbackPanel.class); bModel.setDocument(bModel.getDocument()); bModel.setProject(bModel.getProject()); String username = SecurityContextHolder.getContext().getAuthentication().getName(); repository.upgradeCasAndSave(bModel.getDocument(), Mode.AUTOMATION, username); loadDocumentAction(); setCurationSegmentBeginEnd(); update(target); } catch (UIMAException e) { target.addChildren(getPage(), FeedbackPanel.class); error(ExceptionUtils.getRootCause(e)); } catch (ClassNotFoundException e) { target.addChildren(getPage(), FeedbackPanel.class); error(e.getMessage()); } catch (IOException e) { target.addChildren(getPage(), FeedbackPanel.class); error(e.getMessage()); } catch (BratAnnotationException e) { error(e.getMessage()); } finish.setModelObject(bModel); target.add(finish.setOutputMarkupId(true)); target.appendJavaScript( "Wicket.Window.unloadConfirmation=false;window.location.reload()"); target.add(documentNamePanel.setOutputMarkupId(true)); target.add(numberOfPages); } }); openDocumentsModal.show(aTarget); } }); add( new AnnotationLayersModalPanel( "annotationLayersModalPanel", new Model<BratAnnotatorModel>(bModel)) { private static final long serialVersionUID = -4657965743173979437L; @Override protected void onChange(AjaxRequestTarget aTarget) { curationContainer.setBratAnnotatorModel(bModel); try { aTarget.addChildren(getPage(), FeedbackPanel.class); setCurationSegmentBeginEnd(); } catch (UIMAException e) { error(ExceptionUtils.getRootCauseMessage(e)); } catch (ClassNotFoundException e) { error(e.getMessage()); } catch (IOException e) { error(e.getMessage()); } update(aTarget); // mergeVisualizer.reloadContent(aTarget); aTarget.appendJavaScript( "Wicket.Window.unloadConfirmation = false;window.location.reload()"); } }); add(new ExportModalPanel("exportModalPanel", new Model<BratAnnotatorModel>(bModel))); gotoPageTextField = (NumberTextField<Integer>) new NumberTextField<Integer>("gotoPageText", new Model<Integer>(0)); Form<Void> gotoPageTextFieldForm = new Form<Void>("gotoPageTextFieldForm"); gotoPageTextFieldForm.add( new AjaxFormSubmitBehavior(gotoPageTextFieldForm, "onsubmit") { private static final long serialVersionUID = -4549805321484461545L; @Override protected void onSubmit(AjaxRequestTarget aTarget) { if (gotoPageAddress == 0) { aTarget.appendJavaScript("alert('The sentence number entered is not valid')"); return; } JCas mergeJCas = null; try { aTarget.addChildren(getPage(), FeedbackPanel.class); mergeJCas = repository.readCorrectionCas(bModel.getDocument()); if (bModel.getSentenceAddress() != gotoPageAddress) { ubdateSentenceNumber(mergeJCas, gotoPageAddress); SuggestionBuilder builder = new SuggestionBuilder(repository, annotationService, userRepository); curationContainer = builder.buildCurationContainer(bModel); setCurationSegmentBeginEnd(); curationContainer.setBratAnnotatorModel(bModel); update(aTarget); mergeVisualizer.bratRenderLater(aTarget); } } catch (UIMAException e) { error(ExceptionUtils.getRootCause(e)); } catch (ClassNotFoundException e) { error(e.getMessage()); } catch (IOException e) { error(e.getMessage()); } catch (BratAnnotationException e) { error(e.getMessage()); } } }); gotoPageTextField.setType(Integer.class); gotoPageTextField.setMinimum(1); gotoPageTextField.setDefaultModelObject(1); add(gotoPageTextFieldForm.add(gotoPageTextField)); gotoPageTextField.add( new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = -3853194405966729661L; @Override protected void onUpdate(AjaxRequestTarget target) { JCas mergeJCas = null; try { mergeJCas = repository.readCorrectionCas(bModel.getDocument()); gotoPageAddress = getSentenceAddress(mergeJCas, gotoPageTextField.getModelObject()); } catch (UIMAException e) { error(ExceptionUtils.getRootCause(e)); } catch (ClassNotFoundException e) { error(ExceptionUtils.getRootCause(e)); } catch (IOException e) { error(e.getMessage()); } } }); add( new AjaxLink<Void>("gotoPageLink") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget aTarget) { if (gotoPageAddress == 0) { aTarget.appendJavaScript("alert('The sentence number entered is not valid')"); return; } if (bModel.getDocument() == null) { aTarget.appendJavaScript("alert('Please open a document first!')"); return; } JCas mergeJCas = null; try { aTarget.addChildren(getPage(), FeedbackPanel.class); mergeJCas = repository.readCorrectionCas(bModel.getDocument()); if (bModel.getSentenceAddress() != gotoPageAddress) { ubdateSentenceNumber(mergeJCas, gotoPageAddress); SuggestionBuilder builder = new SuggestionBuilder(repository, annotationService, userRepository); curationContainer = builder.buildCurationContainer(bModel); setCurationSegmentBeginEnd(); curationContainer.setBratAnnotatorModel(bModel); update(aTarget); mergeVisualizer.bratRenderLater(aTarget); } } catch (UIMAException e) { error(ExceptionUtils.getRootCause(e)); } catch (ClassNotFoundException e) { error(e.getMessage()); } catch (IOException e) { error(e.getMessage()); } catch (BratAnnotationException e) { error(e.getMessage()); } } }); finish = new FinishImage( "finishImage", new LoadableDetachableModel<BratAnnotatorModel>() { private static final long serialVersionUID = -2737326878793568454L; @Override protected BratAnnotatorModel load() { return bModel; } }); add( new FinishLink("showYesNoModalPanel", new Model<BratAnnotatorModel>(bModel), finish) { private static final long serialVersionUID = -4657965743173979437L; }); // Show the previous document, if exist add( new AjaxLink<Void>("showPreviousDocument") { private static final long serialVersionUID = 7496156015186497496L; /** * Get the current beginning sentence address and add on it the size of the display window */ @Override public void onClick(AjaxRequestTarget target) { target.addChildren(getPage(), FeedbackPanel.class); // List of all Source Documents in the project List<SourceDocument> listOfSourceDocuements = repository.listSourceDocuments(bModel.getProject()); String username = SecurityContextHolder.getContext().getAuthentication().getName(); User user = userRepository.get(username); List<SourceDocument> sourceDocumentsinIgnorState = new ArrayList<SourceDocument>(); for (SourceDocument sourceDocument : listOfSourceDocuements) { if (repository.existsAnnotationDocument(sourceDocument, user) && repository .getAnnotationDocument(sourceDocument, user) .getState() .equals(AnnotationDocumentState.IGNORE)) { sourceDocumentsinIgnorState.add(sourceDocument); } else if (sourceDocument.isTrainingDocument()) { sourceDocumentsinIgnorState.add(sourceDocument); } } listOfSourceDocuements.removeAll(sourceDocumentsinIgnorState); // Index of the current source document in the list int currentDocumentIndex = listOfSourceDocuements.indexOf(bModel.getDocument()); // If the first the document if (currentDocumentIndex == 0) { target.appendJavaScript("alert('This is the first document!')"); } else { bModel.setDocumentName( listOfSourceDocuements.get(currentDocumentIndex - 1).getName()); bModel.setDocument(listOfSourceDocuements.get(currentDocumentIndex - 1)); try { repository.upgradeCasAndSave( bModel.getDocument(), Mode.AUTOMATION, bModel.getUser().getUsername()); loadDocumentAction(); setCurationSegmentBeginEnd(); update(target); } catch (UIMAException e) { error(ExceptionUtils.getRootCause(e)); } catch (ClassNotFoundException e) { error(ExceptionUtils.getRootCause(e)); } catch (IOException e) { error(ExceptionUtils.getRootCause(e)); } catch (BratAnnotationException e) { target.addChildren(getPage(), FeedbackPanel.class); error(e.getMessage()); } finish.setModelObject(bModel); target.add(finish.setOutputMarkupId(true)); target.add(numberOfPages); target.add(documentNamePanel); mergeVisualizer.bratRenderLater(target); } } }.add(new InputBehavior(new KeyType[] {KeyType.Shift, KeyType.Page_up}, EventType.click))); // Show the next document if exist add( new AjaxLink<Void>("showNextDocument") { private static final long serialVersionUID = 7496156015186497496L; /** * Get the current beginning sentence address and add on it the size of the display window */ @Override public void onClick(AjaxRequestTarget target) { target.addChildren(getPage(), FeedbackPanel.class); // List of all Source Documents in the project List<SourceDocument> listOfSourceDocuements = repository.listSourceDocuments(bModel.getProject()); String username = SecurityContextHolder.getContext().getAuthentication().getName(); User user = userRepository.get(username); List<SourceDocument> sourceDocumentsinIgnorState = new ArrayList<SourceDocument>(); for (SourceDocument sourceDocument : listOfSourceDocuements) { if (repository.existsAnnotationDocument(sourceDocument, user) && repository .getAnnotationDocument(sourceDocument, user) .getState() .equals(AnnotationDocumentState.IGNORE)) { sourceDocumentsinIgnorState.add(sourceDocument); } else if (sourceDocument.isTrainingDocument()) { sourceDocumentsinIgnorState.add(sourceDocument); } } listOfSourceDocuements.removeAll(sourceDocumentsinIgnorState); // Index of the current source document in the list int currentDocumentIndex = listOfSourceDocuements.indexOf(bModel.getDocument()); // If the first document if (currentDocumentIndex == listOfSourceDocuements.size() - 1) { target.appendJavaScript("alert('This is the last document!')"); return; } bModel.setDocumentName(listOfSourceDocuements.get(currentDocumentIndex + 1).getName()); bModel.setDocument(listOfSourceDocuements.get(currentDocumentIndex + 1)); try { repository.upgradeCasAndSave( bModel.getDocument(), Mode.AUTOMATION, bModel.getUser().getUsername()); loadDocumentAction(); setCurationSegmentBeginEnd(); update(target); } catch (UIMAException e) { error(ExceptionUtils.getRootCause(e)); } catch (ClassNotFoundException e) { error(ExceptionUtils.getRootCause(e)); } catch (IOException e) { error(ExceptionUtils.getRootCause(e)); } catch (BratAnnotationException e) { target.addChildren(getPage(), FeedbackPanel.class); error(e.getMessage()); } finish.setModelObject(bModel); target.add(finish.setOutputMarkupId(true)); target.add(numberOfPages); target.add(documentNamePanel); mergeVisualizer.bratRenderLater(target); } }.add( new InputBehavior(new KeyType[] {KeyType.Shift, KeyType.Page_down}, EventType.click))); // Show the next page of this document add( new AjaxLink<Void>("showNext") { private static final long serialVersionUID = 7496156015186497496L; /** * Get the current beginning sentence address and add on it the size of the display window */ @Override public void onClick(AjaxRequestTarget aTarget) { if (bModel.getDocument() != null) { JCas mergeJCas = null; try { aTarget.addChildren(getPage(), FeedbackPanel.class); mergeJCas = repository.readCorrectionCas(bModel.getDocument()); int address = getAddr( selectSentenceAt( mergeJCas, bModel.getSentenceBeginOffset(), bModel.getSentenceEndOffset())); int nextSentenceAddress = getNextPageFirstSentenceAddress( mergeJCas, address, bModel.getPreferences().getWindowSize()); if (address != nextSentenceAddress) { ubdateSentenceNumber(mergeJCas, nextSentenceAddress); SuggestionBuilder builder = new SuggestionBuilder(repository, annotationService, userRepository); curationContainer = builder.buildCurationContainer(bModel); setCurationSegmentBeginEnd(); curationContainer.setBratAnnotatorModel(bModel); update(aTarget); mergeVisualizer.bratRenderLater(aTarget); } else { aTarget.appendJavaScript("alert('This is last page!')"); } } catch (UIMAException e) { error(ExceptionUtils.getRootCause(e)); } catch (ClassNotFoundException e) { error(e.getMessage()); } catch (IOException e) { error(e.getMessage()); } catch (BratAnnotationException e) { error(e.getMessage()); } } else { aTarget.appendJavaScript("alert('Please open a document first!')"); } } }.add(new InputBehavior(new KeyType[] {KeyType.Page_down}, EventType.click))); // SHow the previous page of this document add( new AjaxLink<Void>("showPrevious") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget aTarget) { if (bModel.getDocument() != null) { JCas mergeJCas = null; try { aTarget.addChildren(getPage(), FeedbackPanel.class); mergeJCas = repository.readCorrectionCas(bModel.getDocument()); int previousSentenceAddress = BratAjaxCasUtil.getPreviousDisplayWindowSentenceBeginAddress( mergeJCas, bModel.getSentenceAddress(), bModel.getPreferences().getWindowSize()); if (bModel.getSentenceAddress() != previousSentenceAddress) { ubdateSentenceNumber(mergeJCas, previousSentenceAddress); SuggestionBuilder builder = new SuggestionBuilder(repository, annotationService, userRepository); curationContainer = builder.buildCurationContainer(bModel); setCurationSegmentBeginEnd(); curationContainer.setBratAnnotatorModel(bModel); update(aTarget); mergeVisualizer.bratRenderLater(aTarget); } else { aTarget.appendJavaScript("alert('This is First Page!')"); } } catch (UIMAException e) { error(ExceptionUtils.getRootCause(e)); } catch (ClassNotFoundException e) { error(e.getMessage()); } catch (IOException e) {; error(e.getMessage()); } catch (BratAnnotationException e) { error(e.getMessage()); } } else { aTarget.appendJavaScript("alert('Please open a document first!')"); } } }.add(new InputBehavior(new KeyType[] {KeyType.Page_up}, EventType.click))); add( new AjaxLink<Void>("showFirst") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget aTarget) { if (bModel.getDocument() != null) { JCas mergeJCas = null; try { aTarget.addChildren(getPage(), FeedbackPanel.class); mergeJCas = repository.readCorrectionCas(bModel.getDocument()); int address = getAddr( selectSentenceAt( mergeJCas, bModel.getSentenceBeginOffset(), bModel.getSentenceEndOffset())); int firstAddress = getFirstSentenceAddress(mergeJCas); if (firstAddress != address) { ubdateSentenceNumber(mergeJCas, firstAddress); SuggestionBuilder builder = new SuggestionBuilder(repository, annotationService, userRepository); curationContainer = builder.buildCurationContainer(bModel); setCurationSegmentBeginEnd(); curationContainer.setBratAnnotatorModel(bModel); update(aTarget); mergeVisualizer.bratRenderLater(aTarget); } else { aTarget.appendJavaScript("alert('This is first page!')"); } } catch (UIMAException e) { error(ExceptionUtils.getRootCause(e)); } catch (ClassNotFoundException e) { error(e.getMessage()); } catch (IOException e) { error(e.getMessage()); } catch (BratAnnotationException e) { error(e.getMessage()); } } else { aTarget.appendJavaScript("alert('Please open a document first!')"); } } }.add(new InputBehavior(new KeyType[] {KeyType.Home}, EventType.click))); add( new AjaxLink<Void>("showLast") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget aTarget) { if (bModel.getDocument() != null) { JCas mergeJCas = null; try { aTarget.addChildren(getPage(), FeedbackPanel.class); mergeJCas = repository.readCorrectionCas(bModel.getDocument()); int lastDisplayWindowBeginingSentenceAddress = BratAjaxCasUtil.getLastDisplayWindowFirstSentenceAddress( mergeJCas, bModel.getPreferences().getWindowSize()); if (lastDisplayWindowBeginingSentenceAddress != bModel.getSentenceAddress()) { ubdateSentenceNumber(mergeJCas, lastDisplayWindowBeginingSentenceAddress); SuggestionBuilder builder = new SuggestionBuilder(repository, annotationService, userRepository); curationContainer = builder.buildCurationContainer(bModel); setCurationSegmentBeginEnd(); curationContainer.setBratAnnotatorModel(bModel); update(aTarget); mergeVisualizer.bratRenderLater(aTarget); } else { aTarget.appendJavaScript("alert('This is last Page!')"); } } catch (UIMAException e) { error(ExceptionUtils.getRootCause(e)); } catch (ClassNotFoundException e) { error(e.getMessage()); } catch (IOException e) { error(e.getMessage()); } catch (BratAnnotationException e) { error(e.getMessage()); } } else { aTarget.appendJavaScript("alert('Please open a document first!')"); } } }.add(new InputBehavior(new KeyType[] {KeyType.End}, EventType.click))); add(new GuidelineModalPanel("guidelineModalPanel", new Model<BratAnnotatorModel>(bModel))); }