Search in sources :

Example 1 with IDataTransferNode

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

the class DataTransferHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
    final ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (!(selection instanceof IStructuredSelection)) {
        return null;
    }
    IStructuredSelection ss = (IStructuredSelection) selection;
    final List<IDataTransferProducer> producers = new ArrayList<>();
    final List<IDataTransferConsumer> consumers = new ArrayList<>();
    for (Iterator<?> iter = ss.iterator(); iter.hasNext(); ) {
        Object object = iter.next();
        IDataTransferNode node = adaptTransferNode(object);
        if (node instanceof IDataTransferProducer) {
            producers.add((IDataTransferProducer) node);
        } else if (node instanceof IDataTransferConsumer) {
            consumers.add((IDataTransferConsumer) node);
        }
    }
    if (!consumers.isEmpty()) {
        // We need to choose producer for consumers
        for (IDataTransferConsumer consumer : consumers) {
            IDataTransferProducer producer = chooseProducer(event, consumer);
            if (producer == null) {
                return null;
            }
            producers.add(producer);
        }
    }
    // Run transfer wizard
    if (!producers.isEmpty() || !consumers.isEmpty()) {
        ActiveWizardDialog dialog = new ActiveWizardDialog(workbenchWindow, new DataTransferWizard(producers.toArray(new IDataTransferProducer[producers.size()]), consumers.toArray(new IDataTransferConsumer[consumers.size()])));
        dialog.open();
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DataTransferWizard(org.jkiss.dbeaver.tools.transfer.wizard.DataTransferWizard) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ActiveWizardDialog(org.jkiss.dbeaver.ui.dialogs.ActiveWizardDialog) ISelection(org.eclipse.jface.viewers.ISelection) IDataTransferConsumer(org.jkiss.dbeaver.tools.transfer.IDataTransferConsumer) IDataTransferNode(org.jkiss.dbeaver.tools.transfer.IDataTransferNode) IDataTransferProducer(org.jkiss.dbeaver.tools.transfer.IDataTransferProducer)

Example 2 with IDataTransferNode

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

the class DataTransferHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
    final ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (!(selection instanceof IStructuredSelection)) {
        return null;
    }
    IStructuredSelection ss = (IStructuredSelection) selection;
    final List<IDataTransferProducer> producers = new ArrayList<>();
    final List<IDataTransferConsumer> consumers = new ArrayList<>();
    for (Iterator<?> iter = ss.iterator(); iter.hasNext(); ) {
        Object object = iter.next();
        IDataTransferNode node = adaptTransferNode(object);
        if (node instanceof IDataTransferProducer) {
            producers.add((IDataTransferProducer) node);
        } else if (node instanceof IDataTransferConsumer) {
            consumers.add((IDataTransferConsumer) node);
        }
    }
    if (!consumers.isEmpty()) {
        // We need to choose producer for consumers
        for (IDataTransferConsumer consumer : consumers) {
            IDataTransferProducer producer = chooseProducer(event, consumer);
            if (producer == null) {
                return null;
            }
            producers.add(producer);
        }
    }
    // Run transfer wizard
    if (!producers.isEmpty() || !consumers.isEmpty()) {
        ActiveWizardDialog dialog = new ActiveWizardDialog(workbenchWindow, new DataTransferWizard(producers.toArray(new IDataTransferProducer[producers.size()]), consumers.toArray(new IDataTransferConsumer[consumers.size()])));
        dialog.open();
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DataTransferWizard(org.jkiss.dbeaver.tools.transfer.wizard.DataTransferWizard) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ActiveWizardDialog(org.jkiss.dbeaver.ui.dialogs.ActiveWizardDialog) ISelection(org.eclipse.jface.viewers.ISelection) IDataTransferConsumer(org.jkiss.dbeaver.tools.transfer.IDataTransferConsumer) IDataTransferNode(org.jkiss.dbeaver.tools.transfer.IDataTransferNode) IDataTransferProducer(org.jkiss.dbeaver.tools.transfer.IDataTransferProducer)

Example 3 with IDataTransferNode

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

the class DataTransferHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
    final ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (!(selection instanceof IStructuredSelection)) {
        return null;
    }
    IStructuredSelection ss = (IStructuredSelection) selection;
    final List<IDataTransferProducer> producers = new ArrayList<>();
    final List<IDataTransferConsumer> consumers = new ArrayList<>();
    for (Iterator<?> iter = ss.iterator(); iter.hasNext(); ) {
        Object object = iter.next();
        IDataTransferNode node = adaptTransferNode(object);
        if (node instanceof IDataTransferProducer) {
            producers.add((IDataTransferProducer) node);
        } else if (node instanceof IDataTransferConsumer) {
            consumers.add((IDataTransferConsumer) node);
        }
    }
    // Run transfer wizard
    if (!producers.isEmpty() || !consumers.isEmpty()) {
        try {
            DataTransferWizard.openWizard(workbenchWindow, producers, consumers);
        } catch (Exception e) {
            DBWorkbench.getPlatformUI().showError(DTUIMessages.data_transfer_handler_title_data_transfer_error, DTUIMessages.data_transfer_handler_message_data_transfer_error, e);
        }
    } else {
        DBWorkbench.getPlatformUI().showError(DTUIMessages.data_transfer_handler_title_data_transfer_error, "Can't perform data transfer: selected objects are not recognized as data producers or data consumers");
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ISelection(org.eclipse.jface.viewers.ISelection) ArrayList(java.util.ArrayList) IDataTransferConsumer(org.jkiss.dbeaver.tools.transfer.IDataTransferConsumer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IDataTransferNode(org.jkiss.dbeaver.tools.transfer.IDataTransferNode) ExecutionException(org.eclipse.core.commands.ExecutionException) IDataTransferProducer(org.jkiss.dbeaver.tools.transfer.IDataTransferProducer)

Aggregations

ArrayList (java.util.ArrayList)3 ISelection (org.eclipse.jface.viewers.ISelection)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)3 IDataTransferConsumer (org.jkiss.dbeaver.tools.transfer.IDataTransferConsumer)3 IDataTransferNode (org.jkiss.dbeaver.tools.transfer.IDataTransferNode)3 IDataTransferProducer (org.jkiss.dbeaver.tools.transfer.IDataTransferProducer)3 DataTransferWizard (org.jkiss.dbeaver.tools.transfer.wizard.DataTransferWizard)2 ActiveWizardDialog (org.jkiss.dbeaver.ui.dialogs.ActiveWizardDialog)2 ExecutionException (org.eclipse.core.commands.ExecutionException)1