<NME> PrefPageResultSetMain.java
<BEF> /*
 * DBeaver - Universal Database Manager
 * Copyright (C) 2010-2022 DBeaver Corp and others
 * Copyright (C) 2011-2012 Eugene Fradkin (eugene.fradkin@gmail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jkiss.dbeaver.ui.editors.data.preferences;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.*;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.ModelPreferences;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.resultset.ResultSetPreferences;
import org.jkiss.dbeaver.ui.controls.resultset.ResultSetUtils;
import org.jkiss.dbeaver.ui.controls.resultset.internal.ResultSetMessages;
import org.jkiss.dbeaver.ui.internal.UIMessages;
import org.jkiss.dbeaver.ui.preferences.TargetPrefPage;
import org.jkiss.dbeaver.utils.PrefUtils;
import org.jkiss.utils.CommonUtils;

import java.util.Locale;

/**
 * PrefPageResultSetMain
 */
public class PrefPageResultSetMain extends TargetPrefPage
{
    static final Log log = Log.getLog(PrefPageResultSetMain.class);

    public static final String PAGE_ID = "org.jkiss.dbeaver.preferences.main.resultset"; //$NON-NLS-1$

    private Button autoFetchNextSegmentCheck;
    private Button rereadOnScrollingCheck;
    private Text resultSetSize;
    private Button resultSetUseSQLCheck;
    private Combo orderingModeCombo;
    private Button readQueryReferences;
    private Text queryCancelTimeout;
    private Button filterForceSubselect;

    private Button keepStatementOpenCheck;
    private Button alwaysUseAllColumns;
    private Button newRowsAfter;
    private Button refreshAfterUpdate;
    private Button useNavigatorFilters;

    private Button showErrorsInDialog;
    private Button markCellValueOccurrences;

    private Button advUseFetchSize;

    private Button ignoreColumnLabelCheck;
    private Button useDateTimeEditor;

    public PrefPageResultSetMain()
    {
        super();
    }

