Expand all flow variables

Hi,

I am having a problem with expanding all the flow variable from config tree in the class ConfigEditJTree from package the org.knime.core.node.config.
I used the existing expandAll() method and didn’t worked. I printed the result from getRowCount() and the result is 0.
I tried other 2 recursive methods that are expanding all the flow variables and didn’t worked.

Here is the code:

public ConfigEditJTree(final ConfigEditTreeModel model) {
super(model);
setRootVisible(false);
setShowsRootHandles(true);
final BasicTreeUI treeUI = (BasicTreeUI)getUI();
m_childIndentSum = (treeUI.getLeftChildIndent() + treeUI.getRightChildIndent());
final ConfigEditTreeRenderer renderer = new ConfigEditTreeRenderer(this);
setNodeExpandedState(model.getRoot(), true);
setCellRenderer(renderer);
setCellEditor(new ConfigEditTreeEditor(this, renderer));
setRowHeight(renderer.getPreferredSize().height);
setEditable(true);
setToolTipText(“config tree”); // enable tooltip

    System.out.println("ROW COUNT: "+ getRowCount());
    expandAll();
    //        expandAllNodes(0, getRowCount());
   //        setNodeExpandedState(model.getRoot(), true);

    m_instantiatedTriggerDueToMissedTrain = new AtomicBoolean(false);
}

How can I proceed in order to make it work?

Best regards,
Mihai

Hi @mihais1,

is your plan add create secondary view for the flow variables that is always expanded?
Or why do you try manually create a flow variable view?

best,
Gabriel

Hi @gab1one,

Or why do you try manually create a flow variable view?

I want to have them expanded by default when I’m opening the Flow Variables tab node, because some nodes (e.g. Keras Network Learner node) are having the variables on many levels. My manager wants to see them expanded by default in order to just scroll up or down for seeing all of them.

Best regards,
Mihai

Hi @gab1one,

I managed to expand all the flow variables on the default view by calling the existing expandAll() method inside the setViewportWidth(final int w) method and not in the ConfigEditJTree class constructor.
It works very well for more than one rows for the initial collapsed tree, but it requires opening the node dialog window for 2 times for one single initial row in order to expand the tree. I think this is a Java Swing issue.

Best regards,
Mihai

Have you tried calling this method from the onOpen() method in the Nodedialog class? That might be easier.

best,
Gabriel

1 Like

Hi @gab1one,

You mean the NodeDialog class from org.knime.core.node package? In this class was a little bit difficult to access the flow variables tree because of the inner private class FlowVariablesTab contained by the abstract class NodeDialogPane.
But I found a method called updateView() inside the FlowVariablesTab class and I called here the method expandAll() and now the tree is expanded even for the corner case that I had earlier. Thank you very much for your hint, it was very useful!

Best regards,
Mihai

1 Like