private JComboBox<String> createDatastoreCombobox() { final String[] comboBoxModel = CollectionUtils.array(new String[1], _datastoreCatalog.getDatastoreNames()); final JComboBox<String> comboBox = new JComboBox<>(comboBoxModel); comboBox.setEditable(false); final JDialog parent = this; comboBox.addActionListener(e -> { try { final ComboBoxUpdater comboBoxUpdater = new ComboBoxUpdater(parent); comboBoxUpdater.execute(); } catch (final Exception exception) { final String exceptionMessage = "An unexpected error occurred while updating combo boxes:\n" + exception.getMessage(); logger.error(exceptionMessage); WidgetUtils.showErrorMessage("Unexpected error", exceptionMessage); } }); return comboBox; }
@Inject public SingleColumnNamePropertyWidget(final ConfiguredPropertyDescriptor propertyDescriptor, final ComponentBuilder componentBuilder) { super(componentBuilder, propertyDescriptor); _tableRef = new MutableRef<>(); Enum<?>[] enumConstants = (Enum<?>[]) propertyDescriptor.getType().getEnumConstants(); if (!propertyDescriptor.isRequired()) { enumConstants = CollectionUtils.array(new Enum<?>[] { null }, enumConstants); } _comboBox = new SourceColumnComboBox(); final String currentValue = getCurrentValue(); setValue(currentValue); addComboListener(item -> fireValueChanged()); add(_comboBox); }
public void addExpressionBasedInputColumn(final String expression) { if (!StringUtils.isNullOrEmpty(expression)) { final ExpressionBasedInputColumn<?> expressionBasedInputColumn; if (expression.indexOf("#{") != -1) { expressionBasedInputColumn = new ELInputColumn(expression); } else { expressionBasedInputColumn = new ConstantInputColumn(expression); } if (_multiplePropertyWidget != null) { InputColumn<?>[] currentValue = _multiplePropertyWidget.getValue(); if (currentValue == null) { currentValue = new InputColumn[0]; } @SuppressWarnings("unchecked") final InputColumn<?>[] newValue = CollectionUtils.array(currentValue, expressionBasedInputColumn); _multiplePropertyWidget.onValueTouched(newValue); } else { _singlePropertyWidget.onValueTouched(expressionBasedInputColumn); } } } }
@Inject public SingleEnumPropertyWidget(final ConfiguredPropertyDescriptor propertyDescriptor, final ComponentBuilder componentBuilder) { super(componentBuilder, propertyDescriptor); Enum<?>[] enumConstants = (Enum<?>[]) propertyDescriptor.getType().getEnumConstants(); if (!propertyDescriptor.isRequired()) { enumConstants = CollectionUtils.array(new Enum<?>[] { null }, enumConstants); } _comboBox = new DCComboBox<>(enumConstants); _comboBox.setRenderer(new EnumComboBoxListRenderer()); final Enum<?> currentValue = getCurrentValue(); _comboBox.setSelectedItem(currentValue); addComboListener(item -> fireValueChanged()); add(_comboBox); }
public void setDatastore(final Datastore datastore) { final String previousValue = getValue(); _datastoreRef.set(datastore); if (datastore == null) { _comboBox.setModel(new DefaultComboBoxModel<>(new Schema[1])); } else { try (DatastoreConnection con = datastore.openConnection()) { Schema[] schemas = con.getSchemaNavigator().getSchemas(); schemas = CollectionUtils.array(new Schema[1], schemas); _comboBox.setModel(new DefaultComboBoxModel<>(schemas)); Schema newValue = null; if (previousValue != null) { newValue = con.getSchemaNavigator().getSchemaByName(previousValue); } if (newValue == null) { newValue = con.getSchemaNavigator().getDefaultSchema(); } _comboBox.setSelectedItem(newValue); } } }
_columnTextField = WidgetFactory.createTextField("Column name"); final String[] comboBoxModel = CollectionUtils.array(new String[1], _datastoreCatalog.getDatastoreNames());
_mutableReferenceCatalog = mutableReferenceCatalog; _nameTextField = WidgetFactory.createTextField("Synonym catalog name"); final String[] comboBoxModel = CollectionUtils.array(new String[1], _datastoreCatalog.getDatastoreNames());