saving setting DialogComponentStringListSelection

I have a problem understanding the saveSettings approach. Maybe you could clarify the following for me?

I have a DialogComponentStringListSelection object that I use in my Dialog for a given node. I set the values at run-time, actually while in the confiugre GUI. This has a list of possible values. I save the SettingsModelStringArray that holds the selection (i.e. potentially not all of the possible values) using saveSettingsTo(settings).
Now my problems:

  1. How should I save the complete list?
  2. How do I load the values back into the DialogComponentStringListSelection?
  3. How do I activate the selection with the saved items?

Thanks for the clarification.

Best,

Bernd

Hi Bernd,
normally the settings are stored by the SettingsModel, not the component. Thus, the SettingsModelStringArray only stores the selected values, and not all values of the component.
I would probably set the possible values as choices in the component in the “loadAdditionalSettingsFrom” method (in the dialog). There you get the table specs passed as argument and could read the possible values and transfer them into the component.

  • Peter.

Hi,

i'm sorry for pushing such an old thread, but i think i've exactly the same problem and i would like to know what the recommended solution is since 5 years have passed since Peter's answer.

What is the best (correct?) method to restore the complete DialogComponentStringListSelection with selected and not selected values after i reopen a workflow?

If Peter's solution is still valid and recommended, could you maybe explain it a bit in more detail because i don't understand it yet.

Thanks for your help

Andreas

 

Well i guess there is no best practice because it's not intended to be used like this. But let me ask another question.

The DialogComponentStringListSelection saves it's selected values in a SettingsModelStringArray. So shouldn't the list at least show this values when the workflow is reopened or am i misunderstandig this? Because my list is always blank when i reopen a workflow, even if i saved some values before closing it. I guess updateComponent is not called, but i'm not able to call it manually onOpen because it's protected.

This looks like you are not calling loadSettings on your SettingsModelStringArray in the NodeModel and/or the NodeDialogPane.

I pretty sure im loading correctly, but i have an idea where my error could be. I wrote a little test dialog which shows what i intend to do.

A button adds a line to the list and after saving, closing, and reopening the workflow the list is empty instead of showing the line. I think the error is with the definition of stringList. Using null for the parameter 'list' is probably wrong, but i already tried a few things like an empty array. I also tried to get the array from the SettingsModelStringArray, but it seams, that it's not loaded yet at that moment in the constructor.

protected TestNodeDialog() {
        createNewGroup("Test");
        stringList = new DialogComponentStringListSelection(m_test, "List", null,
                false, 5);
        addDialogComponent(stringList);
        DialogComponentButton button = new DialogComponentButton("Test");
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                ArrayList<String> a = new ArrayList<>();
                a.add("Test");
                stringList.replaceListItems(a, null);
            }
        });
        addDialogComponent(button);
        closeCurrentGroup();
    }