2 DialogComponentStringSelection

Hello,

i have a problem:

i have 2 DialogComponentStringSelection and if the user select a other String from the first DialogComponentStringSelection i want to update the second one. Is this possible?

I have read in the API something about a updateComponent() but in which function i have to to use this possibility to interact with the enduser?

 

Best regards

Markus

hello,

i have solved the problem over a changelistener, but now i have a new problem.... :)

how can i get the selected String from my list?i only get the selected String if i execute my node. Is is possible to get the selcted String of the StringSelection Component to interact with the enduser?

Or it is possible to call the Apply Button function after a event and how can i use the standard Apply Button function?

 

Best regards

Markus

Hi Marcus,

Cool! Yes, the ChangeListener is the way to go. (You should always register the listener with the SettingsModel - but I guess you did that.)

Then, if you want to get the currently selected string, simply get it from the SettingsModel that is associated with the corresponding StringSelectionComponent. (Just keep that SettingsModel in a private member before you pass it to the component constructor).

Does that make sense? Does that help?

 - Peter.

My Code:

NodeDialog:

public final DialogComponentStringSelection rulelist;

normlist = new DialogComponentStringSelection(
                        new SettingsModelString(FuelSurveyManageRulesNodeModel.CFGKEY_SIGN2,
                                FuelSurveyManageRulesNodeModel.DEFAULT_SIGN2), "Select Norm",FuelSurveyManageRulesNodeModel.readXMLNorms()
                        );
                 addDialogComponent(normlist);

 

normlist.getModel().addChangeListener(new ChangeListener() {
                        @Override
                        public void stateChanged(final ChangeEvent e) {

                            logger.warn(FuelSurveyManageRulesNodeModel.getSelectedString());

                        }
                    });

in the NodeModel:

public static final String CFGKEY_SIGN2 = "positiv2";
    public static final String DEFAULT_SIGN2 = "positiv2";
    
    private final static SettingsModelString m_sign2 =
        new SettingsModelString(FuelSurveyManageRulesNodeModel.CFGKEY_SIGN2, DEFAULT_SIGN2);

public static String getSelectedString(){
       
        return m_sign2.getStringValue();
    }

 

But by every change i get the "positive2" how can i get the currently slected String from the component? can you help me?:)

It is possible to call the apply button function by every changing?and if yes, how?

Because to apply the NodeDialog he save the currently selected String...

best regards

markus
 

Hi Markus,

You always get the same value, because you are pulling it from the SettingsModel of the NodeModel. You should get it from the SettingsModel of the Component (normlist).

I would create a member variable in the NodeDialog and store a reference to the SettingsModelString. You can pass this then to the Component constructor and you can access through this the SettingsModel in the ChangeListener.

Don't access NodeModel things in the NodeDialog (except constants maybe).

 - Peter.

Hello Peter,

can you give me a code example, because iam a beginner in KNIME? that would be wonderful :)

Best regards

 

Markus

Hi Makus,

Did you already look at our developer guide?

http://tech.knime.org/developer/settingsmodellistener

Let me know if that doesn't help and I'll get you a more detailed code example.

Best,

 - Peter.

Hello Peter,

sorry for wasting your time... i have looked, but not enough :)

I will try it tomorrow!

best regards

Markus

Hello Peter,

it works!Thank you :)

best regards

Markus