Search in sources :

Example 1 with NetworkHandlerDescriptor

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

the class PrefPageProjectNetworkProfiles method performDefaults.

@Override
protected void performDefaults() {
    super.performDefaults();
    profilesTable.removeAll();
    if (projectMeta != null) {
        for (DBWNetworkProfile profile : projectMeta.getDataSourceRegistry().getNetworkProfiles()) {
            TableItem item = new TableItem(profilesTable, SWT.NONE);
            item.setText(profile.getProfileName());
            item.setImage(DBeaverIcons.getImage(DBIcon.TYPE_DOCUMENT));
            item.setData(profile);
            if (selectedProfile == null) {
                selectedProfile = profile;
                profilesTable.select(0);
            }
            for (NetworkHandlerDescriptor nhd : allHandlers) {
                HandlerBlock handlerBlock = configurations.get(nhd);
                DBWHandlerConfiguration configuration = profile.getConfiguration(nhd);
                if (configuration != null) {
                    handlerBlock.loadedConfigs.put(profile, configuration);
                }
            }
        }
    }
    updateControlsState();
}
Also used : DBWNetworkProfile(org.jkiss.dbeaver.model.net.DBWNetworkProfile) DBWHandlerConfiguration(org.jkiss.dbeaver.model.net.DBWHandlerConfiguration) NetworkHandlerDescriptor(org.jkiss.dbeaver.registry.network.NetworkHandlerDescriptor)

Example 2 with NetworkHandlerDescriptor

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

the class PrefPageProjectNetworkProfiles method updateControlsState.

private void updateControlsState() {
    NetworkHandlerDescriptor descriptor = getSelectedHandler();
    enableHandlerContent(descriptor);
    if (descriptor != null) {
        HandlerBlock handlerBlock = configurations.get(descriptor);
        DBWHandlerConfiguration handlerConfiguration = handlerBlock.loadedConfigs.get(selectedProfile);
        if (handlerConfiguration == null) {
            handlerBlock.configurator.loadSettings(new DBWHandlerConfiguration(descriptor, null));
        } else {
            handlerBlock.configurator.loadSettings(handlerConfiguration);
        }
    }
}
Also used : DBWHandlerConfiguration(org.jkiss.dbeaver.model.net.DBWHandlerConfiguration) NetworkHandlerDescriptor(org.jkiss.dbeaver.registry.network.NetworkHandlerDescriptor)

Example 3 with NetworkHandlerDescriptor

use of org.jkiss.dbeaver.registry.network.NetworkHandlerDescriptor 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 4 with NetworkHandlerDescriptor

use of org.jkiss.dbeaver.registry.network.NetworkHandlerDescriptor in project dbeaver by dbeaver.

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 5 with NetworkHandlerDescriptor

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

the class ConnectionPageSettings method getSubPages.

@Nullable
@Override
public IDialogPage[] getSubPages(boolean extrasOnly, boolean forceCreate) {
    if (extrasOnly) {
        return extraPages;
    }
    if (subPages != null) {
        return subPages;
    }
    if (!forceCreate) {
        return new IDialogPage[0];
    }
    if (this.connectionEditor == null) {
        this.connectionEditor = viewDescriptor.createView(IDataSourceConnectionEditor.class);
        this.connectionEditor.setSite(this);
    }
    if (connectionEditor instanceof ICompositeDialogPage) {
        subPages = ((ICompositeDialogPage) connectionEditor).getSubPages(extrasOnly, true);
        if (!ArrayUtils.isEmpty(subPages)) {
            for (IDialogPage page : subPages) {
                if (page instanceof IDataSourceConnectionEditor) {
                    ((IDataSourceConnectionEditor) page).setSite(this);
                }
            }
        }
        if (isNew() || !getDriver().isEmbedded()) {
            // Add network tabs (for new connections or non-embedded drivers)
            for (NetworkHandlerDescriptor descriptor : NetworkHandlerRegistry.getInstance().getDescriptors(getActiveDataSource())) {
                subPages = ArrayUtils.add(IDialogPage.class, subPages, new ConnectionPageNetworkHandler(this, descriptor));
            }
        }
        if (extraPages != null) {
            subPages = ArrayUtils.concatArrays(subPages, extraPages);
        }
        return subPages;
    } else {
        return extraPages;
    }
}
Also used : IDialogPage(org.eclipse.jface.dialogs.IDialogPage) NetworkHandlerDescriptor(org.jkiss.dbeaver.registry.network.NetworkHandlerDescriptor) Nullable(org.jkiss.code.Nullable)

Aggregations

NetworkHandlerDescriptor (org.jkiss.dbeaver.registry.network.NetworkHandlerDescriptor)14 DBWHandlerConfiguration (org.jkiss.dbeaver.model.net.DBWHandlerConfiguration)10 Nullable (org.jkiss.code.Nullable)4 DBWNetworkProfile (org.jkiss.dbeaver.model.net.DBWNetworkProfile)4 List (java.util.List)2 IDialogPage (org.eclipse.jface.dialogs.IDialogPage)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 TabItem (org.eclipse.swt.widgets.TabItem)2 DBException (org.jkiss.dbeaver.DBException)2 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)2 DBPDriver (org.jkiss.dbeaver.model.connection.DBPDriver)2 DataSourceDescriptor (org.jkiss.dbeaver.registry.DataSourceDescriptor)2 NetworkHandlerRegistry (org.jkiss.dbeaver.registry.network.NetworkHandlerRegistry)2 CustomSashForm (org.jkiss.dbeaver.ui.controls.CustomSashForm)2