Search in sources :

Example 1 with TextField

use of com.googlecode.wicket.kendo.ui.form.TextField in project webanno by webanno.

the class AnnotationFeatureForm method createForwardAnnotationTextField.

private TextField<String> createForwardAnnotationTextField() {
    TextField<String> textfield = new TextField<>("forwardAnno");
    textfield.setOutputMarkupId(true);
    textfield.add(new AjaxFormComponentUpdatingBehavior("keyup") {

        private static final long serialVersionUID = 4554834769861958396L;

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            IAjaxCallListener listener = new AjaxCallListener() {

                private static final long serialVersionUID = -7968540662654079601L;

                @Override
                public CharSequence getPrecondition(Component component) {
                    return "var keycode = Wicket.Event.keyCode(attrs.event);    return true;";
                }
            };
            attributes.getAjaxCallListeners().add(listener);
            attributes.getDynamicExtraParameters().add("var eventKeycode = Wicket.Event" + ".keyCode(attrs.event);return {keycode: eventKeycode};");
            attributes.setPreventDefault(false);
        }

        @Override
        protected void onUpdate(AjaxRequestTarget aTarget) {
            final Request request = RequestCycle.get().getRequest();
            final String jsKeycode = request.getRequestParameters().getParameterValue("keycode").toString("");
            if (jsKeycode.equals("32")) {
                try {
                    JCas jCas = editorPanel.getEditorCas();
                    editorPanel.actionCreateForward(aTarget, jCas);
                    selectedTag = "";
                } catch (Exception e) {
                    handleException(textfield, aTarget, e);
                }
                return;
            }
            if (jsKeycode.equals("13")) {
                selectedTag = "";
                return;
            }
            selectedTag = (textfield.getModelObject() == null ? "" : textfield.getModelObject().charAt(0)) + selectedTag;
            Map<String, String> bindTags = getBindTags();
            if (!bindTags.isEmpty()) {
                List<FeatureState> featureStates = getModelObject().getFeatureStates();
                featureStates.get(0).value = getKeyBindValue(selectedTag, bindTags);
            }
            aTarget.add(textfield);
            aTarget.add(featureEditorPanelContent.get(0));
        }
    });
    textfield.add(new AttributeAppender("style", "opacity:0", ";"));
    // forwardAnno.add(new AttributeAppender("style", "filter:alpha(opacity=0)", ";"));
    return textfield;
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) IAjaxCallListener(org.apache.wicket.ajax.attributes.IAjaxCallListener) Request(org.apache.wicket.request.Request) JCas(org.apache.uima.jcas.JCas) AnnotationDetailEditorPanel.handleException(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.detail.AnnotationDetailEditorPanel.handleException) AnnotationException(de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException) IOException(java.io.IOException) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) TextField(com.googlecode.wicket.kendo.ui.form.TextField) List(java.util.List) ArrayList(java.util.ArrayList) Component(org.apache.wicket.Component) IAjaxCallListener(org.apache.wicket.ajax.attributes.IAjaxCallListener) AjaxCallListener(org.apache.wicket.ajax.attributes.AjaxCallListener) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Aggregations

TextField (com.googlecode.wicket.kendo.ui.form.TextField)1 AnnotationException (de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException)1 AnnotationDetailEditorPanel.handleException (de.tudarmstadt.ukp.clarin.webanno.ui.annotation.detail.AnnotationDetailEditorPanel.handleException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 JCas (org.apache.uima.jcas.JCas)1 Component (org.apache.wicket.Component)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AjaxCallListener (org.apache.wicket.ajax.attributes.AjaxCallListener)1 AjaxRequestAttributes (org.apache.wicket.ajax.attributes.AjaxRequestAttributes)1 IAjaxCallListener (org.apache.wicket.ajax.attributes.IAjaxCallListener)1 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)1 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)1 Request (org.apache.wicket.request.Request)1