Search in sources :

Example 51 with DBPConnectionConfiguration

use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration 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 52 with DBPConnectionConfiguration

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

the class DataSourceDescriptorManager method createNewObject.

@Override
public DataSourceDescriptor createNewObject(DBRProgressMonitor monitor, DBECommandContext commandContext, Object container, Object copyFrom, Map<String, Object> options) {
    if (copyFrom != null) {
        DataSourceDescriptor dsTpl = (DataSourceDescriptor) copyFrom;
        DBPDataSourceRegistry registry;
        DBPDataSourceFolder folder = null;
        if (container instanceof DataSourceRegistry) {
            registry = (DBPDataSourceRegistry) container;
        } else if (container instanceof DBPProject) {
            registry = ((DBPProject) container).getDataSourceRegistry();
        } else if (container instanceof DBPDataSourceFolder) {
            folder = (DBPDataSourceFolder) container;
            registry = folder.getDataSourceRegistry();
        } else {
            registry = dsTpl.getRegistry();
        }
        DataSourceDescriptor dataSource = new DataSourceDescriptor(registry, DataSourceDescriptor.generateNewId(dsTpl.getDriver()), dsTpl.getDriver(), new DBPConnectionConfiguration(dsTpl.getConnectionConfiguration()));
        dataSource.copyFrom(dsTpl);
        if (folder != null) {
            dataSource.setFolder(folder);
        } else if (dsTpl.getRegistry() == registry) {
            // Copy folder only if we copy in the same project
            dataSource.setFolder(dsTpl.getFolder());
        }
        // Generate new name
        String origName = dsTpl.getName();
        String newName = origName;
        for (int i = 0; ; i++) {
            if (registry.findDataSourceByName(newName) == null) {
                break;
            }
            newName = origName + " " + (i + 1);
        }
        dataSource.setName(newName);
        registry.addDataSource(dataSource);
    } else {
        UIUtils.asyncExec(() -> NewConnectionDialog.openNewConnectionDialog(UIUtils.getActiveWorkbenchWindow()));
    }
    return null;
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DBPDataSourceRegistry(org.jkiss.dbeaver.model.app.DBPDataSourceRegistry) DBPDataSourceFolder(org.jkiss.dbeaver.model.DBPDataSourceFolder) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) DBPDataSourceRegistry(org.jkiss.dbeaver.model.app.DBPDataSourceRegistry)

Example 53 with DBPConnectionConfiguration

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

the class MySQLWizardPageSettings method createSecurityGroup.

public void createSecurityGroup(Composite parent) {
    final DBPConnectionConfiguration connectionInfo = wizard.getSettings().getDataSourceContainer().getActualConnectionConfiguration();
    if (connectionInfo != null) {
        Group securityGroup = UIUtils.createControlGroup(parent, MySQLUIMessages.tools_db_export_wizard_page_settings_security_group, 3, GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
        Label infoLabel = new Label(securityGroup, SWT.NONE);
        infoLabel.setText(NLS.bind(MySQLUIMessages.tools_db_export_wizard_page_settings_security_label_info, connectionInfo.getUserName()));
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 3;
        infoLabel.setLayoutData(gd);
        Button authButton = new Button(securityGroup, SWT.PUSH);
        authButton.setText(MySQLUIMessages.tools_db_export_wizard_page_settings_security_button_auth);
        authButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                BaseAuthDialog authDialog = new BaseAuthDialog(getShell(), MySQLUIMessages.tools_db_export_wizard_page_settings_auth_title, false, true);
                authDialog.setUserName(wizard.getSettings().getToolUserName());
                authDialog.setUserPassword(wizard.getSettings().getToolUserPassword());
                authDialog.setSavePassword(true);
                authDialog.setSavePasswordText(MySQLUIMessages.tools_db_export_wizard_page_settings_auth_save_password_checkbox);
                authDialog.setSavePasswordToolTipText(MySQLUIMessages.tools_db_export_wizard_page_settings_auth_save_password_checkbox_tip);
                if (authDialog.open() == IDialogConstants.OK_ID) {
                    wizard.getSettings().setToolUserName(authDialog.getUserName());
                    wizard.getSettings().setToolUserPassword(authDialog.getUserPassword());
                }
            }
        });
        Button resetButton = new Button(securityGroup, SWT.PUSH);
        resetButton.setText(MySQLUIMessages.tools_db_export_wizard_page_settings_security_button_reset);
        resetButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                wizard.getSettings().setToolUserName(null);
                wizard.getSettings().setToolUserPassword(null);
            }
        });
        if (wizard.getSettings() instanceof MySQLNativeCredentialsSettings) {
            MySQLNativeCredentialsSettings settings = (MySQLNativeCredentialsSettings) wizard.getSettings();
            Button overrideCredentials = UIUtils.createCheckbox(securityGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_security_checkbox_override_host_credentials, settings.isOverrideCredentials());
            overrideCredentials.setToolTipText(MySQLUIMessages.tools_db_export_wizard_page_settings_security_checkbox_override_host_credentials_tip);
            overrideCredentials.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    settings.setOverrideCredentials(overrideCredentials.getSelection());
                }
            });
        }
    }
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) Group(org.eclipse.swt.widgets.Group) MySQLNativeCredentialsSettings(org.jkiss.dbeaver.ext.mysql.tasks.MySQLNativeCredentialsSettings) Button(org.eclipse.swt.widgets.Button) BaseAuthDialog(org.jkiss.dbeaver.ui.dialogs.BaseAuthDialog) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 54 with DBPConnectionConfiguration

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

