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;
}
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;
}
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;
}
Aggregations