How to display form validation errors in settings panel

Answered

As in question, I need to add some validation to plugin settings form.

Is there any API to do such thing?

6 comments
Comment actions Permalink
Official comment

There is the apply method in your configurable that throws an exception:

https://sites.google.com/site/malenkov/java/150403

 

This method is called when you press OK or Apply.

If the exception is thrown its content is shown under the settings page:

Comment actions Permalink

--No such API, you need to manage error messages on your own--

Update: not correct, in fact API exists, see the answer provided by Sergey Malenkov 

-2
Comment actions Permalink

Thanks a lot Sergey. Can I invoke SwingWorker on Apply action? and display SwingWorker job result on other place as message (or in the settings window, but I think it not possible)

0
Comment actions Permalink

Nope, because without exception the Settings dialog will be closed.

1
Comment actions Permalink

I meant closed by OK. Apply does not close the dialog, but you cannot destinguish OK and Apply via API.

0
Comment actions Permalink

Hi Sergey Malenkov

is this still valid ?
Or is it possible to directly have the validation to be triggered before pressing the apply button ?

I tried doing something like described here : https://jetbrains.design/intellij/principles/validation_errors/

but it seems that the validation tooltip never shows :/ 
Or do I need something special to make it work on the settings panel ?

In worse case I'll do like said in this topic. But I found it nicer to warn the user directly without waiting him to click on apply :) 

0

Please sign in to leave a comment.