All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nuiton.jaxx.widgets.select.BeanComboBox Maven / Gradle / Ivy

The newest version!
package org.nuiton.jaxx.widgets.select;

/*-
 * #%L
 * JAXX :: Widgets Select
 * %%
 * Copyright (C) 2008 - 2021 Code Lutin, Ultreia.io
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 *
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

import io.ultreia.java4all.decoration.Decorator;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JSeparator;
import javax.swing.JToggleButton;
import javax.swing.JToolBar;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.nuiton.jaxx.runtime.JAXXBinding;
import org.nuiton.jaxx.runtime.JAXXContext;
import org.nuiton.jaxx.runtime.JAXXObject;
import org.nuiton.jaxx.runtime.JAXXObjectDescriptor;
import org.nuiton.jaxx.runtime.JAXXUtil;
import org.nuiton.jaxx.runtime.bean.BeanScopeAware;
import org.nuiton.jaxx.runtime.bean.BeanTypeAware;
import org.nuiton.jaxx.runtime.binding.SimpleJAXXObjectBinding;
import org.nuiton.jaxx.runtime.context.DefaultJAXXContext;
import org.nuiton.jaxx.runtime.swing.JAXXButtonGroup;
import org.nuiton.jaxx.runtime.swing.SwingUtil;
import org.nuiton.jaxx.runtime.swing.Table;
import org.nuiton.jaxx.runtime.swing.model.JaxxDefaultComboBoxModel;
import org.nuiton.jaxx.widgets.select.actions.BeanComboBoxDisplayDecoratorAction;
import org.nuiton.jaxx.widgets.select.actions.BeanComboBoxResetAction;
import static io.ultreia.java4all.i18n.I18n.t;

public class BeanComboBox extends Table implements BeanTypeAware, BeanScopeAware, JAXXObject {

    /*-----------------------------------------------------------------------*/
    /*---------------- Constants for all javaBean properties ----------------*/
    /*-----------------------------------------------------------------------*/

    public static final String PROPERTY_AUTO_COMPLETE = "autoComplete";
    public static final String PROPERTY_AUTO_FOCUS = "autoFocus";
    public static final String PROPERTY_BEAN = "bean";
    public static final String PROPERTY_BEAN_TYPE = "beanType";
    public static final String PROPERTY_DATA = "data";
    public static final String PROPERTY_EDITABLE = "editable";
    public static final String PROPERTY_FORCE = "force";
    public static final String PROPERTY_I18N_PREFIX = "i18nPrefix";
    public static final String PROPERTY_INDEX = "index";
    public static final String PROPERTY_MAXIMUM_ROW_COUNT = "maximumRowCount";
    public static final String PROPERTY_NOT_SELECTED_TOOL_TIP_TEXT = "notSelectedToolTipText";
    public static final String PROPERTY_POPUP_TITLE_TEXT = "popupTitleText";
    public static final String PROPERTY_PROPERTY = "property";
    public static final String PROPERTY_REVERSE_SORT = "reverseSort";
    public static final String PROPERTY_SELECTED_ITEM = "selectedItem";
    public static final String PROPERTY_SELECTED_TOOL_TIP_TEXT = "selectedToolTipText";
    public static final String PROPERTY_SHOW_DECORATOR = "showDecorator";
    public static final String PROPERTY_SHOW_RESET = "showReset";
    public static final String PROPERTY_SORTABLE = "sortable";

    /*-----------------------------------------------------------------------*/
    /*------------------ Constants for all public bindings ------------------*/
    /*-----------------------------------------------------------------------*/

    public static final String BINDING_COMBOBOX_EDITABLE = "combobox.editable";
    public static final String BINDING_COMBOBOX_ENABLED = "combobox.enabled";
    public static final String BINDING_COMBOBOX_FOCUSABLE = "combobox.focusable";
    public static final String BINDING_COMBOBOX_MAXIMUM_ROW_COUNT = "combobox.maximumRowCount";
    public static final String BINDING_COMBOBOX_SELECTED_ITEM = "combobox.selectedItem";
    public static final String BINDING_DISPLAY_DECORATOR_ENABLED = "displayDecorator.enabled";
    public static final String BINDING_RESET_ENABLED = "reset.enabled";
    public static final String BINDING_SORT_DOWN_SELECTED = "sortDown.selected";
    public static final String BINDING_SORT_GROUP_SELECTED_VALUE = "sortGroup.selectedValue";
    public static final String BINDING_SORT_UP_SELECTED = "sortUp.selected";
    public static final String BINDING_TOOLBAR_LEFT_VISIBLE = "toolbarLeft.visible";
    public static final String BINDING_TOOLBAR_RIGHT_VISIBLE = "toolbarRight.visible";

    /*-----------------------------------------------------------------------*/
    /*------------------------- Other static fields -------------------------*/
    /*-----------------------------------------------------------------------*/

    private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAK1XT08bRxQfCAYMDn+aNlIPlRxIE1DLGm5RCUljCCmRKSnQCpVLx96xGbTe2e7MYiOLHHrorV+gh157qfIdop4q9dJr7u2tUj5C35vd9ewuS0xKOKzgvTfv/d6feb/ht39JQfrkU+G3LDfgSrjWMe12LT9wFW8z6+mjg4Od+jFrqA0mGz73lPBJ+DM0TIYPyaTdl0tFrMMaeKqEniroqRJ5qqyLtidc5iYcrdbIhFSnDpNHjClFFi483JCyste3XO16gR/FykWdF+vPH1deDbGNn4cJ6XoAfw7S/uQtHJisR2pkmNuKvFc7pie04lC3BeB87rYgoesoW3eolF/SNvuePCdjNTLqUR+cKbL0v8qj3WlXXU+Rsdv7tO6wZXUefofbLaakJZkDHbOqjLrgty6qout52sOoIuN1EO+fekyRaQRrYQKWjmGMSjRQAjE5TIHhrDGsCuGAA2M66bMT5ku2J3yFolmjKsoj0dllkmUV11GxwRrCp5BoRjnObK4wxaxcQoQceRGxbopGILMHPF94zFenisyYBMJWGasRrEfKIhz4RDHCejJ7S7E2yuaNrsBdm3VTFdpyFWsxPxHBpooqMqVNAsUdq8Zlwv90m3Z5O2jvis66gHlA8YJRj+kQDK7X0kXzKjuQkr6s1UCB9okvAi/ZB6iclqFg2ShuxJntQ1f3ubcPqaCqbExuukLtDbSa8oQXePtcOSxHO8FX7rnPfNbk3Yym0BR+I9vQgnYGobFg3Ti5ZyjcZm6QjYqDV6N15sCVTJ3QQjRd658YxUp8Db7LKctdanMRlg4jxH1eS8/ehui4+PfjtC5CweCS4zRncfcV6VMT+lQfYjWtLd0255ZR9jStn1TQijr1a6wJa+X9VEDsUpXqcEVTUx+vIXQ8ZRqmjCY7JtUGroy6gKH+IGUcr5K041KEZJe3jnTfv0rrZ2wuPYee9m+7Ih9m4LZaDjNIDjzYzHcumnRgAsswgVnKQ4eQYuDgLZm/mISQR3bBKmSQ+YsZBMNowx9ePPd/7bx+FdPGFIArDzqVYEjY4dEW4ohtOuQMXAKVbeqtHsLd1JdL0+fdNyPfiywBPaCYNevkCyqPwFth7NXL329+99c1MrxJJhxB7U2K9lukqI6g/0fCsbvew881uFJnHL4zCBNGOJAscblhZSk/YF2o0d0316gP6cXO6z9++enjl3GdhgDh7cucNLUqfEtGuetwl2mCjbgzl1AnPckCWxhizKNKYlZnvAvr+ts8V4JhpKRoyX1DnQApr8flrmG2hcWzi8uETo910vibQ5Ibd1BoqP5oXfg2TAhZ6bmsU9Zb1K5q2YJamEN+iu+kpbeGpdBkbnHxLC92uD4vkfIETAcX7lZDAP8VMcwSwsa0dHbTKLJQBMQGeyovWGYFD4pagNVVNxSVLFQGT6mPZwl1EaSSgYTSwknYrLFekzqSneGijtoIZNC7lW1hXgYRJbw75FMGuQ2M0cc+ZbCH8hj9aA/HKA3+/PjlYe/T0iD012DAwyl7RrmrIxR0yaB2J1xyeFVBvyHmXvxi0wNfbMIW0W+u2D4PRZKMLgGk2MS3WtIpgGAuCgDWRwDicfQAXFgs37lThr9DpYZU0qczWeReA814g/Bkn3fAkD14Q+8lRDps/1EKfUwhBF2hLWx8fczr6/sUNt0Ga9LAUTFjbqP+/s6DqKYmfZ1snFyUa9KzKcv1XroM2TejIqu9MgDfTovB6621shs4Tvlhvvqz8r1y/mzFO+edzNaNaLb6z4C3mK/UE+PKAzZ3HskVpuzc8+YS+36Eh3viPv5fUK4DR8FD6ME570P4fTTQH4r/xs8/+R42ruzhCXj4D3zlGfYpEAAA";
    private static final Logger log = LogManager.getLogger(BeanComboBox.class);
    private static final long serialVersionUID = 1L;

    /*-----------------------------------------------------------------------*/
    /*--------------------------- Internal states ---------------------------*/
    /*-----------------------------------------------------------------------*/

    protected List $activeBindings = new ArrayList();
    protected Map $bindingSources = new HashMap();
    protected final Map $bindings = new TreeMap();
    protected Map $objectMap = new HashMap();
    protected Map $previousValues = new HashMap();
    protected final JAXXContext delegateContext = new DefaultJAXXContext();

    /*-----------------------------------------------------------------------*/
    /*------------------------ Protected components  ------------------------*/
    /*-----------------------------------------------------------------------*/

    protected Boolean autoComplete;
    protected Boolean autoFocus;
    protected Object bean;
    protected Class beanType;
    protected JComboBox combobox;
    protected List data;
    protected JToggleButton displayDecorator;
    protected Boolean editable;
    protected Boolean force;
    protected BeanComboBoxHandler handler;
    protected String i18nPrefix;
    protected Integer index;
    protected JAXXButtonGroup indexes;
    protected Integer maximumRowCount;
    protected String notSelectedToolTipText;
    protected JPopupMenu popup;
    protected JLabel popupLabel;
    protected JSeparator popupSeparator;
    protected JLabel popupSortLabel;
    protected String popupTitleText;
    protected String property;
    protected JButton reset;
    protected Boolean reverseSort;
    protected Object selectedItem;
    protected String selectedToolTipText;
    protected Boolean showDecorator;
    protected Boolean showReset;
    protected JRadioButtonMenuItem sortDown;
    protected JAXXButtonGroup sortGroup;
    protected JRadioButtonMenuItem sortUp;
    protected Boolean sortable;
    protected JToolBar toolbarLeft;
    protected JToolBar toolbarRight;

    /*-----------------------------------------------------------------------*/
    /*------------------------- Private components  -------------------------*/
    /*-----------------------------------------------------------------------*/

    private JSeparator $JSeparator0;
    private BeanComboBox $Table0;

    /*-----------------------------------------------------------------------*/
    /*---------------------- Raw body code from script ----------------------*/
    /*-----------------------------------------------------------------------*/

    public static final String PROPERTY_EMPTY = "empty";
    
    
    public void init(Decorator decorator, List data) {
        handler.init(decorator, data);
    }
    
    protected void hidePopup() {
        if (popup.isVisible()) {
            popup.setVisible(false);
        }
    }
    
    public boolean isEmpty() { return handler.isEmpty(); }
    
    public void addItem(O item) { handler.addItem(item); }
    
    public void addItems(Iterable items) { handler.addItems(items); }
    
    public void removeItem(O item) { handler.removeItem(item); }
    
    public void removeItems(Iterable items) { handler.removeItems(items); }
    
    public JaxxDefaultComboBoxModel getComboBoxModel() { return (JaxxDefaultComboBoxModel) combobox.getModel(); }

    /*-----------------------------------------------------------------------*/
    /*---------------------------- Constructors  ----------------------------*/
    /*-----------------------------------------------------------------------*/

    public BeanComboBox() {
        $initialize();
    }

    public BeanComboBox(JAXXContext parentContext) {
        JAXXUtil.initContext(this, parentContext);
        $initialize();
    }

    /*-----------------------------------------------------------------------*/
    /*--------------------------- Statics methods ---------------------------*/
    /*-----------------------------------------------------------------------*/

    public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
        return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
    }

    /*-----------------------------------------------------------------------*/
    /*---------------------- JAXXObject implementation ----------------------*/
    /*-----------------------------------------------------------------------*/

    @Override
    public void applyDataBinding(String $binding) {
        if ($bindings.containsKey($binding)) {
            getDataBinding($binding).applyDataBinding();
        }
        processDataBinding($binding);
    }

    @Override
    public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
        super.firePropertyChange(propertyName, oldValue, newValue);
    }

    @Override
    public Map get$objectMap() {
        return $objectMap;
    }

    @Override
    public JAXXBinding getDataBinding(String bindingId) {
        return $bindings.get(bindingId);
    }

    @Override
    public JAXXBinding[] getDataBindings() {
        return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
    }

    @Override
    public Object getObjectById(String id) {
        return $objectMap.get(id);
    }

    @Override
    public void processDataBinding(String $binding, boolean $force) {
        if (!$force && $activeBindings.contains($binding)) { 
            return;
        }
        $activeBindings.add($binding);
        try {
            if ($bindings.containsKey($binding)) {
                getDataBinding($binding).processDataBinding();
            }
        } finally {
            $activeBindings.remove($binding);
        }
    }

    @Override
    public void processDataBinding(String $binding) {
        processDataBinding($binding, false);
    }

    @Override
    public void registerDataBinding(JAXXBinding binding) {
        $bindings.put(binding.getId(), binding);
    }

    @Override
    public void removeDataBinding(String $binding) {
        if ($bindings.containsKey($binding)) {
            getDataBinding($binding).removeDataBinding();
        }
    }

    /*-----------------------------------------------------------------------*/
    /*--------------------- JAXXContext implementation  ---------------------*/
    /*-----------------------------------------------------------------------*/

    @Override
    public  T getContextValue(Class clazz) {
        return delegateContext.getContextValue(clazz, null);
    }

    @Override
    public  T getContextValue(Class clazz, String name) {
        return delegateContext.getContextValue(clazz, name);
    }

    @Override
    public JAXXContext getDelegateContext() {
        return delegateContext;
    }

    @Override
    public  O getParentContainer(Class clazz) {
        return SwingUtil.getParentContainer(this, clazz);
    }

    @Override
    public  O getParentContainer(Object source, Class clazz) {
        return SwingUtil.getParentContainer(source, clazz);
    }

    @Override
    public  void removeContextValue(Class clazz) {
        delegateContext.removeContextValue(clazz, null);
    }

    @Override
    public  void removeContextValue(Class clazz, String name) {
        delegateContext.removeContextValue(clazz, name);
    }

    @Override
    public  void setContextValue(T o) {
        delegateContext.setContextValue(o, null);
    }

    @Override
    public  void setContextValue(T o, String name) {
        delegateContext.setContextValue(o, name);
    }

    /*-----------------------------------------------------------------------*/
    /*---------------------------- Event methods ----------------------------*/
    /*-----------------------------------------------------------------------*/

    public void doPopupMenuCanceled__on__popup(PopupMenuEvent event) {
        if (log.isDebugEnabled()) {
            log.debug(event);
        }
        getDisplayDecorator().setSelected(false);
    }

    public void doPopupMenuWillBecomeInvisible__on__popup(PopupMenuEvent event) {
        if (log.isDebugEnabled()) {
            log.debug(event);
        }
        getDisplayDecorator().setSelected(false);
    }

    public void doStateChanged__on__indexes(ChangeEvent event) {
        if (log.isDebugEnabled()) {
            log.debug(event);
        }
        setIndex((Integer)indexes.getSelectedValue());
    }

    public void doStateChanged__on__sortGroup(ChangeEvent event) {
        if (log.isDebugEnabled()) {
            log.debug(event);
        }
        setReverseSort((Boolean)sortGroup.getSelectedValue());
    }

    /*-----------------------------------------------------------------------*/
    /*----------------------- Public acessor methods  -----------------------*/
    /*-----------------------------------------------------------------------*/

    public Boolean getAutoComplete() {
        return autoComplete;
    }

    public Boolean getAutoFocus() {
        return autoFocus;
    }

    public Object getBean() {
        return bean;
    }

    public Class getBeanType() {
        return beanType;
    }

    public JComboBox getCombobox() {
        return combobox;
    }

    public List getData() {
        return data;
    }

    public JToggleButton getDisplayDecorator() {
        return displayDecorator;
    }

    public Boolean getEditable() {
        return editable;
    }

    public Boolean getForce() {
        return force;
    }

    public BeanComboBoxHandler getHandler() {
        return handler;
    }

    public String getI18nPrefix() {
        return i18nPrefix;
    }

    public Integer getIndex() {
        return index;
    }

    public JAXXButtonGroup getIndexes() {
        return indexes;
    }

    public Integer getMaximumRowCount() {
        return maximumRowCount;
    }

    public String getNotSelectedToolTipText() {
        return notSelectedToolTipText;
    }

    public JPopupMenu getPopup() {
        return popup;
    }

    public JLabel getPopupLabel() {
        return popupLabel;
    }

    public JSeparator getPopupSeparator() {
        return popupSeparator;
    }

    public JLabel getPopupSortLabel() {
        return popupSortLabel;
    }

    public String getPopupTitleText() {
        return popupTitleText;
    }

    public String getProperty() {
        return property;
    }

    public JButton getReset() {
        return reset;
    }

    public Boolean getReverseSort() {
        return reverseSort;
    }

    public Object getSelectedItem() {
        return selectedItem;
    }

    public String getSelectedToolTipText() {
        return selectedToolTipText;
    }

    public Boolean getShowDecorator() {
        return showDecorator;
    }

    public Boolean getShowReset() {
        return showReset;
    }

    public JRadioButtonMenuItem getSortDown() {
        return sortDown;
    }

    public JAXXButtonGroup getSortGroup() {
        return sortGroup;
    }

    public JRadioButtonMenuItem getSortUp() {
        return sortUp;
    }

    public Boolean getSortable() {
        return sortable;
    }

    public JToolBar getToolbarLeft() {
        return toolbarLeft;
    }

    public JToolBar getToolbarRight() {
        return toolbarRight;
    }

    public Boolean isAutoComplete() {
        return autoComplete !=null && autoComplete;
    }

    public Boolean isAutoFocus() {
        return autoFocus !=null && autoFocus;
    }

    public Boolean isEditable() {
        return editable !=null && editable;
    }

    public Boolean isForce() {
        return force !=null && force;
    }

    public Boolean isReverseSort() {
        return reverseSort !=null && reverseSort;
    }

    public Boolean isShowDecorator() {
        return showDecorator !=null && showDecorator;
    }

    public Boolean isShowReset() {
        return showReset !=null && showReset;
    }

    public Boolean isSortable() {
        return sortable !=null && sortable;
    }

    /*-----------------------------------------------------------------------*/
    /*----------------------- Public mutator methods  -----------------------*/
    /*-----------------------------------------------------------------------*/

    public void setAutoComplete(Boolean autoComplete) {
        Boolean oldValue = this.autoComplete;
        this.autoComplete = autoComplete;
        firePropertyChange(PROPERTY_AUTO_COMPLETE, oldValue, autoComplete);
    }

    public void setAutoFocus(Boolean autoFocus) {
        Boolean oldValue = this.autoFocus;
        this.autoFocus = autoFocus;
        firePropertyChange(PROPERTY_AUTO_FOCUS, oldValue, autoFocus);
    }

    public void setBean(Object bean) {
        Object oldValue = this.bean;
        this.bean = bean;
        firePropertyChange(PROPERTY_BEAN, oldValue, bean);
    }

    public void setBeanType(Class beanType) {
        Class oldValue = this.beanType;
        this.beanType = beanType;
        firePropertyChange(PROPERTY_BEAN_TYPE, oldValue, beanType);
    }

    public void setData(List data) {
        List oldValue = this.data;
        this.data = data;
        firePropertyChange(PROPERTY_DATA, oldValue, data);
    }

    public void setEditable(Boolean editable) {
        Boolean oldValue = this.editable;
        this.editable = editable;
        firePropertyChange(PROPERTY_EDITABLE, oldValue, editable);
    }

    public void setForce(Boolean force) {
        Boolean oldValue = this.force;
        this.force = force;
        firePropertyChange(PROPERTY_FORCE, oldValue, force);
    }

    public void setI18nPrefix(String i18nPrefix) {
        String oldValue = this.i18nPrefix;
        this.i18nPrefix = i18nPrefix;
        firePropertyChange(PROPERTY_I18N_PREFIX, oldValue, i18nPrefix);
    }

    public void setIndex(Integer index) {
        Integer oldValue = this.index;
        this.index = index;
        firePropertyChange(PROPERTY_INDEX, oldValue, index);
    }

    public void setMaximumRowCount(Integer maximumRowCount) {
        Integer oldValue = this.maximumRowCount;
        this.maximumRowCount = maximumRowCount;
        firePropertyChange(PROPERTY_MAXIMUM_ROW_COUNT, oldValue, maximumRowCount);
    }

    public void setNotSelectedToolTipText(String notSelectedToolTipText) {
        String oldValue = this.notSelectedToolTipText;
        this.notSelectedToolTipText = notSelectedToolTipText;
        firePropertyChange(PROPERTY_NOT_SELECTED_TOOL_TIP_TEXT, oldValue, notSelectedToolTipText);
    }

    public void setPopupTitleText(String popupTitleText) {
        String oldValue = this.popupTitleText;
        this.popupTitleText = popupTitleText;
        firePropertyChange(PROPERTY_POPUP_TITLE_TEXT, oldValue, popupTitleText);
    }

    public void setProperty(String property) {
        String oldValue = this.property;
        this.property = property;
        firePropertyChange(PROPERTY_PROPERTY, oldValue, property);
    }

    public void setReverseSort(Boolean reverseSort) {
        Boolean oldValue = this.reverseSort;
        this.reverseSort = reverseSort;
        firePropertyChange(PROPERTY_REVERSE_SORT, oldValue, reverseSort);
    }

    public void setSelectedItem(Object selectedItem) {
        Object oldValue = this.selectedItem;
        this.selectedItem = selectedItem;
        firePropertyChange(PROPERTY_SELECTED_ITEM, oldValue, selectedItem);
    }

    public void setSelectedToolTipText(String selectedToolTipText) {
        String oldValue = this.selectedToolTipText;
        this.selectedToolTipText = selectedToolTipText;
        firePropertyChange(PROPERTY_SELECTED_TOOL_TIP_TEXT, oldValue, selectedToolTipText);
    }

    public void setShowDecorator(Boolean showDecorator) {
        Boolean oldValue = this.showDecorator;
        this.showDecorator = showDecorator;
        firePropertyChange(PROPERTY_SHOW_DECORATOR, oldValue, showDecorator);
    }

    public void setShowReset(Boolean showReset) {
        Boolean oldValue = this.showReset;
        this.showReset = showReset;
        firePropertyChange(PROPERTY_SHOW_RESET, oldValue, showReset);
    }

    public void setSortable(Boolean sortable) {
        Boolean oldValue = this.sortable;
        this.sortable = sortable;
        firePropertyChange(PROPERTY_SORTABLE, oldValue, sortable);
    }

    /*-----------------------------------------------------------------------*/
    /*--------------------- Protected acessors methods  ---------------------*/
    /*-----------------------------------------------------------------------*/

    protected JSeparator get$JSeparator0() {
        return $JSeparator0;
    }

    /*-----------------------------------------------------------------------*/
    /*--------------------- Components creation methods ---------------------*/
    /*-----------------------------------------------------------------------*/

    protected void addChildrenToPopup() {
        popup.add(popupSortLabel);
        popup.add(sortUp);
        popup.add(sortDown);
        popup.add(popupSeparator);
        popup.add(popupLabel);
        popup.add($JSeparator0);
    }

    protected void addChildrenToSortDown() {
        { ButtonGroup $buttonGroup = sortGroup; sortDown.putClientProperty("$buttonGroup", $buttonGroup); $buttonGroup.add(sortDown); }
    }

    protected void addChildrenToSortUp() {
        { ButtonGroup $buttonGroup = sortGroup; sortUp.putClientProperty("$buttonGroup", $buttonGroup); $buttonGroup.add(sortUp); }
    }

    protected void addChildrenToToolbarLeft() {
        toolbarLeft.add(reset);
    }

    protected void addChildrenToToolbarRight() {
        toolbarRight.add(displayDecorator);
    }

    protected void createAutoComplete() {
        $objectMap.put("autoComplete", autoComplete = false);
    }

    protected void createAutoFocus() {
        $objectMap.put("autoFocus", autoFocus = true);
    }

    protected void createBean() {
        $objectMap.put("bean", bean = null);
    }

    protected void createBeanType() {
        $objectMap.put("beanType", beanType = null);
    }

    protected void createCombobox() {
        $objectMap.put("combobox", combobox = new JComboBox());
        
        combobox.setName("combobox");
    }

    protected void createData() {
        $objectMap.put("data", data = null);
    }

    protected void createDisplayDecorator() {
        $objectMap.put("displayDecorator", displayDecorator = new JToggleButton());
        
        displayDecorator.setName("displayDecorator");
        displayDecorator.setFocusable(false);
        displayDecorator.setFocusPainted(false);
    }

    protected void createEditable() {
        $objectMap.put("editable", editable = true);
    }

    protected void createForce() {
        $objectMap.put("force", force = false);
    }

    protected void createI18nPrefix() {
        $objectMap.put("i18nPrefix", i18nPrefix = "entitycombobox.common.");
    }

    protected void createIndex() {
        $objectMap.put("index", index = 0);
    }

    protected void createIndexes() {
        $objectMap.put("indexes", indexes = new JAXXButtonGroup());
        
        indexes.setUseToolTipText(true);
        indexes.addChangeListener(JAXXUtil.getEventListener(ChangeListener.class, "stateChanged", this, "doStateChanged__on__indexes"));
    }

    protected void createMaximumRowCount() {
        $objectMap.put("maximumRowCount", maximumRowCount = null);
    }

    protected void createNotSelectedToolTipText() {
        $objectMap.put("notSelectedToolTipText", notSelectedToolTipText = null);
    }

    protected void createPopup() {
        $objectMap.put("popup", popup = new JPopupMenu());
        
        popup.setName("popup");
        popup.addPopupMenuListener(JAXXUtil.getEventListener(PopupMenuListener.class, "popupMenuCanceled", this, "doPopupMenuCanceled__on__popup"));
        popup.addPopupMenuListener(JAXXUtil.getEventListener(PopupMenuListener.class, "popupMenuWillBecomeInvisible", this, "doPopupMenuWillBecomeInvisible__on__popup"));
    }

    protected void createPopupLabel() {
        $objectMap.put("popupLabel", popupLabel = new JLabel());
        
        popupLabel.setName("popupLabel");
    }

    protected void createPopupSeparator() {
        $objectMap.put("popupSeparator", popupSeparator = new JSeparator());
        
        popupSeparator.setName("popupSeparator");
    }

    protected void createPopupSortLabel() {
        $objectMap.put("popupSortLabel", popupSortLabel = new JLabel());
        
        popupSortLabel.setName("popupSortLabel");
        popupSortLabel.setText(t("bean.sort.label"));
    }

    protected void createPopupTitleText() {
        $objectMap.put("popupTitleText", popupTitleText = null);
    }

    protected void createProperty() {
        $objectMap.put("property", property = "");
    }

    protected void createReset() {
        $objectMap.put("reset", reset = new JButton());
        
        reset.setName("reset");
        reset.setFocusable(false);
        reset.setFocusPainted(false);
    }

    protected void createReverseSort() {
        $objectMap.put("reverseSort", reverseSort = false);
    }

    protected void createSelectedItem() {
        $objectMap.put("selectedItem", selectedItem = null);
    }

    protected void createSelectedToolTipText() {
        $objectMap.put("selectedToolTipText", selectedToolTipText = null);
    }

    protected void createShowDecorator() {
        $objectMap.put("showDecorator", showDecorator = true);
    }

    protected void createShowReset() {
        $objectMap.put("showReset", showReset = false);
    }

    protected void createSortDown() {
        $objectMap.put("sortDown", sortDown = new JRadioButtonMenuItem());
        
        sortDown.setName("sortDown");
        sortDown.setText(t("bean.sort.down"));
    }

    protected void createSortGroup() {
        $objectMap.put("sortGroup", sortGroup = new JAXXButtonGroup());
        
        sortGroup.setUseToolTipText(true);
        sortGroup.addChangeListener(JAXXUtil.getEventListener(ChangeListener.class, "stateChanged", this, "doStateChanged__on__sortGroup"));
    }

    protected void createSortUp() {
        $objectMap.put("sortUp", sortUp = new JRadioButtonMenuItem());
        
        sortUp.setName("sortUp");
        sortUp.setText(t("bean.sort.up"));
    }

    protected void createSortable() {
        $objectMap.put("sortable", sortable = true);
    }

    protected void createToolbarLeft() {
        $objectMap.put("toolbarLeft", toolbarLeft = new JToolBar());
        
        toolbarLeft.setName("toolbarLeft");
        toolbarLeft.setBorderPainted(false);
        toolbarLeft.setFloatable(false);
    }

    protected void createToolbarRight() {
        $objectMap.put("toolbarRight", toolbarRight = new JToolBar());
        
        toolbarRight.setName("toolbarRight");
        toolbarRight.setBorderPainted(false);
        toolbarRight.setFloatable(false);
    }

    /*-----------------------------------------------------------------------*/
    /*------------------------ Internal jaxx methods ------------------------*/
    /*-----------------------------------------------------------------------*/

    protected void $initialize() {
        if (log.isDebugEnabled()) {
            log.debug(this);
        }
        $Table0 = this;
        handler = new BeanComboBoxHandler<>();
        handler.beforeInit(this);
        $initialize_01_createComponents();
        $initialize_02_registerDataBindings();
        $initialize_03_finalizeCreateComponents();
        $initialize_04_applyDataBindings();
        $initialize_05_setProperties();
        $initialize_06_finalizeInitialize();
        handler.afterInit(this);
    }

    protected void $initialize_01_createComponents() {
        if (log.isDebugEnabled()) {
            log.debug(this);
        }
        $objectMap.put("$Table0", $Table0);
        createBeanType();
        createAutoComplete();
        createReverseSort();
        createShowReset();
        createShowDecorator();
        createEditable();
        createSortable();
        createAutoFocus();
        createProperty();
        createBean();
        createSelectedItem();
        createIndex();
        createData();
        createMaximumRowCount();
        createIndexes();
        createSortGroup();
        createSelectedToolTipText();
        createNotSelectedToolTipText();
        createPopupTitleText();
        createI18nPrefix();
        createForce();
        createPopup();
        createPopupSortLabel();
        createSortUp();
        createSortDown();
        createPopupSeparator();
        createPopupLabel();
        // inline creation of $JSeparator0
        $objectMap.put("$JSeparator0", $JSeparator0 = new JSeparator());
        
        $JSeparator0.setName("$JSeparator0");
        createToolbarLeft();
        createReset();
        createCombobox();
        createToolbarRight();
        createDisplayDecorator();
        // inline creation of $Table0
        setName("$Table0");
    }

    protected void $initialize_02_registerDataBindings() {
        if (log.isDebugEnabled()) {
            log.debug(this);
        }
        // register 12 data bindings
        registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_SORT_GROUP_SELECTED_VALUE, true ,"reverseSort") {
        
            @Override
            public void processDataBinding() {
                sortGroup.setSelectedValue(isReverseSort());
            }
        });
        registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_SORT_UP_SELECTED, true ,"reverseSort") {
        
            @Override
            public void processDataBinding() {
                sortUp.setSelected(!isReverseSort());
            }
        });
        registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_SORT_DOWN_SELECTED, true ,"reverseSort") {
        
            @Override
            public void processDataBinding() {
                sortDown.setSelected(isReverseSort());
            }
        });
        registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_TOOLBAR_LEFT_VISIBLE, true ,"showReset") {
        
            @Override
            public void processDataBinding() {
                toolbarLeft.setVisible(isShowReset());
            }
        });
        registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_RESET_ENABLED, true ,"editable" ,"enabled") {
        
            @Override
            public void processDataBinding() {
                reset.setEnabled(isEditable() && isEnabled());
            }
        });
        registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_COMBOBOX_SELECTED_ITEM, true ,"selectedItem") {
        
            @Override
            public void processDataBinding() {
                combobox.setSelectedItem(getSelectedItem());
            }
        });
        registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_COMBOBOX_EDITABLE, true ,"editable") {
        
            @Override
            public void processDataBinding() {
                combobox.setEditable(isEditable());
            }
        });
        registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_COMBOBOX_FOCUSABLE, true ,"enabled" ,"editable") {
        
            @Override
            public void processDataBinding() {
                combobox.setFocusable(isEnabled() && isEditable());
            }
        });
        registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_COMBOBOX_ENABLED, true ,"enabled") {
        
            @Override
            public void processDataBinding() {
                combobox.setEnabled(isEnabled());
            }
        });
        registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_COMBOBOX_MAXIMUM_ROW_COUNT, true ,"maximumRowCount") {
        
            @Override
            public void processDataBinding() {
                combobox.setMaximumRowCount( getMaximumRowCount() != null ? getMaximumRowCount() : 8 );
            }
        });
        registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_TOOLBAR_RIGHT_VISIBLE, true ,"showDecorator") {
        
            @Override
            public void processDataBinding() {
                toolbarRight.setVisible(isShowDecorator());
            }
        });
        registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_DISPLAY_DECORATOR_ENABLED, true ,"showDecorator" ,"enabled") {
        
            @Override
            public void processDataBinding() {
                displayDecorator.setEnabled(isShowDecorator() && isEnabled());
            }
        });
    }

    protected void $initialize_03_finalizeCreateComponents() {
        if (log.isDebugEnabled()) {
            log.debug(this);
        }
        // inline complete setup of $Table0
        add(toolbarLeft, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 17, 1, new Insets(0, 0, 0, 0), 0, 0));
        add(combobox, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, 10, 1, new Insets(0, 0, 0, 0), 0, 0));
        add(toolbarRight, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, 13, 1, new Insets(0, 0, 0, 0), 0, 0));
        addChildrenToPopup();
        addChildrenToSortUp();
        addChildrenToSortDown();
        addChildrenToToolbarLeft();
        addChildrenToToolbarRight();
    }

    protected void $initialize_04_applyDataBindings() {
        if (log.isDebugEnabled()) {
            log.debug(this);
        }
        
        // apply 12 data bindings
        JAXXUtil.applyDataBinding(this, $bindings.keySet());
    }

    protected void $initialize_05_setProperties() {
        if (log.isDebugEnabled()) {
            log.debug(this);
        }
        
        // apply 7 property setters
        popup.setBorder(new TitledBorder(t("beancombobox.popup.title")));
        popupSortLabel.setIcon(SwingUtil.getUIManagerActionIcon("bean-sort"));
        sortUp.setIcon(SwingUtil.getUIManagerActionIcon("bean-sort-up"));
        { sortUp.putClientProperty("$value", false);  Object $buttonGroup = sortUp.getClientProperty("$buttonGroup"); if ($buttonGroup instanceof JAXXButtonGroup) { ((JAXXButtonGroup) $buttonGroup).updateSelectedValue(); } }
        
        sortDown.setIcon(SwingUtil.getUIManagerActionIcon("bean-sort-down"));
        { sortDown.putClientProperty("$value", true);  Object $buttonGroup = sortDown.getClientProperty("$buttonGroup"); if ($buttonGroup instanceof JAXXButtonGroup) { ((JAXXButtonGroup) $buttonGroup).updateSelectedValue(); } }
        
        combobox.setModel(new JaxxDefaultComboBoxModel());// late initializer
        
        BeanComboBoxResetAction.init(this, reset, BeanComboBoxResetAction.class);
        BeanComboBoxDisplayDecoratorAction.init(this, displayDecorator, BeanComboBoxDisplayDecoratorAction.class);
    }

    protected void $initialize_06_finalizeInitialize() {
        if (log.isDebugEnabled()) {
            log.debug(this);
        }
    }

}