Search in sources :

Example 1 with NetworkHandlerRegistry

use of org.jkiss.dbeaver.registry.network.NetworkHandlerRegistry in project dbeaver by serge-rider.

the class ConnectionPageNetwork method activatePage.

@Override
public void activatePage() {
    DataSourceDescriptor dataSource = wizard.getPageSettings().getActiveDataSource();
    DriverDescriptor 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();
        for (TabItem item : handlersFolder.getItems()) {
            ((Composite) item.getControl()).layout();
        }
    }
    TabItem selectItem = null;
    for (NetworkHandlerDescriptor descriptor : registry.getDescriptors(dataSource)) {
        DBWHandlerConfiguration configuration = dataSource.getConnectionConfiguration().getHandler(descriptor.getId());
        if (configuration == null) {
            configuration = new DBWHandlerConfiguration(descriptor, driver);
        }
        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) DriverDescriptor(org.jkiss.dbeaver.registry.driver.DriverDescriptor) Composite(org.eclipse.swt.widgets.Composite) 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)

Aggregations

Composite (org.eclipse.swt.widgets.Composite)1 TabItem (org.eclipse.swt.widgets.TabItem)1 DBException (org.jkiss.dbeaver.DBException)1 DBWHandlerConfiguration (org.jkiss.dbeaver.model.net.DBWHandlerConfiguration)1 DataSourceDescriptor (org.jkiss.dbeaver.registry.DataSourceDescriptor)1 DriverDescriptor (org.jkiss.dbeaver.registry.driver.DriverDescriptor)1 NetworkHandlerDescriptor (org.jkiss.dbeaver.registry.network.NetworkHandlerDescriptor)1 NetworkHandlerRegistry (org.jkiss.dbeaver.registry.network.NetworkHandlerRegistry)1