Search in sources :

Example 96 with DBPDataSourceContainer

use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.

the class PostgreFDWConfigWizardPageConfig method refreshFDWProperties.

private void refreshFDWProperties() {
    {
        // Fill options
        DBPDataSourceContainer targetDataSource = getWizard().getSelectedDataSource();
        PostgreFDWConfigWizard.FDWInfo selectedFDW = getWizard().getSelectedFDW();
        PropertySourceCustom propertySource = getWizard().getFdwPropertySource();
        propertySource.setDefValueResolver(targetDataSource.getVariablesResolver(false));
        propertySource.removeAll();
        if (selectedFDW != null && selectedFDW.fdwDescriptor != null) {
            propertySource.addProperties(selectedFDW.fdwDescriptor.getProperties());
        } else if (selectedFDW != null) {
            // Add some default props
            propertySource.addProperty(new PropertyDescriptor(null, "host", "host", "Remote database host", false, String.class, "${host}", null));
            propertySource.addProperty(new PropertyDescriptor(null, "port", "port", "Remote database port", false, String.class, "${port}", null));
            propertySource.addProperty(new PropertyDescriptor(null, "dbname", "dbname", "Remote database name", false, String.class, "${database}", null));
        }
        propsEditor.loadProperties(propertySource);
    }
}
Also used : PropertySourceCustom(org.jkiss.dbeaver.runtime.properties.PropertySourceCustom) PropertyDescriptor(org.jkiss.dbeaver.model.impl.PropertyDescriptor) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Example 97 with DBPDataSourceContainer

use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.

the class PostgreFDWConfigWizardPageInput method createControl.

@Override
public void createControl(Composite parent) {
    Composite composite = UIUtils.createComposite(parent, 1);
    {
        Group databasesGroup = UIUtils.createControlGroup(composite, "Foreign databases", 1, GridData.FILL_BOTH, 0);
        selectorPanel = new DatabaseObjectsSelectorPanel(databasesGroup, true, getWizard().getRunnableContext()) {

            @Override
            protected boolean isDatabaseObjectVisible(DBSObject obj) {
                return super.isDatabaseObjectVisible(obj);
            }

            @Override
            protected void onSelectionChange(Object element) {
                updateState();
            }

            @Override
            protected boolean isFolderVisible(DBNLocalFolder folder) {
                List<DBPDataSourceContainer> dataSources = getWizard().getAvailableDataSources();
                for (DBNDataSource ds : folder.getNestedDataSources()) {
                    if (dataSources.contains(ds.getDataSourceContainer())) {
                        return true;
                    }
                }
                return false;
            }

            @Override
            protected boolean isDataSourceVisible(DBNDataSource dataSource) {
                return getWizard().getAvailableDataSources().contains(dataSource.getDataSourceContainer());
            }
        };
        Composite buttonsPanel = UIUtils.createComposite(databasesGroup, 2);
        UIUtils.createDialogButton(buttonsPanel, "Add database", new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                SelectDataSourceDialog dialog = new SelectDataSourceDialog(getShell(), selectorPanel.getProject(), null);
                if (dialog.open() == IDialogConstants.OK_ID) {
                    DBPDataSourceContainer dataSource = dialog.getDataSource();
                    if (dataSource != null) {
                        getWizard().addAvailableDataSource(dataSource);
                        refreshDataSources();
                    }
                }
            }
        });
        Button delButton = UIUtils.createDialogButton(buttonsPanel, "Remove database", new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                DBNNode selectedNode = NavigatorUtils.getSelectedNode(selectorPanel.getSelection());
                if (selectedNode instanceof DBNDatabaseNode) {
                    getWizard().removeAvailableDataSource(((DBNDatabaseNode) selectedNode).getDataSourceContainer());
                    refreshDataSources();
                }
            }
        });
        delButton.setEnabled(false);
        selectorPanel.addSelectionListener(event -> {
            DBNNode selectedNode = NavigatorUtils.getSelectedNode(event.getSelection());
            delButton.setEnabled(selectedNode instanceof DBNDatabaseNode);
        });
    }
    setControl(composite);
}
Also used : DBSEntity(org.jkiss.dbeaver.model.struct.DBSEntity) DBWorkbench(org.jkiss.dbeaver.runtime.DBWorkbench) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ActiveWizardPage(org.jkiss.dbeaver.ui.dialogs.ActiveWizardPage) Button(org.eclipse.swt.widgets.Button) SelectDataSourceDialog(org.jkiss.dbeaver.ui.navigator.dialogs.SelectDataSourceDialog) org.jkiss.dbeaver.model.navigator(org.jkiss.dbeaver.model.navigator) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) Group(org.eclipse.swt.widgets.Group) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) InvocationTargetException(java.lang.reflect.InvocationTargetException) ArrayList(java.util.ArrayList) DatabaseObjectsSelectorPanel(org.jkiss.dbeaver.ui.navigator.database.DatabaseObjectsSelectorPanel) List(java.util.List) Composite(org.eclipse.swt.widgets.Composite) UIUtils(org.jkiss.dbeaver.ui.UIUtils) NavigatorUtils(org.jkiss.dbeaver.ui.navigator.NavigatorUtils) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DatabaseObjectsSelectorPanel(org.jkiss.dbeaver.ui.navigator.database.DatabaseObjectsSelectorPanel) SelectDataSourceDialog(org.jkiss.dbeaver.ui.navigator.dialogs.SelectDataSourceDialog) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Example 98 with DBPDataSourceContainer