    @Override
    protected boolean hasDataSourceSpecificOptions(DBPDataSourceContainer dataSourceDescriptor)
    {
        DBPPreferenceStore store = dataSourceDescriptor.getPreferenceStore();
        return
            store.contains(ResultSetPreferences.RESULT_SET_AUTO_FETCH_NEXT_SEGMENT) ||
            store.contains(ModelPreferences.RESULT_SET_REREAD_ON_SCROLLING) ||
            store.contains(ModelPreferences.RESULT_SET_MAX_ROWS) ||
            store.contains(ModelPreferences.RESULT_SET_MAX_ROWS_USE_SQL) ||
            store.contains(ModelPreferences.RESULT_SET_READ_METADATA) ||
            store.contains(ResultSetPreferences.RESULT_SET_CANCEL_TIMEOUT) ||
            store.contains(ModelPreferences.SQL_FILTER_FORCE_SUBSELECT) ||
            store.contains(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS) ||
            store.contains(ResultSetPreferences.RS_EDIT_NEW_ROWS_AFTER) ||
            store.contains(ResultSetPreferences.RS_EDIT_REFRESH_AFTER_UPDATE) ||
            store.contains(ModelPreferences.RESULT_SET_USE_FETCH_SIZE) ||
            store.contains(ResultSetPreferences.RESULT_SET_USE_NAVIGATOR_FILTERS) ||
            store.contains(ResultSetPreferences.RESULT_SET_SHOW_ERRORS_IN_DIALOG) ||
                    store.contains(ModelPreferences.RESULT_SET_IGNORE_COLUMN_LABEL)
            ;
    }

    }

    @Override
    protected boolean supportsDataSourceSpecificOptions()
    {
        return true;
    }

    @NotNull
    @Override
    protected Control createPreferenceContent(@NotNull Composite parent) {
        Composite composite = UIUtils.createPlaceholder(parent, 2, 5);
        Composite leftPane = UIUtils.createComposite(composite, 1);
        leftPane.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
        Composite rightPane = UIUtils.createComposite(composite, 1);
        rightPane.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));

        {
            Group queriesGroup = UIUtils.createControlGroup(leftPane, ResultSetMessages.pref_page_database_general_group_queries, 2, SWT.NONE, 0);
            queriesGroup.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));

            resultSetSize = UIUtils.createLabelText(queriesGroup, ResultSetMessages.pref_page_database_general_label_result_set_max_size, "0", SWT.BORDER);
            resultSetSize.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.getDefault()));
            resultSetSize.addFocusListener(new FocusAdapter() {
                @Override
                public void focusLost(FocusEvent e) {
                    int newValue = CommonUtils.toInt(resultSetSize.getText());
                    if (newValue > 0 && newValue < ResultSetPreferences.MIN_SEGMENT_SIZE) {
                        resultSetSize.setText(String.valueOf(ResultSetPreferences.MIN_SEGMENT_SIZE));
                    }
                }
            });

            autoFetchNextSegmentCheck = UIUtils.createCheckbox(queriesGroup, ResultSetMessages.pref_page_database_resultsets_label_auto_fetch_segment, ResultSetMessages.pref_page_database_resultsets_label_auto_fetch_segment_tip, true, 2);
            rereadOnScrollingCheck = UIUtils.createCheckbox(queriesGroup, ResultSetMessages.pref_page_database_resultsets_label_reread_on_scrolling, ResultSetMessages.pref_page_database_resultsets_label_reread_on_scrolling_tip, true, 2);
            resultSetUseSQLCheck = UIUtils.createCheckbox(queriesGroup, ResultSetMessages.pref_page_database_resultsets_label_use_sql, ResultSetMessages.pref_page_database_resultsets_label_use_sql_tip, false, 2);
            orderingModeCombo = UIUtils.createLabelCombo(queriesGroup, ResultSetMessages.pref_page_database_resultsets_label_order_mode, ResultSetMessages.pref_page_database_resultsets_label_order_mode_tip, SWT.DROP_DOWN | SWT.READ_ONLY);
            for (ResultSetUtils.OrderingMode mode : ResultSetUtils.OrderingMode.values()) {
                orderingModeCombo.add(mode.getText());
            }
            readQueryMetadata = UIUtils.createCheckbox(queriesGroup, ResultSetMessages.pref_page_database_resultsets_label_read_metadata,
               ResultSetMessages.pref_page_database_resultsets_label_read_metadata_tip, false, 2);
            readQueryReferences = UIUtils.createCheckbox(queriesGroup, ResultSetMessages.pref_page_database_resultsets_label_read_references,
                ResultSetMessages.pref_page_database_resultsets_label_read_references_tip, false, 2);
            queryCancelTimeout = UIUtils.createLabelText(queriesGroup, ResultSetMessages.pref_page_database_general_label_result_set_cancel_timeout + UIMessages.label_ms, "0");
            queryCancelTimeout.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.getDefault()));
            queryCancelTimeout.setToolTipText(ResultSetMessages.pref_page_database_general_label_result_set_cancel_timeout_tip);
            queryCancelTimeout.setEnabled(false);

            filterForceSubselect = UIUtils.createCheckbox(queriesGroup, ResultSetMessages.pref_page_database_resultsets_label_filter_force_subselect,
                ResultSetMessages.pref_page_database_resultsets_label_filter_force_subselect_tip, false, 2);

            readQueryMetadata.addSelectionListener(new SelectionAdapter() {
                    updateOptionsEnablement();
                }
            });
        }
        {
            Group advGroup = UIUtils.createControlGroup(leftPane, ResultSetMessages.pref_page_results_group_advanced, 1, GridData.VERTICAL_ALIGN_BEGINNING, 0);
            ignoreColumnLabelCheck = UIUtils.createCheckbox(advGroup, ResultSetMessages.pref_page_database_general_use_column_names, ResultSetMessages.pref_page_database_general_use_column_names_tip, false, 1);
            advUseFetchSize = UIUtils.createCheckbox(advGroup, ResultSetMessages.pref_page_database_resultsets_label_fetch_size, ResultSetMessages.pref_page_database_resultsets_label_fetch_size_tip, false, 1);
        }


        // Misc settings
        {
            Group miscGroup = UIUtils.createControlGroup(rightPane, ResultSetMessages.pref_page_sql_editor_group_misc, 1, GridData.VERTICAL_ALIGN_BEGINNING, 0);
            miscGroup.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));

            keepStatementOpenCheck = UIUtils.createCheckbox(miscGroup, ResultSetMessages.pref_page_database_general_checkbox_keep_cursor, false);
            alwaysUseAllColumns = UIUtils.createCheckbox(miscGroup, ResultSetMessages.pref_page_content_editor_checkbox_keys_always_use_all_columns, false);
            newRowsAfter = UIUtils.createCheckbox(miscGroup, ResultSetMessages.pref_page_content_editor_checkbox_new_rows_after, false);
            refreshAfterUpdate = UIUtils.createCheckbox(miscGroup, ResultSetMessages.pref_page_content_editor_checkbox_refresh_after_update, false);
            useNavigatorFilters = UIUtils.createCheckbox(miscGroup, ResultSetMessages.pref_page_content_editor_checkbox_use_navigator_filters, ResultSetMessages.pref_page_content_editor_checkbox_use_navigator_filters_tip, false, 1);
            useDateTimeEditor = UIUtils.createCheckbox(miscGroup, ResultSetMessages.pref_page_content_editor_checkbox_string_editor_for_datetime, ResultSetMessages.pref_page_content_editor_checkbox_string_editor_for_datetime_tip, false, 1);
        }

        {
            Group uiGroup = UIUtils.createControlGroup(rightPane, "UI", 1, GridData.VERTICAL_ALIGN_BEGINNING, 0);
            uiGroup.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));

            showErrorsInDialog = UIUtils.createCheckbox(uiGroup, ResultSetMessages.pref_page_content_editor_ui_show_errors_in_dialog, ResultSetMessages.pref_page_content_editor_ui_show_errors_in_dialog_tip, false, 1);
            markCellValueOccurrences = UIUtils.createCheckbox(uiGroup, ResultSetMessages.pref_page_content_editor_ui_mark_cell_value_occurrences, ResultSetMessages.pref_page_content_editor_ui_mark_cell_value_occurrences_tip, false, 1);
        }

        return composite;
    }

    private void updateOptionsEnablement() {
        readQueryReferences.setEnabled(readQueryMetadata.isEnabled() && readQueryMetadata.getSelection());
    }

    @Override
    protected void loadPreferences(DBPPreferenceStore store)
    {
        try {
            autoFetchNextSegmentCheck.setSelection(store.getBoolean(ResultSetPreferences.RESULT_SET_AUTO_FETCH_NEXT_SEGMENT));
            rereadOnScrollingCheck.setSelection(store.getBoolean(ModelPreferences.RESULT_SET_REREAD_ON_SCROLLING));
            useDateTimeEditor.setSelection(store.getBoolean(ModelPreferences.RESULT_SET_USE_DATETIME_EDITOR));
            int rsSegmentSize = store.getInt(ModelPreferences.RESULT_SET_MAX_ROWS);
            if (rsSegmentSize > 0 && rsSegmentSize < ResultSetPreferences.MIN_SEGMENT_SIZE) {
                rsSegmentSize = ResultSetPreferences.MIN_SEGMENT_SIZE;
            }
            resultSetSize.setText(String.valueOf(rsSegmentSize));
            resultSetUseSQLCheck.setSelection(store.getBoolean(ModelPreferences.RESULT_SET_MAX_ROWS_USE_SQL));
            readQueryReferences.setSelection(store.getBoolean(ModelPreferences.RESULT_SET_READ_REFERENCES));
            queryCancelTimeout.setText(store.getString(ResultSetPreferences.RESULT_SET_CANCEL_TIMEOUT));
            filterForceSubselect.setSelection(store.getBoolean(ModelPreferences.SQL_FILTER_FORCE_SUBSELECT));

            keepStatementOpenCheck.setSelection(store.getBoolean(ResultSetPreferences.KEEP_STATEMENT_OPEN));
            alwaysUseAllColumns.setSelection(store.getBoolean(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS));
            alwaysUseAllColumns.setSelection(store.getBoolean(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS));
            newRowsAfter.setSelection(store.getBoolean(ResultSetPreferences.RS_EDIT_NEW_ROWS_AFTER));
            refreshAfterUpdate.setSelection(store.getBoolean(ResultSetPreferences.RS_EDIT_REFRESH_AFTER_UPDATE));
            useNavigatorFilters.setSelection(store.getBoolean(ResultSetPreferences.RESULT_SET_USE_NAVIGATOR_FILTERS));

            advUseFetchSize.setSelection(store.getBoolean(ModelPreferences.RESULT_SET_USE_FETCH_SIZE));
            ignoreColumnLabelCheck.setSelection(store.getBoolean(ModelPreferences.RESULT_SET_IGNORE_COLUMN_LABEL));

            showErrorsInDialog.setSelection(store.getBoolean(ResultSetPreferences.RESULT_SET_SHOW_ERRORS_IN_DIALOG));
            markCellValueOccurrences.setSelection(store.getBoolean(ResultSetPreferences.RESULT_SET_MARK_CELL_VALUE_OCCURRENCES));

            updateOptionsEnablement();
        } catch (Exception e) {
            log.warn(e);
        }
    }

    @Override
    protected void savePreferences(DBPPreferenceStore store)
    {
        try {
            store.setValue(ModelPreferences.RESULT_SET_USE_DATETIME_EDITOR, useDateTimeEditor.getSelection());
            store.setValue(ResultSetPreferences.RESULT_SET_AUTO_FETCH_NEXT_SEGMENT, autoFetchNextSegmentCheck.getSelection());
            store.setValue(ModelPreferences.RESULT_SET_REREAD_ON_SCROLLING, rereadOnScrollingCheck.getSelection());
            store.setValue(ModelPreferences.RESULT_SET_MAX_ROWS, resultSetSize.getText());
            store.setValue(ModelPreferences.RESULT_SET_READ_REFERENCES, readQueryReferences.getSelection());
            store.setValue(ResultSetPreferences.RESULT_SET_CANCEL_TIMEOUT, queryCancelTimeout.getText());
            store.setValue(ModelPreferences.SQL_FILTER_FORCE_SUBSELECT, filterForceSubselect.getSelection());

            store.setValue(ResultSetPreferences.KEEP_STATEMENT_OPEN, keepStatementOpenCheck.getSelection());
            store.setValue(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS, alwaysUseAllColumns.getSelection());
            store.setValue(ResultSetPreferences.KEEP_STATEMENT_OPEN, keepStatementOpenCheck.getSelection());
            store.setValue(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS, alwaysUseAllColumns.getSelection());
            store.setValue(ResultSetPreferences.RS_EDIT_NEW_ROWS_AFTER, newRowsAfter.getSelection());
            store.setValue(ResultSetPreferences.RS_EDIT_REFRESH_AFTER_UPDATE, refreshAfterUpdate.getSelection());
            store.setValue(ResultSetPreferences.RESULT_SET_USE_NAVIGATOR_FILTERS, useNavigatorFilters.getSelection());

            store.setValue(ModelPreferences.RESULT_SET_USE_FETCH_SIZE, advUseFetchSize.getSelection());
            store.setValue(ModelPreferences.RESULT_SET_IGNORE_COLUMN_LABEL, ignoreColumnLabelCheck.getSelection());

            store.setValue(ResultSetPreferences.RESULT_SET_SHOW_ERRORS_IN_DIALOG, showErrorsInDialog.getSelection());
            store.setValue(ResultSetPreferences.RESULT_SET_MARK_CELL_VALUE_OCCURRENCES, markCellValueOccurrences.getSelection());
        } catch (Exception e) {
            log.warn(e);
        }
        PrefUtils.savePreferenceStore(store);
    }

    @Override
    protected void clearPreferences(DBPPreferenceStore store)
    {
        store.setToDefault(ModelPreferences.RESULT_SET_USE_DATETIME_EDITOR);
        store.setToDefault(ResultSetPreferences.RESULT_SET_AUTO_FETCH_NEXT_SEGMENT);
        store.setToDefault(ModelPreferences.RESULT_SET_REREAD_ON_SCROLLING);
        store.setToDefault(ModelPreferences.RESULT_SET_READ_REFERENCES);
        store.setToDefault(ResultSetPreferences.RESULT_SET_CANCEL_TIMEOUT);
        store.setToDefault(ModelPreferences.SQL_FILTER_FORCE_SUBSELECT);

        store.setToDefault(ResultSetPreferences.KEEP_STATEMENT_OPEN);
        store.setToDefault(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS);

        store.setToDefault(ResultSetPreferences.KEEP_STATEMENT_OPEN);
        store.setToDefault(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS);
        store.setToDefault(ResultSetPreferences.RS_EDIT_NEW_ROWS_AFTER);
        store.setToDefault(ResultSetPreferences.RS_EDIT_REFRESH_AFTER_UPDATE);
        store.setToDefault(ResultSetPreferences.RESULT_SET_USE_NAVIGATOR_FILTERS);

        store.setToDefault(ModelPreferences.RESULT_SET_USE_FETCH_SIZE);
        store.setToDefault(ModelPreferences.RESULT_SET_IGNORE_COLUMN_LABEL);

        store.setToDefault(ResultSetPreferences.RESULT_SET_SHOW_ERRORS_IN_DIALOG);
        store.setToDefault(ResultSetPreferences.RESULT_SET_MARK_CELL_VALUE_OCCURRENCES);

        updateOptionsEnablement();
    }

    @Override
    protected String getPropertyPageID()
    {
        return PAGE_ID;
    }
}
<MSG> #12786 checkbox setting in menu added

