<commit_before>package com.eas.bound;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.eas.client.IdGenerator;
import com.eas.client.converters.StringValueConverter;
import com.eas.core.Utils;
import com.eas.ui.CommonResources;
import com.eas.ui.HasEmptyText;
import com.eas.ui.JavaScriptObjectKeyProvider;
import com.eas.ui.PublishedCell;
import com.eas.ui.events.ActionEvent;
import com.eas.ui.events.ActionHandler;
import com.eas.ui.events.HasActionHandlers;
import com.eas.widgets.WidgetsUtils;
import com.eas.widgets.boxes.StyledListBox;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.InputElement;
import com.google.gwt.dom.client.Style;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.HasValue;

public class ModelCombo extends ModelDecoratorBox<JavaScriptObject> implements HasEmptyText, HasActionHandlers {

    protected static final String CUSTOM_DROPDOWN_CLASS = "combo-field-custom-dropdown";
    protected JavaScriptObjectKeyProvider rowKeyProvider = new JavaScriptObjectKeyProvider();
    protected String keyForNullValue = String.valueOf(IdGenerator.genId());
    protected String emptyText;
    protected JavaScriptObject displayList;
    protected String displayField;
    protected HandlerRegistration boundToList;
    protected HandlerRegistration boundToListElements;
    protected Runnable onRedraw;
    protected InputElement nonListMask = Document.get().createTextInputElement();

    protected boolean list = true;

    public ModelCombo() {
        super(new StyledListBox<JavaScriptObject>());
        StyledListBox<JavaScriptObject> box = (StyledListBox<JavaScriptObject>) decorated;
        box.addItem("...", keyForNullValue, null, "");
        box.getElement().addClassName(CUSTOM_DROPDOWN_CLASS);
        box.getElement().getStyle().setOverflow(Style.Overflow.HIDDEN);
        CommonResources.INSTANCE.commons().ensureInjected();
        box.getElement().addClassName(CommonResources.INSTANCE.commons().withoutDropdown());
        nonListMask.setReadOnly(true);
        nonListMask.addClassName(CommonResources.INSTANCE.commons().borderSized());
        nonListMask.getStyle().setPosition(Style.Position.ABSOLUTE);
        nonListMask.getStyle().setDisplay(Style.Display.NONE);
        nonListMask.getStyle().setTop(0, Style.Unit.PX);
        nonListMask.getStyle().setLeft(0, Style.Unit.PX);
        nonListMask.getStyle().setWidth(100, Style.Unit.PCT);
        nonListMask.getStyle().setHeight(100, Style.Unit.PCT);

        getElement().insertFirst(nonListMask);

        selectButton.getElement().addClassName("decorator-select-combo");
        clearButton.getElement().addClassName("decorator-clear-combo");
    }

    @Override
    public void setFocus(boolean focused) {
        if (list) {
            super.setFocus(focused);
        } else {
            nonListMask.focus();
        }
    }

    @Override
    protected int organizeButtonsContent() {
        int right = super.organizeButtonsContent();
        if (nonListMask != null) {
            nonListMask.getStyle().setPaddingRight(right, Style.Unit.PX);
        }
        return right;
    }

    public Runnable getOnRedraw() {
        return onRedraw;
    }

    public void setOnRedraw(Runnable aValue) {
        onRedraw = aValue;
    }

    protected int actionHandlers;
    protected HandlerRegistration valueChangeReg;

    @Override
    public HandlerRegistration addActionHandler(ActionHandler handler) {
        final HandlerRegistration superReg = super.addHandler(handler, ActionEvent.getType());
        if (actionHandlers == 0) {
            valueChangeReg = addValueChangeHandler(new ValueChangeHandler<JavaScriptObject>() {

                @Override
                public void onValueChange(ValueChangeEvent<JavaScriptObject> event) {
                    if (!settingValue)
                        ActionEvent.fire(ModelCombo.this, ModelCombo.this);
                }

            });
        }
        actionHandlers++;
        return new HandlerRegistration() {
            @Override
            public void removeHandler() {
                superReg.removeHandler();
                actionHandlers--;
                if (actionHandlers == 0) {
                    assert valueChangeReg != null : "Erroneous use of addActionHandler/removeHandler detected in ModelDate";
                    valueChangeReg.removeHandler();
                    valueChangeReg = null;
                }
            }
        };
    }

    public void setValue(JavaScriptObject aValue, boolean fireEvents) {
        JavaScriptObject oldValue = getValue();
        if (oldValue != aValue) {
            super.setValue(aValue, fireEvents);
            nonListMask.setValue(calcLabel(aValue));
        }
    }

    @Override
    protected void onAttach() {
        super.onAttach();
    }

