diff --git a/inception/inception-ui-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/project/layers/ProjectLayersPanel.java b/inception/inception-ui-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/project/layers/ProjectLayersPanel.java
index 73ece6c709e..1080ee8fd7f 100644
--- a/inception/inception-ui-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/project/layers/ProjectLayersPanel.java
+++ b/inception/inception-ui-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/project/layers/ProjectLayersPanel.java
@@ -81,9 +81,11 @@
import de.tudarmstadt.ukp.clarin.webanno.ui.core.settings.ProjectSettingsPanelBase;
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence;
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token;
+import de.tudarmstadt.ukp.inception.annotation.layer.chain.ChainLayerSupport;
import de.tudarmstadt.ukp.inception.bootstrap.BootstrapFileInputField;
import de.tudarmstadt.ukp.inception.bootstrap.BootstrapModalDialog;
import de.tudarmstadt.ukp.inception.export.LayerImportExportUtils;
+import de.tudarmstadt.ukp.inception.project.api.FeatureInitializer;
import de.tudarmstadt.ukp.inception.project.api.ProjectInitializationRequest;
import de.tudarmstadt.ukp.inception.project.api.ProjectService;
import de.tudarmstadt.ukp.inception.schema.api.AnnotationSchemaService;
@@ -169,13 +171,9 @@ public class LayerSelectionPane
private static final long serialVersionUID = -1L;
private final Map
colors = new HashMap<>();
-
private final BootstrapModalDialog dialog;
-
private final Select layerSelection;
-
private final IModel> layerInitializers;
-
private final LambdaAjaxLink addButton;
public LayerSelectionPane(String id, IModel aModel)
@@ -189,14 +187,14 @@ public LayerSelectionPane(String id, IModel aModel)
dialog.trapFocus();
queue(dialog);
- add(new DocLink("helpLinkLayers", "sect_projects_layers"));
+ queue(new DocLink("helpLinkLayers", "sect_projects_layers"));
- add(new LambdaAjaxLink("create", this::actionCreateLayer));
+ queue(new LambdaAjaxLink("create", this::actionCreateLayer));
addButton = new LambdaAjaxLink("add", this::actionAddLayer);
addButton.setOutputMarkupPlaceholderTag(true);
addButton.add(visibleWhenNot(layerInitializers.map(List::isEmpty)));
- add(addButton);
+ queue(addButton);
layerSelection = new Select<>("layerSelection", aModel);
var layers = new ListView("layers", LambdaModel.of(this::listLayers))
@@ -223,7 +221,7 @@ public void onComponentTagBody(MarkupStream markupStream,
}
};
- add(layerSelection.add(layers));
+ queue(layerSelection.add(layers));
layerSelection.setOutputMarkupId(true);
layerSelection.add(OnChangeAjaxBehavior.onChange(_target -> {
featureDetailForm.setModelObject(null);
@@ -292,7 +290,7 @@ public void onLayerTemplateSelected(LayerTemplateSelectedEvent aEvent)
var request = ProjectInitializationRequest.builder().withProject(getModelObject())
.build();
projectService.initializeProject(request, asList(initializer));
- info("Applying project initializer [" + initializer.getName() + "]");
+ success("Applied project initializer [" + initializer.getName() + "]");
}
catch (Exception e) {
error("Error applying project initializer [" + initializer.getName() + "]: "
@@ -441,6 +439,9 @@ public class FeatureSelectionForm
private LambdaAjaxLink btnMoveUp;
private LambdaAjaxLink btnMoveDown;
private ListChoice overviewList;
+ private final BootstrapModalDialog dialog;
+ private final IModel> featureInitializers;
+ private final LambdaAjaxLink addButton;
public FeatureSelectionForm(String id, IModel aModel)
{
@@ -448,6 +449,18 @@ public FeatureSelectionForm(String id, IModel aModel)
setOutputMarkupPlaceholderTag(true);
+ featureInitializers = LoadableDetachableModel.of(this::listFeatureInitializers);
+ add(LambdaBehavior.onDetach(featureInitializers::detach));
+
+ dialog = new BootstrapModalDialog(MID_DIALOG);
+ dialog.trapFocus();
+ queue(dialog);
+
+ addButton = new LambdaAjaxLink("add", this::actionAddFeature);
+ addButton.setOutputMarkupPlaceholderTag(true);
+ addButton.add(visibleWhenNot(featureInitializers.map(List::isEmpty)));
+ queue(addButton);
+
add(new DocLink("featuresHelpLink", "sect_projects_layers_features"));
overviewList = new ListChoice("feature")
@@ -560,7 +573,7 @@ private void actionCreateFeature(AjaxRequestTarget aTarget)
// cancel selection of feature list
selectedFeature.setObject(null);
- AnnotationFeature newFeature = new AnnotationFeature();
+ var newFeature = new AnnotationFeature();
newFeature.setLayer(layerDetailForm.getModelObject());
newFeature.setProject(ProjectLayersPanel.this.getModelObject());
featureDetailForm.setDefaultModelObject(newFeature);
@@ -573,14 +586,23 @@ private void actionCreateFeature(AjaxRequestTarget aTarget)
+ featureDetailForm.getInitialFocusComponent().getMarkupId() + "').focus();"));
}
+ private void actionAddFeature(AjaxRequestTarget aTarget)
+ {
+ var dialogContent = new FeatureTemplateSelectionDialogPanel(
+ BootstrapModalDialog.CONTENT_ID, ProjectLayersPanel.this.getModel(),
+ featureInitializers);
+ dialog.open(dialogContent, aTarget);
+ }
+
private List listFeatures()
{
- List features = annotationService
+ var features = annotationService
.listAnnotationFeature(layerDetailForm.getModelObject());
- if (CHAIN_TYPE.equals(layerDetailForm.getModelObject().getType())
+
+ if (ChainLayerSupport.TYPE.equals(layerDetailForm.getModelObject().getType())
&& !layerDetailForm.getModelObject().isLinkedListBehavior()) {
- List filtered = new ArrayList<>();
- for (AnnotationFeature f : features) {
+ var filtered = new ArrayList();
+ for (var f : features) {
if (!COREFERENCE_RELATION_FEATURE.equals(f.getName())) {
filtered.add(f);
}
@@ -592,6 +614,17 @@ private List listFeatures()
}
}
+ private List listFeatureInitializers()
+ {
+ if (!selectedLayer.isPresent().getObject()) {
+ return emptyList();
+ }
+
+ return projectService.listFeatureInitializers().stream()
+ .filter(initializer -> !initializer.alreadyApplied(selectedLayer.getObject()))
+ .toList();
+ }
+
@Override
protected void onConfigure()
{
@@ -600,5 +633,27 @@ protected void onConfigure()
setVisible(selectedLayer.getObject() != null
&& nonNull(selectedLayer.getObject().getId()));
}
+
+ @OnEvent
+ public void onFeatureTemplateSelected(FeatureTemplateSelectedEvent aEvent)
+ {
+ var target = aEvent.getTarget();
+ var initializer = aEvent.getLayerInitializer();
+ try {
+ target.add(overviewList);
+ target.add(addButton);
+ target.addChildren(getPage(), IFeedback.class);
+ initializer.configure(selectedLayer.getObject());
+ success("Applied feature initializer [" + initializer.getName() + "]");
+ }
+ catch (Exception e) {
+ error("Error applying feature initializer [" + initializer.getName() + "]: "
+ + ExceptionUtils.getRootCauseMessage(e));
+ LOG.error("Error applying feature initializer {}", initializer, e);
+ }
+
+ applicationEventPublisherHolder.get().publishEvent(new LayerConfigurationChangedEvent(
+ this, ProjectLayersPanel.this.getModelObject()));
+ }
}
}
diff --git a/inception/inception-ui-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/project/layers/ProjectLayersPanel.properties b/inception/inception-ui-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/project/layers/ProjectLayersPanel.properties
index d4ae34fac3e..467711a33b3 100755
--- a/inception/inception-ui-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/project/layers/ProjectLayersPanel.properties
+++ b/inception/inception-ui-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/project/layers/ProjectLayersPanel.properties
@@ -64,3 +64,4 @@ DeleteFeatureDialog.title=Confirmation
DeleteFeatureDialog.text=Are you sure you want to permanently delete the feature?
This action triggers a forced upgrade of all annotation documents to the modified type system. All users who are have currently opened documents from this project in the editor will be forced to reload the document before they can continue to work. Not reloading the document may lead to undefined situations.
Depending on the number of documents and annotators in this project, completing the deletion of the feature and upgrading all the annotations may take a while. To complete the action, please enter the feature name into the input field below.
addLayerDialogTitle=Add pre-defined layer...
+addFeatureDialogTitle=Add pre-defined feature...