Search in sources :

Example 6 with StreamConsumerSettings

use of org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings in project dbeaver by serge-rider.

the class ResultSetHandlerOpenWith method openResultsWith.

private static void openResultsWith(IResultSetController resultSet, DataTransferProcessorDescriptor processor) {
    ResultSetDataContainerOptions options = new ResultSetDataContainerOptions();
    IResultSetSelection rsSelection = resultSet.getSelection();
    List<ResultSetRow> rsSelectedRows = rsSelection.getSelectedRows();
    List<DBDAttributeBinding> rsSelectedAttributes = rsSelection.getSelectedAttributes();
    if (rsSelectedRows.size() > 1 || rsSelectedAttributes.size() > 1) {
        List<Long> selectedRows = new ArrayList<>();
        for (ResultSetRow selectedRow : rsSelectedRows) {
            selectedRows.add((long) selectedRow.getRowNumber());
        }
        List<String> selectedAttributes = new ArrayList<>();
        for (DBDAttributeBinding attributeBinding : rsSelectedAttributes) {
            selectedAttributes.add(attributeBinding.getName());
        }
        options.setSelectedRows(selectedRows);
        options.setSelectedColumns(selectedAttributes);
    }
    ResultSetDataContainer dataContainer = new ResultSetDataContainer(resultSet, options);
    if (dataContainer.getDataSource() == null) {
        DBWorkbench.getPlatformUI().showError("Open " + processor.getAppName(), ModelMessages.error_not_connected_to_database);
        return;
    }
    DBPPreferenceStore preferenceStore = DBWorkbench.getPlatform().getPreferenceStore();
    String prevActiveApp = preferenceStore.getString(PARAM_ACTIVE_APP);
    if (!CommonUtils.equalObjects(prevActiveApp, processor.getFullId())) {
    // preferenceStore.setValue(PARAM_ACTIVE_APP, processor.getFullId());
    // resultSet.updateEditControls();
    // resultSet.getControl().layout(true);
    }
    AbstractJob exportJob = new AbstractJob("Open " + processor.getAppName()) {

        {
            setUser(true);
            setSystem(false);
        }

        @Override
        protected IStatus run(DBRProgressMonitor monitor) {
            try {
                File tempDir = DBWorkbench.getPlatform().getTempFolder(monitor, "data-files");
                File tempFile = new File(tempDir, new SimpleDateFormat("yyyyMMdd-HHmmss").format(System.currentTimeMillis()) + "." + processor.getAppFileExtension());
                tempFile.deleteOnExit();
                IDataTransferProcessor processorInstance = processor.getInstance();
                if (!(processorInstance instanceof IStreamDataExporter)) {
                    return Status.CANCEL_STATUS;
                }
                IStreamDataExporter exporter = (IStreamDataExporter) processorInstance;
                StreamTransferConsumer consumer = new StreamTransferConsumer();
                StreamConsumerSettings settings = new StreamConsumerSettings();
                settings.setOutputEncodingBOM(false);
                settings.setOpenFolderOnFinish(false);
                settings.setOutputFolder(tempDir.getAbsolutePath());
                settings.setOutputFilePattern(tempFile.getName());
                Map<String, Object> properties = new HashMap<>();
                // Default values from wizard
                IDialogSettings dtSettings = DataTransferWizard.getWizardDialogSettings();
                IDialogSettings procListSection = dtSettings.getSection("processors");
                IDialogSettings procSettings = null;
                if (procListSection != null) {
                    procSettings = procListSection.getSection("stream_consumer:" + processor.getId());
                }
                for (DBPPropertyDescriptor prop : processor.getProperties()) {
                    Object defValue = procSettings == null ? null : procSettings.get(CommonUtils.toString(prop.getId()));
                    properties.put(prop.getId(), defValue != null ? defValue : prop.getDefaultValue());
                }
                // Remove extension property (we specify file name directly)
                properties.remove(StreamConsumerSettings.PROP_FILE_EXTENSION);
                consumer.initTransfer(dataContainer, settings, new IDataTransferConsumer.TransferParameters(processor.isBinaryFormat(), processor.isHTMLFormat()), exporter, properties);
                DBDDataFilter dataFilter = resultSet.getModel().getDataFilter();
                DatabaseTransferProducer producer = new DatabaseTransferProducer(dataContainer, dataFilter);
                DatabaseProducerSettings producerSettings = new DatabaseProducerSettings();
                producerSettings.setExtractType(DatabaseProducerSettings.ExtractType.SINGLE_QUERY);
                producerSettings.setQueryRowCount(false);
                // disable OpenNewconnection by default (#6432)
                producerSettings.setOpenNewConnections(false);
                producerSettings.setSelectedRowsOnly(!CommonUtils.isEmpty(options.getSelectedRows()));
                producerSettings.setSelectedColumnsOnly(!CommonUtils.isEmpty(options.getSelectedColumns()));
                producer.transferData(monitor, consumer, null, producerSettings, null);
                consumer.finishTransfer(monitor, false);
                UIUtils.asyncExec(() -> {
                    if (!UIUtils.launchProgram(tempFile.getAbsolutePath())) {
                        DBWorkbench.getPlatformUI().showError("Open " + processor.getAppName(), "Can't open " + processor.getAppFileExtension() + " file '" + tempFile.getAbsolutePath() + "'");
                    }
                });
            } catch (Exception e) {
                DBWorkbench.getPlatformUI().showError("Error opening in " + processor.getAppName(), null, e);
            }
            return Status.OK_STATUS;
        }
    };
    exportJob.schedule();
}
Also used : DBDAttributeBinding(org.jkiss.dbeaver.model.data.DBDAttributeBinding) StreamConsumerSettings(org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings) DBDDataFilter(org.jkiss.dbeaver.model.data.DBDDataFilter) StreamTransferConsumer(org.jkiss.dbeaver.tools.transfer.stream.StreamTransferConsumer) IDataTransferConsumer(org.jkiss.dbeaver.tools.transfer.IDataTransferConsumer) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) IDataTransferProcessor(org.jkiss.dbeaver.tools.transfer.IDataTransferProcessor) ExecutionException(org.eclipse.core.commands.ExecutionException) DBPPropertyDescriptor(org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor) AbstractJob(org.jkiss.dbeaver.model.runtime.AbstractJob) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) DatabaseTransferProducer(org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferProducer) DatabaseProducerSettings(org.jkiss.dbeaver.tools.transfer.database.DatabaseProducerSettings) IStreamDataExporter(org.jkiss.dbeaver.tools.transfer.stream.IStreamDataExporter) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat)

