Search in sources :

Example 6 with DataTransferSettings

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

the class DTTaskHandlerTransfer method executeTask.

@Override
public void executeTask(@NotNull DBRRunnableContext runnableContext, @NotNull DBTTask task, @NotNull Locale locale, @NotNull Log log, @NotNull PrintStream logStream, @NotNull DBTTaskExecutionListener listener) throws DBException {
    DataTransferSettings[] settings = new DataTransferSettings[1];
    try {
        runnableContext.run(true, true, monitor -> {
            settings[0] = new DataTransferSettings(monitor, task, log, Collections.emptyMap(), new DataTransferState());
        });
    } catch (InvocationTargetException e) {
        throw new DBException("Error loading task settings", e.getTargetException());
    } catch (InterruptedException e) {
        return;
    }
    executeWithSettings(runnableContext, task, locale, log, listener, settings[0]);
}
Also used : DataTransferSettings(org.jkiss.dbeaver.tools.transfer.DataTransferSettings) DBException(org.jkiss.dbeaver.DBException) DataTransferState(org.jkiss.dbeaver.tools.transfer.DataTransferState) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 7 with DataTransferSettings

use of org.jkiss.dbeaver.tools.transfer.DataTransferSettings in project dbeaver by dbeaver.

the class DatabaseProducerPageInputObjects method updateItemData.

private void updateItemData(TableItem item, DataTransferPipe pipe) {
    DataTransferSettings settings = getWizard().getSettings();
    if (pipe.getProducer() == null || pipe.getProducer().getDatabaseObject() == null) {
        item.setImage(0, null);
        item.setText(0, DTUIMessages.database_producer_page_input_objects_item_text_none);
    } else {
        item.setImage(0, DBeaverIcons.getImage(settings.getProducer().getIcon()));
        item.setText(0, DBUtils.getObjectFullName(pipe.getProducer().getDatabaseObject(), DBPEvaluationContext.DML));
    }
    if (pipe.getConsumer() == null || pipe.getConsumer().getObjectName() == null) {
        item.setImage(1, null);
        item.setText(1, DTUIMessages.database_producer_page_input_objects_item_text_none);
    } else {
        item.setImage(1, DBeaverIcons.getImage(settings.getConsumer().getIcon()));
        item.setText(1, pipe.getConsumer().getObjectName());
    }
}
Also used : DataTransferSettings(org.jkiss.dbeaver.tools.transfer.DataTransferSettings)

Example 8 with DataTransferSettings

use of org.jkiss.dbeaver.tools.transfer.DataTransferSettings in project dbeaver by dbeaver.

the class DatabaseProducerPageInputObjects method createControl.

@Override
public void createControl(Composite parent) {
    initializeDialogUnits(parent);
    Composite composite = UIUtils.createComposite(parent, 1);
    DataTransferSettings settings = getWizard().getSettings();
    {
        Group tablesGroup = UIUtils.createControlGroup(composite, DTMessages.data_transfer_wizard_mappings_name, 3, GridData.FILL_BOTH, 0);
        mappingTable = new Table(tablesGroup, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
        mappingTable.setLayoutData(new GridData(GridData.FILL_BOTH));
        mappingTable.setHeaderVisible(true);
        mappingTable.setLinesVisible(true);
        UIUtils.createTableColumn(mappingTable, SWT.LEFT, DTUIMessages.data_transfer_wizard_final_column_source);
        UIUtils.createTableColumn(mappingTable, SWT.LEFT, DTUIMessages.data_transfer_wizard_final_column_target);
        mappingTable.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (mappingTable.getSelectionIndex() < 0) {
                    return;
                }
                TableItem item = mappingTable.getItem(mappingTable.getSelectionIndex());
                DataTransferPipe pipe = (DataTransferPipe) item.getData();
                if (chooseEntity(pipe)) {
                    updateItemData(item, pipe);
                    updatePageCompletion();
                }
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
                widgetSelected(e);
            }
        });
        UIUtils.asyncExec(() -> UIUtils.packColumns(mappingTable, true));
    }
    {
        Composite controlGroup = UIUtils.createComposite(composite, 1);
        Button autoAssignButton = new Button(controlGroup, SWT.PUSH);
        autoAssignButton.setImage(DBeaverIcons.getImage(UIIcon.ASTERISK));
        autoAssignButton.setText(DTMessages.data_transfer_db_consumer_auto_assign);
        autoAssignButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                autoAssignMappings();
            }
        });
    }
    setControl(composite);
}
Also used : DataTransferSettings(org.jkiss.dbeaver.tools.transfer.DataTransferSettings) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DataTransferPipe(org.jkiss.dbeaver.tools.transfer.DataTransferPipe)