use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.

the class PostgreDebugUIAdapterFactory method getAdapter.

@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
    if (adapterType == DBGEditorAdvisor.class) {
        if (adaptableObject instanceof DBPDataSourceContainer) {
            DBPDataSourceContainer sourceContainer = (DBPDataSourceContainer) adaptableObject;
            DBPDataSource dataSource = sourceContainer.getDataSource();
            if (dataSource instanceof PostgreDataSource) {
                return adapterType.cast(debugEditorAdvisor);
            }
        }
    }
    return null;
}
Also used : PostgreDataSource(org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Example 99 with DBPDataSourceContainer

use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.

the class AbstractNativeToolHandler method validateClientHome.

private void validateClientHome(DBRProgressMonitor monitor, SETTINGS settings) throws DBCException {
    DBPDataSourceContainer dataSourceContainer = settings.getDataSourceContainer();
    if (isNativeClientHomeRequired()) {
        String clientHomeId = dataSourceContainer.getConnectionConfiguration().getClientHomeId();
        final DBPDriver driver = dataSourceContainer.getDriver();
        final List<DBPNativeClientLocation> clientLocations = driver.getNativeClientLocations();
        final DBPNativeClientLocationManager locationManager = driver.getNativeClientManager();
        if (locationManager != null) {
            clientLocations.addAll(locationManager.findLocalClientLocations());
        }
        if (clientHomeId == null) {
            if (!clientLocations.isEmpty()) {
                settings.setClientHome(clientLocations.get(0));
            } else {
                settings.setClientHome(null);
            }
            if (settings.getClientHome() == null) {
                throw new DBCException("Client binaries location is not specified");
            }
        } else {
            DBPNativeClientLocation clientHome = DBUtils.findObject(clientLocations, clientHomeId);
            if (clientHome == null) {
                clientHome = settings.findNativeClientHome(clientHomeId);
            }
            settings.setClientHome(clientHome);
        }
        if (settings.getClientHome() == null) {
            throw new DBCException("Native client home '" + clientHomeId + "' not found");
        }
    }
    DBPNativeClientLocation clientHome = settings.getClientHome();
    if (!isNativeClientHomeRequired() || clientHome == null) {
        return;
    }
    try {
        clientHome.validateFilesPresence(monitor);
    } catch (DBException e) {
        throw new DBCException("Error downloading client file(s)", e);
    } catch (InterruptedException e) {
        // ignore
        throw new DBCException("Client file download interrupted", e);
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) DBPNativeClientLocation(org.jkiss.dbeaver.model.connection.DBPNativeClientLocation) DBPNativeClientLocationManager(org.jkiss.dbeaver.model.connection.DBPNativeClientLocationManager) DBPDriver(org.jkiss.dbeaver.model.connection.DBPDriver) DBCException(org.jkiss.dbeaver.model.exec.DBCException) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Example 100 with DBPDataSourceContainer

use of org.jkiss.dbeaver.model.DBPDataSourceContainer in project dbeaver by dbeaver.

the class NativeToolWizardDialog method openClientConfiguration.

private void openClientConfiguration() {
    AbstractNativeToolWizard toolWizard = (AbstractNativeToolWizard) getWizard();
    DBPDataSourceContainer dataSource = toolWizard.getSettings().getDataSourceContainer();
    if (dataSource != null) {
        NativeClientConfigDialog dialog = new NativeClientConfigDialog(getShell(), dataSource);
        if (dialog.open() == IDialogConstants.OK_ID) {
            toolWizard.updateErrorMessage();
            updateButtons();
        }
    }
}
Also used : DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Aggregations

DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)230 DBException (org.jkiss.dbeaver.DBException)32 ArrayList (java.util.ArrayList)31 IFile (org.eclipse.core.resources.IFile)30 DBCExecutionContext (org.jkiss.dbeaver.model.exec.DBCExecutionContext)27 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)27 DBNDataSource (org.jkiss.dbeaver.model.navigator.DBNDataSource)24 InvocationTargetException (java.lang.reflect.InvocationTargetException)22 DBPDataSource (org.jkiss.dbeaver.model.DBPDataSource)19 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)19 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)18 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 DBPProject (org.jkiss.dbeaver.model.app.DBPProject)18 DBPConnectionConfiguration (org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)18 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)17 GridData (org.eclipse.swt.layout.GridData)16 IEditorPart (org.eclipse.ui.IEditorPart)16 DBNNode (org.jkiss.dbeaver.model.navigator.DBNNode)16 DBNResource (org.jkiss.dbeaver.model.navigator.DBNResource)16 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)13