Package com.dci.intellij.dbn.editor.data.options.ui

Source Code of com.dci.intellij.dbn.editor.data.options.ui.DatatEditorValueListPopupSettingsForm

package com.dci.intellij.dbn.editor.data.options.ui;

import com.dci.intellij.dbn.common.options.ui.ConfigurationEditorForm;
import com.dci.intellij.dbn.common.options.ui.ConfigurationEditorUtil;
import com.dci.intellij.dbn.editor.data.options.DataEditorValueListPopupSettings;
import com.intellij.openapi.options.ConfigurationException;

import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class DatatEditorValueListPopupSettingsForm extends ConfigurationEditorForm<DataEditorValueListPopupSettings> {
    private JTextField elementCountThresholdTextBox;
    private JTextField dataLengthThresholdTextBox;
    private JCheckBox activeForPrimaryKeysCheckBox;
    private JPanel mainPanel;

    public DatatEditorValueListPopupSettingsForm(DataEditorValueListPopupSettings settings) {
        super(settings);
        updateBorderTitleForeground(mainPanel);
        resetChanges();
        registerComponent(elementCountThresholdTextBox);
        registerComponent(activeForPrimaryKeysCheckBox);
    }

    public JPanel getComponent() {
        return mainPanel;
    }

    public void applyChanges() throws ConfigurationException {
        DataEditorValueListPopupSettings settings = getConfiguration();
        settings.setActiveForPrimaryKeyColumns(activeForPrimaryKeysCheckBox.isSelected());
        settings.setElementCountThreshold(ConfigurationEditorUtil.validateIntegerInputValue(elementCountThresholdTextBox, "Element count threshold", 0, 10000, null));
        settings.setDataLengthThreshold(ConfigurationEditorUtil.validateIntegerInputValue(dataLengthThresholdTextBox, "Data length threshold", 0, 1000, null));
    }

    public void resetChanges() {
        DataEditorValueListPopupSettings settings = getConfiguration();
        activeForPrimaryKeysCheckBox.setSelected(settings.isActiveForPrimaryKeyColumns());
        elementCountThresholdTextBox.setText(Integer.toString(settings.getElementCountThreshold()));
        dataLengthThresholdTextBox.setText(Integer.toString(settings.getDataLengthThreshold()));
    }
}
TOP

Related Classes of com.dci.intellij.dbn.editor.data.options.ui.DatatEditorValueListPopupSettingsForm

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.