Search in sources :

Example 1 with DBDCellValue

use of org.jkiss.dbeaver.model.data.DBDCellValue in project dbeaver by dbeaver.

the class DatabaseProducerPageExtractSettings method createControl.

@Override
public void createControl(Composite parent) {
    initializeDialogUnits(parent);
    Composite composite = UIUtils.createComposite(parent, 1);
    final DatabaseProducerSettings settings = getWizard().getPageSettings(this, DatabaseProducerSettings.class);
    {
        Group generalSettings = UIUtils.createControlGroup(composite, DTMessages.data_transfer_wizard_output_group_progress, 4, GridData.FILL_HORIZONTAL, 0);
        Label threadsNumLabel = UIUtils.createControlLabel(generalSettings, DTMessages.data_transfer_wizard_output_label_max_threads);
        threadsNumText = new Text(generalSettings, SWT.BORDER);
        threadsNumText.setToolTipText(DTUIMessages.database_producer_page_extract_settings_threads_num_text_tooltip);
        threadsNumText.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.ENGLISH));
        threadsNumText.addModifyListener(e -> {
            try {
                getWizard().getSettings().setMaxJobCount(Integer.parseInt(threadsNumText.getText()));
            } catch (NumberFormatException e1) {
            // do nothing
            }
        });
        if (getWizard().getSettings().getDataPipes().size() < 2) {
            threadsNumLabel.setEnabled(false);
            threadsNumText.setEnabled(false);
        }
        threadsNumText.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 3, 1));
        {
            UIUtils.createControlLabel(generalSettings, DTMessages.data_transfer_wizard_output_label_extract_type);
            rowsExtractType = new Combo(generalSettings, SWT.DROP_DOWN | SWT.READ_ONLY);
            rowsExtractType.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 3, 1));
            rowsExtractType.setItems(DTMessages.data_transfer_wizard_output_combo_extract_type_item_single_query, DTMessages.data_transfer_wizard_output_combo_extract_type_item_by_segments);
            rowsExtractType.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    switch(rowsExtractType.getSelectionIndex()) {
                        case EXTRACT_TYPE_SEGMENTS:
                            settings.setExtractType(DatabaseProducerSettings.ExtractType.SEGMENTS);
                            break;
                        case EXTRACT_TYPE_SINGLE_QUERY:
                            settings.setExtractType(DatabaseProducerSettings.ExtractType.SINGLE_QUERY);
                            break;
                    }
                    updatePageCompletion();
                }
            });
            segmentSizeLabel = UIUtils.createControlLabel(generalSettings, DTMessages.data_transfer_wizard_output_label_segment_size);
            segmentSizeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 1, 1));
            segmentSizeText = new Text(generalSettings, SWT.BORDER);
            segmentSizeText.addModifyListener(e -> {
                try {
                    settings.setSegmentSize(Integer.parseInt(segmentSizeText.getText()));
                } catch (NumberFormatException e1) {
                // just skip it
                }
            });
            segmentSizeText.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 1, 1));
        }
        newConnectionCheckbox = UIUtils.createCheckbox(generalSettings, DTMessages.data_transfer_wizard_output_checkbox_new_connection, DTUIMessages.database_producer_page_extract_settings_new_connection_checkbox_tooltip, true, 4);
        newConnectionCheckbox.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                settings.setOpenNewConnections(newConnectionCheckbox.getSelection());
            }
        });
        rowCountCheckbox = UIUtils.createCheckbox(generalSettings, DTMessages.data_transfer_wizard_output_checkbox_select_row_count, DTUIMessages.database_producer_page_extract_settings_row_count_checkbox_tooltip, true, 4);
        rowCountCheckbox.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                settings.setQueryRowCount(rowCountCheckbox.getSelection());
            }
        });
        fetchSizeText = UIUtils.createLabelText(generalSettings, DTUIMessages.database_producer_page_extract_settings_text_fetch_size_label, "", SWT.BORDER);
        fetchSizeText.setToolTipText(DTUIMessages.database_producer_page_extract_settings_text_fetch_size_tooltip);
        fetchSizeText.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.ENGLISH));
        fetchSizeText.addModifyListener(e -> {
            settings.setFetchSize(Integer.parseInt(fetchSizeText.getText()));
        });
        IStructuredSelection curSelection = getWizard().getCurrentSelection();
        boolean hasSelection = curSelection != null && !curSelection.isEmpty() && curSelection.getFirstElement() instanceof DBDCellValue;
        if (hasSelection) {
            selectedColumnsOnlyCheckbox = UIUtils.createCheckbox(generalSettings, DTMessages.data_transfer_wizard_output_checkbox_selected_columns_only, null, false, 4);
            selectedColumnsOnlyCheckbox.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    settings.setSelectedColumnsOnly(selectedColumnsOnlyCheckbox.getSelection());
                }
            });
            selectedRowsOnlyCheckbox = UIUtils.createCheckbox(generalSettings, DTMessages.data_transfer_wizard_output_checkbox_selected_rows_only, null, false, 4);
            selectedRowsOnlyCheckbox.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    settings.setSelectedRowsOnly(selectedRowsOnlyCheckbox.getSelection());
                }
            });
            SelectionAdapter listener = new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    boolean selection = selectedColumnsOnlyCheckbox.getSelection() || selectedRowsOnlyCheckbox.getSelection();
                    newConnectionCheckbox.setEnabled(!selection);
                }
            };
            selectedColumnsOnlyCheckbox.addSelectionListener(listener);
            selectedRowsOnlyCheckbox.addSelectionListener(listener);
        }
    }
    setControl(composite);
}
Also used : DTUIMessages(org.jkiss.dbeaver.tools.transfer.ui.internal.DTUIMessages) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ActiveWizardPage(org.jkiss.dbeaver.ui.dialogs.ActiveWizardPage) org.eclipse.swt.widgets(org.eclipse.swt.widgets) DBDCellValue(org.jkiss.dbeaver.model.data.DBDCellValue) DataTransferWizard(org.jkiss.dbeaver.tools.transfer.ui.wizard.DataTransferWizard) DatabaseProducerSettings(org.jkiss.dbeaver.tools.transfer.database.DatabaseProducerSettings) UIUtils(org.jkiss.dbeaver.ui.UIUtils) Locale(java.util.Locale) SWT(org.eclipse.swt.SWT) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DTMessages(org.jkiss.dbeaver.tools.transfer.internal.DTMessages) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DBDCellValue(org.jkiss.dbeaver.model.data.DBDCellValue) DatabaseProducerSettings(org.jkiss.dbeaver.tools.transfer.database.DatabaseProducerSettings) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 2 with DBDCellValue

