Hi,
let me first explain what I would like to do (though I have no clue whether I’ve chosen the right approach…)
I would like to have a checkbox. If it’s checked several different widgets should be enabled. I’ve made a little testcase which partially does what it should:
@Widget(title = "Use Settings", description = "...")
@ValueReference(UseSettingsReference.class)
boolean m_useSettings = false;
static final class UseSettingsReference implements BooleanReference {
}
@Persistor(TestPersistor.class)
TestGroup tg = new TestGroup();
@Effect(predicate = UseSettingsPredicate.class, type = EffectType.ENABLE)
static class TestGroup implements WidgetGroup {
@Widget(title = "w1", description = "")
@TextInputWidget()
String m_teststring = "test";
@Widget(title = "w2", description = "")
@NumberInputWidget()
int m_testnumber = 5;
}
public static final class UseSettingsPredicate implements EffectPredicateProvider {
@Override
public EffectPredicate init(PredicateInitializer i) {
// TODO Auto-generated method stub
return i.getBoolean(UseSettingsReference.class).isTrue();
}
}
private static final class TestPersistor implements NodeParametersPersistor<TestGroup> {
@Override
public TestGroup load(NodeSettingsRO settings) throws InvalidSettingsException {
// TODO Auto-generated method stub
return null;
}
@Override
public void save(TestGroup param, NodeSettingsWO settings) {
// TODO Auto-generated method stub
}
@Override
public String[][] getConfigPaths() {
// TODO Auto-generated method stub
return null;
}
}
As a result widget w2 can be enabled/disabled via the checkbox while it’s not possible for w1. If I change w1 to a number input widget it works.
First question: Is this the right approach? Finally, I want to have a dropdown box, a number input widget and another checkbox in that group.
Second question: Do I have to implement this Persistor class? If I try to run it without, KNIME complains at runtime about a missing default persistor class for TestGroup
Thanks a lot in advance!
Antje
