Search in sources :

Example 11 with DataTransferSettings

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

the class DataTransferPageSettings method createSettingsPages.

private void createSettingsPages(Composite composite) {
    DataTransferSettings dtSettings = getWizard().getSettings();
    {
        DataTransferPipe dataPipe = dtSettings.getDataPipes().get(0);
        StringBuilder title = new StringBuilder();
        title.append(DTMessages.data_transfer_wizard_settings_title).append(" (").append(dtSettings.getProducer().getName()).append(" to ").append(dtSettings.getConsumer().getName());
        if (dtSettings.getProcessor() != null) {
            title.append(", ").append(dtSettings.getProcessor().getName());
        }
        title.append(")");
        setTitle(title.toString());
        producerSettingsPage = getSettingsPage(dataPipe.getProducer());
        consumerSettingsPage = getSettingsPage(dataPipe.getConsumer());
    }
    Composite settingsComposite = composite;
    if (producerSettingsPage != null && consumerSettingsPage != null) {
        SashForm sash = new SashForm(composite, SWT.HORIZONTAL);
        sash.setLayoutData(new GridData(GridData.FILL_BOTH));
        settingsComposite = sash;
    }
    if (producerSettingsPage != null) {
        producerSettingsPage.setWizard(getWizard());
        Composite producerGroup = UIUtils.createPlaceholder(settingsComposite, 1);
        UIUtils.createInfoLabel(producerGroup, producerSettingsPage.getTitle());
        Composite settingPanel = new Composite(producerGroup, SWT.NONE);
        settingPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
        settingPanel.setLayout(new FillLayout());
        producerSettingsPage.createControl(settingPanel);
        if (producerSettingsPage instanceof ActiveWizardPage) {
            ((ActiveWizardPage) producerSettingsPage).activatePage();
        }
    }
    if (consumerSettingsPage != null) {
        consumerSettingsPage.setWizard(getWizard());
        Composite consumerGroup = UIUtils.createPlaceholder(settingsComposite, 1);
        UIUtils.createInfoLabel(consumerGroup, consumerSettingsPage.getTitle());
        Composite settingPanel = new Composite(consumerGroup, SWT.NONE);
        settingPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
        settingPanel.setLayout(new FillLayout());
        consumerSettingsPage.createControl(settingPanel);
        if (consumerSettingsPage instanceof ActiveWizardPage) {
            ((ActiveWizardPage) consumerSettingsPage).activatePage();
        }
    }
}
Also used : DataTransferSettings(org.jkiss.dbeaver.tools.transfer.DataTransferSettings) SashForm(org.eclipse.swt.custom.SashForm) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) DataTransferPipe(org.jkiss.dbeaver.tools.transfer.DataTransferPipe) ActiveWizardPage(org.jkiss.dbeaver.ui.dialogs.ActiveWizardPage)

Example 12 with DataTransferSettings

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

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 13 with DataTransferSettings

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

the class DatabaseConsumerPageMapping method showPreview.

private void showPreview(DatabaseMappingContainer mappingContainer) {
    DataTransferPipe pipe = getPipe(mappingContainer);
    DataTransferSettings dtSettings = getWizard().getSettings();
    PreviewMappingDialog previewDialog = new PreviewMappingDialog(getShell(), pipe, mappingContainer, dtSettings);
    previewDialog.open();
}
Also used : DataTransferSettings(org.jkiss.dbeaver.tools.transfer.DataTransferSettings) DataTransferPipe(org.jkiss.dbeaver.tools.transfer.DataTransferPipe)

Example 14 with DataTransferSettings

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

the class DatabaseProducerPageInputObjects method activatePage.

@Override
public void activatePage() {
    // final DatabaseProducerSettings settings = getWizard().getPageSettings(this, DatabaseProducerSettings.class);
    DataTransferSettings settings = getWizard().getSettings();
    mappingTable.removeAll();
    for (DataTransferPipe pipe : settings.getDataPipes()) {
        TableItem item = new TableItem(mappingTable, SWT.NONE);
        item.setData(pipe);
        updateItemData(item, pipe);
    }
    updatePageCompletion();
}
Also used : DataTransferSettings(org.jkiss.dbeaver.tools.transfer.DataTransferSettings) DataTransferPipe(org.jkiss.dbeaver.tools.transfer.DataTransferPipe)

Example 15 with DataTransferSettings

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

the class DatabaseProducerPageInputObjects method chooseEntity.

protected boolean chooseEntity(DataTransferPipe pipe) {
    DataTransferSettings settings = getWizard().getSettings();
    final DBNModel navigatorModel = DBWorkbench.getPlatform().getNavigatorModel();
    final DBNNode rootNode = DBWorkbench.getPlatform().getWorkspace().getProjects().size() == 1 ? navigatorModel.getRoot().getProjectNode(DBWorkbench.getPlatform().getWorkspace().getActiveProject()) : navigatorModel.getRoot();
    boolean chooseConsumer = settings.isConsumerOptional();
    DBNNode node = DBWorkbench.getPlatformUI().selectObject(UIUtils.getActiveWorkbenchShell(), chooseConsumer ? NLS.bind(DTUIMessages.database_producer_page_input_objects_node_select_target, pipe.getProducer().getDatabaseObject().getName()) : NLS.bind(DTUIMessages.database_producer_page_input_objects_node_select_source, pipe.getConsumer().getObjectName()), rootNode, lastSelection, new Class[] { DBSObjectContainer.class, DBSDataContainer.class }, new Class[] { chooseConsumer ? DBSDataManipulator.class : DBSDataContainer.class }, null);
    if (node instanceof DBNDatabaseNode) {
        lastSelection = (DBNDatabaseNode) node;
        DBSObject object = ((DBNDatabaseNode) node).getObject();
        if (chooseConsumer) {
            if (object instanceof DBSDataManipulator) {
                pipe.setConsumer(new DatabaseTransferConsumer((DBSDataManipulator) object));
            }
        } else {
            if (object instanceof DBSDataContainer) {
                pipe.setProducer(new DatabaseTransferProducer((DBSDataContainer) object));
            }
        }
        return true;
    }
    return false;
}
Also used : DataTransferSettings(org.jkiss.dbeaver.tools.transfer.DataTransferSettings) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DatabaseTransferConsumer(org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferConsumer) DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) DBSDataManipulator(org.jkiss.dbeaver.model.struct.DBSDataManipulator) DatabaseTransferProducer(org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferProducer) DBSDataContainer(org.jkiss.dbeaver.model.struct.DBSDataContainer) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) DBNModel(org.jkiss.dbeaver.model.navigator.DBNModel)

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