Search in sources :

Example 26 with DBPConnectionConfiguration

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

the class OracleConnectionPage method loadSettings.

@Override
public void loadSettings() {
    super.loadSettings();
    // Load values from new connection info
    DBPConnectionConfiguration connectionInfo = site.getActiveDataSource().getConnectionConfiguration();
    final String sidService = connectionInfo.getProviderProperty(OracleConstants.PROP_SID_SERVICE);
    if (sidService != null) {
        sidServiceCombo.setText(OracleConnectionType.valueOf(sidService).getTitle());
    }
    //if (isOCI) {
    oraHomeSelector.populateHomes(site.getDriver(), connectionInfo.getClientHomeId());
    if (tnsNameCombo.getItemCount() == 0) {
        populateTnsNameCombo();
    }
    if (serviceNameCombo.getItemCount() == 0) {
        for (String alias : getAvailableServiceNames()) {
            serviceNameCombo.add(alias);
        }
    }
    String conTypeProperty = connectionInfo.getProviderProperty(OracleConstants.PROP_CONNECTION_TYPE);
    if (conTypeProperty != null) {
        connectionType = OracleConstants.ConnectionType.valueOf(CommonUtils.toString(conTypeProperty));
    } else {
        connectionType = OracleConstants.ConnectionType.BASIC;
    }
    connectionTypeFolder.setSelection(connectionType.ordinal());
    switch(connectionType) {
        case BASIC:
            hostText.setText(CommonUtils.notEmpty(connectionInfo.getHostName()));
            if (!CommonUtils.isEmpty(connectionInfo.getHostPort())) {
                portText.setText(String.valueOf(connectionInfo.getHostPort()));
            } else if (site.getDriver().getDefaultPort() != null) {
                portText.setText(site.getDriver().getDefaultPort());
            } else {
                portText.setText("");
            }
            serviceNameCombo.setText(CommonUtils.notEmpty(connectionInfo.getDatabaseName()));
            break;
        case TNS:
            {
                tnsNameCombo.setText(CommonUtils.notEmpty(connectionInfo.getDatabaseName()));
                String tnsPathProperty = connectionInfo.getProviderProperty(OracleConstants.PROP_TNS_PATH);
                //                }
                if (tnsPathProperty != null) {
                    tnsPathText.setText(tnsPathProperty);
                }
                break;
            }
        case CUSTOM:
            connectionUrlText.setText(CommonUtils.notEmpty(connectionInfo.getUrl()));
            break;
    }
    if (OracleConstants.OS_AUTH_USER_NAME.equals(connectionInfo.getUserName())) {
        userNameText.setEnabled(false);
        passwordText.setEnabled(false);
        osAuthCheck.setSelection(true);
    } else {
        userNameText.setText(CommonUtils.notEmpty(connectionInfo.getUserName()));
        passwordText.setText(CommonUtils.notEmpty(connectionInfo.getUserPassword()));
        osAuthCheck.setSelection(false);
    }
    final String roleName = connectionInfo.getProviderProperty(OracleConstants.PROP_INTERNAL_LOGON);
    if (roleName != null) {
        userRoleCombo.setText(roleName.toUpperCase(Locale.ENGLISH));
    }
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)

Example 27 with DBPConnectionConfiguration

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

the class DatabaseNavigatorLabelProvider method getToolTipText.

@Override
public String getToolTipText(Object element) {
    if (element instanceof DBNDataSource) {
        final DBPDataSourceContainer ds = ((DBNDataSource) element).getDataSourceContainer();
        if (ds != null) {
            StringBuilder info = new StringBuilder();
            info.append("Name: ").append(ds.getName()).append("\n");
            final DBPConnectionConfiguration cfg = ds.getConnectionConfiguration();
            if (!CommonUtils.isEmpty(cfg.getUrl())) {
                info.append("URL: ").append(cfg.getUrl()).append("\n");
            } else if (!CommonUtils.isEmpty(cfg.getDatabaseName())) {
                info.append("Database: ").append(cfg.getDatabaseName()).append("\n");
            }
            if (!CommonUtils.isEmpty(cfg.getUserName())) {
                info.append("User: ").append(cfg.getUserName()).append("\n");
            }
            if (!CommonUtils.isEmpty(ds.getDescription())) {
                info.append("Description: ").append(ds.getDescription()).append("\n");
            }
            /*
                if (cfg.getConnectionType() != null) {
                    info.append("Type: ").append(cfg.getConnectionType().getName()).append("\n");
                }
*/
            if (ds.isConnectionReadOnly()) {
                info.append("Read-only connection\n");
            }
            if (ds.isProvided()) {
                info.append("Provided connection\n");
            }
            return info.toString().trim();
        }
    } else if (element instanceof DBNDatabaseNode) {
        final String description = ((DBNDatabaseNode) element).getNodeDescription();
        if (!CommonUtils.isEmptyTrimmed(description)) {
            return description;
        }
    }
    return null;
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DBNDataSource(org.jkiss.dbeaver.model.navigator.DBNDataSource) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)

