Inconsistent behavior of some checkboxes on the PostgreSQL connection configuration page
On the aforementioned page, we have 3 checkboxes: a) Show all databases; b) Show template databases; c) Show databases not available for connection. If the first one is not set, the latter two are not applicable. However, if we check one of them, e.g. the second one, and then we uncheck the first one, checkbox b is still set (but grayed). We also have the same checkboxes in the global preferences, and there we can even apply checkboxes b and c without checking button a.
diff --git a/plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/ui/PostgreConnectionPageAdvanced.java b/plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/ui/PostgreConnectionPageAdvanced.java
index 3d86556b1b..4529685533 100644
--- a/plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/ui/PostgreConnectionPageAdvanced.java
+++ b/plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/ui/PostgreConnectionPageAdvanced.java
@@ -84,8 +84,7 @@ public class PostgreConnectionPageAdvanced extends ConnectionPageAbstract
             showNonDefault.addSelectionListener(new SelectionAdapter() {
                 @Override
                 public void widgetSelected(SelectionEvent e) {
-                    showTemplates.setEnabled(showNonDefault.getSelection());
-                    showUnavailable.setEnabled(showNonDefault.getSelection());
+                    setCheckboxesState();
                 }
             });
             showTemplates = UIUtils.createCheckbox(secureGroup, PostgreMessages.dialog_setting_connection_show_templates, PostgreMessages.dialog_setting_connection_show_templates_tip, false, 2);
@@ -125,6 +124,16 @@ public class PostgreConnectionPageAdvanced extends ConnectionPageAbstract
         loadSettings();
     }
 
+    private void setCheckboxesState() {
+        boolean enable = showNonDefault.getSelection();
+        if (!enable) {
+            showUnavailable.setSelection(false);
+            showTemplates.setSelection(false);
+        }
+        showUnavailable.setEnabled(enable);
+        showTemplates.setEnabled(enable);
+    }
+
     @Override
     public boolean isComplete()
     {
@@ -145,11 +154,10 @@ public class PostgreConnectionPageAdvanced extends ConnectionPageAbstract
         showTemplates.setSelection(
             CommonUtils.getBoolean(connectionInfo.getProviderProperty(PostgreConstants.PROP_SHOW_TEMPLATES_DB),
             globalPrefs.getBoolean(PostgreConstants.PROP_SHOW_TEMPLATES_DB)));
-        showTemplates.setEnabled(showNonDefault.getSelection());
         showUnavailable.setSelection(
             CommonUtils.getBoolean(connectionInfo.getProviderProperty(PostgreConstants.PROP_SHOW_UNAVAILABLE_DB),
             globalPrefs.getBoolean(PostgreConstants.PROP_SHOW_UNAVAILABLE_DB)));
-        showUnavailable.setEnabled(showNonDefault.getSelection());
+        setCheckboxesState();
         showDatabaseStatistics.setSelection(
             CommonUtils.getBoolean(connectionInfo.getProviderProperty(PostgreConstants.PROP_SHOW_DATABASE_STATISTICS),
                 globalPrefs.getBoolean(PostgreConstants.PROP_SHOW_DATABASE_STATISTICS)));
diff --git a/plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/ui/PrefPagePostgreSQL.java b/plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/ui/PrefPagePostgreSQL.java
index 9eb6ff68de..cfb96b1b4c 100644
--- a/plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/ui/PrefPagePostgreSQL.java
+++ b/plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/ui/PrefPagePostgreSQL.java
@@ -79,8 +79,7 @@ public class PrefPagePostgreSQL extends AbstractPrefPage implements IWorkbenchPr
             showNonDefault.addSelectionListener(new SelectionAdapter() {
                 @Override
                 public void widgetSelected(SelectionEvent e) {
-                    showTemplates.setEnabled(showNonDefault.getSelection());
-                    showUnavailable.setEnabled(showNonDefault.getSelection());
+                    setCheckboxesState();
                 }
             });
             showTemplates = UIUtils.createCheckbox(secureGroup,
@@ -95,6 +94,7 @@ public class PrefPagePostgreSQL extends AbstractPrefPage implements IWorkbenchPr
                     globalPrefs.getBoolean(PostgreConstants.PROP_SHOW_UNAVAILABLE_DB),
                     2
             );
+            setCheckboxesState();
             showDatabaseStatistics = UIUtils.createCheckbox(
                 secureGroup,
                 PostgreMessages.dialog_setting_connection_database_statistics,
@@ -129,6 +129,16 @@ public class PrefPagePostgreSQL extends AbstractPrefPage implements IWorkbenchPr
         return cfgGroup;
     }
 
+    private void setCheckboxesState() {
+        boolean enable = showNonDefault.getSelection();
+        if (!enable) {
+            showUnavailable.setSelection(false);
+            showTemplates.setSelection(false);
+        }
+        showUnavailable.setEnabled(enable);
+        showTemplates.setEnabled(enable);
+    }
+
     @Override
     public boolean performOk() {
         DBPPreferenceStore preferenceStore = DBWorkbench.getPlatform().getPreferenceStore();
['plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/ui/PostgreConnectionPageAdvanced.java', 'plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/ui/PrefPagePostgreSQL.java']