Search in sources :

Example 1 with JComboBoxUndoListener

use of org.apache.cayenne.modeler.undo.JComboBoxUndoListener in project cayenne by apache.

the class DefaultWidgetFactory method createUndoableComboBox.

/**
 * Creates undoable JComboBox.
 */
public <T> JComboBox<T> createUndoableComboBox() {
    JComboBox<T> comboBox = new JComboBox<>();
    comboBox.addItemListener(new JComboBoxUndoListener());
    comboBox.setBackground(Color.WHITE);
    comboBox.setMaximumRowCount(ModelerPreferences.COMBOBOX_MAX_VISIBLE_SIZE);
    return comboBox;
}
Also used : JComboBox(javax.swing.JComboBox) JComboBoxUndoListener(org.apache.cayenne.modeler.undo.JComboBoxUndoListener)

Example 2 with JComboBoxUndoListener

use of org.apache.cayenne.modeler.undo.JComboBoxUndoListener in project cayenne by apache.

the class ComboSelectionBinding method updateView.

public void updateView() {
    Object value = getValue();
    modelUpdateDisabled = true;
    try {
        clear();
        ItemListener[] listeners = comboBox.getItemListeners();
        for (ItemListener itemListener : listeners) {
            if (itemListener instanceof JComboBoxUndoListener) {
                // in order not to add event to undo list
                ((JComboBoxUndoListener) itemListener).setIsUserAction(false);
            }
        }
        if (value != null) {
            this.comboBox.setSelectedItem(value.toString());
        } else if (noSelectionValue != null) {
            this.comboBox.setSelectedItem(noSelectionValue);
        } else {
            this.comboBox.setSelectedIndex(-1);
        }
    } finally {
        modelUpdateDisabled = false;
    }
}
Also used : ItemListener(java.awt.event.ItemListener) JComboBoxUndoListener(org.apache.cayenne.modeler.undo.JComboBoxUndoListener)

Aggregations

JComboBoxUndoListener (org.apache.cayenne.modeler.undo.JComboBoxUndoListener)2 ItemListener (java.awt.event.ItemListener)1 JComboBox (javax.swing.JComboBox)1