Search in sources :

Example 91 with DBSObject

use of org.jkiss.dbeaver.model.struct.DBSObject in project dbeaver by serge-rider.

the class DataTransferWizard method loadSettings.

void loadSettings() {
    // Load node settings
    Collection<DBSObject> objectTypes = settings.getSourceObjects();
    List<DataTransferNodeDescriptor> nodes = new ArrayList<>();
    DataTransferRegistry registry = DataTransferRegistry.getInstance();
    if (ArrayUtils.isEmpty(settings.getInitProducers())) {
        nodes.addAll(registry.getAvailableProducers(objectTypes));
    } else {
        for (IDataTransferProducer source : settings.getInitProducers()) {
            DataTransferNodeDescriptor node = registry.getNodeByType(source.getClass());
            if (node != null && !nodes.contains(node)) {
                nodes.add(node);
            }
        }
    }
    if (ArrayUtils.isEmpty(settings.getInitConsumers())) {
        nodes.addAll(registry.getAvailableConsumers(objectTypes));
    } else {
        for (IDataTransferConsumer target : settings.getInitConsumers()) {
            DataTransferNodeDescriptor node = registry.getNodeByType(target.getClass());
            if (node != null && !nodes.contains(node)) {
                nodes.add(node);
            }
        }
    }
    boolean settingsChanged = nodeSettings.size() != nodes.size();
    if (!settingsChanged) {
        List<NodePageSettings> nsList = new ArrayList<>(nodeSettings.values());
        for (int i = 0; i < nodeSettings.size(); i++) {
            if (nsList.get(i).sourceNode != nodes.get(i)) {
                settingsChanged = true;
                break;
            }
        }
    }
    if (settingsChanged) {
        nodeSettings.clear();
        for (DataTransferNodeDescriptor node : nodes) {
            addNodeSettings(node);
        }
    }
    updateWizardTitle();
}
Also used : DataTransferRegistry(org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DataTransferNodeDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor)

Example 92 with DBSObject

use of org.jkiss.dbeaver.model.struct.DBSObject in project dbeaver by serge-rider.

the class DataTransferPagePipes method loadProducers.

private void loadProducers() {
    DataTransferSettings settings = getWizard().getSettings();
    Collection<DBSObject> objects = settings.getSourceObjects();
    List<TransferTarget> transferTargets = new ArrayList<>();
    for (DataTransferNodeDescriptor producer : DataTransferRegistry.getInstance().getAvailableProducers(objects)) {
        Collection<DataTransferProcessorDescriptor> processors = producer.getAvailableProcessors(objects);
        if (CommonUtils.isEmpty(processors)) {
            transferTargets.add(new TransferTarget(producer, null));
        } else {
            for (DataTransferProcessorDescriptor processor : processors) {
                transferTargets.add(new TransferTarget(producer, processor));
            }
        }
    }
    nodesTable.setInput(transferTargets);
}
Also used : DataTransferSettings(org.jkiss.dbeaver.tools.transfer.DataTransferSettings) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ArrayList(java.util.ArrayList) DataTransferNodeDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor) DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)

Example 93 with DBSObject

use of org.jkiss.dbeaver.model.struct.DBSObject in project dbeaver by serge-rider.

the class DataTransferPagePipes method createInputsTable.

