My specific problem is how to create better dialogs for some of my nodes. The question is how far you can go using the standard Pane and Component approach before being forced into using raw swing. I really, really don’t want to go there. My needs seem very simple.
Take Rename for example. The dialog needs to select one or more columns (zero is OK too) to be renamed, and for each column request a string for the new column name. I can select columns using DialogComponentColumnFilter in the same tab or DataColumnSpecFilterPanel in a separate tab, but then I want to input one new column name for each. The number of New Name input fields needs to be set dynamically, depending on how many columns there are to rename.
I can see all the bits to do that in the parent NodeDialogPane or the various components, but they’re private and/or final so I can’t reuse them. For example, DialogComponentButton has a listener, and DialogComponentLabel has a settable label, but the question is how to get them to play together. I can see how to dynamically add components if more are needed, but not how to remove them (if the user picks less columns to rename).
Perhaps the answer is to clone and modify existing Panes and Components, but a solution by building on what is there would be better. Any suggestions?
Thanks for the suggestion. I already looked at that code, but for my purposes I would have to (at least) rewrite the inner RenameColumnPanel, which means dealing with swing, which is what I’m trying to avoid. I need far less functionality than that node offers, so I would prefer to build up from not much instead of cut down from too much, if you get my drift.
My question is really about: if I’m only using standard Knime components, can I add a listener to modify a dialog dynamically, and if so how?
Could you clarify what you mean by adding and removing components? I ask because you keep mentioning wanting to do this, but you also preface this issue with not wanting to be “forced into using raw swing.” What sort of UI modification things are you envisioning that both let you add and remove components and let you avoid the windowing toolkit?
The typical simple node starts with a DefaultNodeSettingsPane and adds various DialogComponents to the default tab in the constructor. The resulting configuration dialog is perfectly adequate for my needs, but it’s static. It can’t adapt to different inputs or different selections.
I want to defer adding dialog components until I know what the input DataTableSpec is. I’m having some success by overriding loadAdditionalSettingsFrom(), and deleting and re-creating the default tab. I haven’t tried a Listener yet.
There is a problem that the lifecycle for the dialog is not documented (that I can find), so it’s guesswork and spelunking code to figure out what is possible. A few clues might help.