Search in sources :

Example 1 with DataSourceNavigatorSettings

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

the class ConnectionPageGeneral method saveSettings.

@Override
public void saveSettings(DBPDataSourceContainer dataSource) {
    if (dataSourceDescriptor != null && !activated) {
        // No changes anyway
        return;
    }
    final DBPConnectionConfiguration confConfig = dataSource.getConnectionConfiguration();
    String name = connectionNameChanged ? connectionNameText.getText() : generateConnectionName(getWizard().getPageSettings());
    dataSource.setName(name);
    dataSource.setFolder(dataSourceFolder);
    if (connectionTypeCombo.getSelectionIndex() >= 0) {
        confConfig.setConnectionType(connectionTypeCombo.getItem(connectionTypeCombo.getSelectionIndex()));
    }
    DataSourceDescriptor dsDescriptor = (DataSourceDescriptor) dataSource;
    final String description = descriptionText.getText();
    if (description.isEmpty()) {
        dsDescriptor.setDescription(null);
    } else {
        dsDescriptor.setDescription(description);
    }
    if (this.navigatorSettings == null) {
        this.navigatorSettings = new DataSourceNavigatorSettings(getWizard().getSelectedNavigatorSettings());
    }
    dsDescriptor.setNavigatorSettings(this.navigatorSettings);
    dsDescriptor.setConnectionReadOnly(this.readOnlyConnection.getSelection());
    dsDescriptor.setModifyPermissions(this.accessRestrictions);
    for (FilterInfo filterInfo : filters) {
        if (filterInfo.filter != null) {
            dataSource.setObjectFilter(filterInfo.type, null, filterInfo.filter);
        }
    }
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DataSourceNavigatorSettings(org.jkiss.dbeaver.registry.DataSourceNavigatorSettings) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor)

Example 2 with DataSourceNavigatorSettings

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

the class ConnectionPageGeneral method activatePage.

@Override
public void activatePage() {
    if (this.navigatorSettings == null) {
        this.navigatorSettings = new DataSourceNavigatorSettings(getWizard().getSelectedNavigatorSettings());
    }
    if (connectionNameText != null) {
        if (dataSourceDescriptor != null && !CommonUtils.isEmpty(dataSourceDescriptor.getName())) {
            connectionNameText.setText(dataSourceDescriptor.getName());
            connectionNameChanged = true;
        } else {
            ConnectionPageSettings settings = wizard.getPageSettings();
            if (CommonUtils.isEmpty(connectionNameText.getText()) || !connectionNameChanged) {
                String newName = generateConnectionName(settings);
                if (newName != null) {
                    connectionNameText.setText(newName);
                }
                connectionNameChanged = false;
            }
        }
    }
    if (dataSourceDescriptor != null) {
        if (!activated) {
            // Get settings from data source descriptor
            final DBPConnectionConfiguration conConfig = dataSourceDescriptor.getConnectionConfiguration();
            connectionTypeCombo.select(conConfig.getConnectionType());
            updateNavigatorSettingsPreset();
            dataSourceFolder = dataSourceDescriptor.getFolder();
            if (dataSourceDescriptor.getFolder() == null) {
                connectionFolderCombo.select(0);
            } else {
                connectionFolderCombo.select(connectionFolders.indexOf(dataSourceFolder));
            }
            if (dataSourceDescriptor.getDescription() != null) {
                descriptionText.setText(dataSourceDescriptor.getDescription());
            }
            readOnlyConnection.setSelection(dataSourceDescriptor.isConnectionReadOnly());
            activated = true;
        }
    } else {
        // Default settings
        connectionTypeCombo.select(0);
        if (dataSourceFolder != null) {
            connectionFolderCombo.select(connectionFolders.indexOf(dataSourceFolder));
        } else {
            connectionFolderCombo.select(0);
        }
        readOnlyConnection.setSelection(false);
    }
    long features = getWizard().getSelectedDriver().getDataSourceProvider().getFeatures();
    for (FilterInfo filterInfo : filters) {
        if (DBSCatalog.class.isAssignableFrom(filterInfo.type)) {
            enableFilter(filterInfo, (features & DBPDataSourceProvider.FEATURE_CATALOGS) != 0);
        } else if (DBSSchema.class.isAssignableFrom(filterInfo.type)) {
            enableFilter(filterInfo, (features & DBPDataSourceProvider.FEATURE_SCHEMAS) != 0);
        } else {
            enableFilter(filterInfo, true);
        }
    }
    filtersGroup.layout();
}
Also used : DBSSchema(org.jkiss.dbeaver.model.struct.rdb.DBSSchema) DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DataSourceNavigatorSettings(org.jkiss.dbeaver.registry.DataSourceNavigatorSettings)

Example 3 with DataSourceNavigatorSettings

use of org.jkiss.dbeaver.registry.DataSourceNavigatorSettings in project dbeaver by dbeaver.

the class ConnectionPageGeneral method activatePage.