Example 7 with StreamConsumerSettings

use of org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings in project dbeaver by dbeaver.

the class OpenSpreadsheetHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IResultSetController resultSet = ResultSetHandlerMain.getActiveResultSet(HandlerUtil.getActivePart(event));
    if (resultSet == null) {
        DBWorkbench.getPlatformUI().showError("Open Excel", "No active results viewer");
        return null;
    }
    ResultSetDataContainerOptions options = new ResultSetDataContainerOptions();
    IResultSetSelection rsSelection = resultSet.getSelection();
    List<ResultSetRow> rsSelectedRows = rsSelection.getSelectedRows();
    if (rsSelectedRows.size() > 1) {
        List<Long> selectedRows = new ArrayList<>();
        for (ResultSetRow selectedRow : rsSelectedRows) {
            selectedRows.add((long) selectedRow.getRowNumber());
        }
        List<String> selectedAttributes = new ArrayList<>();
        for (DBDAttributeBinding attributeBinding : rsSelection.getSelectedAttributes()) {
            selectedAttributes.add(attributeBinding.getName());
        }
        options.setSelectedRows(selectedRows);
        options.setSelectedColumns(selectedAttributes);
    }
    ResultSetDataContainer dataContainer = new ResultSetDataContainer(resultSet, options);
    if (dataContainer.getDataSource() == null) {
        DBWorkbench.getPlatformUI().showError("Open Excel", ModelMessages.error_not_connected_to_database);
        return null;
    }
    AbstractJob exportJob = new AbstractJob("Open Excel") {

        {
            setUser(true);
            setSystem(false);
        }

        @Override
        protected IStatus run(DBRProgressMonitor monitor) {
            try {
                File tempDir = DBWorkbench.getPlatform().getTempFolder(monitor, "office-files");
                File tempFile = new File(tempDir, CommonUtils.escapeFileName(CommonUtils.truncateString(dataContainer.getName(), 32)) + "." + new SimpleDateFormat("yyyyMMdd-HHmmss").format(System.currentTimeMillis()) + ".xlsx");
                tempFile.deleteOnExit();
                StreamExporterAbstract exporter = new DataExporterXLSX();
                StreamTransferConsumer consumer = new StreamTransferConsumer();
                StreamConsumerSettings settings = new StreamConsumerSettings();
                settings.setOutputEncodingBOM(false);
                settings.setOpenFolderOnFinish(false);
                settings.setOutputFolder(tempDir.getAbsolutePath());
                settings.setOutputFilePattern(tempFile.getName());
                Map<String, Object> properties = DataExporterXLSX.getDefaultProperties();
                consumer.initTransfer(dataContainer, settings, new IDataTransferConsumer.TransferParameters(true, false), exporter, properties);
                DBDDataFilter dataFilter = resultSet.getModel().getDataFilter();
                DatabaseTransferProducer producer = new DatabaseTransferProducer(dataContainer, dataFilter);
                DatabaseProducerSettings producerSettings = new DatabaseProducerSettings();
                producerSettings.setExtractType(DatabaseProducerSettings.ExtractType.SINGLE_QUERY);
                producerSettings.setQueryRowCount(false);
                producerSettings.setSelectedRowsOnly(true);
                producerSettings.setSelectedColumnsOnly(true);
                producer.transferData(monitor, consumer, null, producerSettings, null);
                consumer.finishTransfer(monitor, false);
                UIUtils.asyncExec(() -> {
                    if (!UIUtils.launchProgram(tempFile.getAbsolutePath())) {
                        DBWorkbench.getPlatformUI().showError("Open XLSX", "Can't open XLSX file '" + tempFile.getAbsolutePath() + "'");
                    }
                });
            } catch (Exception e) {
                DBWorkbench.getPlatformUI().showError("Error opening in Excel", null, e);
            }
            return Status.OK_STATUS;
        }
    };
    exportJob.schedule();
    return null;
}
Also used : StreamExporterAbstract(org.jkiss.dbeaver.tools.transfer.stream.exporter.StreamExporterAbstract) ArrayList(java.util.ArrayList) DBDAttributeBinding(org.jkiss.dbeaver.model.data.DBDAttributeBinding) StreamConsumerSettings(org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings) DBDDataFilter(org.jkiss.dbeaver.model.data.DBDDataFilter) StreamTransferConsumer(org.jkiss.dbeaver.tools.transfer.stream.StreamTransferConsumer) IDataTransferConsumer(org.jkiss.dbeaver.tools.transfer.IDataTransferConsumer) ExecutionException(org.eclipse.core.commands.ExecutionException) DataExporterXLSX(org.jkiss.dbeaver.data.office.export.DataExporterXLSX) AbstractJob(org.jkiss.dbeaver.model.runtime.AbstractJob) DatabaseTransferProducer(org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferProducer) DatabaseProducerSettings(org.jkiss.dbeaver.tools.transfer.database.DatabaseProducerSettings) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat)

