enable or disable a field based on the presence of domain values of a selected column?

Sorry for all these very specific questions but I try to implement a node where the user can select a single column. If this column does have domain values a checkbox should be enabled (not set). Is that possible? I did not succeed whatever I tried.

This is what I tried so far:

    @Widget(title = "Select Column", description = "...")
	@ValueReference(value = ColumnNameRef.class)
	@ChoicesProvider(DoubleStringColumnsProvider.class)
	String m_inputColumn;
	
	interface ColumnNameRef extends ParameterReference<String> {
    }


	@Widget(title = "checkbox", description = "...")
	@Effect(predicate = HasDomainValues.class, type = EffectType.ENABLE)
	boolean m_option = false;
	
	static final class HasDomainValues implements EffectPredicateProvider {

		@Override
		public EffectPredicate init(PredicateInitializer i) {
			return i.getConstant(
	                (NodeParametersInput context) -> {
	                	String selectedColumn = i.getString(ColumnNameRef.class).toString();  //cannot get the name of the selected column this way!
	                	DataColumnDomain domain = context.getInTableSpec(0).map(tSpec -> tSpec.getColumnSpec(selectedColumn).getDomain()).get();
	                	return domain.hasValues() || domain.hasBounds();
	                });
		}
		
	}

Thanks a lot in advance!

Hi @niederle,

Currently, this is not possible directly, but it can be done with some effort.
You need to add another boolean field such as m_inputColumnHasADomain as intermediate state.

@ValueProvider(InputColumnHasADomainValueProvider.class)
@ValueReference(InputColumnHasADomainValueReference.class)
@Persistor(InputColumnHasADomainPersistor.class)
boolean m_inputColumnHasADomain;
  • Without the @Widget annotation, the field will not be displayed in the dialog.
  • The ValueProvidershould update the boolean field when the dialog gets opened/the input column changes to calculate whether the current input column has a domain.
  • The ValueReferencecan then be used in the EffectPredicateProvider: (i.getBoolean(InputColumnHasADomainValueReference.class).isTrue())
  • The Persistor should be used to not save the field as a setting, as it is only used for effects in the dialog. (load() { return false}, save() {}, getConfigPaths() {return new String[0][]}

Best,
Robin