/** * Constructs the property widget * * @param beanJobBuilder the transformer job builder for the table lookup * @param inputColumnsProperty the property represeting the columns to use for settig up * conditional lookup (InputColumn[]) * @param mappedColumnsProperty the property representing the mapped columns in the datastore * (String[]) */ public MultipleMappedColumnsPropertyWidget( AbstractBeanJobBuilder<?, ?, ?> beanJobBuilder, ConfiguredPropertyDescriptor inputColumnsProperty, ConfiguredPropertyDescriptor mappedColumnsProperty) { super(beanJobBuilder, inputColumnsProperty); _mappedColumnComboBoxes = new WeakHashMap<InputColumn<?>, SourceColumnComboBox>(); _mappedColumnsProperty = mappedColumnsProperty; _tableRef = new MutableRef<Table>(); _mappedColumnNamesPropertyWidget = createMappedColumnNamesPropertyWidget(); _sourceColumnUpdating = false; final InputColumn<?>[] currentValue = getCurrentValue(); final String[] currentMappedColumnsValue = (String[]) beanJobBuilder.getConfiguredProperty(mappedColumnsProperty); if (currentValue != null && currentMappedColumnsValue != null) { // first create combo's, then set value (so combo is ready before it // is requested) _mappedColumnNamesPropertyWidget.setValue(currentMappedColumnsValue); final int minLength = Math.min(currentValue.length, currentMappedColumnsValue.length); for (int i = 0; i < minLength; i++) { final InputColumn<?> inputColumn = currentValue[i]; final String mappedColumnName = currentMappedColumnsValue[i]; createComboBox(inputColumn, new MutableColumn(mappedColumnName)); } setValue(currentValue); } }
/** Invoked whenever a configured property within this widget factory is changed. */ public void onConfigurationChanged() { final Collection<PropertyWidget<?>> widgets = getWidgets(); for (PropertyWidget<?> widget : widgets) { @SuppressWarnings("unchecked") final PropertyWidget<Object> objectWidget = (PropertyWidget<Object>) widget; final ConfiguredPropertyDescriptor propertyDescriptor = objectWidget.getPropertyDescriptor(); final Object value = _beanJobBuilder.getConfiguredProperty(propertyDescriptor); objectWidget.onValueTouched(value); } }
/** * Registers a widget in this factory in rare cases when the factory is not used to actually * instantiate the widget, but it is still needed to register the widget for compliancy with eg. * the onConfigurationChanged() behaviour. * * @param propertyDescriptor * @param widget */ public void registerWidget( ConfiguredPropertyDescriptor propertyDescriptor, PropertyWidget<?> widget) { if (widget == null) { _widgets.remove(propertyDescriptor); } else { _widgets.put(propertyDescriptor, widget); @SuppressWarnings("unchecked") PropertyWidget<Object> objectWidget = (PropertyWidget<Object>) widget; Object value = _beanJobBuilder.getConfiguredProperty(objectWidget.getPropertyDescriptor()); objectWidget.initialize(value); } }