Example 8 with StreamConsumerSettings

use of org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings in project dbeaver by dbeaver.

the class StreamConsumerPageOutput method createControl.

@Override
public void createControl(Composite parent) {
    initializeDialogUnits(parent);
    Composite composite = UIUtils.createComposite(parent, 1);
    final StreamConsumerSettings settings = getWizard().getPageSettings(this, StreamConsumerSettings.class);
    {
        Group generalSettings = UIUtils.createControlGroup(composite, DTMessages.data_transfer_wizard_output_group_general, 5, GridData.FILL_HORIZONTAL, 0);
        clipboardCheck = UIUtils.createCheckbox(generalSettings, DTMessages.data_transfer_wizard_output_label_copy_to_clipboard, null, false, 5);
        clipboardCheck.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                settings.setOutputClipboard(clipboardCheck.getSelection());
                updateControlsEnablement();
                updatePageCompletion();
            }
        });
        // Output path/pattern
        directoryText = DialogUtils.createOutputFolderChooser(generalSettings, null, e -> {
            settings.setOutputFolder(directoryText.getText());
            updatePageCompletion();
        });
        ((GridData) directoryText.getParent().getLayoutData()).horizontalSpan = 4;
        UIUtils.createControlLabel(generalSettings, DTMessages.data_transfer_wizard_output_label_file_name_pattern);
        fileNameText = new Text(generalSettings, SWT.BORDER);
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 4;
        UIUtils.setContentProposalToolTip(fileNameText, DTUIMessages.stream_consumer_page_output_tooltip_output_file_name_pattern, StreamTransferConsumer.VARIABLE_DATASOURCE, StreamTransferConsumer.VARIABLE_CATALOG, StreamTransferConsumer.VARIABLE_SCHEMA, StreamTransferConsumer.VARIABLE_TABLE, StreamTransferConsumer.VARIABLE_TIMESTAMP, StreamTransferConsumer.VARIABLE_DATE, StreamTransferConsumer.VARIABLE_INDEX, StreamTransferConsumer.VARIABLE_PROJECT, StreamTransferConsumer.VARIABLE_CONN_TYPE);
        fileNameText.setLayoutData(gd);
        fileNameText.addModifyListener(e -> {
            settings.setOutputFilePattern(fileNameText.getText());
            updatePageCompletion();
        });
        ContentAssistUtils.installContentProposal(fileNameText, new SmartTextContentAdapter(), new StringContentProposalProvider(GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_DATASOURCE), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_CATALOG), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_SCHEMA), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_TABLE), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_TIMESTAMP), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_DATE), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_INDEX), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_CONN_TYPE), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_PROJECT)));
        {
            UIUtils.createControlLabel(generalSettings, DTMessages.data_transfer_wizard_output_label_encoding);
            encodingCombo = UIUtils.createEncodingCombo(generalSettings, settings.getOutputEncoding());
            // encodingCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, true, false, 1, 1));
            encodingCombo.addModifyListener(e -> {
                int index = encodingCombo.getSelectionIndex();
                if (index >= 0) {
                    settings.setOutputEncoding(encodingCombo.getItem(index));
                }
                updatePageCompletion();
            });
            timestampPattern = UIUtils.createLabelText(generalSettings, DTMessages.data_transfer_wizard_output_label_timestamp_pattern, GeneralUtils.DEFAULT_TIMESTAMP_PATTERN, SWT.BORDER);
            timestampPattern.addModifyListener(e -> {
                settings.setOutputTimestampPattern(timestampPattern.getText());
            });
            encodingBOMCheckbox = UIUtils.createCheckbox(generalSettings, DTMessages.data_transfer_wizard_output_label_insert_bom, DTMessages.data_transfer_wizard_output_label_insert_bom_tooltip, false, 1);
            encodingBOMCheckbox.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    settings.setOutputEncodingBOM(encodingBOMCheckbox.getSelection());
                }
            });
        }
        singleFileCheck = UIUtils.createCheckbox(generalSettings, DTMessages.data_transfer_wizard_output_label_use_single_file, DTMessages.data_transfer_wizard_output_label_use_single_file_tip, false, 5);
        singleFileCheck.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                settings.setUseSingleFile(singleFileCheck.getSelection());
                updatePageCompletion();
            }
        });
        compressCheckbox = UIUtils.createCheckbox(generalSettings, DTMessages.data_transfer_wizard_output_checkbox_compress, null, false, 1);
        compressCheckbox.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                settings.setCompressResults(compressCheckbox.getSelection());
                updateControlsEnablement();
            }
        });
        {
            Composite outFilesSettings = UIUtils.createComposite(generalSettings, 3);
            outFilesSettings.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false, 5, 1));
            splitFilesCheckbox = UIUtils.createCheckbox(outFilesSettings, DTMessages.data_transfer_wizard_output_checkbox_split_files, DTMessages.data_transfer_wizard_output_checkbox_split_files_tip, false, 1);
            splitFilesCheckbox.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    settings.setSplitOutFiles(splitFilesCheckbox.getSelection());
                    updateControlsEnablement();
                }
            });
            maximumFileSizeLabel = UIUtils.createControlLabel(outFilesSettings, DTUIMessages.stream_consumer_page_output_label_maximum_file_size);
            maximumFileSizeText = new Text(outFilesSettings, SWT.BORDER);
            maximumFileSizeText.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.ENGLISH));
            maximumFileSizeText.addModifyListener(e -> settings.setMaxOutFileSize(CommonUtils.toLong(maximumFileSizeText.getText())));
            gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            gd.widthHint = UIUtils.getFontHeight(maximumFileSizeText) * 10;
            maximumFileSizeText.setLayoutData(gd);
        }
    }
    {
        Group resultsSettings = UIUtils.createControlGroup(composite, DTUIMessages.stream_consumer_page_output_label_results, 2, GridData.FILL_HORIZONTAL, 0);
        showFolderCheckbox = UIUtils.createCheckbox(resultsSettings, DTMessages.data_transfer_wizard_output_checkbox_open_folder, true);
        showFolderCheckbox.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                settings.setOpenFolderOnFinish(showFolderCheckbox.getSelection());
            }
        });
        showFolderCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 2, 1));
        execProcessCheckbox = UIUtils.createCheckbox(resultsSettings, DTUIMessages.stream_consumer_page_output_checkbox_execute_process, true);
        execProcessCheckbox.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                settings.setExecuteProcessOnFinish(execProcessCheckbox.getSelection());
                updateControlsEnablement();
                updatePageCompletion();
            }
        });
        execProcessText = new Text(resultsSettings, SWT.BORDER);
        execProcessText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        execProcessText.addModifyListener(e -> {
            settings.setFinishProcessCommand(execProcessText.getText());
            updatePageCompletion();
        });
        UIUtils.setContentProposalToolTip(execProcessText, DTUIMessages.stream_consumer_page_output_tooltip_process_command_line, StreamTransferConsumer.VARIABLE_FILE, StreamTransferConsumer.VARIABLE_TABLE, StreamTransferConsumer.VARIABLE_TIMESTAMP, StreamTransferConsumer.VARIABLE_DATE, StreamTransferConsumer.VARIABLE_PROJECT, StreamTransferConsumer.VARIABLE_CONN_TYPE);
        ContentAssistUtils.installContentProposal(execProcessText, new SmartTextContentAdapter(), new StringContentProposalProvider(GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_TABLE), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_TIMESTAMP), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_DATE), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_PROJECT), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_CONN_TYPE), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_FILE)));
        showFinalMessageCheckbox = UIUtils.createCheckbox(resultsSettings, DTUIMessages.stream_consumer_page_output_label_show_finish_message, null, getWizard().getSettings().isShowFinalMessage(), 4);
        showFinalMessageCheckbox.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                getWizard().getSettings().setShowFinalMessage(showFinalMessageCheckbox.getSelection());
            }
        });
    }
    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) GeneralUtils(org.jkiss.dbeaver.utils.GeneralUtils) CommonUtils(org.jkiss.utils.CommonUtils) StreamConsumerSettings(org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings) org.eclipse.swt.widgets(org.eclipse.swt.widgets) StreamTransferConsumer(org.jkiss.dbeaver.tools.transfer.stream.StreamTransferConsumer) StringContentProposalProvider(org.jkiss.dbeaver.ui.contentassist.StringContentProposalProvider) SmartTextContentAdapter(org.jkiss.dbeaver.ui.contentassist.SmartTextContentAdapter) ContentAssistUtils(org.jkiss.dbeaver.ui.contentassist.ContentAssistUtils) DataTransferWizard(org.jkiss.dbeaver.tools.transfer.ui.wizard.DataTransferWizard) UIUtils(org.jkiss.dbeaver.ui.UIUtils) Locale(java.util.Locale) SWT(org.eclipse.swt.SWT) DialogUtils(org.jkiss.dbeaver.ui.dialogs.DialogUtils) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) DTMessages(org.jkiss.dbeaver.tools.transfer.internal.DTMessages) StreamConsumerSettings(org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings) 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)

