use of org.jkiss.dbeaver.tools.transfer.IDataTransferConsumer 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;
}
use of org.jkiss.dbeaver.tools.transfer.IDataTransferConsumer in project dbeaver by serge-rider.
the class DataTransferJob method transferData.
private boolean transferData(DBRProgressMonitor monitor, DataTransferPipe transferPipe) {
IDataTransferProducer producer = transferPipe.getProducer();
IDataTransferConsumer consumer = transferPipe.getConsumer();
IDataTransferSettings consumerSettings = settings.getNodeSettings(consumer);
setName(NLS.bind(CoreMessages.data_transfer_wizard_job_container_name, CommonUtils.truncateString(producer.getSourceObject().getName(), 200)));
IDataTransferSettings nodeSettings = settings.getNodeSettings(producer);
try {
//consumer.initTransfer(producer.getSourceObject(), consumerSettings, );
producer.transferData(monitor, consumer, nodeSettings);
consumer.finishTransfer(monitor, false);
return true;
} catch (Exception e) {
new DataTransferErrorJob(e).schedule();
return false;
}
}
use of org.jkiss.dbeaver.tools.transfer.IDataTransferConsumer 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;
}
use of org.jkiss.dbeaver.tools.transfer.IDataTransferConsumer 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;
}
use of org.jkiss.dbeaver.tools.transfer.IDataTransferConsumer 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);
}
}
// 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;
}
Aggregations