// return model;
// }
// }
private void createModel(final JComboBox cb, DirectoryKladrItem[] items, boolean addEmpty) {
ComboBoxModel cbModel = cb.getModel();
FilteredComboBoxModel filteredModel;
if (cbModel != null && cbModel instanceof FilteredComboBoxModel) {
filteredModel = (FilteredComboBoxModel) cbModel;
} else {
filteredModel = new FilteredComboBoxModel(cb, true) {
@Override
public Object addItem(String txt) {
try {
// System.out.println("CREATE NEW ITEM");
int number = getNumber(cb);
AddressObjectDetails details = new AddressObjectDetails();
details.title = (String) txt;
Object parent = combos[number - 1].getSelectedItem();
if (!(parent instanceof DirectoryKladrItem)) {
throw new ClipsException("Родительский элемент не является элементом справочника");
} else {
DirectoryKladrItem localParent = (DirectoryKladrItem) parent;
int level = localParent.getType().getLevel() + 1;
DialogNewKladrItem dnki = new DialogNewKladrItem(DialogAddressM.this, details, level, getAuditManager());
dnki.setVisible(true);
if (dnki.getDlgResult() == ModalDialog.DLG_OK) {
DirectoryKladrItem kladrItem = dnki.getKladrItem();
localParent.getItems().append(kladrItem);
createModel(cb, getChildren(localParent), true);
// cb.setSelectedItem(kladrItem);
return kladrItem;
} else {
// System.out.println("ОТМЕНА");
}
}
} catch (ClipsException ce) {
MessageBox.showException(ce);
}
return null;
}
};
}
DefaultComboBoxModel model = new DefaultComboBoxModel(items);
if (addEmpty) {
model.insertElementAt("", 0);
}
filteredModel.setContainModel(model);
// filteredModel.addEnterListener(new EnterKeyListener() {
//
// @Override
// public void onEnterPressed(KeyEvent e) {
// try {