Search in sources :

Example 1 with DefaultLayerChangedEvent

use of de.tudarmstadt.ukp.clarin.webanno.ui.annotation.event.DefaultLayerChangedEvent in project webanno by webanno.

the class LayerSelectionPanel method actionChangeDefaultLayer.

private void actionChangeDefaultLayer(AjaxRequestTarget aTarget) {
    AnnotatorState state = getModelObject();
    aTarget.add(relationHint);
    aTarget.add(forwardAnnotationGroup);
    // If forward annotation was enabled, disable it
    if (state.isForwardAnnotation()) {
        state.setForwardAnnotation(false);
    }
    send(this, Broadcast.BUBBLE, new DefaultLayerChangedEvent(layerSelector.getModelObject()));
    // Save the currently selected layer as a user preference so it is remains active when a
    // user leaves the application and later comes back to continue annotating
    long prevDefaultLayer = state.getPreferences().getDefaultLayer();
    if (state.getDefaultAnnotationLayer() != null) {
        state.getPreferences().setDefaultLayer(state.getDefaultAnnotationLayer().getId());
    } else {
        state.getPreferences().setDefaultLayer(-1);
    }
    if (prevDefaultLayer != state.getPreferences().getDefaultLayer()) {
        try {
            userPreferencesService.savePreferences(state.getProject(), userDao.getCurrentUsername(), state.getMode(), state.getPreferences());
        } catch (IOException e) {
            handleException(this, aTarget, e);
        }
    }
}
Also used : DefaultLayerChangedEvent(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.event.DefaultLayerChangedEvent) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) IOException(java.io.IOException)

Aggregations

AnnotatorState (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState)1 DefaultLayerChangedEvent (de.tudarmstadt.ukp.clarin.webanno.ui.annotation.event.DefaultLayerChangedEvent)1 IOException (java.io.IOException)1