use of org.jkiss.dbeaver.registry.transfer.DataTransferNodeDescriptor in project dbeaver by serge-rider.
the class DataTransferPagePipes method loadConsumers.
private void loadConsumers() {
DataTransferSettings settings = getWizard().getSettings();
Collection<Class<?>> objectTypes = settings.getObjectTypes();
List<TransferTarget> transferTargets = new ArrayList<>();
for (DataTransferNodeDescriptor consumer : DataTransferRegistry.getInstance().getAvailableConsumers(objectTypes)) {
Collection<DataTransferProcessorDescriptor> processors = consumer.getAvailableProcessors(objectTypes);
if (CommonUtils.isEmpty(processors)) {
transferTargets.add(new TransferTarget(consumer, null));
} else {
for (DataTransferProcessorDescriptor processor : processors) {
transferTargets.add(new TransferTarget(consumer, processor));
}
}
}
consumersTable.setInput(transferTargets);
}
use of org.jkiss.dbeaver.registry.transfer.DataTransferNodeDescriptor in project dbeaver by serge-rider.
the class DataTransferPagePipes method createControl.
@Override
public void createControl(Composite parent) {
initializeDialogUnits(parent);
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
consumersTable = new TableViewer(composite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
consumersTable.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
consumersTable.getTable().setLinesVisible(true);
consumersTable.setContentProvider(new IStructuredContentProvider() {
@Override
public void dispose() {
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof Collection) {
return ((Collection<?>) inputElement).toArray();
}
return new Object[0];
}
});
CellLabelProvider labelProvider = new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
TransferTarget element = (TransferTarget) cell.getElement();
if (cell.getColumnIndex() == 0) {
if (element.processor != null) {
cell.setImage(DBeaverIcons.getImage(element.processor.getIcon()));
cell.setText(element.processor.getName());
} else {
cell.setImage(DBeaverIcons.getImage(element.consumer.getIcon()));
cell.setText(element.consumer.getName());
}
} else {
if (element.processor != null) {
cell.setText(element.processor.getDescription());
} else {
cell.setText(element.consumer.getDescription());
}
}
}
};
{
TableViewerColumn columnName = new TableViewerColumn(consumersTable, SWT.LEFT);
columnName.setLabelProvider(labelProvider);
columnName.getColumn().setText(CoreMessages.data_transfer_wizard_init_column_exported);
TableViewerColumn columnDesc = new TableViewerColumn(consumersTable, SWT.LEFT);
columnDesc.setLabelProvider(labelProvider);
columnDesc.getColumn().setText(CoreMessages.data_transfer_wizard_init_column_description);
}
loadConsumers();
consumersTable.getTable().addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
final IStructuredSelection selection = (IStructuredSelection) consumersTable.getSelection();
TransferTarget target;
if (!selection.isEmpty()) {
target = (TransferTarget) selection.getFirstElement();
} else {
target = null;
}
if (target == null) {
getWizard().getSettings().selectConsumer(null, null);
} else {
getWizard().getSettings().selectConsumer(target.consumer, target.processor);
}
updatePageCompletion();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
if (isPageComplete()) {
getWizard().getContainer().showPage(getWizard().getNextPage(DataTransferPagePipes.this));
}
}
});
consumersTable.getTable().addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
UIUtils.packColumns(consumersTable.getTable());
UIUtils.maxTableColumnsWidth(consumersTable.getTable());
consumersTable.getTable().removeControlListener(this);
}
});
setControl(composite);
DataTransferNodeDescriptor consumer = getWizard().getSettings().getConsumer();
DataTransferProcessorDescriptor processor = getWizard().getSettings().getProcessor();
if (consumer != null) {
Collection<TransferTarget> targets = (Collection<TransferTarget>) consumersTable.getInput();
for (TransferTarget target : targets) {
if (target.consumer == consumer && target.processor == processor) {
consumersTable.setSelection(new StructuredSelection(target));
break;
}
}
}
updatePageCompletion();
}
use of org.jkiss.dbeaver.registry.transfer.DataTransferNodeDescriptor in project dbeaver by serge-rider.
the class DataTransferSettings method loadFrom.
void loadFrom(IRunnableContext runnableContext, IDialogSettings dialogSettings) {
try {
maxJobCount = dialogSettings.getInt("maxJobCount");
} catch (NumberFormatException e) {
maxJobCount = DEFAULT_THREADS_NUM;
}
String producerId = dialogSettings.get("producer");
if (!CommonUtils.isEmpty(producerId)) {
DataTransferNodeDescriptor producerNode = DataTransferRegistry.getInstance().getNodeById(producerId);
if (producerNode != null) {
this.producer = producerNode;
}
}
if (consumerOptional) {
DataTransferNodeDescriptor savedConsumer = null;
String consumerId = dialogSettings.get("consumer");
if (!CommonUtils.isEmpty(consumerId)) {
DataTransferNodeDescriptor consumerNode = DataTransferRegistry.getInstance().getNodeById(consumerId);
if (consumerNode != null) {
savedConsumer = consumerNode;
}
}
DataTransferProcessorDescriptor savedProcessor = null;
if (savedConsumer != null) {
String processorId = dialogSettings.get("processor");
if (!CommonUtils.isEmpty(processorId)) {
savedProcessor = savedConsumer.getProcessor(processorId);
}
}
if (savedConsumer != null) {
selectConsumer(savedConsumer, savedProcessor);
}
}
// Load nodes' settings
for (Map.Entry<Class, NodeSettings> entry : nodeSettings.entrySet()) {
IDialogSettings nodeSection = DialogSettings.getOrCreateSection(dialogSettings, entry.getKey().getSimpleName());
entry.getValue().settings.loadSettings(runnableContext, this, nodeSection);
}
IDialogSettings processorsSection = dialogSettings.getSection("processors");
if (processorsSection != null) {
for (IDialogSettings procSection : ArrayUtils.safeArray(processorsSection.getSections())) {
String processorId = procSection.getName();
String nodeId = procSection.get("@node");
String propNamesId = procSection.get("@propNames");
DataTransferNodeDescriptor node = DataTransferRegistry.getInstance().getNodeById(nodeId);
if (node != null) {
Map<Object, Object> props = new HashMap<>();
DataTransferProcessorDescriptor nodeProcessor = node.getProcessor(processorId);
if (nodeProcessor != null) {
for (String prop : CommonUtils.splitString(propNamesId, ',')) {
props.put(prop, procSection.get(prop));
}
processorPropsHistory.put(nodeProcessor, props);
NodeSettings nodeSettings = this.nodeSettings.get(node.getNodeClass());
if (nodeSettings != null) {
}
}
}
}
}
}
Aggregations