Skip to content

Commit

Permalink
Merge branch 'main' into feature/2312-external-recommender-v2
Browse files Browse the repository at this point in the history
* main: (64 commits)
  #3610 - Minimizing icon in document level feature is wrong after updating feature
  #3656 - The color of the existing layers changes after adding another layer
  #3679 - NullPointerException during export in WebAnno format
  #283 - Resize span
  #283 - Resize span
  #283 - Resize span
  #3675 - Clean up more brat code
  #3675 - Clean up more brat code
  #3675 - Clean up more brat code
  #3676 - Error when rejecting annotation suggestion
  #3675 - Clean up more brat code
  #1535 - Keyboard shortcuts do not work when focus is in certain editors
  #3571 - Update dependencies
  #3670 - Remove LIF support
  #3670 - Remove LIF support
  #3668 - Disable tutorial for now
  #3664 - Avoid server-side HTML composition not using Wicket
  #3664 - Avoid server-side HTML composition not using Wicket
  #283 - Resize span
  #3660 - Option to disable span clipping
  ...
  • Loading branch information
reckart committed Jan 4, 2023
2 parents 591f17e + ba84242 commit 2ff4386
Show file tree
Hide file tree
Showing 242 changed files with 25,523 additions and 13,234 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public FinishDocumentDialogContent(String aId, IModel<FinishDocumentDialogModel>

var state = new BootstrapRadioChoice<AnnotationDocumentState>("state",
asList(FINISHED, IGNORE));
state.setEscapeModelStrings(false);
state.setEscapeModelStrings(false); // SAFE - RENDERING ONLY CONTROLLED SET OF ICONS
state.setChoiceRenderer(new EnumChoiceRenderer<>(state));
form.add(state);
form.add(new TextArea<>("comment").add(new StringValidator(0, MAX_COMMENT_LENGTH)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ public KeybindingLabel(String aId, KeyBinding aLabel)
protected void onInitialize()
{
super.onInitialize();
setEscapeModelStrings(false);
setEscapeModelStrings(false); // SAFE - RENDERING ONLY CONTROLLED SET OF KEYS
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package de.tudarmstadt.ukp.clarin.webanno.api.annotation.rendering;

import static java.lang.invoke.MethodHandles.lookup;
import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang3.exception.ExceptionUtils.getRootCauseMessage;
import static org.slf4j.LoggerFactory.getLogger;

Expand Down Expand Up @@ -98,8 +100,14 @@ public void render(VDocument aVDoc, RenderRequest aRequest)
allLayers = schemaService.listAnnotationLayer(aRequest.getProject());
}

// Sort layers by creation order (i.e. by ID) to ensure the colors remain the same even
// if a new layer is added to a project
var sortedLayers = allLayers.stream() //
.sorted(comparing(AnnotationLayer::getId)) //
.collect(toList());

Map<String[], Queue<String>> colorQueues = new HashMap<>();
for (AnnotationLayer layer : allLayers) {
for (AnnotationLayer layer : sortedLayers) {
ColoringStrategy coloringStrategy = aRequest.getColoringStrategyOverride()
.orElse(coloringService.getStrategy(layer, prefs.get(), colorQueues));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ public static <T extends AnnotationFS> T getNext(T aRef)
return null;
}

// First match is a hit?
// If the first annotation we hit is already the reference annotation, we can simply
// move on to the next one and are done.
if (it.get() == aRef) {
it.moveToNext();
return it.isValid() ? (T) it.get() : null;
Expand All @@ -389,6 +390,7 @@ public static <T extends AnnotationFS> T getNext(T aRef)
it.moveToNext();
return it.isValid() ? (T) it.get() : null;
}
it.moveToNext();
}

return null;
Expand All @@ -405,7 +407,8 @@ public static <T extends AnnotationFS> T getPrev(T aRef)
return null;
}

// First match is a hit?
// If the first annotation we hit is already the reference annotation, we can simply
// move on to the previous one and are done.
if (it.get() == aRef) {
it.moveToPrevious();
return it.isValid() ? (T) it.get() : null;
Expand All @@ -427,6 +430,7 @@ public static <T extends AnnotationFS> T getPrev(T aRef)
it.moveToPrevious();
return it.isValid() ? (T) it.get() : null;
}
it.moveToNext();
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import de.tudarmstadt.ukp.clarin.webanno.model.Tag;
import de.tudarmstadt.ukp.inception.annotation.feature.string.KendoChoiceDescriptionScriptReference;
import de.tudarmstadt.ukp.inception.rendering.editorstate.FeatureState;
import de.tudarmstadt.ukp.inception.support.kendo.KendoStyleUtils;

public class ReorderableTagAutoCompleteField
extends AutoCompleteTextField<ReorderableTag>
Expand Down Expand Up @@ -71,21 +72,20 @@ protected List<ReorderableTag> getChoices(String aTerm)
}

@Override
public void onConfigure(JQueryBehavior behavior)
public void onConfigure(JQueryBehavior aBehavior)
{
super.onConfigure(behavior);
super.onConfigure(aBehavior);

behavior.setOption("delay", 500);
behavior.setOption("animation", false);
behavior.setOption("footerTemplate",
aBehavior.setOption("delay", 500);
aBehavior.setOption("animation", false);
aBehavior.setOption("footerTemplate",
Options.asString("#: instance.dataSource.total() # items found"));
// Prevent scrolling action from closing the dropdown while the focus is on the
// input field
behavior.setOption("close",
String.join(" ", "function(e) {",
" if (document.activeElement == e.sender.element[0]) {",
" e.preventDefault();" + " }", "}"));
behavior.setOption("select", " function (e) { this.trigger('change'); }");

KendoStyleUtils.keepDropdownVisibleWhenScrolling(aBehavior);
KendoStyleUtils.autoDropdownHeight(aBehavior);
// KendoStyleUtils.autoDropdownWidth(aBehavior);

aBehavior.setOption("select", " function (e) { this.trigger('change'); }");
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.spring.injection.annot.SpringBean;

import com.googlecode.wicket.jquery.core.JQueryBehavior;
Expand All @@ -51,6 +52,9 @@
public class MultiSelectTextFeatureEditor
extends FeatureEditor
{
private static final String CID_TEXT_INDICATOR = "textIndicator";
private static final String CID_VALUE = "value";

private static final long serialVersionUID = 7469241620229001983L;

private @SpringBean AnnotationSchemaService annotationService;
Expand All @@ -61,32 +65,89 @@ public class MultiSelectTextFeatureEditor
// // For showing the status of Constraints rules kicking in.
// private RulesIndicator indicator = new RulesIndicator();

private final MultiSelect<ReorderableTag> field;
private FormComponent<?> field;

public MultiSelectTextFeatureEditor(String aId, MarkupContainer aOwner,
final IModel<FeatureState> aFeatureStateModel, AnnotationActionHandler aHandler)
{
super(aId, aOwner, CompoundPropertyModel.of(aFeatureStateModel));

field = new MultiSelect<ReorderableTag>("value", new ChoiceRenderer<>())
field = createInput();
add(field);

add(new ConstraintsInUseIndicator(CID_TEXT_INDICATOR, getModel()));
}

@SuppressWarnings("unchecked")
@Override
public void onConfigure()
{
super.onConfigure();

// Workaround for https://github.com/sebfz1/wicket-jquery-ui/issues/352
if ((isEnabledInHierarchy() && !(field instanceof MultiSelect))
|| !isEnabledInHierarchy() && (field instanceof MultiSelect)) {
field = (FormComponent<ReorderableTag>) field.replaceWith(createInput());
}

// Hides feature if "Hide un-constraint feature" is enabled and constraint rules are applied
// and feature doesn't match any constraint rule
// if enabled and constraints rule execution returns anything other than green
var featState = getModelObject();
setVisible(!featState.feature.isHideUnconstraintFeature() || //
(featState.indicator.isAffected()
&& featState.indicator.getStatusColor().equals("green")));
}

private FormComponent<?> createInput()
{
if (isEnabledInHierarchy()) {
return createEditableInput();
}
else {
return createReadOnlyInput();
}
}

@SuppressWarnings({ "unchecked", "rawtypes" })
private FormComponent<String> createReadOnlyInput()
{
var input = new com.googlecode.wicket.kendo.ui.form.multiselect. //
MultiSelect<String>(CID_VALUE)
{
private static final long serialVersionUID = 1L;

@Override
public void onConfigure(JQueryBehavior aBehavior)
{
super.onConfigure(aBehavior);
styleMultiSelect(aBehavior);
}
};
var choices = getChoices(getModel(), null).stream().map(t -> t.getName()).collect(toList());
input.setChoices(Model.ofList(choices));
return (FormComponent) input;
}

@SuppressWarnings({ "unchecked", "rawtypes" })
private FormComponent<ReorderableTag> createEditableInput()
{
return (FormComponent) new MultiSelect<ReorderableTag>(CID_VALUE, new ChoiceRenderer<>())
{
private static final long serialVersionUID = 7769511105678209462L;

@Override
protected List<ReorderableTag> getChoices(String aInput)
{
return MultiSelectTextFeatureEditor.this.getChoices(aFeatureStateModel, aInput);
return MultiSelectTextFeatureEditor.this
.getChoices(MultiSelectTextFeatureEditor.this.getModel(), aInput);
}

@Override
public void onConfigure(JQueryBehavior aBehavior)
{
super.onConfigure(aBehavior);

aBehavior.setOption("autoWidth", true);
aBehavior.setOption("animation", false);
aBehavior.setOption("delay", 250);
aBehavior.setOption("height", 300);
styleMultiSelect(aBehavior);
}

@Override
Expand All @@ -103,7 +164,6 @@ protected IJQueryTemplate newTemplate()
* return strings on the way out into the model. This is a very evil hack and we need to
* avoid declaring generic types because we work against them!
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void convertInput()
{
Expand All @@ -114,9 +174,14 @@ public void convertInput()
.collect(toList()));
}
};
add(field);
}

add(new ConstraintsInUseIndicator("textIndicator", getModel()));
private void styleMultiSelect(JQueryBehavior aBehavior)
{
aBehavior.setOption("autoWidth", true);
aBehavior.setOption("animation", false);
aBehavior.setOption("delay", 250);
aBehavior.setOption("height", 300);
}

@SuppressWarnings("rawtypes")
Expand All @@ -126,22 +191,6 @@ public FormComponent getFocusComponent()
return field;
}

/**
* Hides feature if "Hide un-constraint feature" is enabled and constraint rules are applied and
* feature doesn't match any constraint rule
*/
@Override
public void onConfigure()
{
super.onConfigure();

// if enabled and constraints rule execution returns anything other than green
var featState = getModelObject();
setVisible(!featState.feature.isHideUnconstraintFeature() || //
(featState.indicator.isAffected()
&& featState.indicator.getStatusColor().equals("green")));
}

private List<ReorderableTag> getChoices(final IModel<FeatureState> aFeatureStateModel,
String aInput)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public NumberFeatureEditor(String aId, MarkupContainer aItem, IModel<FeatureStat
switch (getModelObject().feature.getType()) {
case CAS.TYPE_NAME_INTEGER: {
Options options = new Options();
options.set("format", "'n0'");
options.set("format", "'#'");
field = new NumberTextField<>("value", Integer.class, options);
if (aTraits.isLimited()) {
field.setMinimum(aTraits.getMinimum());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</span>
</label>
<div class="feature-editor-value">
<input wicket:id="value"></input>
<input wicket:id="value" type="text"></input>
<div wicket:id="keyBindings" class="col-sm-12"/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</label>
<div class="feature-editor-value">
<span style="padding: 0px;">
<input wicket:id="value"></input>
<input wicket:id="value" type="text"></input>
</span>
<div wicket:id="keyBindings" class="col-sm-12"/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.spring.injection.annot.SpringBean;

import com.googlecode.wicket.jquery.core.Options;
import com.googlecode.wicket.kendo.ui.form.NumberTextField;

import de.tudarmstadt.ukp.clarin.webanno.api.annotation.keybindings.KeyBindingsConfigurationPanel;
Expand Down Expand Up @@ -97,17 +98,19 @@ protected void onSubmit()
add(form);

NumberTextField<Integer> collapsedRows = new NumberTextField<>("collapsedRows",
Integer.class);
Integer.class, new Options().set("format", "'#'"));
collapsedRows.setModel(PropertyModel.of(traits, "collapsedRows"));
collapsedRows.setMinimum(1);
collapsedRows.setMaximum(100);
collapsedRows.add(visibleWhen(
() -> traits.getObject().isMultipleRows() && !traits.getObject().isDynamicSize()));
form.add(collapsedRows);

NumberTextField<Integer> expandedRows = new NumberTextField<>("expandedRows",
Integer.class);
NumberTextField<Integer> expandedRows = new NumberTextField<>("expandedRows", Integer.class,
new Options().set("format", "'#'"));
expandedRows.setModel(PropertyModel.of(traits, "expandedRows"));
expandedRows.setMinimum(1);
collapsedRows.setMaximum(100);
expandedRows.add(visibleWhen(
() -> traits.getObject().isMultipleRows() && !traits.getObject().isDynamicSize()));
form.add(expandedRows);
Expand Down
Loading

0 comments on commit 2ff4386

Please sign in to comment.