Search in sources :

Example 16 with DBWHandlerConfiguration

use of org.jkiss.dbeaver.model.net.DBWHandlerConfiguration in project dbeaver by serge-rider.

the class ConnectionPageNetworkHandler method updateProfileList.

private void updateProfileList() {
    DBPConnectionConfiguration cfg = site.getActiveDataSource().getConnectionConfiguration();
    String profileId = cfg.getConfigProfileName();
    activeProfile = CommonUtils.isEmpty(profileId) ? null : site.getProject().getDataSourceRegistry().getNetworkProfile(profileId);
    // Refresh profile list
    profileCombo.removeAll();
    profileCombo.add("");
    for (DBWNetworkProfile profile : site.getProject().getDataSourceRegistry().getNetworkProfiles()) {
        profileCombo.add(profile.getProfileName());
        if (CommonUtils.equalObjects(profileId, profile.getProfileName())) {
            profileCombo.select(profileCombo.getItemCount() - 1);
        }
    }
    // Update settings from profile
    if (activeProfile != null) {
    }
    // Update page controls
    handlerConfiguration = cfg.getHandler(handlerDescriptor.getId());
    if (handlerConfiguration == null) {
        handlerConfiguration = new DBWHandlerConfiguration(handlerDescriptor, site.getActiveDataSource());
    }
    useHandlerCheck.setSelection(handlerConfiguration.isEnabled());
    configurator.loadSettings(handlerConfiguration);
    enableHandlerContent();
}
Also used : DBWNetworkProfile(org.jkiss.dbeaver.model.net.DBWNetworkProfile) DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DBWHandlerConfiguration(org.jkiss.dbeaver.model.net.DBWHandlerConfiguration)

Example 17 with DBWHandlerConfiguration

use of org.jkiss.dbeaver.model.net.DBWHandlerConfiguration in project dbeaver by serge-rider.

the class ConnectionPageNetwork method saveSettings.

@Override
public void saveSettings(DBPDataSourceContainer dataSource) {
    boolean foundHandlers = false;
    java.util.List<DBWHandlerConfiguration> handlers = new ArrayList<>();
    for (HandlerBlock handlerBlock : configurations.values()) {
        DBWHandlerConfiguration configuration = handlerBlock.loadedConfigs.get(dataSource.getId());
        if (configuration != null) {
            foundHandlers = true;
            handlerBlock.configurator.saveSettings(configuration);
            handlers.add(configuration);
        }
    }
    if (foundHandlers) {
        dataSource.getConnectionConfiguration().setHandlers(handlers);
    }
}
Also used : DBWHandlerConfiguration(org.jkiss.dbeaver.model.net.DBWHandlerConfiguration) ArrayList(java.util.ArrayList)

Example 18 with DBWHandlerConfiguration

use of org.jkiss.dbeaver.model.net.DBWHandlerConfiguration in project dbeaver by serge-rider.

the class ConnectionPageNetwork method activatePage.

@Override
public void activatePage() {
    DataSourceDescriptor dataSource = wizard.getPageSettings().getActiveDataSource();
    DBPDriver driver = wizard.getSelectedDriver();
    NetworkHandlerRegistry registry = NetworkHandlerRegistry.getInstance();
    if (prevDataSource == null || prevDataSource != dataSource) {
        for (TabItem item : handlersFolder.getItems()) {
            item.dispose();
        }
        for (NetworkHandlerDescriptor descriptor : registry.getDescriptors(dataSource)) {
            try {
                createHandlerTab(descriptor);
            } catch (DBException e) {
                log.warn(e);
            }
        }
        prevDataSource = dataSource;
        handlersFolder.layout(true, true);
    // for (TabItem item : handlersFolder.getItems()) {
    // ((Composite)item.getControl()).layout(false);
    // }
    }
    TabItem selectItem = null;
    for (NetworkHandlerDescriptor descriptor : registry.getDescriptors(dataSource)) {
        DBWHandlerConfiguration configuration = dataSource.getConnectionConfiguration().getHandler(descriptor.getId());
        if (configuration == null) {
            configuration = new DBWHandlerConfiguration(descriptor, dataSource);
        }
        HandlerBlock handlerBlock = configurations.get(descriptor);
        if (handlerBlock == null) {
            continue;
        }
        // handlerBlock.useHandlerCheck.setSelection(configuration.isEnabled());
        if (selectItem == null && configuration.isEnabled()) {
            selectItem = handlerBlock.tabItem;
        }
        if (!handlerBlock.loadedConfigs.containsKey(dataSource.getId())) {
            handlerBlock.configurator.loadSettings(configuration);
            handlerBlock.loadedConfigs.put(dataSource.getId(), configuration);
        }
        enableHandlerContent(descriptor);
    }
    if (selectItem != null) {
        handlersFolder.setSelection(selectItem);
    } else {
        handlersFolder.setSelection(0);
    }
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) DBException(org.jkiss.dbeaver.DBException) DBPDriver(org.jkiss.dbeaver.model.connection.DBPDriver) DBWHandlerConfiguration(org.jkiss.dbeaver.model.net.DBWHandlerConfiguration) NetworkHandlerDescriptor(org.jkiss.dbeaver.registry.network.NetworkHandlerDescriptor) NetworkHandlerRegistry(org.jkiss.dbeaver.registry.network.NetworkHandlerRegistry) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor)

