Modify the (ok) configuration of a developing node

How to program the OK button of configuration of a node (in development), to validate some components that I need to validate before it is executed.

When you click on OK (or Apply), the #configure() method of the NodeModel is called, so you can almost certainly (without knowing the details of what you want to do!) do what you want there.

Steve

3 Likes

You can also override the saveAdditionalSettings() method in the NodeDialog, if you want to perform your validation before the settings are saved to the node. By throwing an exception in that method, you can prevent a user from configuring a node with an illegal value.

best,
Gabriel

2 Likes

Thank you very much, I tried it and I think it is the best option.
Taday

Hello, when programming the method saveAdditionalSettings (), I can validate using Execptions and I show a JOptionPane to inform the user of the error, but in doing so the dialog window closes.

  • I would like to know if in some way you can keep the dialog window open until the user fixes the incorrect parameters?
  • I already try creating the dialog window again but it does not work for me, what can I do?

If you throw InvalidSettingsException in the saveAdditionalSettings(), does that prevent the settings dialog from closing?

Steve

2 Likes

Hi Vernalis,

Do you know if there is a way to differentiate between the OK and the Apply buttons when the saveAdditionalSettings method is called?

I have a scenario where I have to do certain things only with the press of the OK button but not with the Apply button.

Thank you!

NodeDialogPane has an #onClose() method which looks like it should do what you want if you override it:

    /**
     * Override this method in order to react on events if the surrounding
     * dialog is supposed to be closed. The method is called in the Event Dispatch Thread.
     */
    public void onClose() {
        // default implementation does nothing.
    }
1 Like