    @Override
    protected void clearValue() {
        try {
            setJsValue(null, true);
            ActionEvent.fire(this, this);
        } catch (Exception e) {
            e.printStackTrace();
        }<commit_msg>Error message text fix<commit_after>package com.eas.bound;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.eas.client.IdGenerator;
import com.eas.client.converters.StringValueConverter;
import com.eas.core.Utils;
import com.eas.ui.CommonResources;
import com.eas.ui.HasEmptyText;
import com.eas.ui.JavaScriptObjectKeyProvider;
import com.eas.ui.PublishedCell;
import com.eas.ui.events.ActionEvent;
import com.eas.ui.events.ActionHandler;
import com.eas.ui.events.HasActionHandlers;
import com.eas.widgets.WidgetsUtils;
import com.eas.widgets.boxes.StyledListBox;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.InputElement;
import com.google.gwt.dom.client.Style;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.HasValue;

public class ModelCombo extends ModelDecoratorBox<JavaScriptObject> implements HasEmptyText, HasActionHandlers {

    protected static final String CUSTOM_DROPDOWN_CLASS = "combo-field-custom-dropdown";
    protected JavaScriptObjectKeyProvider rowKeyProvider = new JavaScriptObjectKeyProvider();
    protected String keyForNullValue = String.valueOf(IdGenerator.genId());
    protected String emptyText;
    protected JavaScriptObject displayList;
    protected String displayField;
    protected HandlerRegistration boundToList;
    protected HandlerRegistration boundToListElements;
    protected Runnable onRedraw;
    protected InputElement nonListMask = Document.get().createTextInputElement();

    protected boolean list = true;

    public ModelCombo() {
        super(new StyledListBox<JavaScriptObject>());
        StyledListBox<JavaScriptObject> box = (StyledListBox<JavaScriptObject>) decorated;
        box.addItem("...", keyForNullValue, null, "");
        box.getElement().addClassName(CUSTOM_DROPDOWN_CLASS);
        box.getElement().getStyle().setOverflow(Style.Overflow.HIDDEN);
        CommonResources.INSTANCE.commons().ensureInjected();
        box.getElement().addClassName(CommonResources.INSTANCE.commons().withoutDropdown());
        nonListMask.setReadOnly(true);
        nonListMask.addClassName(CommonResources.INSTANCE.commons().borderSized());
        nonListMask.getStyle().setPosition(Style.Position.ABSOLUTE);
        nonListMask.getStyle().setDisplay(Style.Display.NONE);
        nonListMask.getStyle().setTop(0, Style.Unit.PX);
        nonListMask.getStyle().setLeft(0, Style.Unit.PX);
        nonListMask.getStyle().setWidth(100, Style.Unit.PCT);
        nonListMask.getStyle().setHeight(100, Style.Unit.PCT);

        getElement().insertFirst(nonListMask);

        selectButton.getElement().addClassName("decorator-select-combo");
        clearButton.getElement().addClassName("decorator-clear-combo");
    }

    @Override
    public void setFocus(boolean focused) {
        if (list) {
            super.setFocus(focused);
        } else {
            nonListMask.focus();
        }
    }

    @Override
    protected int organizeButtonsContent() {
        int right = super.organizeButtonsContent();
        if (nonListMask != null) {
            nonListMask.getStyle().setPaddingRight(right, Style.Unit.PX);
        }
        return right;
    }

    public Runnable getOnRedraw() {
        return onRedraw;
    }

    public void setOnRedraw(Runnable aValue) {
        onRedraw = aValue;
    }

    protected int actionHandlers;
    protected HandlerRegistration valueChangeReg;

    @Override
    public HandlerRegistration addActionHandler(ActionHandler handler) {
        final HandlerRegistration superReg = super.addHandler(handler, ActionEvent.getType());
        if (actionHandlers == 0) {
            valueChangeReg = addValueChangeHandler(new ValueChangeHandler<JavaScriptObject>() {

                @Override
                public void onValueChange(ValueChangeEvent<JavaScriptObject> event) {
                    if (!settingValue)
                        ActionEvent.fire(ModelCombo.this, ModelCombo.this);
                }

            });
        }
        actionHandlers++;
        return new HandlerRegistration() {
            @Override
            public void removeHandler() {
                superReg.removeHandler();
                actionHandlers--;
                if (actionHandlers == 0) {
                    assert valueChangeReg != null : "Erroneous use of addActionHandler/removeHandler detected in ModelCombo";
                    valueChangeReg.removeHandler();
                    valueChangeReg = null;
                }
            }
        };
    }

    public void setValue(JavaScriptObject aValue, boolean fireEvents) {
        JavaScriptObject oldValue = getValue();
        if (oldValue != aValue) {
            super.setValue(aValue, fireEvents);
            nonListMask.setValue(calcLabel(aValue));
        }
    }

    @Override
    protected void onAttach() {
        super.onAttach();
    }

    @Override
    protected void clearValue() {
        try {
            setJsValue(null, true);
            ActionEvent.fire(this, this);
        } catch (Exception e) {
            e.printStackTrace();
        }
{'fraction_non_alphanumeric': 0.10154810173239956, 'fraction_numerical': 0.0018429782528566164, 'mean_word_length': 2.990073529411765, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6740937', 'n_tokens_mistral': 3020, 'n_tokens_neox': 2895, 'n_words': 515}