Example 28 with DBPConnectionConfiguration

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

the class PostgreConnectionPage method loadSettings.

@Override
public void loadSettings() {
    super.loadSettings();
    if (!activated) {
        setImageDescriptor(LOGO_IMG);
    }
    // Load values from new connection info
    DBPConnectionConfiguration connectionInfo = site.getActiveDataSource().getConnectionConfiguration();
    if (hostText != null) {
        if (!CommonUtils.isEmpty(connectionInfo.getHostName())) {
            hostText.setText(connectionInfo.getHostName());
        } else {
            hostText.setText(PostgreConstants.DEFAULT_HOST);
        }
    }
    if (portText != null) {
        if (!CommonUtils.isEmpty(connectionInfo.getHostPort())) {
            portText.setText(String.valueOf(connectionInfo.getHostPort()));
        } else if (site.getDriver().getDefaultPort() != null) {
            portText.setText(site.getDriver().getDefaultPort());
        } else {
            portText.setText("");
        }
    }
    if (dbText != null) {
        String databaseName = connectionInfo.getDatabaseName();
        if (CommonUtils.isEmpty(databaseName) && getSite().isNew()) {
            databaseName = PostgreConstants.DEFAULT_DATABASE;
        }
        dbText.setText(databaseName);
    }
    if (usernameText != null) {
        usernameText.setText(CommonUtils.notEmpty(connectionInfo.getUserName()));
    }
    if (passwordText != null) {
        passwordText.setText(CommonUtils.notEmpty(connectionInfo.getUserPassword()));
    }
    homesSelector.populateHomes(site.getDriver(), connectionInfo.getClientHomeId());
    final boolean showNDD = CommonUtils.toBoolean(connectionInfo.getProviderProperty(PostgreConstants.PROP_SHOW_NON_DEFAULT_DB));
    hideNonDefault.setSelection(showNDD);
    activated = true;
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)

Example 29 with DBPConnectionConfiguration

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

the class PostgreConnectionPage method saveSettings.

@Override
public void saveSettings(DBPDataSourceContainer dataSource) {
    DBPConnectionConfiguration connectionInfo = dataSource.getConnectionConfiguration();
    if (hostText != null) {
        connectionInfo.setHostName(hostText.getText().trim());
    }
    if (portText != null) {
        connectionInfo.setHostPort(portText.getText().trim());
    }
    if (dbText != null) {
        connectionInfo.setDatabaseName(dbText.getText().trim());
    }
    if (usernameText != null) {
        connectionInfo.setUserName(usernameText.getText().trim());
    }
    if (passwordText != null) {
        connectionInfo.setUserPassword(passwordText.getText());
    }
    if (homesSelector != null) {
        connectionInfo.setClientHomeId(homesSelector.getSelectedHome());
    }
    connectionInfo.setProviderProperty(PostgreConstants.PROP_SHOW_NON_DEFAULT_DB, String.valueOf(hideNonDefault.getSelection()));
    super.saveSettings(dataSource);
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)

Example 30 with DBPConnectionConfiguration

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

the class WMIConnectionPage method saveSettings.

@Override
public void saveSettings(DBPDataSourceContainer dataSource) {
    DBPConnectionConfiguration connectionInfo = dataSource.getConnectionConfiguration();
    if (hostText != null) {
        connectionInfo.setHostName(hostText.getText().trim());
    }
    if (domainText != null) {
        connectionInfo.setServerName(domainText.getText().trim());
    }
    if (namespaceCombo != null) {
        connectionInfo.setDatabaseName(namespaceCombo.getText().trim());
    }
    if (usernameText != null) {
        connectionInfo.setUserName(usernameText.getText().trim());
    }
    if (passwordText != null) {
        connectionInfo.setUserPassword(passwordText.getText());
    }
    super.saveSettings(dataSource);
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)

Aggregations

DBPConnectionConfiguration (org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)38 DBException (org.jkiss.dbeaver.DBException)7 DataSourceDescriptor (org.jkiss.dbeaver.registry.DataSourceDescriptor)4 ArrayList (java.util.ArrayList)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 GridData (org.eclipse.swt.layout.GridData)3 Button (org.eclipse.swt.widgets.Button)3 Group (org.eclipse.swt.widgets.Group)3 Label (org.eclipse.swt.widgets.Label)3 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)3 EncryptionException (org.jkiss.dbeaver.registry.encode.EncryptionException)3 SecuredPasswordEncrypter (org.jkiss.dbeaver.registry.encode.SecuredPasswordEncrypter)3 BaseAuthDialog (org.jkiss.dbeaver.ui.dialogs.connection.BaseAuthDialog)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 DBPConnectionBootstrap (org.jkiss.dbeaver.model.connection.DBPConnectionBootstrap)2 DBPConnectionEventType (org.jkiss.dbeaver.model.connection.DBPConnectionEventType)2 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)2 DBRRunnableWithProgress (org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress)2 DriverDescriptor (org.jkiss.dbeaver.registry.driver.DriverDescriptor)2