Search in sources :

Example 1 with SQLScriptBindingType

use of org.jkiss.dbeaver.ui.editors.sql.SQLScriptBindingType in project dbeaver by serge-rider.

the class PrefPageSQLResources method createContents.

@Override
protected Control createContents(Composite parent) {
    Composite composite = UIUtils.createComposite(parent, 1);
    // Connection association
    {
        Composite connGroup = UIUtils.createControlGroup(composite, SQLEditorMessages.pref_page_sql_editor_group_connection_association, 2, GridData.FILL_HORIZONTAL, 0);
        Label tipLabel = new Label(connGroup, SWT.WRAP);
        tipLabel.setText(SQLEditorMessages.pref_page_sql_editor_checkbox_bind_connection_hint);
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        tipLabel.setLayoutData(gd);
        bindEmbeddedReadCheck = UIUtils.createCheckbox(connGroup, SQLEditorMessages.pref_page_sql_editor_checkbox_bind_embedded_read, SQLEditorMessages.pref_page_sql_editor_checkbox_bind_embedded_read_tip, false, 2);
        bindEmbeddedWriteCheck = UIUtils.createCheckbox(connGroup, SQLEditorMessages.pref_page_sql_editor_checkbox_bind_embedded_write, SQLEditorMessages.pref_page_sql_editor_checkbox_bind_embedded_write_tip, false, 2);
        bindEmbeddedWriteCheck.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                enableCommentType();
            }
        });
        commentTypeComposite = UIUtils.createComposite(connGroup, 1);
        for (SQLScriptBindingType bt : SQLScriptBindingType.values()) {
            if (bt != SQLScriptBindingType.EXTERNAL) {
                UIUtils.createRadioButton(commentTypeComposite, bt.getDescription(), bt, SelectionListener.widgetSelectedAdapter(selectionEvent -> {
                    curScriptBindingType = (SQLScriptBindingType) selectionEvent.widget.getData();
                }));
            }
        }
    }
    // Resources
    {
        Composite scriptsGroup = UIUtils.createControlGroup(composite, SQLEditorMessages.pref_page_sql_editor_group_resources, 2, GridData.FILL_HORIZONTAL, 0);
        deleteEmptyCombo = UIUtils.createLabelCombo(scriptsGroup, SQLEditorMessages.pref_page_sql_editor_checkbox_delete_empty_scripts, SWT.DROP_DOWN | SWT.READ_ONLY);
        for (SQLPreferenceConstants.EmptyScriptCloseBehavior escb : SQLPreferenceConstants.EmptyScriptCloseBehavior.values()) {
            deleteEmptyCombo.add(escb.getTitle());
        }
        deleteEmptyCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        deleteEmptyCombo.select(0);
        autoFoldersCheck = UIUtils.createCheckbox(scriptsGroup, SQLEditorMessages.pref_page_sql_editor_checkbox_put_new_scripts, null, false, 2);
        connectionFoldersCheck = UIUtils.createCheckbox(scriptsGroup, SQLEditorMessages.pref_page_sql_editor_checkbox_create_script_folders, null, false, 2);
        scriptTitlePattern = UIUtils.createLabelText(scriptsGroup, SQLEditorMessages.pref_page_sql_editor_title_pattern, "");
        ContentAssistUtils.installContentProposal(scriptTitlePattern, new SmartTextContentAdapter(), new StringContentProposalProvider(GeneralUtils.variablePattern(SQLEditor.VAR_CONNECTION_NAME), GeneralUtils.variablePattern(SQLEditor.VAR_DRIVER_NAME), GeneralUtils.variablePattern(SQLEditor.VAR_FILE_NAME), GeneralUtils.variablePattern(SQLEditor.VAR_FILE_EXT), GeneralUtils.variablePattern(SQLEditor.VAR_ACTIVE_DATABASE), GeneralUtils.variablePattern(SQLEditor.VAR_ACTIVE_SCHEMA)));
        UIUtils.setContentProposalToolTip(scriptTitlePattern, "Output file name patterns", SQLEditor.VAR_CONNECTION_NAME, SQLEditor.VAR_DRIVER_NAME, SQLEditor.VAR_FILE_NAME, SQLEditor.VAR_FILE_EXT, SQLEditor.VAR_ACTIVE_DATABASE, SQLEditor.VAR_ACTIVE_SCHEMA);
    }
    performDefaults();
    return composite;
}
Also used : SQLScriptBindingType(org.jkiss.dbeaver.ui.editors.sql.SQLScriptBindingType) SmartTextContentAdapter(org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter) StringContentProposalProvider(org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 2 with SQLScriptBindingType

use of org.jkiss.dbeaver.ui.editors.sql.SQLScriptBindingType in project dbeaver by serge-rider.

the class PrefPageSQLResources method performDefaults.

@Override
protected void performDefaults() {
    DBPPreferenceStore store = DBWorkbench.getPlatform().getPreferenceStore();
    bindEmbeddedReadCheck.setSelection(store.getBoolean(SQLPreferenceConstants.SCRIPT_BIND_EMBEDDED_READ));
    bindEmbeddedWriteCheck.setSelection(store.getBoolean(SQLPreferenceConstants.SCRIPT_BIND_EMBEDDED_WRITE));
    try {
        SQLScriptBindingType bindingType = SQLScriptBindingType.valueOf(store.getString(SQLPreferenceConstants.SCRIPT_BIND_COMMENT_TYPE));
        for (Control ch : commentTypeComposite.getChildren()) {
            if (ch instanceof Button && ch.getData() == bindingType) {
                ((Button) ch).setSelection(true);
            }
        }
    } catch (IllegalArgumentException e) {
        log.error(e);
    }
    enableCommentType();
    deleteEmptyCombo.setText(SQLPreferenceConstants.EmptyScriptCloseBehavior.getByName(store.getString(SQLPreferenceConstants.SCRIPT_DELETE_EMPTY)).getTitle());
    autoFoldersCheck.setSelection(store.getBoolean(SQLPreferenceConstants.SCRIPT_AUTO_FOLDERS));
    connectionFoldersCheck.setSelection(store.getBoolean(SQLPreferenceConstants.SCRIPT_CREATE_CONNECTION_FOLDERS));
    scriptTitlePattern.setText(store.getString(SQLPreferenceConstants.SCRIPT_TITLE_PATTERN));
    super.performDefaults();
}
Also used : SQLScriptBindingType(org.jkiss.dbeaver.ui.editors.sql.SQLScriptBindingType) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Example 3 with SQLScriptBindingType

use of org.jkiss.dbeaver.ui.editors.sql.SQLScriptBindingType in project dbeaver by dbeaver.

the class PrefPageSQLResources method performDefaults.

@Override
protected void performDefaults() {
    DBPPreferenceStore store = DBWorkbench.getPlatform().getPreferenceStore();
    bindEmbeddedReadCheck.setSelection(store.getBoolean(SQLPreferenceConstants.SCRIPT_BIND_EMBEDDED_READ));
    bindEmbeddedWriteCheck.setSelection(store.getBoolean(SQLPreferenceConstants.SCRIPT_BIND_EMBEDDED_WRITE));
    try {
        SQLScriptBindingType bindingType = SQLScriptBindingType.valueOf(store.getString(SQLPreferenceConstants.SCRIPT_BIND_COMMENT_TYPE));
        for (Control ch : commentTypeComposite.getChildren()) {
            if (ch instanceof Button && ch.getData() == bindingType) {
                ((Button) ch).setSelection(true);
            }
        }
    } catch (IllegalArgumentException e) {
        log.error(e);
    }
    enableCommentType();
    deleteEmptyCombo.setText(SQLPreferenceConstants.EmptyScriptCloseBehavior.getByName(store.getString(SQLPreferenceConstants.SCRIPT_DELETE_EMPTY)).getTitle());
    autoFoldersCheck.setSelection(store.getBoolean(SQLPreferenceConstants.SCRIPT_AUTO_FOLDERS));
    connectionFoldersCheck.setSelection(store.getBoolean(SQLPreferenceConstants.SCRIPT_CREATE_CONNECTION_FOLDERS));
    scriptTitlePattern.setText(store.getString(SQLPreferenceConstants.SCRIPT_TITLE_PATTERN));
    super.performDefaults();
}
Also used : SQLScriptBindingType(org.jkiss.dbeaver.ui.editors.sql.SQLScriptBindingType) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Example 4 with SQLScriptBindingType

use of org.jkiss.dbeaver.ui.editors.sql.SQLScriptBindingType in project dbeaver by dbeaver.

the class PrefPageSQLResources method createContents.

@Override
protected Control createContents(Composite parent) {
    Composite composite = UIUtils.createComposite(parent, 1);
    // Connection association
    {
        Composite connGroup = UIUtils.createControlGroup(composite, SQLEditorMessages.pref_page_sql_editor_group_connection_association, 2, GridData.FILL_HORIZONTAL, 0);
        Label tipLabel = new Label(connGroup, SWT.WRAP);
        tipLabel.setText(SQLEditorMessages.pref_page_sql_editor_checkbox_bind_connection_hint);
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        tipLabel.setLayoutData(gd);
        bindEmbeddedReadCheck = UIUtils.createCheckbox(connGroup, SQLEditorMessages.pref_page_sql_editor_checkbox_bind_embedded_read, SQLEditorMessages.pref_page_sql_editor_checkbox_bind_embedded_read_tip, false, 2);
        bindEmbeddedWriteCheck = UIUtils.createCheckbox(connGroup, SQLEditorMessages.pref_page_sql_editor_checkbox_bind_embedded_write, SQLEditorMessages.pref_page_sql_editor_checkbox_bind_embedded_write_tip, false, 2);
        bindEmbeddedWriteCheck.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                enableCommentType();
            }
        });
        commentTypeComposite = UIUtils.createComposite(connGroup, 1);
        for (SQLScriptBindingType bt : SQLScriptBindingType.values()) {
            if (bt != SQLScriptBindingType.EXTERNAL) {
                UIUtils.createRadioButton(commentTypeComposite, bt.getDescription(), bt, SelectionListener.widgetSelectedAdapter(selectionEvent -> {
                    curScriptBindingType = (SQLScriptBindingType) selectionEvent.widget.getData();
                }));
            }
        }
    }
    // Resources
    {
        Composite scriptsGroup = UIUtils.createControlGroup(composite, SQLEditorMessages.pref_page_sql_editor_group_resources, 2, GridData.FILL_HORIZONTAL, 0);
        deleteEmptyCombo = UIUtils.createLabelCombo(scriptsGroup, SQLEditorMessages.pref_page_sql_editor_checkbox_delete_empty_scripts, SWT.DROP_DOWN | SWT.READ_ONLY);
        for (SQLPreferenceConstants.EmptyScriptCloseBehavior escb : SQLPreferenceConstants.EmptyScriptCloseBehavior.values()) {
            deleteEmptyCombo.add(escb.getTitle());
        }
        deleteEmptyCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        deleteEmptyCombo.select(0);
        autoFoldersCheck = UIUtils.createCheckbox(scriptsGroup, SQLEditorMessages.pref_page_sql_editor_checkbox_put_new_scripts, null, false, 2);
        connectionFoldersCheck = UIUtils.createCheckbox(scriptsGroup, SQLEditorMessages.pref_page_sql_editor_checkbox_create_script_folders, null, false, 2);
        scriptTitlePattern = UIUtils.createLabelText(scriptsGroup, SQLEditorMessages.pref_page_sql_editor_title_pattern, "");
        ContentAssistUtils.installContentProposal(scriptTitlePattern, new SmartTextContentAdapter(), new StringContentProposalProvider(GeneralUtils.variablePattern(SQLEditor.VAR_CONNECTION_NAME), GeneralUtils.variablePattern(SQLEditor.VAR_DRIVER_NAME), GeneralUtils.variablePattern(SQLEditor.VAR_FILE_NAME), GeneralUtils.variablePattern(SQLEditor.VAR_FILE_EXT), GeneralUtils.variablePattern(SQLEditor.VAR_ACTIVE_DATABASE), GeneralUtils.variablePattern(SQLEditor.VAR_ACTIVE_SCHEMA)));
        UIUtils.setContentProposalToolTip(scriptTitlePattern, "Output file name patterns", SQLEditor.VAR_CONNECTION_NAME, SQLEditor.VAR_DRIVER_NAME, SQLEditor.VAR_FILE_NAME, SQLEditor.VAR_FILE_EXT, SQLEditor.VAR_ACTIVE_DATABASE, SQLEditor.VAR_ACTIVE_SCHEMA);
    }
    performDefaults();
    return composite;
}
Also used : SQLScriptBindingType(org.jkiss.dbeaver.ui.editors.sql.SQLScriptBindingType) SmartTextContentAdapter(org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter) StringContentProposalProvider(org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

SQLScriptBindingType (org.jkiss.dbeaver.ui.editors.sql.SQLScriptBindingType)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 DBPPreferenceStore (org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)2 SmartTextContentAdapter (org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter)2 StringContentProposalProvider (org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider)2