@Override
public void activatePage() {
    if (this.navigatorSettings == null) {
        this.navigatorSettings = new DataSourceNavigatorSettings(getWizard().getSelectedNavigatorSettings());
    }
    if (connectionNameText != null) {
        if (dataSourceDescriptor != null && !CommonUtils.isEmpty(dataSourceDescriptor.getName())) {
            connectionNameText.setText(dataSourceDescriptor.getName());
            connectionNameChanged = true;
        } else {
            ConnectionPageSettings settings = wizard.getPageSettings();
            if (CommonUtils.isEmpty(connectionNameText.getText()) || !connectionNameChanged) {
                String newName = generateConnectionName(settings);
                if (newName != null) {
                    connectionNameText.setText(newName);
                }
                connectionNameChanged = false;
            }
        }
    }
    if (dataSourceDescriptor != null) {
        if (!activated) {
            // Get settings from data source descriptor
            final DBPConnectionConfiguration conConfig = dataSourceDescriptor.getConnectionConfiguration();
            connectionTypeCombo.select(conConfig.getConnectionType());
            updateNavigatorSettingsPreset();
            dataSourceFolder = dataSourceDescriptor.getFolder();
            if (dataSourceDescriptor.getFolder() == null) {
                connectionFolderCombo.select(0);
            } else {
                connectionFolderCombo.select(connectionFolders.indexOf(dataSourceFolder));
            }
            if (dataSourceDescriptor.getDescription() != null) {
                descriptionText.setText(dataSourceDescriptor.getDescription());
            }
            readOnlyConnection.setSelection(dataSourceDescriptor.isConnectionReadOnly());
            activated = true;
        }
    } else {
        // Default settings
        connectionTypeCombo.select(0);
        if (dataSourceFolder != null) {
            connectionFolderCombo.select(connectionFolders.indexOf(dataSourceFolder));
        } else {
            connectionFolderCombo.select(0);
        }
        readOnlyConnection.setSelection(false);
    }
    long features = getWizard().getSelectedDriver().getDataSourceProvider().getFeatures();
    for (FilterInfo filterInfo : filters) {
        if (DBSCatalog.class.isAssignableFrom(filterInfo.type)) {
            enableFilter(filterInfo, (features & DBPDataSourceProvider.FEATURE_CATALOGS) != 0);
        } else if (DBSSchema.class.isAssignableFrom(filterInfo.type)) {
            enableFilter(filterInfo, (features & DBPDataSourceProvider.FEATURE_SCHEMAS) != 0);
        } else {
            enableFilter(filterInfo, true);
        }
    }
    filtersGroup.layout();
}
Also used : DBSSchema(org.jkiss.dbeaver.model.struct.rdb.DBSSchema) DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DataSourceNavigatorSettings(org.jkiss.dbeaver.registry.DataSourceNavigatorSettings)

Example 4 with DataSourceNavigatorSettings

use of org.jkiss.dbeaver.registry.DataSourceNavigatorSettings in project dbeaver by dbeaver.

the class ConnectionPageGeneral method saveSettings.

@Override
public void saveSettings(DBPDataSourceContainer dataSource) {
    if (dataSourceDescriptor != null && !activated) {
        // No changes anyway
        return;
    }
    final DBPConnectionConfiguration confConfig = dataSource.getConnectionConfiguration();
    String name = connectionNameChanged ? connectionNameText.getText() : generateConnectionName(getWizard().getPageSettings());
    dataSource.setName(name);
    dataSource.setFolder(dataSourceFolder);
    if (connectionTypeCombo.getSelectionIndex() >= 0) {
        confConfig.setConnectionType(connectionTypeCombo.getItem(connectionTypeCombo.getSelectionIndex()));
    }
    DataSourceDescriptor dsDescriptor = (DataSourceDescriptor) dataSource;
    final String description = descriptionText.getText();
    if (description.isEmpty()) {
        dsDescriptor.setDescription(null);
    } else {
        dsDescriptor.setDescription(description);
    }
    if (this.navigatorSettings == null) {
        this.navigatorSettings = new DataSourceNavigatorSettings(getWizard().getSelectedNavigatorSettings());
    }
    dsDescriptor.setNavigatorSettings(this.navigatorSettings);
    dsDescriptor.setConnectionReadOnly(this.readOnlyConnection.getSelection());
    dsDescriptor.setModifyPermissions(this.accessRestrictions);
    for (FilterInfo filterInfo : filters) {
        if (filterInfo.filter != null) {
            dataSource.setObjectFilter(filterInfo.type, null, filterInfo.filter);
        }
    }
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DataSourceNavigatorSettings(org.jkiss.dbeaver.registry.DataSourceNavigatorSettings) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor)

Aggregations

DBPConnectionConfiguration (org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)4 DataSourceNavigatorSettings (org.jkiss.dbeaver.registry.DataSourceNavigatorSettings)4 DBSSchema (org.jkiss.dbeaver.model.struct.rdb.DBSSchema)2 DataSourceDescriptor (org.jkiss.dbeaver.registry.DataSourceDescriptor)2