Search in sources :

Example 26 with DataTransferProcessorDescriptor

use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor in project dbeaver by serge-rider.

the class DataTransferPagePipes method activatePage.

@Override
public void activatePage() {
    if (activated) {
        // Second activation - we need to disable any selectors
        if (getWizard().getSettings().isPipeChangeRestricted() || getWizard().isTaskEditor()) {
            nodesTable.getTable().setEnabled(false);
        }
        return;
    }
    activated = true;
    if (getWizard().getSettings().isConsumerOptional()) {
        setTitle(DTMessages.data_transfer_wizard_init_title);
        setDescription(DTMessages.data_transfer_wizard_init_description);
        loadConsumers();
    } else {
        setTitle(DTMessages.data_transfer_wizard_producers_title);
        setDescription(DTMessages.data_transfer_wizard_producers_description);
        loadProducers();
    }
    DataTransferNodeDescriptor consumer = getWizard().getSettings().getConsumer();
    DataTransferNodeDescriptor producer = getWizard().getSettings().getProducer();
    DataTransferProcessorDescriptor processor = getWizard().getSettings().getProcessor();
    if (consumer != null || producer != null) {
        Collection<TransferTarget> targets = (Collection<TransferTarget>) nodesTable.getInput();
        for (TransferTarget target : targets) {
            if ((target.node == consumer || target.node == producer) && target.processor == processor) {
                UIUtils.asyncExec(() -> {
                    nodesTable.setSelection(new StructuredSelection(target));
                    setSelectedSettings();
                });
                break;
            }
        }
    }
    inputsTable.setInput(getWizard().getSettings().getSourceObjects());
    UIUtils.maxTableColumnsWidth(inputsTable.getTable());
    UIUtils.maxTableColumnsWidth(nodesTable.getTable());
    updatePageCompletion();
}
Also used : DataTransferNodeDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor) DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor) Collection(java.util.Collection)

Example 27 with DataTransferProcessorDescriptor

use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor in project dbeaver by serge-rider.

the class DataTransferPageFinal method activatePage.

@Override
public void activatePage() {
    resultTable.removeAll();
    DataTransferSettings settings = getWizard().getSettings();
    List<DataTransferPipe> dataPipes = settings.getDataPipes();
    IDataTransferSettings consumerSettings = null, producerSettings = null;
    for (int i = 0; i < dataPipes.size(); i++) {
        DataTransferPipe pipe = dataPipes.get(i);
        try {
            pipe.initPipe(settings, i, dataPipes.size());
        } catch (DBException e) {
            DBWorkbench.getPlatformUI().showError(DTUIMessages.data_transfer_page_final_title_error_initializing_transfer_pipe, DTUIMessages.data_transfer_page_final_message_error_initializing_data_transfer_pipe, e);
            continue;
        }
        IDataTransferConsumer consumer = pipe.getConsumer();
        IDataTransferProducer producer = pipe.getProducer();
        if (consumerSettings == null) {
            consumerSettings = settings.getNodeSettings(settings.getConsumer());
        }
        if (producerSettings == null) {
            producerSettings = settings.getNodeSettings(settings.getProducer());
        }
        DataTransferProcessorDescriptor processorDescriptor = settings.getProcessor();
        TableItem item = new TableItem(resultTable, SWT.NONE);
        {
            item.setText(0, producer.getObjectContainerName());
            if (producer.getObjectContainerIcon() != null) {
                item.setImage(0, DBeaverIcons.getImage(producer.getObjectContainerIcon()));
            }
            item.setText(1, CommonUtils.notEmpty(producer.getObjectName()));
            DBPImage producerObjectIcon = producer.getObjectIcon();
            if (producerObjectIcon == null) {
                producerObjectIcon = settings.getProducer().getIcon();
            }
            if (producerObjectIcon != null) {
                item.setImage(1, DBeaverIcons.getImage(producerObjectIcon));
            }
            Color producerColor = getNodeColor(producer);
            if (producerColor != null) {
                item.setBackground(0, producerColor);
                item.setBackground(1, producerColor);
            }
        }
        {
            item.setText(2, consumer.getObjectContainerName());
            if (consumer.getObjectContainerIcon() != null) {
                item.setImage(2, DBeaverIcons.getImage(consumer.getObjectContainerIcon()));
            }
            item.setText(3, consumer.getObjectName());
            DBPImage consumerObjectIcon = consumer.getObjectIcon();
            if (consumerObjectIcon == null && processorDescriptor != null) {
                consumerObjectIcon = processorDescriptor.getIcon();
            }
            if (consumerObjectIcon == null && settings.getConsumer() != null) {
                consumerObjectIcon = settings.getConsumer().getIcon();
            }
            if (consumerObjectIcon != null) {
                item.setImage(3, DBeaverIcons.getImage(consumerObjectIcon));
            }
            Color consumerColor = getNodeColor(consumer);
            if (consumerColor != null) {
                item.setBackground(2, consumerColor);
                item.setBackground(3, consumerColor);
            }
        }
    }
    printSummary(sourceSettingsText, settings.getProducer(), producerSettings, settings.isProducerProcessor() ? settings.getProcessor() : null);
    printSummary(targetSettingsText, settings.getConsumer(), consumerSettings, settings.isProducerProcessor() ? null : settings.getProcessor());
    activated = true;
    int tableWidth = resultTable.getSize().x;
    TableColumn[] columns = resultTable.getColumns();
    for (TableColumn column : columns) {
        column.setWidth(tableWidth / columns.length - 1);
    }
    updatePageCompletion();
    getWizard().updateSaveTaskButtons();
}
Also used : DBException(org.jkiss.dbeaver.DBException) Color(org.eclipse.swt.graphics.Color) DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor) DBPImage(org.jkiss.dbeaver.model.DBPImage)

