Confusion about validating External System system settings

I have a bug in my External System implementation where the user can't configure the Global settings from the Project Import dialog, but it works from the Preferences pane under Build Tools. I can't figure out how to do this correctly.

When implementing this, I followed the design of the Gradle implementation. So I have a DepsSettings which extends AbstractExternalSystemSettings, and I also have a DepsSystemSettings. DepsSettings allows access to the system settings via a property, similar to mySystemSettings in the Gradle implementation. My problem is in DepsSystemSettingsControl, which extends ExternalSystemSettingsControl<DepsSettings>. In this class, isModified() compares the UI controls' values to the settings accessed via the property on DepsSettings, and apply() applies the UI values to the settings via the property as normal.

My problem is with the validate() method - it accepts a DepsSettings and validates it, but it really ends up validating the system settings values accessed via the property. validate() is never called by the Preferences pane, so I call it myself at the end of my apply() method. However validate() is called at several previous points by the Import dialog, and that validation fails because apply() has not yet been called so the values are not set in my DepsSystemSettings yet.

What should I be doing here? It actually looks like the Gradle implementation doesn't implement validate() at all - surely this can't be right? Should validate() actually validate the UI control state, and if so what is the passed settings element for? There doesn't seem to be any information that I can use to decide in which of the two contexts my settings control is being invoked, and it seems like they should behave consistently either way.

Please sign in to leave a comment.