Search in sources :

Example 11 with SmartTextContentAdapter

use of org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter in project dbeaver by serge-rider.

the class PostgreBackupWizardPageSettings method createControl.

@Override
public void createControl(Composite parent) {
    Composite composite = UIUtils.createPlaceholder(parent, 1);
    SelectionListener changeListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateState();
        }
    };
    Group formatGroup = UIUtils.createControlGroup(composite, PostgreMessages.wizard_backup_page_setting_group_setting, 2, GridData.FILL_HORIZONTAL, 0);
    formatCombo = UIUtils.createLabelCombo(formatGroup, PostgreMessages.wizard_backup_page_setting_label_format, SWT.DROP_DOWN | SWT.READ_ONLY);
    formatCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
    for (PostgreDatabaseBackupSettings.ExportFormat format : PostgreDatabaseBackupSettings.ExportFormat.values()) {
        formatCombo.add(format.getTitle());
    }
    formatCombo.select(wizard.getSettings().getFormat().ordinal());
    formatCombo.addSelectionListener(changeListener);
    compressCombo = UIUtils.createLabelCombo(formatGroup, PostgreMessages.wizard_backup_page_setting_label_compression, SWT.DROP_DOWN | SWT.READ_ONLY);
    compressCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
    compressCombo.add("");
    for (int i = 0; i <= 9; i++) {
        String compStr = String.valueOf(i);
        compressCombo.add(compStr);
        if (compStr.equals(wizard.getSettings().getCompression())) {
            compressCombo.select(i);
        }
    }
    if (compressCombo.getSelectionIndex() < 0) {
        compressCombo.select(0);
    }
    compressCombo.addSelectionListener(changeListener);
    UIUtils.createControlLabel(formatGroup, PostgreMessages.wizard_backup_page_setting_label_encoding);
    encodingCombo = UIUtils.createEncodingCombo(formatGroup, null);
    encodingCombo.addSelectionListener(changeListener);
    encodingCombo.setText(wizard.getSettings().getEncoding());
    useInsertsCheck = UIUtils.createCheckbox(formatGroup, PostgreMessages.wizard_backup_page_setting_checkbox_use_insert, null, wizard.getSettings().isUseInserts(), 2);
    useInsertsCheck.addSelectionListener(changeListener);
    noPrivilegesCheck = UIUtils.createCheckbox(formatGroup, PostgreMessages.wizard_backup_page_setting_checkbox_no_privileges, null, wizard.getSettings().isNoPrivileges(), 2);
    noPrivilegesCheck.addSelectionListener(changeListener);
    noOwnerCheck = UIUtils.createCheckbox(formatGroup, PostgreMessages.wizard_backup_page_setting_checkbox_no_owner, null, wizard.getSettings().isNoOwner(), 2);
    noOwnerCheck.addSelectionListener(changeListener);
    Group outputGroup = UIUtils.createControlGroup(composite, PostgreMessages.wizard_backup_page_setting_group_output, 2, GridData.FILL_HORIZONTAL, 0);
    outputFolderText = DialogUtils.createOutputFolderChooser(outputGroup, PostgreMessages.wizard_backup_page_setting_label_output_folder, wizard.getSettings().getOutputFolder() != null ? wizard.getSettings().getOutputFolder().getAbsolutePath() : null, e -> updateState());
    outputFileText = UIUtils.createLabelText(outputGroup, PostgreMessages.wizard_backup_page_setting_label_file_name_pattern, wizard.getSettings().getOutputFilePattern());
    UIUtils.setContentProposalToolTip(outputFileText, PostgreMessages.wizard_backup_page_setting_label_file_name_pattern_output, NativeToolUtils.VARIABLE_HOST, NativeToolUtils.VARIABLE_DATABASE, NativeToolUtils.VARIABLE_TABLE, NativeToolUtils.VARIABLE_DATE, NativeToolUtils.VARIABLE_TIMESTAMP, NativeToolUtils.VARIABLE_CONN_TYPE);
    ContentAssistUtils.installContentProposal(outputFileText, new SmartTextContentAdapter(), new StringContentProposalProvider(GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_HOST), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_DATABASE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_TABLE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_DATE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_TIMESTAMP), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_CONN_TYPE)));
    outputFileText.addModifyListener(e -> wizard.getSettings().setOutputFilePattern(outputFileText.getText()));
    createExtraArgsInput(outputGroup);
    Composite extraGroup = UIUtils.createComposite(composite, 2);
    createSecurityGroup(extraGroup);
    wizard.createTaskSaveGroup(extraGroup);
    setControl(composite);
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GeneralUtils(org.jkiss.dbeaver.utils.GeneralUtils) CommonUtils(org.jkiss.utils.CommonUtils) org.eclipse.swt.widgets(org.eclipse.swt.widgets) StringContentProposalProvider(org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider) NativeToolUtils(org.jkiss.dbeaver.tasks.nativetool.NativeToolUtils) SmartTextContentAdapter(org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter) File(java.io.File) PostgreDatabaseBackupSettings(org.jkiss.dbeaver.ext.postgresql.tasks.PostgreDatabaseBackupSettings) ContentAssistUtils(org.jkiss.dbeaver.ui.contentassist.ContentAssistUtils) UIUtils(org.jkiss.dbeaver.ui.UIUtils) SWT(org.eclipse.swt.SWT) PostgreMessages(org.jkiss.dbeaver.ext.postgresql.PostgreMessages) DialogUtils(org.jkiss.dbeaver.ui.dialogs.DialogUtils) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) SelectionListener(org.eclipse.swt.events.SelectionListener) SmartTextContentAdapter(org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) PostgreDatabaseBackupSettings(org.jkiss.dbeaver.ext.postgresql.tasks.PostgreDatabaseBackupSettings) StringContentProposalProvider(org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 12 with SmartTextContentAdapter

use of org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter in project dbeaver by serge-rider.

the class EditVirtualAttributePage method createPageContents.

@Override
protected Control createPageContents(Composite parent) {
    final Composite dialogArea = UIUtils.createComposite(parent, 1);
    dialogArea.setLayoutData(new GridData(GridData.FILL_BOTH));
    DBPDataSource dataSource = vAttr.getEntity().getDataSource();
    Composite panel = UIUtils.createComposite(dialogArea, 2);
    panel.setLayoutData(new GridData(GridData.FILL_BOTH));
    String name = vAttr.getName();
    int index = 1;
    for (; ; ) {
        DBVEntityAttribute vAttr2 = vAttr.getEntity().getVirtualAttribute(name);
        if (vAttr2 == null || vAttr2 == vAttr) {
            break;
        }
        index++;
        name = vAttr.getName() + index;
    }
    nameText = UIUtils.createLabelText(panel, "Column Name", name);
    typeCombo = UIUtils.createLabelCombo(panel, "Type Name", "Column type name", SWT.BORDER | SWT.DROP_DOWN);
    {
        DBPDataTypeProvider dataTypeProvider = DBUtils.getAdapter(DBPDataTypeProvider.class, dataSource);
        if (dataTypeProvider != null) {
            List<DBSDataType> localDataTypes = new ArrayList<>(dataTypeProvider.getLocalDataTypes());
            localDataTypes.sort(Comparator.comparing(DBSDataType::getFullTypeName));
            for (DBSDataType dataType : localDataTypes) {
                typeCombo.add(dataType.getFullTypeName());
            }
            String defTypeName = vAttr.getTypeName();
            if (CommonUtils.isEmpty(defTypeName)) {
                defTypeName = dataTypeProvider.getDefaultDataTypeName(DBPDataKind.STRING);
                vAttr.setTypeName(defTypeName);
                DBSDataType dataType = dataTypeProvider.getLocalDataType(defTypeName);
                if (dataType != null) {
                    vAttr.setDataKind(dataType.getDataKind());
                }
            }
            if (!CommonUtils.isEmpty(defTypeName)) {
                typeCombo.setText(defTypeName);
            }
            typeCombo.addModifyListener(e -> {
                DBSDataType dataType = dataTypeProvider.getLocalDataType(typeCombo.getText());
                if (dataType != null) {
                    kindCombo.setText(dataType.getDataKind().name());
                }
            });
        } else {
            typeCombo.setText(CommonUtils.notEmpty(vAttr.getTypeName()));
        }
        ContentAssistUtils.installContentProposal(typeCombo, new ComboContentAdapter(), new StringContentProposalProvider(typeCombo.getItems()));
    }
    kindCombo = UIUtils.createLabelCombo(panel, "Data Kind", "Column data kind", SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
    for (DBPDataKind dataKind : DBPDataKind.values()) {
        if (dataKind != DBPDataKind.UNKNOWN) {
            kindCombo.add(dataKind.name());
        }
    }
    kindCombo.setText(vAttr.getDataKind().name());
    expressionText = UIUtils.createLabelText(panel, "Expression", CommonUtils.notEmpty(vAttr.getExpression()), SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = 300;
    gd.heightHint = expressionText.getLineHeight() * 5;
    expressionText.setLayoutData(gd);
    List<String> expressionProposals = new ArrayList<>();
    if (viewer != null) {
        for (DBDAttributeBinding attr : viewer.getModel().getAttributes()) {
            expressionProposals.add(attr.getLabel());
        }
    }
    ContentAssistUtils.installContentProposal(expressionText, new SmartTextContentAdapter(), new StringContentProposalProvider(expressionProposals.toArray(new String[0])));
    previewText = UIUtils.createLabelText(panel, "Preview", "", SWT.BORDER | SWT.READ_ONLY);
    previewText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    expressionText.addModifyListener(e -> generatePreviewValue());
    generatePreviewValue();
    return dialogArea;
}
Also used : StringContentProposalProvider(org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider) ResultSetRow(org.jkiss.dbeaver.ui.controls.resultset.ResultSetRow) BaseObjectEditPage(org.jkiss.dbeaver.ui.editors.object.struct.BaseObjectEditPage) ArrayList(java.util.ArrayList) IHelpContextIdProvider(org.jkiss.dbeaver.ui.IHelpContextIdProvider) DBVUtils(org.jkiss.dbeaver.model.virtual.DBVUtils) DBSDataType(org.jkiss.dbeaver.model.struct.DBSDataType) Composite(org.eclipse.swt.widgets.Composite) UIUtils(org.jkiss.dbeaver.ui.UIUtils) ResultSetViewer(org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer) GridData(org.eclipse.swt.layout.GridData) org.jkiss.dbeaver.model(org.jkiss.dbeaver.model) ComboContentAdapter(org.eclipse.jface.fieldassist.ComboContentAdapter) GeneralUtils(org.jkiss.dbeaver.utils.GeneralUtils) CommonUtils(org.jkiss.utils.CommonUtils) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) DBDAttributeBinding(org.jkiss.dbeaver.model.data.DBDAttributeBinding) SmartTextContentAdapter(org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter) ContentAssistUtils(org.jkiss.dbeaver.ui.contentassist.ContentAssistUtils) List(java.util.List) DBException(org.jkiss.dbeaver.DBException) SWT(org.eclipse.swt.SWT) DBVEntityAttribute(org.jkiss.dbeaver.model.virtual.DBVEntityAttribute) JexlExpression(org.apache.commons.jexl3.JexlExpression) Comparator(java.util.Comparator) Control(org.eclipse.swt.widgets.Control) ComboContentAdapter(org.eclipse.jface.fieldassist.ComboContentAdapter) SmartTextContentAdapter(org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter) Composite(org.eclipse.swt.widgets.Composite) DBSDataType(org.jkiss.dbeaver.model.struct.DBSDataType) DBVEntityAttribute(org.jkiss.dbeaver.model.virtual.DBVEntityAttribute) ArrayList(java.util.ArrayList) DBDAttributeBinding(org.jkiss.dbeaver.model.data.DBDAttributeBinding) StringContentProposalProvider(org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider) GridData(org.eclipse.swt.layout.GridData) ArrayList(java.util.ArrayList) List(java.util.List)

Example 13 with SmartTextContentAdapter

use of org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter in project dbeaver by serge-rider.

the class MySQLExportWizardPageSettings method createControl.

@Override
public void createControl(Composite parent) {
    Composite composite = UIUtils.createPlaceholder(parent, 1);
    SelectionListener changeListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateState();
        }
    };
    Group methodGroup = UIUtils.createControlGroup(composite, MySQLUIMessages.tools_db_export_wizard_page_settings_group_exe_method, 1, GridData.FILL_HORIZONTAL, 0);
    methodCombo = new Combo(methodGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    methodCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    methodCombo.add(MySQLUIMessages.tools_db_export_wizard_page_settings_combo_item_online_backup);
    methodCombo.add(MySQLUIMessages.tools_db_export_wizard_page_settings_combo_item_lock_tables);
    methodCombo.add(MySQLUIMessages.tools_db_export_wizard_page_settings_combo_item_normal);
    methodCombo.select(wizard.getSettings().getMethod().ordinal());
    methodCombo.addSelectionListener(changeListener);
    Group settingsGroup = UIUtils.createControlGroup(composite, MySQLUIMessages.tools_db_export_wizard_page_settings_group_settings, 3, GridData.FILL_HORIZONTAL, 0);
    noCreateStatementsCheck = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_no_create, wizard.getSettings().isNoCreateStatements());
    noCreateStatementsCheck.addSelectionListener(changeListener);
    addDropStatementsCheck = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_add_drop, wizard.getSettings().isAddDropStatements());
    addDropStatementsCheck.addSelectionListener(changeListener);
    disableKeysCheck = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_disable_keys, wizard.getSettings().isDisableKeys());
    disableKeysCheck.addSelectionListener(changeListener);
    extendedInsertsCheck = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_ext_inserts, wizard.getSettings().isExtendedInserts());
    extendedInsertsCheck.addSelectionListener(changeListener);
    dumpEventsCheck = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_dump_events, wizard.getSettings().isDumpEvents());
    dumpEventsCheck.addSelectionListener(changeListener);
    commentsCheck = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_addnl_comments, wizard.getSettings().isComments());
    commentsCheck.addSelectionListener(changeListener);
    removeDefiner = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_remove_definer, wizard.getSettings().isRemoveDefiner());
    removeDefiner.addSelectionListener(changeListener);
    binaryInHex = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_binary_hex, wizard.getSettings().isBinariesInHex());
    binaryInHex.addSelectionListener(changeListener);
    noData = UIUtils.createCheckbox(settingsGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_checkbox_no_data, wizard.getSettings().isNoData());
    noData.addSelectionListener(changeListener);
    Group outputGroup = UIUtils.createControlGroup(composite, MySQLUIMessages.tools_db_export_wizard_page_settings_group_output, 2, GridData.FILL_HORIZONTAL, 0);
    outputFolderText = DialogUtils.createOutputFolderChooser(outputGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_label_out_text, e -> updateState());
    outputFileText = UIUtils.createLabelText(outputGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_label_file_name_pattern_text, wizard.getSettings().getOutputFilePattern());
    UIUtils.setContentProposalToolTip(outputFileText, MySQLUIMessages.tools_db_export_wizard_page_settings_label_file_name_pattern_tip, NativeToolUtils.VARIABLE_HOST, NativeToolUtils.VARIABLE_DATABASE, NativeToolUtils.VARIABLE_TABLE, NativeToolUtils.VARIABLE_DATE, NativeToolUtils.VARIABLE_TIMESTAMP, NativeToolUtils.VARIABLE_CONN_TYPE);
    ContentAssistUtils.installContentProposal(outputFileText, new SmartTextContentAdapter(), new StringContentProposalProvider(GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_HOST), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_DATABASE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_TABLE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_DATE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_TIMESTAMP), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_CONN_TYPE)));
    createExtraArgsInput(outputGroup);
    if (wizard.getSettings().getOutputFolder() != null) {
        outputFolderText.setText(wizard.getSettings().getOutputFolder().getAbsolutePath());
    }
    outputFileText.addModifyListener(e -> wizard.getSettings().setOutputFilePattern(outputFileText.getText()));
    Composite extraGroup = UIUtils.createComposite(composite, 2);
    createSecurityGroup(extraGroup);
    wizard.createTaskSaveGroup(extraGroup);
    setControl(composite);
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GeneralUtils(org.jkiss.dbeaver.utils.GeneralUtils) CommonUtils(org.jkiss.utils.CommonUtils) org.eclipse.swt.widgets(org.eclipse.swt.widgets) StringContentProposalProvider(org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider) MySQLExportSettings(org.jkiss.dbeaver.ext.mysql.tasks.MySQLExportSettings) MySQLUIMessages(org.jkiss.dbeaver.ext.mysql.ui.internal.MySQLUIMessages) NativeToolUtils(org.jkiss.dbeaver.tasks.nativetool.NativeToolUtils) SmartTextContentAdapter(org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter) File(java.io.File) ContentAssistUtils(org.jkiss.dbeaver.ui.contentassist.ContentAssistUtils) UIUtils(org.jkiss.dbeaver.ui.UIUtils) SWT(org.eclipse.swt.SWT) DialogUtils(org.jkiss.dbeaver.ui.dialogs.DialogUtils) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) SelectionListener(org.eclipse.swt.events.SelectionListener) SmartTextContentAdapter(org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter) StringContentProposalProvider(org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 14 with SmartTextContentAdapter

use of org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter in project dbeaver by dbeaver.

the class PostgreBackupWizardPageSettings method createControl.

@Override
public void createControl(Composite parent) {
    Composite composite = UIUtils.createPlaceholder(parent, 1);
    SelectionListener changeListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateState();
        }
    };
    Group formatGroup = UIUtils.createControlGroup(composite, PostgreMessages.wizard_backup_page_setting_group_setting, 2, GridData.FILL_HORIZONTAL, 0);
    formatCombo = UIUtils.createLabelCombo(formatGroup, PostgreMessages.wizard_backup_page_setting_label_format, SWT.DROP_DOWN | SWT.READ_ONLY);
    formatCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
    for (PostgreDatabaseBackupSettings.ExportFormat format : PostgreDatabaseBackupSettings.ExportFormat.values()) {
        formatCombo.add(format.getTitle());
    }
    formatCombo.select(wizard.getSettings().getFormat().ordinal());
    formatCombo.addSelectionListener(changeListener);
    compressCombo = UIUtils.createLabelCombo(formatGroup, PostgreMessages.wizard_backup_page_setting_label_compression, SWT.DROP_DOWN | SWT.READ_ONLY);
    compressCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
    compressCombo.add("");
    for (int i = 0; i <= 9; i++) {
        String compStr = String.valueOf(i);
        compressCombo.add(compStr);
        if (compStr.equals(wizard.getSettings().getCompression())) {
            compressCombo.select(i);
        }
    }
    if (compressCombo.getSelectionIndex() < 0) {
        compressCombo.select(0);
    }
    compressCombo.addSelectionListener(changeListener);
    UIUtils.createControlLabel(formatGroup, PostgreMessages.wizard_backup_page_setting_label_encoding);
    encodingCombo = UIUtils.createEncodingCombo(formatGroup, null);
    encodingCombo.addSelectionListener(changeListener);
    encodingCombo.setText(wizard.getSettings().getEncoding());
    useInsertsCheck = UIUtils.createCheckbox(formatGroup, PostgreMessages.wizard_backup_page_setting_checkbox_use_insert, null, wizard.getSettings().isUseInserts(), 2);
    useInsertsCheck.addSelectionListener(changeListener);
    noPrivilegesCheck = UIUtils.createCheckbox(formatGroup, PostgreMessages.wizard_backup_page_setting_checkbox_no_privileges, null, wizard.getSettings().isNoPrivileges(), 2);
    noPrivilegesCheck.addSelectionListener(changeListener);
    noOwnerCheck = UIUtils.createCheckbox(formatGroup, PostgreMessages.wizard_backup_page_setting_checkbox_no_owner, null, wizard.getSettings().isNoOwner(), 2);
    noOwnerCheck.addSelectionListener(changeListener);
    Group outputGroup = UIUtils.createControlGroup(composite, PostgreMessages.wizard_backup_page_setting_group_output, 2, GridData.FILL_HORIZONTAL, 0);
    outputFolderText = DialogUtils.createOutputFolderChooser(outputGroup, PostgreMessages.wizard_backup_page_setting_label_output_folder, wizard.getSettings().getOutputFolder() != null ? wizard.getSettings().getOutputFolder().getAbsolutePath() : null, e -> updateState());
    outputFileText = UIUtils.createLabelText(outputGroup, PostgreMessages.wizard_backup_page_setting_label_file_name_pattern, wizard.getSettings().getOutputFilePattern());
    UIUtils.setContentProposalToolTip(outputFileText, PostgreMessages.wizard_backup_page_setting_label_file_name_pattern_output, NativeToolUtils.VARIABLE_HOST, NativeToolUtils.VARIABLE_DATABASE, NativeToolUtils.VARIABLE_TABLE, NativeToolUtils.VARIABLE_DATE, NativeToolUtils.VARIABLE_TIMESTAMP, NativeToolUtils.VARIABLE_CONN_TYPE);
    ContentAssistUtils.installContentProposal(outputFileText, new SmartTextContentAdapter(), new StringContentProposalProvider(GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_HOST), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_DATABASE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_TABLE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_DATE), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_TIMESTAMP), GeneralUtils.variablePattern(NativeToolUtils.VARIABLE_CONN_TYPE)));
    outputFileText.addModifyListener(e -> wizard.getSettings().setOutputFilePattern(outputFileText.getText()));
    createExtraArgsInput(outputGroup);
    Composite extraGroup = UIUtils.createComposite(composite, 2);
    createSecurityGroup(extraGroup);
    wizard.createTaskSaveGroup(extraGroup);
    setControl(composite);
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GeneralUtils(org.jkiss.dbeaver.utils.GeneralUtils) CommonUtils(org.jkiss.utils.CommonUtils) org.eclipse.swt.widgets(org.eclipse.swt.widgets) StringContentProposalProvider(org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider) NativeToolUtils(org.jkiss.dbeaver.tasks.nativetool.NativeToolUtils) SmartTextContentAdapter(org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter) File(java.io.File) PostgreDatabaseBackupSettings(org.jkiss.dbeaver.ext.postgresql.tasks.PostgreDatabaseBackupSettings) ContentAssistUtils(org.jkiss.dbeaver.ui.contentassist.ContentAssistUtils) UIUtils(org.jkiss.dbeaver.ui.UIUtils) SWT(org.eclipse.swt.SWT) PostgreMessages(org.jkiss.dbeaver.ext.postgresql.PostgreMessages) DialogUtils(org.jkiss.dbeaver.ui.dialogs.DialogUtils) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) SelectionListener(org.eclipse.swt.events.SelectionListener) SmartTextContentAdapter(org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) PostgreDatabaseBackupSettings(org.jkiss.dbeaver.ext.postgresql.tasks.PostgreDatabaseBackupSettings) StringContentProposalProvider(org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 15 with SmartTextContentAdapter

use of org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter in project dbeaver by dbeaver.

the class EditVirtualAttributePage method createPageContents.

@Override
protected Control createPageContents(Composite parent) {
    final Composite dialogArea = UIUtils.createComposite(parent, 1);
    dialogArea.setLayoutData(new GridData(GridData.FILL_BOTH));
    DBPDataSource dataSource = vAttr.getEntity().getDataSource();
    Composite panel = UIUtils.createComposite(dialogArea, 2);
    panel.setLayoutData(new GridData(GridData.FILL_BOTH));
    String name = vAttr.getName();
    int index = 1;
    for (; ; ) {
        DBVEntityAttribute vAttr2 = vAttr.getEntity().getVirtualAttribute(name);
        if (vAttr2 == null || vAttr2 == vAttr) {
            break;
        }
        index++;
        name = vAttr.getName() + index;
    }
    nameText = UIUtils.createLabelText(panel, "Column Name", name);
    typeCombo = UIUtils.createLabelCombo(panel, "Type Name", "Column type name", SWT.BORDER | SWT.DROP_DOWN);
    {
        DBPDataTypeProvider dataTypeProvider = DBUtils.getAdapter(DBPDataTypeProvider.class, dataSource);
        if (dataTypeProvider != null) {
            List<DBSDataType> localDataTypes = new ArrayList<>(dataTypeProvider.getLocalDataTypes());
            localDataTypes.sort(Comparator.comparing(DBSDataType::getFullTypeName));
            for (DBSDataType dataType : localDataTypes) {
                typeCombo.add(dataType.getFullTypeName());
            }
            String defTypeName = vAttr.getTypeName();
            if (CommonUtils.isEmpty(defTypeName)) {
                defTypeName = dataTypeProvider.getDefaultDataTypeName(DBPDataKind.STRING);
                vAttr.setTypeName(defTypeName);
                DBSDataType dataType = dataTypeProvider.getLocalDataType(defTypeName);
                if (dataType != null) {
                    vAttr.setDataKind(dataType.getDataKind());
                }
            }
            if (!CommonUtils.isEmpty(defTypeName)) {
                typeCombo.setText(defTypeName);
            }
            typeCombo.addModifyListener(e -> {
                DBSDataType dataType = dataTypeProvider.getLocalDataType(typeCombo.getText());
                if (dataType != null) {
                    kindCombo.setText(dataType.getDataKind().name());
                }
            });
        } else {
            typeCombo.setText(CommonUtils.notEmpty(vAttr.getTypeName()));
        }
        ContentAssistUtils.installContentProposal(typeCombo, new ComboContentAdapter(), new StringContentProposalProvider(typeCombo.getItems()));
    }
    kindCombo = UIUtils.createLabelCombo(panel, "Data Kind", "Column data kind", SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
    for (DBPDataKind dataKind : DBPDataKind.values()) {
        if (dataKind != DBPDataKind.UNKNOWN) {
            kindCombo.add(dataKind.name());
        }
    }
    kindCombo.setText(vAttr.getDataKind().name());
    expressionText = UIUtils.createLabelText(panel, "Expression", CommonUtils.notEmpty(vAttr.getExpression()), SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = 300;
    gd.heightHint = expressionText.getLineHeight() * 5;
    expressionText.setLayoutData(gd);
    List<String> expressionProposals = new ArrayList<>();
    if (viewer != null) {
        for (DBDAttributeBinding attr : viewer.getModel().getAttributes()) {
            expressionProposals.add(attr.getLabel());
        }
    }
    ContentAssistUtils.installContentProposal(expressionText, new SmartTextContentAdapter(), new StringContentProposalProvider(expressionProposals.toArray(new String[0])));
    previewText = UIUtils.createLabelText(panel, "Preview", "", SWT.BORDER | SWT.READ_ONLY);
    previewText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    expressionText.addModifyListener(e -> generatePreviewValue());
    generatePreviewValue();
    return dialogArea;
}
Also used : StringContentProposalProvider(org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider) ResultSetRow(org.jkiss.dbeaver.ui.controls.resultset.ResultSetRow) BaseObjectEditPage(org.jkiss.dbeaver.ui.editors.object.struct.BaseObjectEditPage) ArrayList(java.util.ArrayList) IHelpContextIdProvider(org.jkiss.dbeaver.ui.IHelpContextIdProvider) DBVUtils(org.jkiss.dbeaver.model.virtual.DBVUtils) DBSDataType(org.jkiss.dbeaver.model.struct.DBSDataType) Composite(org.eclipse.swt.widgets.Composite) UIUtils(org.jkiss.dbeaver.ui.UIUtils) ResultSetViewer(org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer) GridData(org.eclipse.swt.layout.GridData) org.jkiss.dbeaver.model(org.jkiss.dbeaver.model) ComboContentAdapter(org.eclipse.jface.fieldassist.ComboContentAdapter) GeneralUtils(org.jkiss.dbeaver.utils.GeneralUtils) CommonUtils(org.jkiss.utils.CommonUtils) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) DBDAttributeBinding(org.jkiss.dbeaver.model.data.DBDAttributeBinding) SmartTextContentAdapter(org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter) ContentAssistUtils(org.jkiss.dbeaver.ui.contentassist.ContentAssistUtils) List(java.util.List) DBException(org.jkiss.dbeaver.DBException) SWT(org.eclipse.swt.SWT) DBVEntityAttribute(org.jkiss.dbeaver.model.virtual.DBVEntityAttribute) JexlExpression(org.apache.commons.jexl3.JexlExpression) Comparator(java.util.Comparator) Control(org.eclipse.swt.widgets.Control) ComboContentAdapter(org.eclipse.jface.fieldassist.ComboContentAdapter) SmartTextContentAdapter(org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter) Composite(org.eclipse.swt.widgets.Composite) DBSDataType(org.jkiss.dbeaver.model.struct.DBSDataType) DBVEntityAttribute(org.jkiss.dbeaver.model.virtual.DBVEntityAttribute) ArrayList(java.util.ArrayList) DBDAttributeBinding(org.jkiss.dbeaver.model.data.DBDAttributeBinding) StringContentProposalProvider(org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider) GridData(org.eclipse.swt.layout.GridData) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

SmartTextContentAdapter (org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter)16 GridData (org.eclipse.swt.layout.GridData)14 StringContentProposalProvider (org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider)14 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)10 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 SWT (org.eclipse.swt.SWT)8 UIUtils (org.jkiss.dbeaver.ui.UIUtils)8 ContentAssistUtils (org.jkiss.dbeaver.ui.contentassist.ContentAssistUtils)8 GeneralUtils (org.jkiss.dbeaver.utils.GeneralUtils)8 CommonUtils (org.jkiss.utils.CommonUtils)8 org.eclipse.swt.widgets (org.eclipse.swt.widgets)6 DialogUtils (org.jkiss.dbeaver.ui.dialogs.DialogUtils)6 File (java.io.File)4 SelectionListener (org.eclipse.swt.events.SelectionListener)4 NativeToolUtils (org.jkiss.dbeaver.tasks.nativetool.NativeToolUtils)4 ArrayList (java.util.ArrayList)2 Comparator (java.util.Comparator)2 List (java.util.List)2 Locale (java.util.Locale)2 JexlExpression (org.apache.commons.jexl3.JexlExpression)2