Example 9 with StreamConsumerSettings

use of org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings in project dbeaver by dbeaver.

the class StreamConsumerPageOutput method activatePage.

@Override
public void activatePage() {
    boolean isBinary = getWizard().getSettings().getProcessor().isBinaryFormat();
    final StreamConsumerSettings settings = getWizard().getPageSettings(this, StreamConsumerSettings.class);
    clipboardCheck.setSelection(settings.isOutputClipboard());
    singleFileCheck.setSelection(settings.isUseSingleFile());
    directoryText.setText(CommonUtils.toString(settings.getOutputFolder()));
    fileNameText.setText(CommonUtils.toString(settings.getOutputFilePattern()));
    compressCheckbox.setSelection(settings.isCompressResults());
    splitFilesCheckbox.setSelection(settings.isSplitOutFiles());
    maximumFileSizeText.setText(String.valueOf(settings.getMaxOutFileSize()));
    encodingCombo.setText(CommonUtils.toString(settings.getOutputEncoding()));
    timestampPattern.setText(settings.getOutputTimestampPattern());
    encodingBOMCheckbox.setSelection(settings.isOutputEncodingBOM());
    showFolderCheckbox.setSelection(settings.isOpenFolderOnFinish());
    execProcessCheckbox.setSelection(settings.isExecuteProcessOnFinish());
    execProcessText.setText(CommonUtils.toString(settings.getFinishProcessCommand()));
    if (isBinary) {
        clipboardCheck.setSelection(false);
        encodingBOMCheckbox.setSelection(false);
        settings.setOutputClipboard(false);
    }
    showFinalMessageCheckbox.setSelection(getWizard().getSettings().isShowFinalMessage());
    updatePageCompletion();
    updateControlsEnablement();
}
Also used : StreamConsumerSettings(org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings)

