DataCleaner icon indicating copy to clipboard operation
DataCleaner copied to clipboard

Creating configuration widget with dropdown selectors

Open ghost opened this issue 5 years ago • 3 comments

I am currently working on a custom writer in data cleaner. The configuration widget of the writer should offer the user to select a from a list of predefined fields (corresponding to roles in the output file) in a dropdown menu. I already checked the existing analyzers and while there are some with dropdown options in the configuration menu (such as the "insert into table"), I cannot get it working. I always get editable text fields instead of comboboxes. I even resorted to copying the whole "insert into table" writer into a test writer but I still get the text widgets

What kind of magic is deciding how the options are displayed? Is there any comprehensive documentation how to write the config widgets?

What I want: grafik

What I get grafik

ghost avatar Oct 29 '20 09:10 ghost

The best we have is rather comprehensive Javadoc in the DataCleaner-api and DataCleaner-desktop-api modules.

And then some good examples:

From InsertIntoTableAnalyzer (removed a few lines that are besides the point):

    @Configured(PROPERTY_NAME_VALUES)
    InputColumn<?>[] values;

    @Configured
    @MappedProperty(PROPERTY_NAME_VALUES)
    String[] columnNames;

So here you see how @MappedProperty maps the two fields. Instead of a String array you could have an array of your own enum type for example.

kaspersorensen avatar Oct 29 '20 13:10 kaspersorensen

Thanks a lot. By using an enum I can make it work for version 1

However, I still do not understand how this works with the String array. Where does it get the available values from?

ghost avatar Oct 29 '20 14:10 ghost

In that case the values are being populated because the String array was also decorated with the @ColumnProperty annotation. If you have a truly bespoke situation then you probably have to implement your own renderer for the property. I honestly can't remember how to do it anymore off hand, but there should be examples in the code that you can follow. Look for classes annotated with @Renderer and named something like "PropertyWidgetRenderer" or such.

kaspersorensen avatar Oct 30 '20 11:10 kaspersorensen