private void createInputsTable(Composite composite) {
    Composite panel = UIUtils.createComposite(composite, 1);
    // UIUtils.createControlLabel(panel, DTUIMessages.data_transfer_wizard_final_group_objects);
    inputsTable = new TableViewer(panel, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
    inputsTable.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
    inputsTable.getTable().setLinesVisible(true);
    inputsTable.getTable().setHeaderVisible(true);
    inputsTable.setContentProvider(new ListContentProvider());
    UIUtils.createTableContextMenu(inputsTable.getTable(), null);
    DBNModel nModel = DBWorkbench.getPlatform().getNavigatorModel();
    CellLabelProvider labelProvider = new CellLabelProvider() {

        @Override
        public void update(ViewerCell cell) {
            DBSObject element = (DBSObject) cell.getElement();
            if (cell.getColumnIndex() == 0) {
                DBNDatabaseNode objectNode = nModel.getNodeByObject(element);
                DBPImage icon = objectNode != null ? objectNode.getNodeIconDefault() : DBValueFormatting.getObjectImage(element);
                cell.setImage(DBeaverIcons.getImage(icon));
                cell.setText(DBUtils.getObjectFullName(element, DBPEvaluationContext.UI));
            } else if (element.getDescription() != null) {
                cell.setText(element.getDescription());
            }
        }
    };
    {
        TableViewerColumn columnName = new TableViewerColumn(inputsTable, SWT.LEFT);
        columnName.setLabelProvider(labelProvider);
        columnName.getColumn().setText(DTMessages.data_transfer_wizard_init_column_exported);
        TableViewerColumn columnDesc = new TableViewerColumn(inputsTable, SWT.LEFT);
        columnDesc.setLabelProvider(labelProvider);
        columnDesc.getColumn().setText(DTMessages.data_transfer_wizard_init_column_description);
    }
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ListContentProvider(org.jkiss.dbeaver.ui.controls.ListContentProvider) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) DBNModel(org.jkiss.dbeaver.model.navigator.DBNModel) DBPImage(org.jkiss.dbeaver.model.DBPImage)

Example 94 with DBSObject

use of org.jkiss.dbeaver.model.struct.DBSObject in project dbeaver by serge-rider.

the class CompileHandler method getSelectedObjects.

private List<OracleSourceObject> getSelectedObjects(ExecutionEvent event) {
    List<OracleSourceObject> objects = new ArrayList<>();
    final ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
    if (currentSelection instanceof IStructuredSelection && !currentSelection.isEmpty()) {
        for (Iterator<?> iter = ((IStructuredSelection) currentSelection).iterator(); iter.hasNext(); ) {
            final Object element = iter.next();
            final OracleSourceObject sourceObject = RuntimeUtils.getObjectAdapter(element, OracleSourceObject.class);
            if (sourceObject != null) {
                objects.add(sourceObject);
            }
        }
    }
    if (objects.isEmpty()) {
        final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
        if (activePart instanceof IEditorPart) {
            if (((IEditorPart) activePart).getEditorInput() instanceof IDatabaseEditorInput) {
                DBSObject dbsObject = ((IDatabaseEditorInput) ((IEditorPart) activePart).getEditorInput()).getDatabaseObject();
                if (dbsObject instanceof OracleSourceObject) {
                    objects.add((OracleSourceObject) dbsObject);
                }
            }
        }
    }
    return objects;
}
Also used : IDatabaseEditorInput(org.jkiss.dbeaver.ui.editors.IDatabaseEditorInput) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ArrayList(java.util.ArrayList) ISelection(org.eclipse.jface.viewers.ISelection) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) OracleSourceObject(org.jkiss.dbeaver.ext.oracle.model.source.OracleSourceObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) OracleSourceObject(org.jkiss.dbeaver.ext.oracle.model.source.OracleSourceObject)

Example 95 with DBSObject

use of org.jkiss.dbeaver.model.struct.DBSObject in project dbeaver by serge-rider.

the class OracleScriptExecuteWizardPageSettings method saveState.

@Override
public void saveState() {
    super.saveState();
    OracleScriptExecuteSettings settings = wizard.getSettings();
    List<DBSObject> selectedConnections = settings.getDatabaseObjects();
    settings.setDataSourceContainer(selectedConnections.isEmpty() ? null : selectedConnections.get(0).getDataSource().getContainer());
    settings.setInputFile(inputFileText.getText());
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) OracleScriptExecuteSettings(org.jkiss.dbeaver.ext.oracle.tasks.OracleScriptExecuteSettings)

Aggregations

DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)374 DBException (org.jkiss.dbeaver.DBException)129 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)66 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)66 ArrayList (java.util.ArrayList)54 InvocationTargetException (java.lang.reflect.InvocationTargetException)52 ISelection (org.eclipse.jface.viewers.ISelection)46 JDBCResultSet (org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet)46 AbstractObjectReference (org.jkiss.dbeaver.model.impl.struct.AbstractObjectReference)44 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)38 GridData (org.eclipse.swt.layout.GridData)38 JDBCPreparedStatement (org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement)38 DBPDataSource (org.jkiss.dbeaver.model.DBPDataSource)30 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)29 DBNNode (org.jkiss.dbeaver.model.navigator.DBNNode)29 DBSObjectContainer (org.jkiss.dbeaver.model.struct.DBSObjectContainer)28 Composite (org.eclipse.swt.widgets.Composite)27 IEditorPart (org.eclipse.ui.IEditorPart)26 DBCExecutionContext (org.jkiss.dbeaver.model.exec.DBCExecutionContext)24 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)22