Example 9 with DataTransferSettings

use of org.jkiss.dbeaver.tools.transfer.DataTransferSettings in project dbeaver by dbeaver.

the class DataTransferPagePipes method setSelectedSettings.

private void setSelectedSettings() {
    final IStructuredSelection selection = (IStructuredSelection) nodesTable.getSelection();
    TransferTarget target;
    if (!selection.isEmpty()) {
        target = (TransferTarget) selection.getFirstElement();
    } else {
        target = null;
    }
    DataTransferSettings settings = getWizard().getSettings();
    if (target == null) {
        settings.selectConsumer(null, null, true);
    } else {
        if (settings.isConsumerOptional()) {
            settings.selectConsumer(target.node, target.processor, true);
        } else if (settings.isProducerOptional()) {
            settings.selectProducer(target.node, target.processor, true);
        } else {
        // no optional nodes
        }
    }
    updatePageCompletion();
}
Also used : DataTransferSettings(org.jkiss.dbeaver.tools.transfer.DataTransferSettings)

Example 10 with DataTransferSettings

use of org.jkiss.dbeaver.tools.transfer.DataTransferSettings in project dbeaver by dbeaver.

the class DataTransferPagePipes method loadProducers.

private void loadProducers() {
    DataTransferSettings settings = getWizard().getSettings();
    Collection<DBSObject> objects = settings.getSourceObjects();
    List<TransferTarget> transferTargets = new ArrayList<>();
    for (DataTransferNodeDescriptor producer : DataTransferRegistry.getInstance().getAvailableProducers(objects)) {
        Collection<DataTransferProcessorDescriptor> processors = producer.getAvailableProcessors(objects);
        if (CommonUtils.isEmpty(processors)) {
            transferTargets.add(new TransferTarget(producer, null));
        } else {
            for (DataTransferProcessorDescriptor processor : processors) {
                transferTargets.add(new TransferTarget(producer, processor));
            }
        }
    }
    nodesTable.setInput(transferTargets);
}
Also used : DataTransferSettings(org.jkiss.dbeaver.tools.transfer.DataTransferSettings) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ArrayList(java.util.ArrayList) DataTransferNodeDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor) DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)

Aggregations

DataTransferSettings (org.jkiss.dbeaver.tools.transfer.DataTransferSettings)22 DataTransferPipe (org.jkiss.dbeaver.tools.transfer.DataTransferPipe)8 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)6 ArrayList (java.util.ArrayList)4 GridData (org.eclipse.swt.layout.GridData)4 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)4 DBNModel (org.jkiss.dbeaver.model.navigator.DBNModel)4 DBNNode (org.jkiss.dbeaver.model.navigator.DBNNode)4 DataTransferNodeDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor)4 DataTransferProcessorDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 SashForm (org.eclipse.swt.custom.SashForm)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 DBException (org.jkiss.dbeaver.DBException)2 DBSDataContainer (org.jkiss.dbeaver.model.struct.DBSDataContainer)2 DBSDataManipulator (org.jkiss.dbeaver.model.struct.DBSDataManipulator)2 DBSObjectContainer (org.jkiss.dbeaver.model.struct.DBSObjectContainer)2