// A hack to rememeber the Visural DropDown display
// value
private void actionDelete(AjaxRequestTarget aTarget)
        throws IOException, UIMAException, ClassNotFoundException
    {
        BratAnnotatorModel bratAnnotatorModel = getModelObject();
        JCas jCas = getCas(bratAnnotatorModel);
        AnnotationFS fs = selectByAddr(jCas, selectedAnnotationId);
        TypeAdapter adapter = getAdapter(selectedAnnotationLayer);
        String attachFeatureName = adapter.getAttachFeatureName();
        String attachTypeName = adapter.getAnnotationTypeName();
        Set<TypeAdapter> typeAdapters = new HashSet<TypeAdapter>();
        for (AnnotationLayer layer : annotationService.listAnnotationLayer(bratAnnotatorModel
                .getProject())) {
            typeAdapters.add(getAdapter(layer));
        }
        // delete associated relation annotation
        for (TypeAdapter ad : typeAdapters) {
            if (adapter.getAnnotationTypeName().equals(ad.getAnnotationTypeName())) {
                continue;
            }
            String tn = ad.getAttachTypeName();
            if (tn == null) {
                continue;
            }
            if (tn.equals(attachTypeName)) {
                Sentence thisSentence = BratAjaxCasUtil.getCurrentSentence(jCas, beginOffset,
                        endOffset);
                ad.deleteBySpan(jCas, fs, thisSentence.getBegin(), thisSentence.getEnd());
                break;
            }
            String fn = ad.getAttachFeatureName();
            if (fn == null) {
                continue;
            }
            if (fn.equals(attachFeatureName)) {
                Sentence thisSentence = BratAjaxCasUtil.getCurrentSentence(jCas, beginOffset,
                        endOffset);
                ad.deleteBySpan(jCas, fs, thisSentence.getBegin(), thisSentence.getEnd());
                break;
            }
        }
        // BEGIN HACK - Issue 933
        if (adapter instanceof ChainAdapter) {
            ((ChainAdapter) adapter).setArc(false);
        }
        // END HACK - Issue 933
        adapter.delete(jCas, selectedAnnotationId);
        repository.updateJCas(bratAnnotatorModel.getMode(), bratAnnotatorModel.getDocument(),
                bratAnnotatorModel.getUser(), jCas);
        // update timestamp now
        int sentenceNumber = BratAjaxCasUtil.getSentenceNumber(jCas, beginOffset);
        bratAnnotatorModel.getDocument().setSentenceAccessed(sentenceNumber);
        repository.updateTimeStamp(bratAnnotatorModel.getDocument(), bratAnnotatorModel.getUser(),
                bratAnnotatorModel.getMode());
        if (bratAnnotatorModel.isScrollPage()) {
            updateSentenceAddressAndOffsets(jCas, beginOffset);
        }
        bratAnnotatorModel.setRememberedSpanLayer(selectedAnnotationLayer);
        bratAnnotatorModel.setAnnotate(false);
        // store latest annotations
        for (IModel<String> model : featureValueModels) {
            AnnotationFeature feature = featuresModel.get(featureValueModels.indexOf(model))
                    .getObject().feature;
            selectedAnnotationLayer = feature.getLayer();
            selectedFeatureValues.put(feature, model.getObject());
        }
        info(generateMessage(selectedAnnotationLayer, null, true));
        // A hack to rememeber the Visural DropDown display
        // value
        bratAnnotatorModel.setRememberedSpanLayer(selectedAnnotationLayer);
        bratAnnotatorModel.setRememberedSpanFeatures(selectedFeatureValues);
        selectedSpanText = "";
        selectedAnnotationId = -1;
        aTarget.add(annotationFeatureForm);
       // setLayerAndFeatureModels(jCas);
        bratRender(aTarget, jCas);
        onChange(aTarget, getModelObject());
    }
}
info(generateMessage(selectedAnnotationLayer, null, true));
// A hack to rememeber the Visural DropDown display
// value
bratAnnotatorModel.setRememberedSpanLayer(selectedAnnotationLayer);
bratAnnotatorModel.setRememberedSpanFeatures(selectedFeatureValues);
bratAnnotatorModel.setRememberedSpanLayer(selectedAnnotationLayer);
bratAnnotatorModel.setAnnotate(false);
// store latest annotations
for (IModel<String> model : featureValueModels) {
AnnotationFeature feature = featuresModel.get(featureValueModels.indexOf(model))
.getObject().feature;
selectedAnnotationLayer = feature.getLayer();
selectedFeatureValues.put(feature, model.getObject());
}
info(generateMessage(selectedAnnotationLayer, null, true));
// A hack to rememeber the Visural DropDown display
// value
bratAnnotatorModel.setRememberedSpanLayer(selectedAnnotationLayer);
bratAnnotatorModel.setRememberedSpanFeatures(selectedFeatureValues);
selectedSpanText = "";
selectedAnnotationId = -1;
aTarget.add(annotationFeatureForm);
// setLayerAndFeatureModels(jCas);
bratRender(aTarget, jCas);
onChange(aTarget, getModelObject());
}
repository.updateJCas(bratAnnotatorModel.getMode(), bratAnnotatorModel.getDocument(),
bratAnnotatorModel.getUser(), jCas);
// update timestamp now
int sentenceNumber = BratAjaxCasUtil.getSentenceNumber(jCas, beginOffset);
bratAnnotatorModel.getDocument().setSentenceAccessed(sentenceNumber);
repository.updateTimeStamp(bratAnnotatorModel.getDocument(), bratAnnotatorModel.getUser(),
bratAnnotatorModel.getMode());
if (bratAnnotatorModel.isScrollPage()) {
updateSentenceAddressAndOffsets(jCas, beginOffset);
}
bratAnnotatorModel.setRememberedSpanLayer(selectedAnnotationLayer);
bratAnnotatorModel.setAnnotate(false);
// store latest annotations
for (IModel<String> model : featureValueModels) {
AnnotationFeature feature = featuresModel.get(featureValueModels.indexOf(model))
.getObject().feature;
selectedAnnotationLayer = feature.getLayer();
selectedFeatureValues.put(feature, model.getObject());
}
info(generateMessage(selectedAnnotationLayer, null, true));
// A hack to rememeber the Visural DropDown display
// value
bratAnnotatorModel.setRememberedSpanLayer(selectedAnnotationLayer);
bratAnnotatorModel.setRememberedSpanFeatures(selectedFeatureValues);
selectedSpanText = "";
selectedAnnotationId = -1;
aTarget.add(annotationFeatureForm);
// setLayerAndFeatureModels(jCas);
bratRender(aTarget, jCas);
onChange(aTarget, getModelObject());
}