Example 19 with DBWHandlerConfiguration

use of org.jkiss.dbeaver.model.net.DBWHandlerConfiguration in project dbeaver by dbeaver.

the class ConnectionPageNetworkHandler method updateProfileList.

private void updateProfileList() {
    DBPConnectionConfiguration cfg = site.getActiveDataSource().getConnectionConfiguration();
    String profileId = cfg.getConfigProfileName();
    activeProfile = CommonUtils.isEmpty(profileId) ? null : site.getProject().getDataSourceRegistry().getNetworkProfile(profileId);
    // Refresh profile list
    profileCombo.removeAll();
    profileCombo.add("");
    for (DBWNetworkProfile profile : site.getProject().getDataSourceRegistry().getNetworkProfiles()) {
        profileCombo.add(profile.getProfileName());
        if (CommonUtils.equalObjects(profileId, profile.getProfileName())) {
            profileCombo.select(profileCombo.getItemCount() - 1);
        }
    }
    // Update settings from profile
    if (activeProfile != null) {
    }
    // Update page controls
    handlerConfiguration = cfg.getHandler(handlerDescriptor.getId());
    if (handlerConfiguration == null) {
        handlerConfiguration = new DBWHandlerConfiguration(handlerDescriptor, site.getActiveDataSource());
    }
    useHandlerCheck.setSelection(handlerConfiguration.isEnabled());
    configurator.loadSettings(handlerConfiguration);
    enableHandlerContent();
}
Also used : DBWNetworkProfile(org.jkiss.dbeaver.model.net.DBWNetworkProfile) DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DBWHandlerConfiguration(org.jkiss.dbeaver.model.net.DBWHandlerConfiguration)

Example 20 with DBWHandlerConfiguration

use of org.jkiss.dbeaver.model.net.DBWHandlerConfiguration in project dbeaver by dbeaver.

the class ConnectionPageNetworkHandler method setConnectionConfigProfile.

private void setConnectionConfigProfile(String profileName) {
    activeProfile = CommonUtils.isEmpty(profileName) ? null : site.getProject().getDataSourceRegistry().getNetworkProfile(profileName);
    DBPDataSourceContainer dataSource = site.getActiveDataSource();
    DBPConnectionConfiguration cfg = dataSource.getConnectionConfiguration();
    String oldProfileId = cfg.getConfigProfileName();
    saveSettings(site.getActiveDataSource());
    if (activeProfile != null) {
        cfg.setConfigProfile(activeProfile);
        handlerConfiguration = cfg.getHandler(handlerDescriptor.getId());
        if (handlerConfiguration == null) {
            handlerConfiguration = new DBWHandlerConfiguration(handlerDescriptor, dataSource);
        }
    } else {
        cfg.setConfigProfile(null);
    }
    site.firePropertyChange(this, PROP_CONFIG_PROFILE, oldProfileId, activeProfile == null ? null : activeProfile.getProfileName());
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DBWHandlerConfiguration(org.jkiss.dbeaver.model.net.DBWHandlerConfiguration) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Aggregations

DBWHandlerConfiguration (org.jkiss.dbeaver.model.net.DBWHandlerConfiguration)64 DBException (org.jkiss.dbeaver.DBException)20 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)12 DBPConnectionConfiguration (org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)12 NetworkHandlerDescriptor (org.jkiss.dbeaver.registry.network.NetworkHandlerDescriptor)12 SQLException (java.sql.SQLException)8 DBWNetworkProfile (org.jkiss.dbeaver.model.net.DBWNetworkProfile)8 DBRShellCommand (org.jkiss.dbeaver.model.runtime.DBRShellCommand)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 GridData (org.eclipse.swt.layout.GridData)6 GridLayout (org.eclipse.swt.layout.GridLayout)6 Nullable (org.jkiss.code.Nullable)6 DBPDataSourceOrigin (org.jkiss.dbeaver.model.DBPDataSourceOrigin)6 DBPDriver (org.jkiss.dbeaver.model.connection.DBPDriver)6 SimplePreferenceStore (org.jkiss.dbeaver.model.impl.preferences.SimplePreferenceStore)6 UIPropertyConfiguratorDescriptor (org.jkiss.dbeaver.registry.configurator.UIPropertyConfiguratorDescriptor)6 TypeToken (com.google.gson.reflect.TypeToken)4 MalformedURLException (java.net.MalformedURLException)4 ArrayList (java.util.ArrayList)4