use of org.jkiss.dbeaver.model.data.DBDCellValue in project dbeaver by serge-rider.

the class DatabaseProducerPageExtractSettings method createControl.

@Override
public void createControl(Composite parent) {
    initializeDialogUnits(parent);
    Composite composite = UIUtils.createComposite(parent, 1);
    final DatabaseProducerSettings settings = getWizard().getPageSettings(this, DatabaseProducerSettings.class);
    {
        Group generalSettings = UIUtils.createControlGroup(composite, DTMessages.data_transfer_wizard_output_group_progress, 4, GridData.FILL_HORIZONTAL, 0);
        Label threadsNumLabel = UIUtils.createControlLabel(generalSettings, DTMessages.data_transfer_wizard_output_label_max_threads);
        threadsNumText = new Text(generalSettings, SWT.BORDER);
        threadsNumText.setToolTipText(DTUIMessages.database_producer_page_extract_settings_threads_num_text_tooltip);
        threadsNumText.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.ENGLISH));
        threadsNumText.addModifyListener(e -> {
            try {
                getWizard().getSettings().setMaxJobCount(Integer.parseInt(threadsNumText.getText()));
            } catch (NumberFormatException e1) {
            // do nothing
            }
        });
        if (getWizard().getSettings().getDataPipes().size() < 2) {
            threadsNumLabel.setEnabled(false);
            threadsNumText.setEnabled(false);
        }
        threadsNumText.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 3, 1));
        {
            UIUtils.createControlLabel(generalSettings, DTMessages.data_transfer_wizard_output_label_extract_type);
            rowsExtractType = new Combo(generalSettings, SWT.DROP_DOWN | SWT.READ_ONLY);
            rowsExtractType.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 3, 1));
            rowsExtractType.setItems(DTMessages.data_transfer_wizard_output_combo_extract_type_item_single_query, DTMessages.data_transfer_wizard_output_combo_extract_type_item_by_segments);
            rowsExtractType.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    switch(rowsExtractType.getSelectionIndex()) {
                        case EXTRACT_TYPE_SEGMENTS:
                            settings.setExtractType(DatabaseProducerSettings.ExtractType.SEGMENTS);
                            break;
                        case EXTRACT_TYPE_SINGLE_QUERY:
                            settings.setExtractType(DatabaseProducerSettings.ExtractType.SINGLE_QUERY);
                            break;
                    }
                    updatePageCompletion();
                }
            });
            segmentSizeLabel = UIUtils.createControlLabel(generalSettings, DTMessages.data_transfer_wizard_output_label_segment_size);
            segmentSizeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 1, 1));
            segmentSizeText = new Text(generalSettings, SWT.BORDER);
            segmentSizeText.addModifyListener(e -> {
                try {
                    settings.setSegmentSize(Integer.parseInt(segmentSizeText.getText()));
                } catch (NumberFormatException e1) {
                // just skip it
                }
            });
            segmentSizeText.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 1, 1));
        }
        newConnectionCheckbox = UIUtils.createCheckbox(generalSettings, DTMessages.data_transfer_wizard_output_checkbox_new_connection, DTUIMessages.database_producer_page_extract_settings_new_connection_checkbox_tooltip, true, 4);
        newConnectionCheckbox.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                settings.setOpenNewConnections(newConnectionCheckbox.getSelection());
            }
        });
        rowCountCheckbox = UIUtils.createCheckbox(generalSettings, DTMessages.data_transfer_wizard_output_checkbox_select_row_count, DTUIMessages.database_producer_page_extract_settings_row_count_checkbox_tooltip, true, 4);
        rowCountCheckbox.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                settings.setQueryRowCount(rowCountCheckbox.getSelection());
            }
        });
        fetchSizeText = UIUtils.createLabelText(generalSettings, DTUIMessages.database_producer_page_extract_settings_text_fetch_size_label, "", SWT.BORDER);
        fetchSizeText.setToolTipText(DTUIMessages.database_producer_page_extract_settings_text_fetch_size_tooltip);
        fetchSizeText.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.ENGLISH));
        fetchSizeText.addModifyListener(e -> {
            settings.setFetchSize(Integer.parseInt(fetchSizeText.getText()));
        });
        IStructuredSelection curSelection = getWizard().getCurrentSelection();
        boolean hasSelection = curSelection != null && !curSelection.isEmpty() && curSelection.getFirstElement() instanceof DBDCellValue;
        if (hasSelection) {
            selectedColumnsOnlyCheckbox = UIUtils.createCheckbox(generalSettings, DTMessages.data_transfer_wizard_output_checkbox_selected_columns_only, null, false, 4);
            selectedColumnsOnlyCheckbox.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    settings.setSelectedColumnsOnly(selectedColumnsOnlyCheckbox.getSelection());
                }
            });
            selectedRowsOnlyCheckbox = UIUtils.createCheckbox(generalSettings, DTMessages.data_transfer_wizard_output_checkbox_selected_rows_only, null, false, 4);
            selectedRowsOnlyCheckbox.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    settings.setSelectedRowsOnly(selectedRowsOnlyCheckbox.getSelection());
                }
            });
            SelectionAdapter listener = new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    boolean selection = selectedColumnsOnlyCheckbox.getSelection() || selectedRowsOnlyCheckbox.getSelection();
                    newConnectionCheckbox.setEnabled(!selection);
                }
            };
            selectedColumnsOnlyCheckbox.addSelectionListener(listener);
            selectedRowsOnlyCheckbox.addSelectionListener(listener);
        }
    }
    setControl(composite);
}
Also used : DTUIMessages(org.jkiss.dbeaver.tools.transfer.ui.internal.DTUIMessages) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ActiveWizardPage(org.jkiss.dbeaver.ui.dialogs.ActiveWizardPage) org.eclipse.swt.widgets(org.eclipse.swt.widgets) DBDCellValue(org.jkiss.dbeaver.model.data.DBDCellValue) DataTransferWizard(org.jkiss.dbeaver.tools.transfer.ui.wizard.DataTransferWizard) DatabaseProducerSettings(org.jkiss.dbeaver.tools.transfer.database.DatabaseProducerSettings) UIUtils(org.jkiss.dbeaver.ui.UIUtils) Locale(java.util.Locale) SWT(org.eclipse.swt.SWT) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DTMessages(org.jkiss.dbeaver.tools.transfer.internal.DTMessages) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DBDCellValue(org.jkiss.dbeaver.model.data.DBDCellValue) DatabaseProducerSettings(org.jkiss.dbeaver.tools.transfer.database.DatabaseProducerSettings) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

Locale (java.util.Locale)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 SWT (org.eclipse.swt.SWT)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 org.eclipse.swt.widgets (org.eclipse.swt.widgets)2 DBDCellValue (org.jkiss.dbeaver.model.data.DBDCellValue)2 DatabaseProducerSettings (org.jkiss.dbeaver.tools.transfer.database.DatabaseProducerSettings)2 DTMessages (org.jkiss.dbeaver.tools.transfer.internal.DTMessages)2 DTUIMessages (org.jkiss.dbeaver.tools.transfer.ui.internal.DTUIMessages)2 DataTransferWizard (org.jkiss.dbeaver.tools.transfer.ui.wizard.DataTransferWizard)2 UIUtils (org.jkiss.dbeaver.ui.UIUtils)2 ActiveWizardPage (org.jkiss.dbeaver.ui.dialogs.ActiveWizardPage)2