Search in sources :

Example 11 with DBPNativeClientLocation

use of org.jkiss.dbeaver.model.connection.DBPNativeClientLocation in project dbeaver by dbeaver.

the class ConnectionWizard method getActiveDataSource.

@NotNull
public DataSourceDescriptor getActiveDataSource() {
    DriverDescriptor driver = (DriverDescriptor) getSelectedDriver();
    DataSourceDescriptor info = infoMap.get(driver);
    DBPDataSourceRegistry registry = getDataSourceRegistry();
    if (registry == null) {
        throw new IllegalStateException("No active project");
    }
    if (info == null) {
        DBPConnectionConfiguration connectionInfo = new DBPConnectionConfiguration();
        info = new DataSourceDescriptor(registry, DataSourceDescriptor.generateNewId(getSelectedDriver()), driver, connectionInfo);
        DBPNativeClientLocation defaultClientLocation = driver.getDefaultClientLocation();
        if (defaultClientLocation != null) {
            info.getConnectionConfiguration().setClientHomeId(defaultClientLocation.getName());
        }
        info.setSavePassword(true);
        infoMap.put(driver, info);
    }
    return info;
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DriverDescriptor(org.jkiss.dbeaver.registry.driver.DriverDescriptor) DBPNativeClientLocation(org.jkiss.dbeaver.model.connection.DBPNativeClientLocation) DBPDataSourceRegistry(org.jkiss.dbeaver.model.app.DBPDataSourceRegistry) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor) NotNull(org.jkiss.code.NotNull)

Example 12 with DBPNativeClientLocation

use of org.jkiss.dbeaver.model.connection.DBPNativeClientLocation in project dbeaver by serge-rider.

the class AbstractNativeToolWizard method updateErrorMessage.

void updateErrorMessage() {
    WizardPage currentPage = (WizardPage) getStartingPage();
    if (isNativeClientHomeRequired()) {
        String clientHomeId = getSettings().getDataSourceContainer().getConnectionConfiguration().getClientHomeId();
        List<DBPNativeClientLocation> nativeClientLocations = getSettings().getDataSourceContainer().getDriver().getNativeClientLocations();
        if (CommonUtils.isEmpty(clientHomeId)) {
            if (nativeClientLocations != null && !nativeClientLocations.isEmpty()) {
                settings.setClientHome(nativeClientLocations.get(0));
            } else {
                settings.setClientHome(null);
            }
            if (settings.getClientHome() == null) {
                currentPage.setErrorMessage(TaskNativeUIMessages.tools_wizard_message_no_client_home);
                getContainer().updateMessage();
                return;
            }
        } else {
            DBPNativeClientLocation clientHome = DBUtils.findObject(nativeClientLocations, clientHomeId);
            if (clientHome == null) {
                clientHome = getSettings().findNativeClientHome(clientHomeId);
            }
            if (clientHome == null) {
                // Make local client home from location
                clientHome = new LocalNativeClientLocation(clientHomeId, clientHomeId);
            }
            settings.setClientHome(clientHome);
        }
        if (settings.getClientHome() == null) {
            currentPage.setErrorMessage(NLS.bind(TaskNativeUIMessages.tools_wizard_message_client_home_not_found, clientHomeId));
        } else {
            currentPage.setErrorMessage(null);
        }
        getContainer().updateMessage();
    }
}
Also used : DBPNativeClientLocation(org.jkiss.dbeaver.model.connection.DBPNativeClientLocation) WizardPage(org.eclipse.jface.wizard.WizardPage) LocalNativeClientLocation(org.jkiss.dbeaver.model.connection.LocalNativeClientLocation)

Example 13 with DBPNativeClientLocation

use of org.jkiss.dbeaver.model.connection.DBPNativeClientLocation in project dbeaver by serge-rider.

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 14 with DBPNativeClientLocation

use of org.jkiss.dbeaver.model.connection.DBPNativeClientLocation in project dbeaver by serge-rider.

the class ClientHomesPanel method loadHomes.

public void loadHomes(DBPDriver driver) {
    homesTable.removeAll();
    this.driver = driver;
    selectHome(null);
    DBPNativeClientLocationManager clientManager = this.driver.getNativeClientManager();
    if (clientManager == null) {
        // $NON-NLS-1$ //$NON-NLS-2$
        log.debug("Client manager is not supported by driver '" + driver.getName() + "'");
    }
    Set<DBPNativeClientLocation> providedHomes = new LinkedHashSet<>();
    if (clientManager != null) {
        providedHomes.addAll(clientManager.findLocalClientLocations());
    }
    Set<DBPNativeClientLocation> allHomes = new LinkedHashSet<>();
    allHomes.addAll(driver.getNativeClientLocations());
    allHomes.addAll(providedHomes);
    for (DBPNativeClientLocation home : allHomes) {
        TableItem item = createHomeItem(clientManager, home, home instanceof RemoteNativeClientLocation || providedHomes.contains(home));
        if (item != null) {
            HomeInfo homeInfo = (HomeInfo) item.getData();
            if (homeInfo.isDefault) {
                homesTable.setSelection(homesTable.indexOf(item));
                selectHome(homeInfo);
            }
        }
    }
}
Also used : DBPNativeClientLocationManager(org.jkiss.dbeaver.model.connection.DBPNativeClientLocationManager) DBPNativeClientLocation(org.jkiss.dbeaver.model.connection.DBPNativeClientLocation) RemoteNativeClientLocation(org.jkiss.dbeaver.registry.driver.RemoteNativeClientLocation)

Aggregations

DBPNativeClientLocation (org.jkiss.dbeaver.model.connection.DBPNativeClientLocation)14 DBPNativeClientLocationManager (org.jkiss.dbeaver.model.connection.DBPNativeClientLocationManager)6 Map (java.util.Map)2 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)2 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)2 WizardPage (org.eclipse.jface.wizard.WizardPage)2 NotNull (org.jkiss.code.NotNull)2 DBException (org.jkiss.dbeaver.DBException)2 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)2 DBPDataSourceRegistry (org.jkiss.dbeaver.model.app.DBPDataSourceRegistry)2 DBPConnectionConfiguration (org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)2 DBPDriver (org.jkiss.dbeaver.model.connection.DBPDriver)2 DBPDriverLibrary (org.jkiss.dbeaver.model.connection.DBPDriverLibrary)2 LocalNativeClientLocation (org.jkiss.dbeaver.model.connection.LocalNativeClientLocation)2 DBCException (org.jkiss.dbeaver.model.exec.DBCException)2 AbstractJob (org.jkiss.dbeaver.model.runtime.AbstractJob)2 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)2 DataSourceDescriptor (org.jkiss.dbeaver.registry.DataSourceDescriptor)2 DriverDescriptor (org.jkiss.dbeaver.registry.driver.DriverDescriptor)2 RemoteNativeClientLocation (org.jkiss.dbeaver.registry.driver.RemoteNativeClientLocation)2