the class MySQLConnectionPage method saveSettings.

@Override
public void saveSettings(DBPDataSourceContainer dataSource) {
    DBPConnectionConfiguration connectionInfo = dataSource.getConnectionConfiguration();
    if (hostText != null) {
        connectionInfo.setHostName(hostText.getText().trim());
    }
    if (portText != null) {
        connectionInfo.setHostPort(portText.getText().trim());
    }
    if (dbText != null) {
        connectionInfo.setDatabaseName(dbText.getText().trim());
    }
    if (serverTimezoneCombo != null) {
        String serverTimeZone = serverTimezoneCombo.getText();
        if (CommonUtils.isEmpty(serverTimeZone) || serverTimeZone.equals(MySQLUIMessages.dialog_connection_auto_detect)) {
            connectionInfo.removeProviderProperty(MySQLConstants.PROP_SERVER_TIMEZONE);
        } else {
            connectionInfo.setProviderProperty(MySQLConstants.PROP_SERVER_TIMEZONE, serverTimeZone);
        }
    }
    if (homesSelector != null) {
        connectionInfo.setClientHomeId(homesSelector.getSelectedHome());
    }
    super.saveSettings(dataSource);
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)

Example 55 with DBPConnectionConfiguration

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

the class DataSourceDescriptorManager method createNewObject.

@Override
public DataSourceDescriptor createNewObject(DBRProgressMonitor monitor, DBECommandContext commandContext, Object container, Object copyFrom, Map<String, Object> options) {
    if (copyFrom != null) {
        DataSourceDescriptor dsTpl = (DataSourceDescriptor) copyFrom;
        DBPDataSourceRegistry registry;
        DBPDataSourceFolder folder = null;
        if (container instanceof DataSourceRegistry) {
            registry = (DBPDataSourceRegistry) container;
        } else if (container instanceof DBPProject) {
            registry = ((DBPProject) container).getDataSourceRegistry();
        } else if (container instanceof DBPDataSourceFolder) {
            folder = (DBPDataSourceFolder) container;
            registry = folder.getDataSourceRegistry();
        } else {
            registry = dsTpl.getRegistry();
        }
        DataSourceDescriptor dataSource = new DataSourceDescriptor(registry, DataSourceDescriptor.generateNewId(dsTpl.getDriver()), dsTpl.getDriver(), new DBPConnectionConfiguration(dsTpl.getConnectionConfiguration()));
        dataSource.copyFrom(dsTpl);
        if (folder != null) {
            dataSource.setFolder(folder);
        } else if (dsTpl.getRegistry() == registry) {
            // Copy folder only if we copy in the same project
            dataSource.setFolder(dsTpl.getFolder());
        }
        // Generate new name
        String origName = dsTpl.getName();
        String newName = origName;
        for (int i = 0; ; i++) {
            if (registry.findDataSourceByName(newName) == null) {
                break;
            }
            newName = origName + " " + (i + 1);
        }
        dataSource.setName(newName);
        registry.addDataSource(dataSource);
    } else {
        UIUtils.asyncExec(() -> NewConnectionDialog.openNewConnectionDialog(UIUtils.getActiveWorkbenchWindow()));
    }
    return null;
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DBPDataSourceRegistry(org.jkiss.dbeaver.model.app.DBPDataSourceRegistry) DBPDataSourceFolder(org.jkiss.dbeaver.model.DBPDataSourceFolder) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) DBPDataSourceRegistry(org.jkiss.dbeaver.model.app.DBPDataSourceRegistry)

Aggregations

DBPConnectionConfiguration (org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)172 DBException (org.jkiss.dbeaver.DBException)25 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)18 DataSourceDescriptor (org.jkiss.dbeaver.registry.DataSourceDescriptor)16 DBPDriver (org.jkiss.dbeaver.model.connection.DBPDriver)14 DBWHandlerConfiguration (org.jkiss.dbeaver.model.net.DBWHandlerConfiguration)12 ArrayList (java.util.ArrayList)10 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)10 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 GridData (org.eclipse.swt.layout.GridData)10 DBPDataSourceRegistry (org.jkiss.dbeaver.model.app.DBPDataSourceRegistry)10 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 Button (org.eclipse.swt.widgets.Button)8 Group (org.eclipse.swt.widgets.Group)8 Label (org.eclipse.swt.widgets.Label)8 DBPDataSourceFolder (org.jkiss.dbeaver.model.DBPDataSourceFolder)7 Map (java.util.Map)6 Properties (java.util.Properties)6 DriverDescriptor (org.jkiss.dbeaver.registry.driver.DriverDescriptor)6 File (java.io.File)5