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;
}
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;
}
}
Aggregations