Search in sources :

Example 1 with SQLExternalFormatterConfigurationPage

use of org.jkiss.dbeaver.ui.editors.sql.preferences.format.SQLExternalFormatterConfigurationPage in project dbeaver by serge-rider.

the class PrefPageSQLFormat method showFormatterSettings.

private void showFormatterSettings() {
    if (curConfigurator != null) {
        curConfigurator.saveSettings(getTargetPreferenceStore());
    }
    UIUtils.disposeChildControls(formatterConfigPlaceholder);
    SQLFormatterDescriptor selFormatter = formatters.get(formatterSelector.getSelectionIndex());
    try {
        SQLFormatter sqlFormatter = selFormatter.createFormatter();
        // FIXME: for now we support only predefined list of formatters
        if (sqlFormatter instanceof SQLFormatterTokenized) {
            curConfigurator = new SQLTokenizedFormatterConfigurationPage();
        } else if (sqlFormatter instanceof SQLFormatterExternal) {
            curConfigurator = new SQLExternalFormatterConfigurationPage();
        } else {
            curConfigurator = GeneralUtils.adapt(sqlFormatter, SQLFormatterConfigurator.class);
        }
        if (curConfigurator instanceof IDialogPage) {
            curConfigurator.configure(selFormatter, () -> {
                curConfigurator.saveSettings(getTargetPreferenceStore());
                formatSQL();
            });
            ((IDialogPage) curConfigurator).createControl(formatterConfigPlaceholder);
            curConfigurator.loadSettings(getTargetPreferenceStore());
        }
    } catch (DBException e) {
        log.error("Error creating formatter configurator", e);
        setMessage(CommonUtils.toString(e.getMessage()), SWT.ICON_ERROR);
        return;
    }
    ((Composite) getControl()).layout(true, true);
    if (isDataSourcePreferencePage()) {
        enablePreferenceContent(useDataSourceSettings());
    }
}
Also used : SQLFormatterDescriptor(org.jkiss.dbeaver.model.sql.registry.SQLFormatterDescriptor) DBException(org.jkiss.dbeaver.DBException) SQLFormatter(org.jkiss.dbeaver.model.sql.format.SQLFormatter) SQLFormatterTokenized(org.jkiss.dbeaver.model.sql.format.tokenized.SQLFormatterTokenized) Composite(org.eclipse.swt.widgets.Composite) SQLFormatterExternal(org.jkiss.dbeaver.model.sql.format.external.SQLFormatterExternal) SQLExternalFormatterConfigurationPage(org.jkiss.dbeaver.ui.editors.sql.preferences.format.SQLExternalFormatterConfigurationPage) IDialogPage(org.eclipse.jface.dialogs.IDialogPage) SQLTokenizedFormatterConfigurationPage(org.jkiss.dbeaver.ui.editors.sql.preferences.format.tokenized.SQLTokenizedFormatterConfigurationPage)

Aggregations

IDialogPage (org.eclipse.jface.dialogs.IDialogPage)1 Composite (org.eclipse.swt.widgets.Composite)1 DBException (org.jkiss.dbeaver.DBException)1 SQLFormatter (org.jkiss.dbeaver.model.sql.format.SQLFormatter)1 SQLFormatterExternal (org.jkiss.dbeaver.model.sql.format.external.SQLFormatterExternal)1 SQLFormatterTokenized (org.jkiss.dbeaver.model.sql.format.tokenized.SQLFormatterTokenized)1 SQLFormatterDescriptor (org.jkiss.dbeaver.model.sql.registry.SQLFormatterDescriptor)1 SQLExternalFormatterConfigurationPage (org.jkiss.dbeaver.ui.editors.sql.preferences.format.SQLExternalFormatterConfigurationPage)1 SQLTokenizedFormatterConfigurationPage (org.jkiss.dbeaver.ui.editors.sql.preferences.format.tokenized.SQLTokenizedFormatterConfigurationPage)1