Example 10 with StreamConsumerSettings

use of org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings in project dbeaver by dbeaver.

the class StreamConsumerPageSettings method activatePage.

@Override
public void activatePage() {
    final StreamConsumerSettings settings = getWizard().getPageSettings(this, StreamConsumerSettings.class);
    DataTransferProcessorDescriptor processor = getWizard().getSettings().getProcessor();
    propertySource = new PropertySourceCustom(processor.getProperties(), getWizard().getSettings().getProcessorProperties());
    propsEditor.loadProperties(propertySource);
    switch(settings.getLobExtractType()) {
        case SKIP:
            lobExtractType.select(EXTRACT_LOB_SKIP);
            break;
        case FILES:
            lobExtractType.select(EXTRACT_LOB_FILES);
            break;
        case INLINE:
            lobExtractType.select(EXTRACT_LOB_INLINE);
            break;
    }
    switch(settings.getLobEncoding()) {
        case BASE64:
            lobEncodingCombo.select(LOB_ENCODING_BASE64);
            break;
        case HEX:
            lobEncodingCombo.select(LOB_ENCODING_HEX);
            break;
        case BINARY:
            lobEncodingCombo.select(LOB_ENCODING_BINARY);
            break;
        case NATIVE:
            lobEncodingCombo.select(LOB_ENCODING_NATIVE);
            break;
    }
    updatePageCompletion();
}
Also used : StreamConsumerSettings(org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings) PropertySourceCustom(org.jkiss.dbeaver.runtime.properties.PropertySourceCustom) DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)

