Search in sources :

Example 6 with DBPAuthModelDescriptor

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

the class ConnectionPageWithAuth method saveSettings.

@Override
public void saveSettings(DBPDataSourceContainer dataSource) {
    DBPAuthModelDescriptor selectedAuthModel = authModelSelector.getSelectedAuthModel();
    dataSource.getConnectionConfiguration().setAuthModelId(selectedAuthModel == null ? null : selectedAuthModel.getId());
    authModelSelector.saveSettings(dataSource);
    super.saveSettings(dataSource);
}
Also used : DBPAuthModelDescriptor(org.jkiss.dbeaver.model.connection.DBPAuthModelDescriptor)

Example 7 with DBPAuthModelDescriptor

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

the class ConnectionPageWithAuth method saveSettings.

@Override
public void saveSettings(DBPDataSourceContainer dataSource) {
    DBPAuthModelDescriptor selectedAuthModel = authModelSelector.getSelectedAuthModel();
    dataSource.getConnectionConfiguration().setAuthModelId(selectedAuthModel == null ? null : selectedAuthModel.getId());
    authModelSelector.saveSettings(dataSource);
    super.saveSettings(dataSource);
}
Also used : DBPAuthModelDescriptor(org.jkiss.dbeaver.model.connection.DBPAuthModelDescriptor)

Example 8 with DBPAuthModelDescriptor

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

the class AuthModelSelector method loadSettings.

public void loadSettings(DBPDataSourceContainer dataSourceContainer, DBPAuthModelDescriptor activeAuthModel, String defaultAuthModelId) {
    this.activeDataSource = dataSourceContainer;
    this.selectedAuthModel = activeAuthModel;
    this.allAuthModels = activeDataSource.getDriver() == DriverDescriptor.NULL_DRIVER ? DataSourceProviderRegistry.getInstance().getAllAuthModels() : DataSourceProviderRegistry.getInstance().getApplicableAuthModels(activeDataSource.getDriver());
    this.allAuthModels.removeIf(o -> modelFilter != null && !modelFilter.isValidElement(o));
    this.allAuthModels.sort((Comparator<DBPAuthModelDescriptor>) (o1, o2) -> AuthModelDatabaseNative.ID.equals(o1.getId()) ? -1 : (AuthModelDatabaseNative.ID.equals(o2.getId()) ? 1 : o1.getName().compareTo(o2.getName())));
    if (selectedAuthModel == null && !CommonUtils.isEmpty(defaultAuthModelId)) {
        // Set default to native
        for (DBPAuthModelDescriptor amd : allAuthModels) {
            if (amd.getId().equals(defaultAuthModelId)) {
                selectedAuthModel = amd;
                break;
            }
        }
        if (selectedAuthModel == null) {
            // First one
            selectedAuthModel = allAuthModels.get(0);
        }
    }
    changeAuthModel();
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CommonUtils(org.jkiss.utils.CommonUtils) IElementFilter(org.jkiss.dbeaver.ui.IElementFilter) UIConnectionMessages(org.jkiss.dbeaver.ui.internal.UIConnectionMessages) org.eclipse.swt.widgets(org.eclipse.swt.widgets) IObjectPropertyConfigurator(org.jkiss.dbeaver.ui.IObjectPropertyConfigurator) DBPAuthModelDescriptor(org.jkiss.dbeaver.model.connection.DBPAuthModelDescriptor) DriverDescriptor(org.jkiss.dbeaver.registry.driver.DriverDescriptor) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) AuthModelDatabaseNative(org.jkiss.dbeaver.model.impl.auth.AuthModelDatabaseNative) List(java.util.List) DBException(org.jkiss.dbeaver.DBException) UIUtils(org.jkiss.dbeaver.ui.UIUtils) SWT(org.eclipse.swt.SWT) Log(org.jkiss.dbeaver.Log) DataSourceProviderRegistry(org.jkiss.dbeaver.registry.DataSourceProviderRegistry) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) UIPropertyConfiguratorRegistry(org.jkiss.dbeaver.registry.configurator.UIPropertyConfiguratorRegistry) Comparator(java.util.Comparator) UIPropertyConfiguratorDescriptor(org.jkiss.dbeaver.registry.configurator.UIPropertyConfiguratorDescriptor) DBPAuthModelDescriptor(org.jkiss.dbeaver.model.connection.DBPAuthModelDescriptor)

Aggregations

DBPAuthModelDescriptor (org.jkiss.dbeaver.model.connection.DBPAuthModelDescriptor)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 GridData (org.eclipse.swt.layout.GridData)4 DBException (org.jkiss.dbeaver.DBException)4 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)4 UIPropertyConfiguratorDescriptor (org.jkiss.dbeaver.registry.configurator.UIPropertyConfiguratorDescriptor)4 Comparator (java.util.Comparator)2 List (java.util.List)2 SWT (org.eclipse.swt.SWT)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 org.eclipse.swt.widgets (org.eclipse.swt.widgets)2 Log (org.jkiss.dbeaver.Log)2 DBPConnectionConfiguration (org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)2 AuthModelDatabaseNative (org.jkiss.dbeaver.model.impl.auth.AuthModelDatabaseNative)2 DataSourceProviderRegistry (org.jkiss.dbeaver.registry.DataSourceProviderRegistry)2 UIPropertyConfiguratorRegistry (org.jkiss.dbeaver.registry.configurator.UIPropertyConfiguratorRegistry)2 DriverDescriptor (org.jkiss.dbeaver.registry.driver.DriverDescriptor)2 IElementFilter (org.jkiss.dbeaver.ui.IElementFilter)2 IObjectPropertyConfigurator (org.jkiss.dbeaver.ui.IObjectPropertyConfigurator)2