Example 28 with DataTransferProcessorDescriptor

use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor in project dbeaver by serge-rider.

the class ResultSetHandlerCopyAs method updateElement.

@Override
public void updateElement(UIElement element, Map parameters) {
    // Put processor name in command label
    DataTransferProcessorDescriptor processor = getActiveProcessor((String) parameters.get(PARAM_PROCESSOR_ID));
    if (processor != null) {
        String commandName = ActionUtils.findCommandName(CMD_COPY_AS);
        element.setText(commandName + " " + processor.getName());
        if (!CommonUtils.isEmpty(processor.getDescription())) {
            element.setTooltip(processor.getDescription());
        }
        if (processor.getIcon() != null) {
            element.setIcon(DBeaverIcons.getImageDescriptor(processor.getIcon()));
        }
    }
}
Also used : DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)

Example 29 with DataTransferProcessorDescriptor

use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor in project dbeaver by serge-rider.

the class ResultSetHandlerCopyAs method fillCopyAsMenu.

public static void fillCopyAsMenu(ResultSetViewer viewer, IContributionManager copyAsMenu) {
    IWorkbenchPartSite site = viewer.getSite();
    copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerCopySpecial.CMD_COPY_SPECIAL));
    copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerCopySpecial.CMD_COPY_COLUMN_NAMES));
    copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_COPY_ROW_NAMES));
    // Add copy commands for different formats
    copyAsMenu.add(new Separator());
    ResultSetDataContainerOptions options = new ResultSetDataContainerOptions();
    ResultSetDataContainer dataContainer = new ResultSetDataContainer(viewer, options);
    List<DataTransferProcessorDescriptor> appProcessors = new ArrayList<>();
    for (final DataTransferNodeDescriptor consumerNode : DataTransferRegistry.getInstance().getAvailableConsumers(Collections.singleton(dataContainer))) {
        for (DataTransferProcessorDescriptor processor : consumerNode.getProcessors()) {
            if (processor.isBinaryFormat()) {
                continue;
            }
            appProcessors.add(processor);
        }
    }
    appProcessors.sort(Comparator.comparing(DataTransferProcessorDescriptor::getName));
    for (DataTransferProcessorDescriptor processor : appProcessors) {
        CommandContributionItemParameter params = new CommandContributionItemParameter(site, processor.getId(), ResultSetHandlerCopyAs.CMD_COPY_AS, CommandContributionItem.STYLE_PUSH);
        params.label = processor.getName();
        if (processor.getIcon() != null) {
            params.icon = DBeaverIcons.getImageDescriptor(processor.getIcon());
        }
        Map<String, Object> parameters = new HashMap<>();
        parameters.put(ResultSetHandlerCopyAs.PARAM_PROCESSOR_ID, processor.getFullId());
        params.parameters = parameters;
        copyAsMenu.add(new CommandContributionItem(params));
    }
}
Also used : DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) DataTransferNodeDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Example 30 with DataTransferProcessorDescriptor

use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor in project dbeaver by serge-rider.

the class ResultSetHandlerOpenWith method getDefaultAppProcessor.

private static DataTransferProcessorDescriptor getDefaultAppProcessor() {
    List<DataTransferProcessorDescriptor> processors = new ArrayList<>();
    for (final DataTransferNodeDescriptor consumerNode : DataTransferRegistry.getInstance().getNodes(DataTransferNodeDescriptor.NodeType.CONSUMER)) {
        for (DataTransferProcessorDescriptor processor : consumerNode.getProcessors()) {
            if (processor.getAppFileExtension() != null) {
                processors.add(processor);
            }
        }
    }
    processors.sort(Comparator.comparingInt(DataTransferProcessorDescriptor::getOrder));
    return processors.isEmpty() ? null : processors.get(0);
}
Also used : DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor) DataTransferNodeDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor)

Aggregations

DataTransferProcessorDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)34 DataTransferNodeDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor)16 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)10 DBException (org.jkiss.dbeaver.DBException)6 ArrayList (java.util.ArrayList)4 CommandContributionItem (org.eclipse.ui.menus.CommandContributionItem)4 CommandContributionItemParameter (org.eclipse.ui.menus.CommandContributionItemParameter)4 DBPPropertyDescriptor (org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor)4 PropertySourceCustom (org.jkiss.dbeaver.runtime.properties.PropertySourceCustom)4 DataTransferSettings (org.jkiss.dbeaver.tools.transfer.DataTransferSettings)4 Collection (java.util.Collection)2 Date (java.util.Date)2 Color (org.eclipse.swt.graphics.Color)2 IWorkbenchPartSite (org.eclipse.ui.IWorkbenchPartSite)2 DBPImage (org.jkiss.dbeaver.model.DBPImage)2 DBPObject (org.jkiss.dbeaver.model.DBPObject)2 DBCException (org.jkiss.dbeaver.model.exec.DBCException)2 MonitorRunnableContext (org.jkiss.dbeaver.model.runtime.MonitorRunnableContext)2 DataTransferRegistry (org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry)2 StreamConsumerSettings (org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings)2