Aggregations

StreamConsumerSettings (org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings)21 StreamTransferConsumer (org.jkiss.dbeaver.tools.transfer.stream.StreamTransferConsumer)8 ExecutionException (org.eclipse.core.commands.ExecutionException)6 DBDAttributeBinding (org.jkiss.dbeaver.model.data.DBDAttributeBinding)6 DBDDataFilter (org.jkiss.dbeaver.model.data.DBDDataFilter)6 AbstractJob (org.jkiss.dbeaver.model.runtime.AbstractJob)6 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)6 IDataTransferConsumer (org.jkiss.dbeaver.tools.transfer.IDataTransferConsumer)6 DatabaseProducerSettings (org.jkiss.dbeaver.tools.transfer.database.DatabaseProducerSettings)6 DatabaseTransferProducer (org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferProducer)6 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 GridData (org.eclipse.swt.layout.GridData)5 File (java.io.File)4 SimpleDateFormat (java.text.SimpleDateFormat)4 DBPDataFormatterRegistry (org.jkiss.dbeaver.model.app.DBPDataFormatterRegistry)4 DBPPropertyDescriptor (org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor)4 IDataTransferProcessor (org.jkiss.dbeaver.tools.transfer.IDataTransferProcessor)4 IStreamDataExporter (org.jkiss.dbeaver.tools.transfer.stream.IStreamDataExporter)4 PreferenceDialog (org.eclipse.jface.preference.PreferenceDialog)3