<DFF> @@ -57,6 +57,7 @@ public class PrefPageResultSetMain extends TargetPrefPage
     private Button readQueryReferences;
     private Text queryCancelTimeout;
     private Button filterForceSubselect;
+    private Button replaceAllNullsOnDefault;
 
     private Button keepStatementOpenCheck;
     private Button alwaysUseAllColumns;
@@ -95,7 +96,8 @@ public class PrefPageResultSetMain extends TargetPrefPage
             store.contains(ModelPreferences.RESULT_SET_USE_FETCH_SIZE) ||
             store.contains(ResultSetPreferences.RESULT_SET_USE_NAVIGATOR_FILTERS) ||
             store.contains(ResultSetPreferences.RESULT_SET_SHOW_ERRORS_IN_DIALOG) ||
-                    store.contains(ModelPreferences.RESULT_SET_IGNORE_COLUMN_LABEL)
+            store.contains(ModelPreferences.RESULT_SET_IGNORE_COLUMN_LABEL) ||
+            store.contains(ModelPreferences.RESULT_SET_IGNORE_COLUMN_LABEL)
             ;
     }
 
@@ -155,6 +157,10 @@ public class PrefPageResultSetMain extends TargetPrefPage
                     updateOptionsEnablement();
                 }
             });
+
+            replaceAllNullsOnDefault = UIUtils.createCheckbox(queriesGroup, ResultSetMessages.pref_page_database_resultsets_label_replace_nulls_on_default,
+            ResultSetMessages.pref_page_database_resultsets_label_replace_nulls_on_default_tip, true, 2);
+
         }
         {
             Group advGroup = UIUtils.createControlGroup(leftPane, ResultSetMessages.pref_page_results_group_advanced, 1, GridData.VERTICAL_ALIGN_BEGINNING, 0);
@@ -207,6 +213,7 @@ public class PrefPageResultSetMain extends TargetPrefPage
             readQueryReferences.setSelection(store.getBoolean(ModelPreferences.RESULT_SET_READ_REFERENCES));
             queryCancelTimeout.setText(store.getString(ResultSetPreferences.RESULT_SET_CANCEL_TIMEOUT));
             filterForceSubselect.setSelection(store.getBoolean(ModelPreferences.SQL_FILTER_FORCE_SUBSELECT));
+            replaceAllNullsOnDefault.setSelection(store.getBoolean(ModelPreferences.SQL_REPLACE_NULLS_TO_DEFAULT_VALUES));
 
             keepStatementOpenCheck.setSelection(store.getBoolean(ResultSetPreferences.KEEP_STATEMENT_OPEN));
             alwaysUseAllColumns.setSelection(store.getBoolean(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS));
@@ -238,6 +245,7 @@ public class PrefPageResultSetMain extends TargetPrefPage
             store.setValue(ModelPreferences.RESULT_SET_READ_REFERENCES, readQueryReferences.getSelection());
             store.setValue(ResultSetPreferences.RESULT_SET_CANCEL_TIMEOUT, queryCancelTimeout.getText());
             store.setValue(ModelPreferences.SQL_FILTER_FORCE_SUBSELECT, filterForceSubselect.getSelection());
+            store.setValue(ModelPreferences.SQL_REPLACE_NULLS_TO_DEFAULT_VALUES, replaceAllNullsOnDefault.getSelection());
 
             store.setValue(ResultSetPreferences.KEEP_STATEMENT_OPEN, keepStatementOpenCheck.getSelection());
             store.setValue(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS, alwaysUseAllColumns.getSelection());
@@ -267,6 +275,7 @@ public class PrefPageResultSetMain extends TargetPrefPage
         store.setToDefault(ModelPreferences.RESULT_SET_READ_REFERENCES);
         store.setToDefault(ResultSetPreferences.RESULT_SET_CANCEL_TIMEOUT);
         store.setToDefault(ModelPreferences.SQL_FILTER_FORCE_SUBSELECT);
+        store.setToDefault(ModelPreferences.SQL_REPLACE_NULLS_TO_DEFAULT_VALUES);
 
         store.setToDefault(ResultSetPreferences.KEEP_STATEMENT_OPEN);
         store.setToDefault(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS);

{'commit': 'diff --git a/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/ModelPreferences.java b/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/ModelPreferences.java\nindex 410e40a16d..1d25526491 100644\n--- a/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/ModelPreferences.java\n+++ b/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/ModelPreferences.java\n@@ -104,6 +104,7 @@ public final class ModelPreferences\n     public static final String SQL_CONTROL_COMMAND_PREFIX = "sql.command.prefix"; //$NON-NLS-1$\r\n     public static final String SQL_VARIABLES_ENABLED = "sql.variables.enabled"; //$NON-NLS-1$\r\n     public static final String SQL_FILTER_FORCE_SUBSELECT = "sql.query.filter.force.subselect"; //$NON-NLS-1$\r\n+    public static final String SQL_REPLACE_NULLS_TO_DEFAULT_VALUES = "sql.replace.nulls.to.default"; //$NON-NLS-1$\r\n \r\n     public final static String SQL_FORMAT_KEYWORD_CASE = "sql.format.keywordCase";\r\n     public final static String SQL_FORMAT_EXTERNAL_CMD = "sql.format.external.cmd";\r\n@@ -237,6 +238,7 @@ public final class ModelPreferences\n         PrefUtils.setDefaultPreferenceValue(store, SQL_CONTROL_COMMAND_PREFIX, String.valueOf(SQLConstants.DEFAULT_CONTROL_COMMAND_PREFIX));\r\n         PrefUtils.setDefaultPreferenceValue(store, SQL_VARIABLES_ENABLED, true);\r\n         PrefUtils.setDefaultPreferenceValue(store, SQL_FILTER_FORCE_SUBSELECT, false);\r\n+        PrefUtils.setDefaultPreferenceValue(store, SQL_REPLACE_NULLS_TO_DEFAULT_VALUES, true);\r\n \r\n         PrefUtils.setDefaultPreferenceValue(store, SQL_FORMAT_KEYWORD_CASE, "");\r\n         PrefUtils.setDefaultPreferenceValue(store, SQL_FORMAT_LF_BEFORE_COMMA, false);\r\ndiff --git a/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/ExecuteInsertBatchImpl.java b/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/ExecuteInsertBatchImpl.java\nindex b82b1a2df1..dc6fd6935b 100644\n--- a/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/ExecuteInsertBatchImpl.java\n+++ b/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/ExecuteInsertBatchImpl.java\n@@ -18,6 +18,8 @@ package org.jkiss.dbeaver.model.impl.data;\n \n import org.jkiss.code.NotNull;\n import org.jkiss.code.Nullable;\n+import org.jkiss.dbeaver.ModelPreferences;\n+import org.jkiss.dbeaver.model.DBPDataSource;\n import org.jkiss.dbeaver.model.DBPEvaluationContext;\n import org.jkiss.dbeaver.model.DBUtils;\n import org.jkiss.dbeaver.model.data.*;\n@@ -131,15 +133,16 @@ public class ExecuteInsertBatchImpl extends ExecuteBatchImpl {\n                 break;\n             }\n         }\n-        if (allNulls && !useMultiRowInsert && method instanceof BaseInsertMethod && !useUpsert\n-                && session.getDataSource().getSQLDialect().supportsInsertAllDefaultValuesStatement()) {\n+        DBPDataSource dataSource = session.getDataSource();\n+        boolean replaceNullsToDefaults = dataSource.getContainer().getPreferenceStore().getBoolean(ModelPreferences.SQL_REPLACE_NULLS_TO_DEFAULT_VALUES); // Disable this setting to set actually nulls into row\n+        if (allNulls && replaceNullsToDefaults && !useMultiRowInsert && method instanceof BaseInsertMethod && !useUpsert\n+                && dataSource.getSQLDialect().supportsInsertAllDefaultValuesStatement()) {\n             checkDefaultAttributeValues(attributes);\n             if (allColumnsDefault) {\n                 query.setLength(0);\n                 query.append("INSERT INTO ").append(tableName).append(" DEFAULT VALUES");\n                 return query;\n             }\n-\n         }\n         boolean hasKey = false;\n         for (int i = 0; i < attributes.length; i++) {\ndiff --git a/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages.java b/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages.java\nindex affa5eba20..e9cb223e17 100644\n--- a/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages.java\n+++ b/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages.java\n@@ -282,6 +282,8 @@ public class ResultSetMessages extends NLS {\n     public static String pref_page_database_resultsets_group_string;\n     public static String pref_page_database_resultsets_checkbox_string_use_editor;\n     public static String pref_page_database_resultsets_checkbox_string_use_editor_tip;\n+    public static String pref_page_database_resultsets_label_replace_nulls_on_default;\n+    public static String pref_page_database_resultsets_label_replace_nulls_on_default_tip;\n \n     public static String pref_page_database_resultsets_label_read_metadata_tip;\n     public static String pref_page_database_resultsets_label_read_references_tip;\ndiff --git a/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages.properties b/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages.properties\nindex 690e52c2ef..7c8cdaf8a0 100644\n--- a/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages.properties\n+++ b/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages.properties\n@@ -270,6 +270,8 @@ pref_page_database_resultsets_label_use_sql_tip = Modify source SQL query to scr\n pref_page_database_resultsets_group_string = Strings\n pref_page_database_resultsets_checkbox_string_use_editor = Open in separate editor\n pref_page_database_resultsets_checkbox_string_use_editor_tip = Opens separate string editor instead of dialog\n+pref_page_database_resultsets_label_replace_nulls_on_default = Replace all nulls insert in default values\n+pref_page_database_resultsets_label_replace_nulls_on_default_tip = Use "DEFAULT VALUES" insert, when in the row only zero values. Database specific setting.\n \n pref_page_database_general_label_cache_max_size = LOB cache max size\n pref_page_database_general_label_max_lob_length = Maximum LOB length to keep in memory\ndiff --git a/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages_ru.properties b/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages_ru.properties\nindex 0391d00738..859b9ebb1d 100644\n--- a/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages_ru.properties\n+++ b/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/internal/ResultSetMessages_ru.properties\n@@ -216,6 +216,8 @@ pref_page_database_resultsets_label_use_sql_tip = \\u041C\\u043E\\u0434\\u0438\\u0444\n pref_page_database_resultsets_group_string = \\u041D\\u0430\\u0441\\u0442\\u0440\\u043E\\u0439\\u043A\\u0438\n pref_page_database_resultsets_checkbox_string_use_editor = \\u041E\\u0442\\u043A\\u0440\\u044B\\u0432\\u0430\\u0442\\u044C \\u0432 \\u043E\\u0442\\u0434\\u0435\\u043B\\u044C\\u043D\\u043E\\u043C \\u0440\\u0435\\u0434\\u0430\\u043A\\u0442\\u043E\\u0440\\u0435\n pref_page_database_resultsets_checkbox_string_use_editor_tip = \\u041E\\u0442\\u043A\\u0440\\u044B\\u0432\\u0430\\u0442\\u044C \\u0432 \\u043E\\u0442\\u0434\\u0435\\u043B\\u044C\\u043D\\u043E\\u043C \\u0440\\u0435\\u0434\\u0430\\u043A\\u0442\\u043E\\u0440\\u0435 (\\u0432\\u043C\\u0435\\u0441\\u0442\\u043E \\u0434\\u0438\\u0430\\u043B\\u043E\\u0433\\u0430)\n+pref_page_database_resultsets_label_replace_nulls_on_default = \\u0417\\u0430\\u043C\\u0435\\u043D\\u044F\\u0442\\u044C \\u0432\\u0441\\u0435 \\u043D\\u0443\\u043B\\u0438 \\u043D\\u0430 \\u0437\\u043D\\u0430\\u0447\\u0435\\u043D\\u0438\\u044F \\u043F\\u043E \\u0443\\u043C\\u043E\\u043B\\u0447\\u0430\\u043D\\u0438\\u044E \\u043F\\u0440\\u0438 \\u0432\\u0441\\u0442\\u0430\\u0432\\u043A\\u0435\n+pref_page_database_resultsets_label_replace_nulls_on_default_tip = \\u0418\\u0441\\u043F\\u043E\\u043B\\u044C\\u0437\\u043E\\u0432\\u0430\\u0442\\u044C "INSERT DEFAULT VALUES" \\u0432\\u044B\\u0440\\u0430\\u0436\\u0435\\u043D\\u0438\\u0435 \\u0432 \\u0441\\u043B\\u0443\\u0447\\u0430\\u0435, \\u043A\\u043E\\u0433\\u0434\\u0430 \\u0432 \\u0441\\u0442\\u0440\\u043E\\u043A\\u0443 \\u0432\\u0441\\u0442\\u0430\\u0432\\u043B\\u044F\\u044E\\u0442\\u0441\\u044F \\u0442\\u043E\\u043B\\u044C\\u043A\\u043E \\u043D\\u0443\\u043B\\u0438,\\n\\u0430 \\u0443 \\u0432\\u0441\\u0435\\u0445 \\u043A\\u043E\\u043B\\u043E\\u043D\\u043E\\u043A \\u043F\\u0440\\u043E\\u043F\\u0438\\u0441\\u0430\\u043D\\u044B \\u0437\\u043D\\u0430\\u0447\\u0435\\u043D\\u0438\\u044F \\u043F\\u043E \\u0443\\u043C\\u043E\\u043B\\u0447\\u0430\\u043D\\u0438\\u044E. \\u042D\\u0442\\u0430 \\u043D\\u0430\\u0441\\u0442\\u0440\\u043E\\u0439\\u043A\\u0430 \\u0437\\u0430\\u0432\\u0438\\u0441\\u0438\\u0442 \\u043E\\u0442 \\u0411\\u0414.\n #ResultSetsMain\n pref_page_database_resultsets_label_read_metadata_tip = \\u041E\\u0442\\u043A\\u043B\\u044E\\u0447\\u0430\\u0435\\u0442 \\u0447\\u0442\\u0435\\u043D\\u0438\\u0435 \\u043C\\u0435\\u0442\\u0430\\u0434\\u0430\\u043D\\u043D\\u044B\\u0445. \\u0412\\u044B\\u043F\\u043E\\u043B\\u043D\\u044F\\u0435\\u0442 \\u0437\\u0430\\u043F\\u0440\\u043E\\u0441 \\u0431\\u044B\\u0441\\u0442\\u0440\\u0435\\u0435, \\u043D\\u043E \\u043E\\u0442\\u043A\\u043B\\u044E\\u0447\\u0430\\u0435\\u0442 \\u0440\\u0435\\u0434\\u0430\\u043A\\u0442\\u0438\\u0440\\u043E\\u0432\\u0430\\u043D\\u0438\\u0435 \\u0440\\u0435\\u0437\\u0443\\u043B\\u044C\\u0442\\u0430\\u0442\\u043E\\u0432 \\u0438 \\u043D\\u0430\\u0432\\u0438\\u0433\\u0430\\u0446\\u0438\\u044E \\u043F\\u043E \\u0432\\u043D\\u0435\\u0448\\u043D\\u0438\\u043C \\u043A\\u043B\\u0430\\u0432\\u0438\\u0448\\u0430\\u043C\n pref_page_database_resultsets_label_read_references_tip = \\u041E\\u0442\\u043A\\u043B\\u044E\\u0447\\u0430\\u0435\\u0442 \\u0447\\u0442\\u0435\\u043D\\u0438\\u0435 \\u0438\\u043D\\u0444\\u043E\\u0440\\u043C\\u0430\\u0446\\u0438\\u0438 \\u043F\\u043E \\u0441\\u0441\\u044B\\u043B\\u043A\\u0430\\u043C (\\u0432\\u043D\\u0435\\u0448\\u043D\\u0438\\u043C \\u043A\\u043B\\u044E\\u0447\\u0430\\u043C).\ndiff --git a/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/editors/data/preferences/PrefPageResultSetMain.java b/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/editors/data/preferences/PrefPageResultSetMain.java\nindex 37d2755e46..ca61f7fea3 100644\n--- a/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/editors/data/preferences/PrefPageResultSetMain.java\n+++ b/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/editors/data/preferences/PrefPageResultSetMain.java\n@@ -57,6 +57,7 @@ public class PrefPageResultSetMain extends TargetPrefPage\n     private Button readQueryReferences;\n     private Text queryCancelTimeout;\n     private Button filterForceSubselect;\n+    private Button replaceAllNullsOnDefault;\n \n     private Button keepStatementOpenCheck;\n     private Button alwaysUseAllColumns;\n@@ -95,7 +96,8 @@ public class PrefPageResultSetMain extends TargetPrefPage\n             store.contains(ModelPreferences.RESULT_SET_USE_FETCH_SIZE) ||\n             store.contains(ResultSetPreferences.RESULT_SET_USE_NAVIGATOR_FILTERS) ||\n             store.contains(ResultSetPreferences.RESULT_SET_SHOW_ERRORS_IN_DIALOG) ||\n-                    store.contains(ModelPreferences.RESULT_SET_IGNORE_COLUMN_LABEL)\n+            store.contains(ModelPreferences.RESULT_SET_IGNORE_COLUMN_LABEL) ||\n+            store.contains(ModelPreferences.RESULT_SET_IGNORE_COLUMN_LABEL)\n             ;\n     }\n \n@@ -155,6 +157,10 @@ public class PrefPageResultSetMain extends TargetPrefPage\n                     updateOptionsEnablement();\n                 }\n             });\n+\n+            replaceAllNullsOnDefault = UIUtils.createCheckbox(queriesGroup, ResultSetMessages.pref_page_database_resultsets_label_replace_nulls_on_default,\n+            ResultSetMessages.pref_page_database_resultsets_label_replace_nulls_on_default_tip, true, 2);\n+\n         }\n         {\n             Group advGroup = UIUtils.createControlGroup(leftPane, ResultSetMessages.pref_page_results_group_advanced, 1, GridData.VERTICAL_ALIGN_BEGINNING, 0);\n@@ -207,6 +213,7 @@ public class PrefPageResultSetMain extends TargetPrefPage\n             readQueryReferences.setSelection(store.getBoolean(ModelPreferences.RESULT_SET_READ_REFERENCES));\n             queryCancelTimeout.setText(store.getString(ResultSetPreferences.RESULT_SET_CANCEL_TIMEOUT));\n             filterForceSubselect.setSelection(store.getBoolean(ModelPreferences.SQL_FILTER_FORCE_SUBSELECT));\n+            replaceAllNullsOnDefault.setSelection(store.getBoolean(ModelPreferences.SQL_REPLACE_NULLS_TO_DEFAULT_VALUES));\n \n             keepStatementOpenCheck.setSelection(store.getBoolean(ResultSetPreferences.KEEP_STATEMENT_OPEN));\n             alwaysUseAllColumns.setSelection(store.getBoolean(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS));\n@@ -238,6 +245,7 @@ public class PrefPageResultSetMain extends TargetPrefPage\n             store.setValue(ModelPreferences.RESULT_SET_READ_REFERENCES, readQueryReferences.getSelection());\n             store.setValue(ResultSetPreferences.RESULT_SET_CANCEL_TIMEOUT, queryCancelTimeout.getText());\n             store.setValue(ModelPreferences.SQL_FILTER_FORCE_SUBSELECT, filterForceSubselect.getSelection());\n+            store.setValue(ModelPreferences.SQL_REPLACE_NULLS_TO_DEFAULT_VALUES, replaceAllNullsOnDefault.getSelection());\n \n             store.setValue(ResultSetPreferences.KEEP_STATEMENT_OPEN, keepStatementOpenCheck.getSelection());\n             store.setValue(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS, alwaysUseAllColumns.getSelection());\n@@ -267,6 +275,7 @@ public class PrefPageResultSetMain extends TargetPrefPage\n         store.setToDefault(ModelPreferences.RESULT_SET_READ_REFERENCES);\n         store.setToDefault(ResultSetPreferences.RESULT_SET_CANCEL_TIMEOUT);\n         store.setToDefault(ModelPreferences.SQL_FILTER_FORCE_SUBSELECT);\n+        store.setToDefault(ModelPreferences.SQL_REPLACE_NULLS_TO_DEFAULT_VALUES);\n \n         store.setToDefault(ResultSetPreferences.KEEP_STATEMENT_OPEN);\n         store.setToDefault(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS);\n', 'commit_subject': '#12786 checkbox setting in menu added', 'repo_name': 'dbeaver/dbeaver', 'committer': {'name': 'LonwoLonwo', 'email': 'd7d422a6587fe11f39396c8bf8dfc77b60318e2e@yandex.ru', 'time_sec': '1627303714', 'tz_offset': '180', 'date': {'seconds': '1627303714'}}, 'commit_tree': 'e1ff86a27283be65675187b85bb36fae3da269bb', 'commit_message': '#12786 checkbox setting in menu added\n', 'language_name': 'HTML', 'license': 'apache-2.0', 'hunks': '@@ -57,6 +57,7 @@ public class PrefPageResultSetMain extends TargetPrefPage\n     private Button readQueryReferences;\n     private Text queryCancelTimeout;\n     private Button filterForceSubselect;\n+    private Button replaceAllNullsOnDefault;\n \n     private Button keepStatementOpenCheck;\n     private Button alwaysUseAllColumns;\n@@ -95,7 +96,8 @@ public class PrefPageResultSetMain extends TargetPrefPage\n             store.contains(ModelPreferences.RESULT_SET_USE_FETCH_SIZE) ||\n             store.contains(ResultSetPreferences.RESULT_SET_USE_NAVIGATOR_FILTERS) ||\n             store.contains(ResultSetPreferences.RESULT_SET_SHOW_ERRORS_IN_DIALOG) ||\n-                    store.contains(ModelPreferences.RESULT_SET_IGNORE_COLUMN_LABEL)\n+            store.contains(ModelPreferences.RESULT_SET_IGNORE_COLUMN_LABEL) ||\n+            store.contains(ModelPreferences.RESULT_SET_IGNORE_COLUMN_LABEL)\n             ;\n     }\n \n@@ -155,6 +157,10 @@ public class PrefPageResultSetMain extends TargetPrefPage\n                     updateOptionsEnablement();\n                 }\n             });\n+\n+            replaceAllNullsOnDefault = UIUtils.createCheckbox(queriesGroup, ResultSetMessages.pref_page_database_resultsets_label_replace_nulls_on_default,\n+            ResultSetMessages.pref_page_database_resultsets_label_replace_nulls_on_default_tip, true, 2);\n+\n         }\n         {\n             Group advGroup = UIUtils.createControlGroup(leftPane, ResultSetMessages.pref_page_results_group_advanced, 1, GridData.VERTICAL_ALIGN_BEGINNING, 0);\n@@ -207,6 +213,7 @@ public class PrefPageResultSetMain extends TargetPrefPage\n             readQueryReferences.setSelection(store.getBoolean(ModelPreferences.RESULT_SET_READ_REFERENCES));\n             queryCancelTimeout.setText(store.getString(ResultSetPreferences.RESULT_SET_CANCEL_TIMEOUT));\n             filterForceSubselect.setSelection(store.getBoolean(ModelPreferences.SQL_FILTER_FORCE_SUBSELECT));\n+            replaceAllNullsOnDefault.setSelection(store.getBoolean(ModelPreferences.SQL_REPLACE_NULLS_TO_DEFAULT_VALUES));\n \n             keepStatementOpenCheck.setSelection(store.getBoolean(ResultSetPreferences.KEEP_STATEMENT_OPEN));\n             alwaysUseAllColumns.setSelection(store.getBoolean(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS));\n@@ -238,6 +245,7 @@ public class PrefPageResultSetMain extends TargetPrefPage\n             store.setValue(ModelPreferences.RESULT_SET_READ_REFERENCES, readQueryReferences.getSelection());\n             store.setValue(ResultSetPreferences.RESULT_SET_CANCEL_TIMEOUT, queryCancelTimeout.getText());\n             store.setValue(ModelPreferences.SQL_FILTER_FORCE_SUBSELECT, filterForceSubselect.getSelection());\n+            store.setValue(ModelPreferences.SQL_REPLACE_NULLS_TO_DEFAULT_VALUES, replaceAllNullsOnDefault.getSelection());\n \n             store.setValue(ResultSetPreferences.KEEP_STATEMENT_OPEN, keepStatementOpenCheck.getSelection());\n             store.setValue(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS, alwaysUseAllColumns.getSelection());\n@@ -267,6 +275,7 @@ public class PrefPageResultSetMain extends TargetPrefPage\n         store.setToDefault(ModelPreferences.RESULT_SET_READ_REFERENCES);\n         store.setToDefault(ResultSetPreferences.RESULT_SET_CANCEL_TIMEOUT);\n         store.setToDefault(ModelPreferences.SQL_FILTER_FORCE_SUBSELECT);\n+        store.setToDefault(ModelPreferences.SQL_REPLACE_NULLS_TO_DEFAULT_VALUES);\n \n         store.setToDefault(ResultSetPreferences.KEEP_STATEMENT_OPEN);\n         store.setToDefault(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS);\n', 'addition_count': 10, 'deletion_count': 1, 'src_file': 'a/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/editors/data/preferences/PrefPageResultSetMain.java', 'tgt_file': 'b/plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/editors/data/preferences/PrefPageResultSetMain.java', 'file_extension': '.java', 'before_file': '/*\n * DBeaver - Universal Database Manager\n * Copyright (C) 2010-2022 DBeaver Corp and others\n * Copyright (C) 2011-2012 Eugene Fradkin (eugene.fradkin@gmail.com)\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage org.jkiss.dbeaver.ui.editors.data.preferences;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.FocusAdapter;\nimport org.eclipse.swt.events.FocusEvent;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.widgets.*;\nimport org.jkiss.code.NotNull;\nimport org.jkiss.dbeaver.Log;\nimport org.jkiss.dbeaver.ModelPreferences;\nimport org.jkiss.dbeaver.model.DBPDataSourceContainer;\nimport org.jkiss.dbeaver.model.preferences.DBPPreferenceStore;\nimport org.jkiss.dbeaver.ui.UIUtils;\nimport org.jkiss.dbeaver.ui.controls.resultset.ResultSetPreferences;\nimport org.jkiss.dbeaver.ui.controls.resultset.ResultSetUtils;\nimport org.jkiss.dbeaver.ui.controls.resultset.internal.ResultSetMessages;\nimport org.jkiss.dbeaver.ui.internal.UIMessages;\nimport org.jkiss.dbeaver.ui.preferences.TargetPrefPage;\nimport org.jkiss.dbeaver.utils.PrefUtils;\nimport org.jkiss.utils.CommonUtils;\n\nimport java.util.Locale;\n\n/**\n * PrefPageResultSetMain\n */\npublic class PrefPageResultSetMain extends TargetPrefPage\n{\n    static final Log log = Log.getLog(PrefPageResultSetMain.class);\n\n    public static final String PAGE_ID = "org.jkiss.dbeaver.preferences.main.resultset"; //$NON-NLS-1$\n\n    private Button autoFetchNextSegmentCheck;\n    private Button rereadOnScrollingCheck;\n    private Text resultSetSize;\n    private Button resultSetUseSQLCheck;\n    private Combo orderingModeCombo;\n    private Button readQueryReferences;\n    private Text queryCancelTimeout;\n    private Button filterForceSubselect;\n\n    private Button keepStatementOpenCheck;\n    private Button alwaysUseAllColumns;\n    private Button newRowsAfter;\n    private Button refreshAfterUpdate;\n    private Button useNavigatorFilters;\n\n    private Button showErrorsInDialog;\n    private Button markCellValueOccurrences;\n\n    private Button advUseFetchSize;\n\n    private Button ignoreColumnLabelCheck;\n    private Button useDateTimeEditor;\n\n    public PrefPageResultSetMain()\n    {\n        super();\n    }\n\n    @Override\n    protected boolean hasDataSourceSpecificOptions(DBPDataSourceContainer dataSourceDescriptor)\n    {\n        DBPPreferenceStore store = dataSourceDescriptor.getPreferenceStore();\n        return\n            store.contains(ResultSetPreferences.RESULT_SET_AUTO_FETCH_NEXT_SEGMENT) ||\n            store.contains(ModelPreferences.RESULT_SET_REREAD_ON_SCROLLING) ||\n            store.contains(ModelPreferences.RESULT_SET_MAX_ROWS) ||\n            store.contains(ModelPreferences.RESULT_SET_MAX_ROWS_USE_SQL) ||\n            store.contains(ModelPreferences.RESULT_SET_READ_METADATA) ||\n            store.contains(ResultSetPreferences.RESULT_SET_CANCEL_TIMEOUT) ||\n            store.contains(ModelPreferences.SQL_FILTER_FORCE_SUBSELECT) ||\n            store.contains(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS) ||\n            store.contains(ResultSetPreferences.RS_EDIT_NEW_ROWS_AFTER) ||\n            store.contains(ResultSetPreferences.RS_EDIT_REFRESH_AFTER_UPDATE) ||\n            store.contains(ModelPreferences.RESULT_SET_USE_FETCH_SIZE) ||\n            store.contains(ResultSetPreferences.RESULT_SET_USE_NAVIGATOR_FILTERS) ||\n            store.contains(ResultSetPreferences.RESULT_SET_SHOW_ERRORS_IN_DIALOG) ||\n                    store.contains(ModelPreferences.RESULT_SET_IGNORE_COLUMN_LABEL)\n            ;\n    }\n\n    }\n\n    @Override\n    protected boolean supportsDataSourceSpecificOptions()\n    {\n        return true;\n    }\n\n    @NotNull\n    @Override\n    protected Control createPreferenceContent(@NotNull Composite parent) {\n        Composite composite = UIUtils.createPlaceholder(parent, 2, 5);\n        Composite leftPane = UIUtils.createComposite(composite, 1);\n        leftPane.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));\n        Composite rightPane = UIUtils.createComposite(composite, 1);\n        rightPane.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));\n\n        {\n            Group queriesGroup = UIUtils.createControlGroup(leftPane, ResultSetMessages.pref_page_database_general_group_queries, 2, SWT.NONE, 0);\n            queriesGroup.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));\n\n            resultSetSize = UIUtils.createLabelText(queriesGroup, ResultSetMessages.pref_page_database_general_label_result_set_max_size, "0", SWT.BORDER);\n            resultSetSize.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.getDefault()));\n            resultSetSize.addFocusListener(new FocusAdapter() {\n                @Override\n                public void focusLost(FocusEvent e) {\n                    int newValue = CommonUtils.toInt(resultSetSize.getText());\n                    if (newValue > 0 && newValue < ResultSetPreferences.MIN_SEGMENT_SIZE) {\n                        resultSetSize.setText(String.valueOf(ResultSetPreferences.MIN_SEGMENT_SIZE));\n                    }\n                }\n            });\n\n            autoFetchNextSegmentCheck = UIUtils.createCheckbox(queriesGroup, ResultSetMessages.pref_page_database_resultsets_label_auto_fetch_segment, ResultSetMessages.pref_page_database_resultsets_label_auto_fetch_segment_tip, true, 2);\n            rereadOnScrollingCheck = UIUtils.createCheckbox(queriesGroup, ResultSetMessages.pref_page_database_resultsets_label_reread_on_scrolling, ResultSetMessages.pref_page_database_resultsets_label_reread_on_scrolling_tip, true, 2);\n            resultSetUseSQLCheck = UIUtils.createCheckbox(queriesGroup, ResultSetMessages.pref_page_database_resultsets_label_use_sql, ResultSetMessages.pref_page_database_resultsets_label_use_sql_tip, false, 2);\n            orderingModeCombo = UIUtils.createLabelCombo(queriesGroup, ResultSetMessages.pref_page_database_resultsets_label_order_mode, ResultSetMessages.pref_page_database_resultsets_label_order_mode_tip, SWT.DROP_DOWN | SWT.READ_ONLY);\n            for (ResultSetUtils.OrderingMode mode : ResultSetUtils.OrderingMode.values()) {\n                orderingModeCombo.add(mode.getText());\n            }\n            readQueryMetadata = UIUtils.createCheckbox(queriesGroup, ResultSetMessages.pref_page_database_resultsets_label_read_metadata,\n               ResultSetMessages.pref_page_database_resultsets_label_read_metadata_tip, false, 2);\n            readQueryReferences = UIUtils.createCheckbox(queriesGroup, ResultSetMessages.pref_page_database_resultsets_label_read_references,\n                ResultSetMessages.pref_page_database_resultsets_label_read_references_tip, false, 2);\n            queryCancelTimeout = UIUtils.createLabelText(queriesGroup, ResultSetMessages.pref_page_database_general_label_result_set_cancel_timeout + UIMessages.label_ms, "0");\n            queryCancelTimeout.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.getDefault()));\n            queryCancelTimeout.setToolTipText(ResultSetMessages.pref_page_database_general_label_result_set_cancel_timeout_tip);\n            queryCancelTimeout.setEnabled(false);\n\n            filterForceSubselect = UIUtils.createCheckbox(queriesGroup, ResultSetMessages.pref_page_database_resultsets_label_filter_force_subselect,\n                ResultSetMessages.pref_page_database_resultsets_label_filter_force_subselect_tip, false, 2);\n\n            readQueryMetadata.addSelectionListener(new SelectionAdapter() {\n                    updateOptionsEnablement();\n                }\n            });\n        }\n        {\n            Group advGroup = UIUtils.createControlGroup(leftPane, ResultSetMessages.pref_page_results_group_advanced, 1, GridData.VERTICAL_ALIGN_BEGINNING, 0);\n            ignoreColumnLabelCheck = UIUtils.createCheckbox(advGroup, ResultSetMessages.pref_page_database_general_use_column_names, ResultSetMessages.pref_page_database_general_use_column_names_tip, false, 1);\n            advUseFetchSize = UIUtils.createCheckbox(advGroup, ResultSetMessages.pref_page_database_resultsets_label_fetch_size, ResultSetMessages.pref_page_database_resultsets_label_fetch_size_tip, false, 1);\n        }\n\n\n        // Misc settings\n        {\n            Group miscGroup = UIUtils.createControlGroup(rightPane, ResultSetMessages.pref_page_sql_editor_group_misc, 1, GridData.VERTICAL_ALIGN_BEGINNING, 0);\n            miscGroup.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));\n\n            keepStatementOpenCheck = UIUtils.createCheckbox(miscGroup, ResultSetMessages.pref_page_database_general_checkbox_keep_cursor, false);\n            alwaysUseAllColumns = UIUtils.createCheckbox(miscGroup, ResultSetMessages.pref_page_content_editor_checkbox_keys_always_use_all_columns, false);\n            newRowsAfter = UIUtils.createCheckbox(miscGroup, ResultSetMessages.pref_page_content_editor_checkbox_new_rows_after, false);\n            refreshAfterUpdate = UIUtils.createCheckbox(miscGroup, ResultSetMessages.pref_page_content_editor_checkbox_refresh_after_update, false);\n            useNavigatorFilters = UIUtils.createCheckbox(miscGroup, ResultSetMessages.pref_page_content_editor_checkbox_use_navigator_filters, ResultSetMessages.pref_page_content_editor_checkbox_use_navigator_filters_tip, false, 1);\n            useDateTimeEditor = UIUtils.createCheckbox(miscGroup, ResultSetMessages.pref_page_content_editor_checkbox_string_editor_for_datetime, ResultSetMessages.pref_page_content_editor_checkbox_string_editor_for_datetime_tip, false, 1);\n        }\n\n        {\n            Group uiGroup = UIUtils.createControlGroup(rightPane, "UI", 1, GridData.VERTICAL_ALIGN_BEGINNING, 0);\n            uiGroup.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));\n\n            showErrorsInDialog = UIUtils.createCheckbox(uiGroup, ResultSetMessages.pref_page_content_editor_ui_show_errors_in_dialog, ResultSetMessages.pref_page_content_editor_ui_show_errors_in_dialog_tip, false, 1);\n            markCellValueOccurrences = UIUtils.createCheckbox(uiGroup, ResultSetMessages.pref_page_content_editor_ui_mark_cell_value_occurrences, ResultSetMessages.pref_page_content_editor_ui_mark_cell_value_occurrences_tip, false, 1);\n        }\n\n        return composite;\n    }\n\n    private void updateOptionsEnablement() {\n        readQueryReferences.setEnabled(readQueryMetadata.isEnabled() && readQueryMetadata.getSelection());\n    }\n\n    @Override\n    protected void loadPreferences(DBPPreferenceStore store)\n    {\n        try {\n            autoFetchNextSegmentCheck.setSelection(store.getBoolean(ResultSetPreferences.RESULT_SET_AUTO_FETCH_NEXT_SEGMENT));\n            rereadOnScrollingCheck.setSelection(store.getBoolean(ModelPreferences.RESULT_SET_REREAD_ON_SCROLLING));\n            useDateTimeEditor.setSelection(store.getBoolean(ModelPreferences.RESULT_SET_USE_DATETIME_EDITOR));\n            int rsSegmentSize = store.getInt(ModelPreferences.RESULT_SET_MAX_ROWS);\n            if (rsSegmentSize > 0 && rsSegmentSize < ResultSetPreferences.MIN_SEGMENT_SIZE) {\n                rsSegmentSize = ResultSetPreferences.MIN_SEGMENT_SIZE;\n            }\n            resultSetSize.setText(String.valueOf(rsSegmentSize));\n            resultSetUseSQLCheck.setSelection(store.getBoolean(ModelPreferences.RESULT_SET_MAX_ROWS_USE_SQL));\n            readQueryReferences.setSelection(store.getBoolean(ModelPreferences.RESULT_SET_READ_REFERENCES));\n            queryCancelTimeout.setText(store.getString(ResultSetPreferences.RESULT_SET_CANCEL_TIMEOUT));\n            filterForceSubselect.setSelection(store.getBoolean(ModelPreferences.SQL_FILTER_FORCE_SUBSELECT));\n\n            keepStatementOpenCheck.setSelection(store.getBoolean(ResultSetPreferences.KEEP_STATEMENT_OPEN));\n            alwaysUseAllColumns.setSelection(store.getBoolean(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS));\n            alwaysUseAllColumns.setSelection(store.getBoolean(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS));\n            newRowsAfter.setSelection(store.getBoolean(ResultSetPreferences.RS_EDIT_NEW_ROWS_AFTER));\n            refreshAfterUpdate.setSelection(store.getBoolean(ResultSetPreferences.RS_EDIT_REFRESH_AFTER_UPDATE));\n            useNavigatorFilters.setSelection(store.getBoolean(ResultSetPreferences.RESULT_SET_USE_NAVIGATOR_FILTERS));\n\n            advUseFetchSize.setSelection(store.getBoolean(ModelPreferences.RESULT_SET_USE_FETCH_SIZE));\n            ignoreColumnLabelCheck.setSelection(store.getBoolean(ModelPreferences.RESULT_SET_IGNORE_COLUMN_LABEL));\n\n            showErrorsInDialog.setSelection(store.getBoolean(ResultSetPreferences.RESULT_SET_SHOW_ERRORS_IN_DIALOG));\n            markCellValueOccurrences.setSelection(store.getBoolean(ResultSetPreferences.RESULT_SET_MARK_CELL_VALUE_OCCURRENCES));\n\n            updateOptionsEnablement();\n        } catch (Exception e) {\n            log.warn(e);\n        }\n    }\n\n    @Override\n    protected void savePreferences(DBPPreferenceStore store)\n    {\n        try {\n            store.setValue(ModelPreferences.RESULT_SET_USE_DATETIME_EDITOR, useDateTimeEditor.getSelection());\n            store.setValue(ResultSetPreferences.RESULT_SET_AUTO_FETCH_NEXT_SEGMENT, autoFetchNextSegmentCheck.getSelection());\n            store.setValue(ModelPreferences.RESULT_SET_REREAD_ON_SCROLLING, rereadOnScrollingCheck.getSelection());\n            store.setValue(ModelPreferences.RESULT_SET_MAX_ROWS, resultSetSize.getText());\n            store.setValue(ModelPreferences.RESULT_SET_READ_REFERENCES, readQueryReferences.getSelection());\n            store.setValue(ResultSetPreferences.RESULT_SET_CANCEL_TIMEOUT, queryCancelTimeout.getText());\n            store.setValue(ModelPreferences.SQL_FILTER_FORCE_SUBSELECT, filterForceSubselect.getSelection());\n\n            store.setValue(ResultSetPreferences.KEEP_STATEMENT_OPEN, keepStatementOpenCheck.getSelection());\n            store.setValue(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS, alwaysUseAllColumns.getSelection());\n            store.setValue(ResultSetPreferences.KEEP_STATEMENT_OPEN, keepStatementOpenCheck.getSelection());\n            store.setValue(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS, alwaysUseAllColumns.getSelection());\n            store.setValue(ResultSetPreferences.RS_EDIT_NEW_ROWS_AFTER, newRowsAfter.getSelection());\n            store.setValue(ResultSetPreferences.RS_EDIT_REFRESH_AFTER_UPDATE, refreshAfterUpdate.getSelection());\n            store.setValue(ResultSetPreferences.RESULT_SET_USE_NAVIGATOR_FILTERS, useNavigatorFilters.getSelection());\n\n            store.setValue(ModelPreferences.RESULT_SET_USE_FETCH_SIZE, advUseFetchSize.getSelection());\n            store.setValue(ModelPreferences.RESULT_SET_IGNORE_COLUMN_LABEL, ignoreColumnLabelCheck.getSelection());\n\n            store.setValue(ResultSetPreferences.RESULT_SET_SHOW_ERRORS_IN_DIALOG, showErrorsInDialog.getSelection());\n            store.setValue(ResultSetPreferences.RESULT_SET_MARK_CELL_VALUE_OCCURRENCES, markCellValueOccurrences.getSelection());\n        } catch (Exception e) {\n            log.warn(e);\n        }\n        PrefUtils.savePreferenceStore(store);\n    }\n\n    @Override\n    protected void clearPreferences(DBPPreferenceStore store)\n    {\n        store.setToDefault(ModelPreferences.RESULT_SET_USE_DATETIME_EDITOR);\n        store.setToDefault(ResultSetPreferences.RESULT_SET_AUTO_FETCH_NEXT_SEGMENT);\n        store.setToDefault(ModelPreferences.RESULT_SET_REREAD_ON_SCROLLING);\n        store.setToDefault(ModelPreferences.RESULT_SET_READ_REFERENCES);\n        store.setToDefault(ResultSetPreferences.RESULT_SET_CANCEL_TIMEOUT);\n        store.setToDefault(ModelPreferences.SQL_FILTER_FORCE_SUBSELECT);\n\n        store.setToDefault(ResultSetPreferences.KEEP_STATEMENT_OPEN);\n        store.setToDefault(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS);\n\n        store.setToDefault(ResultSetPreferences.KEEP_STATEMENT_OPEN);\n        store.setToDefault(ResultSetPreferences.RS_EDIT_USE_ALL_COLUMNS);\n        store.setToDefault(ResultSetPreferences.RS_EDIT_NEW_ROWS_AFTER);\n        store.setToDefault(ResultSetPreferences.RS_EDIT_REFRESH_AFTER_UPDATE);\n        store.setToDefault(ResultSetPreferences.RESULT_SET_USE_NAVIGATOR_FILTERS);\n\n        store.setToDefault(ModelPreferences.RESULT_SET_USE_FETCH_SIZE);\n        store.setToDefault(ModelPreferences.RESULT_SET_IGNORE_COLUMN_LABEL);\n\n        store.setToDefault(ResultSetPreferences.RESULT_SET_SHOW_ERRORS_IN_DIALOG);\n        store.setToDefault(ResultSetPreferences.RESULT_SET_MARK_CELL_VALUE_OCCURRENCES);\n\n        updateOptionsEnablement();\n    }\n\n    @Override\n    protected String getPropertyPageID()\n    {\n        return PAGE_ID;\n    }\n}', 'message': '#12786 checkbox setting in menu added\n', 'author_name': 'LonwoLonwo', 'lang': 'jkiss'}