Search in sources :

Example 1 with DataSourceDescriptor

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

the class NavigatorHandlerObjectOpen method openEntityEditor.

public static IEditorPart openEntityEditor(@NotNull DBNNode selectedNode, @Nullable String defaultPageId, @Nullable Map<String, Object> attributes, IWorkbenchWindow workbenchWindow) {
    if (selectedNode instanceof DBNDataSource) {
        final DataSourceDescriptor dataSourceContainer = (DataSourceDescriptor) ((DBNDataSource) selectedNode).getDataSourceContainer();
        openConnectionEditor(workbenchWindow, dataSourceContainer);
        return null;
    }
    if (!selectedNode.isPersisted()) {
        log.debug("Node '" + selectedNode.getNodeName() + "' s not persisted. Open not possible.");
        return null;
    }
    try {
        String defaultFolderId = null;
        if (selectedNode instanceof DBNDatabaseFolder && !(selectedNode.getParentNode() instanceof DBNDatabaseFolder) && selectedNode.getParentNode() instanceof DBNDatabaseNode) {
            defaultFolderId = selectedNode.getNodeType();
            selectedNode = selectedNode.getParentNode();
        }
        DatabaseEditorInputFactory.setLookupEditor(true);
        try {
            for (IEditorReference ref : workbenchWindow.getActivePage().getEditorReferences()) {
                IEditorInput editorInput;
                try {
                    editorInput = ref.getEditorInput();
                } catch (Throwable e) {
                    continue;
                }
                if (editorInput instanceof INavigatorEditorInput) {
                    boolean matches;
                    if (editorInput instanceof DatabaseLazyEditorInput) {
                        matches = selectedNode.getNodeItemPath().equals(((DatabaseLazyEditorInput) editorInput).getNodePath());
                    } else {
                        matches = ((INavigatorEditorInput) editorInput).getNavigatorNode() == selectedNode;
                    }
                    if (matches) {
                        final IEditorPart editor = ref.getEditor(true);
                        if (editor instanceof ITabbedFolderContainer && defaultFolderId != null) {
                            // Activate default folder
                            ((ITabbedFolderContainer) editor).switchFolder(defaultFolderId);
                        }
                        workbenchWindow.getActivePage().activate(editor);
                        return editor;
                    }
                }
            }
        } finally {
            DatabaseEditorInputFactory.setLookupEditor(false);
        }
        if (selectedNode instanceof DBNDatabaseObject) {
            DBNDatabaseObject objectNode = (DBNDatabaseObject) selectedNode;
            ObjectEditorInput objectInput = new ObjectEditorInput(objectNode);
            setInputAttributes(objectInput, defaultPageId, defaultFolderId, attributes);
            return workbenchWindow.getActivePage().openEditor(objectInput, objectNode.getMeta().getEditorId());
        } else if (selectedNode instanceof DBNDatabaseNode) {
            DBNDatabaseNode dnNode = (DBNDatabaseNode) selectedNode;
            if (dnNode.getObject() != null) {
                EntityEditorInput editorInput = new EntityEditorInput(dnNode);
                if (DBeaverCore.getGlobalPreferenceStore().getBoolean(DBeaverPreferences.NAVIGATOR_REFRESH_EDITORS_ON_OPEN)) {
                    if (dnNode.getObject() instanceof DBSObjectContainer) {
                    // do not auto-refresh object containers (too expensive)
                    } else {
                        refreshDatabaseNode(dnNode);
                    }
                }
                setInputAttributes(editorInput, defaultPageId, defaultFolderId, attributes);
                return workbenchWindow.getActivePage().openEditor(editorInput, EntityEditor.class.getName());
            } else {
                UIUtils.showErrorDialog(workbenchWindow.getShell(), "No object", "Node do not has associated database object");
                return null;
            }
        } else {
            NodeEditorInput folderInput = new NodeEditorInput(selectedNode);
            return workbenchWindow.getActivePage().openEditor(folderInput, FolderEditor.class.getName());
        }
    } catch (Exception ex) {
        UIUtils.showErrorDialog(workbenchWindow.getShell(), CoreMessages.actions_navigator_error_dialog_open_entity_title, "Can't open entity '" + selectedNode.getNodeName() + "'", ex);
        return null;
    }
}
Also used : EntityEditorInput(org.jkiss.dbeaver.ui.editors.entity.EntityEditorInput) ExecutionException(org.eclipse.core.commands.ExecutionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) DBException(org.jkiss.dbeaver.DBException) ITabbedFolderContainer(org.jkiss.dbeaver.ui.controls.folders.ITabbedFolderContainer) ObjectEditorInput(org.jkiss.dbeaver.ui.editors.object.ObjectEditorInput) NodeEditorInput(org.jkiss.dbeaver.ui.editors.entity.NodeEditorInput) DBSObjectContainer(org.jkiss.dbeaver.model.struct.DBSObjectContainer) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor)

Example 2 with DataSourceDescriptor

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

the class DataSourceHandler method connectToDataSource.

/**
     * Connects datasource
     * @param monitor progress monitor or null. If nul then new job will be started
     * @param dataSourceContainer    container to connect
     * @param onFinish               finish handler
     */
public static void connectToDataSource(@Nullable DBRProgressMonitor monitor, @NotNull DBPDataSourceContainer dataSourceContainer, @Nullable final DBRProgressListener onFinish) {
    if (dataSourceContainer instanceof DataSourceDescriptor && !dataSourceContainer.isConnected()) {
        final DataSourceDescriptor dataSourceDescriptor = (DataSourceDescriptor) dataSourceContainer;
        if (!ArrayUtils.isEmpty(Job.getJobManager().find(dataSourceDescriptor))) {
            // Already connecting/disconnecting - just return
            return;
        }
        final ConnectJob connectJob = new ConnectJob(dataSourceDescriptor);
        final JobChangeAdapter jobChangeAdapter = new JobChangeAdapter() {

            @Override
            public void done(IJobChangeEvent event) {
                IStatus result = connectJob.getConnectStatus();
                if (result.isOK()) {
                    if (!dataSourceDescriptor.isSavePassword()) {
                    // Rest password back to null
                    // TODO: to be correct we need to reset password info.
                    // but we need a password to open isolated contexts (e.g. for data export)
                    // Currently it is not possible to ask for password from isolation context opening
                    // procedure. We need to do something here...
                    //dataSourceDescriptor.getConnectionConfiguration().setUserName(oldName);
                    //dataSourceDescriptor.getConnectionConfiguration().setUserPassword(oldPassword);
                    }
                }
                if (onFinish != null) {
                    onFinish.onTaskFinished(result);
                } else if (!result.isOK()) {
                    DBUserInterface.getInstance().showError(connectJob.getName(), //NLS.bind(CoreMessages.runtime_jobs_connect_status_error, dataSourceContainer.getName()),
                    null, result);
                }
            }
        };
        if (monitor != null) {
            connectJob.runSync(monitor);
            jobChangeAdapter.done(new IJobChangeEvent() {

                @Override
                public long getDelay() {
                    return 0;
                }

                @Override
                public Job getJob() {
                    return connectJob;
                }

                @Override
                public IStatus getResult() {
                    return connectJob.getConnectStatus();
                }

                public IStatus getJobGroupResult() {
                    return null;
                }
            });
        } else {
            connectJob.addJobChangeListener(jobChangeAdapter);
            // Schedule in UI because connect may be initiated during application startup
            // and UI is still not initiated. In this case no progress dialog will appear
            // to be sure run in UI async
            DBeaverUI.asyncExec(new Runnable() {

                @Override
                public void run() {
                    connectJob.schedule();
                }
            });
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) ConnectJob(org.jkiss.dbeaver.runtime.jobs.ConnectJob) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) DisconnectJob(org.jkiss.dbeaver.runtime.jobs.DisconnectJob) ConnectJob(org.jkiss.dbeaver.runtime.jobs.ConnectJob) Job(org.eclipse.core.runtime.jobs.Job) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor)

Example 3 with DataSourceDescriptor

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

the class ConnectionPageGeneral method activatePage.

@Override
public void activatePage() {
    if (connectionNameText != null) {
        ConnectionPageSettings settings = wizard.getPageSettings();
        String newName;
        if (settings != null) {
            DBPConnectionConfiguration connectionInfo = settings.getActiveDataSource().getConnectionConfiguration();
            //$NON-NLS-1$
            newName = dataSourceDescriptor == null ? "" : settings.getActiveDataSource().getName();
            if (CommonUtils.isEmpty(newName)) {
                newName = connectionInfo.getDatabaseName();
                if (CommonUtils.isEmpty(newName)) {
                    newName = connectionInfo.getHostName();
                }
                if (CommonUtils.isEmpty(newName)) {
                    newName = connectionInfo.getUrl();
                }
                if (CommonUtils.isEmpty(newName)) {
                    newName = CoreMessages.dialog_connection_wizard_final_default_new_connection_name;
                }
                //$NON-NLS-1$
                StringTokenizer st = new StringTokenizer(newName, "/\\:,?=%$#@!^&*()");
                while (st.hasMoreTokens()) {
                    newName = st.nextToken();
                }
                if (!CommonUtils.isEmpty(settings.getDriver().getCategory())) {
                    //$NON-NLS-1$
                    newName = settings.getDriver().getCategory() + " - " + newName;
                } else {
                    //$NON-NLS-1$
                    newName = settings.getDriver().getName() + " - " + newName;
                }
                newName = CommonUtils.truncateString(newName, 50);
            }
        } else {
            newName = wizard.getSelectedDriver().getName();
        }
        if (CommonUtils.isEmpty(connectionNameText.getText()) || !connectionNameChanged) {
            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());
            dataSourceFolder = dataSourceDescriptor.getFolder();
            if (dataSourceDescriptor.getFolder() == null) {
                connectionFolderCombo.select(0);
            } else {
                connectionFolderCombo.select(dataSourceFolder);
            }
            savePasswordCheck.setSelection(dataSourceDescriptor.isSavePassword());
            autocommit.setSelection(dataSourceDescriptor.isDefaultAutoCommit());
            showSystemObjects.setSelection(dataSourceDescriptor.isShowSystemObjects());
            showUtilityObjects.setSelection(dataSourceDescriptor.isShowUtilityObjects());
            readOnlyConnection.setSelection(dataSourceDescriptor.isConnectionReadOnly());
            isolationLevel.add("");
            if (dataSourceDescriptor.isConnected()) {
                DBPDataSource dataSource = dataSourceDescriptor.getDataSource();
                isolationLevel.setEnabled(!autocommit.getSelection());
                supportedLevels.clear();
                DBPTransactionIsolation defaultLevel = dataSourceDescriptor.getActiveTransactionsIsolation();
                for (DBPTransactionIsolation level : CommonUtils.safeCollection(dataSource.getInfo().getSupportedTransactionsIsolation())) {
                    if (!level.isEnabled())
                        continue;
                    isolationLevel.add(level.getTitle());
                    supportedLevels.add(level);
                    if (level.equals(defaultLevel)) {
                        isolationLevel.select(isolationLevel.getItemCount() - 1);
                    }
                }
                if (dataSource instanceof DBSObjectContainer) {
                    new SchemaReadJob((DBSObjectContainer) dataSource).schedule();
                }
            } else {
                isolationLevel.setEnabled(false);
            }
            defaultSchema.setText(CommonUtils.notEmpty(conConfig.getBootstrap().getDefaultObjectName()));
            keepAliveInterval.setSelection(conConfig.getKeepAliveInterval());
            if (dataSourceDescriptor.getDescription() != null) {
                descriptionText.setText(dataSourceDescriptor.getDescription());
            }
            activated = true;
        }
    } else {
        if (eventsButton != null) {
            eventsButton.setFont(getFont());
            DataSourceDescriptor dataSource = getActiveDataSource();
            for (DBPConnectionEventType eventType : dataSource.getConnectionConfiguration().getDeclaredEvents()) {
                if (dataSource.getConnectionConfiguration().getEvent(eventType).isEnabled()) {
                    eventsButton.setFont(boldFont);
                    break;
                }
            }
        }
        // Default settings
        savePasswordCheck.setSelection(true);
        connectionTypeCombo.select(0);
        autocommit.setSelection((connectionTypeCombo.getItem(0)).isAutocommit());
        if (dataSourceFolder != null) {
            connectionFolderCombo.select(dataSourceFolder);
        } else {
            connectionFolderCombo.select(0);
        }
        showSystemObjects.setSelection(true);
        showUtilityObjects.setSelection(false);
        readOnlyConnection.setSelection(false);
        isolationLevel.setEnabled(false);
        defaultSchema.setText("");
    }
    if (savePasswordCheck != null) {
    //savePasswordCheck.setEnabled();
    }
    long features = wizard.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 : DBPConnectionEventType(org.jkiss.dbeaver.model.connection.DBPConnectionEventType) DBSSchema(org.jkiss.dbeaver.model.struct.rdb.DBSSchema) DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DBSObjectContainer(org.jkiss.dbeaver.model.struct.DBSObjectContainer) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor)

Example 4 with DataSourceDescriptor

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

the class ConnectionPageGeneral method createControl.

@Override
public void createControl(Composite parent) {
    boldFont = UIUtils.makeBoldFont(parent.getFont());
    Composite group = new Composite(parent, SWT.NONE);
    GridLayout gl = new GridLayout(2, false);
    group.setLayout(gl);
    //$NON-NLS-1$
    String connectionName = dataSourceDescriptor == null ? "" : dataSourceDescriptor.getName();
    connectionNameText = UIUtils.createLabelText(group, CoreMessages.dialog_connection_wizard_final_label_connection_name, CommonUtils.toString(connectionName));
    connectionNameText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            connectionNameChanged = true;
            ConnectionPageGeneral.this.getContainer().updateButtons();
        }
    });
    {
        UIUtils.createControlLabel(group, "Connection type");
        Composite ctGroup = UIUtils.createPlaceholder(group, 2, 5);
        connectionTypeCombo = new CSmartCombo<>(ctGroup, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY, new ConnectionTypeLabelProvider());
        loadConnectionTypes();
        connectionTypeCombo.select(0);
        connectionTypeCombo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                DBPConnectionType type = connectionTypeCombo.getItem(connectionTypeCombo.getSelectionIndex());
                autocommit.setSelection(type.isAutocommit());
            }
        });
        Button pickerButton = new Button(ctGroup, SWT.PUSH);
        pickerButton.setText("Edit");
        pickerButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                DataSourceDescriptor dataSource = getActiveDataSource();
                UIUtils.showPreferencesFor(getControl().getShell(), dataSource.getConnectionConfiguration().getConnectionType(), PrefPageConnectionTypes.PAGE_ID);
                loadConnectionTypes();
                DBPConnectionType connectionType = dataSource.getConnectionConfiguration().getConnectionType();
                connectionTypeCombo.select(connectionType);
                autocommit.setSelection(connectionType.isAutocommit());
            }
        });
    }
    {
        UIUtils.createControlLabel(group, "Connection folder");
        connectionFolderCombo = new CSmartCombo<>(group, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY, new ConnectionFolderLabelProvider());
        //connectionFolderCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        loadConnectionFolders();
        connectionFolderCombo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                dataSourceFolder = connectionFolderCombo.getItem(connectionFolderCombo.getSelectionIndex());
            }
        });
    }
    {
        Composite optionsGroup = new Composite(group, SWT.NONE);
        gl = new GridLayout(2, true);
        gl.verticalSpacing = 0;
        gl.horizontalSpacing = 5;
        gl.marginHeight = 0;
        gl.marginWidth = 0;
        optionsGroup.setLayout(gl);
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        optionsGroup.setLayoutData(gd);
        Composite leftSide = UIUtils.createPlaceholder(optionsGroup, 1, 5);
        leftSide.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
        Composite rightSide = UIUtils.createPlaceholder(optionsGroup, 1, 5);
        rightSide.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
        {
            Group securityGroup = UIUtils.createControlGroup(leftSide, CoreMessages.dialog_connection_wizard_final_group_security, 1, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, 0);
            savePasswordCheck = UIUtils.createCheckbox(securityGroup, CoreMessages.dialog_connection_wizard_final_checkbox_save_password_locally, dataSourceDescriptor == null || dataSourceDescriptor.isSavePassword());
            savePasswordCheck.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        }
        {
            Group txnGroup = UIUtils.createControlGroup(rightSide, "Connection", 2, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, 0);
            autocommit = UIUtils.createLabelCheckbox(txnGroup, CoreMessages.dialog_connection_wizard_final_checkbox_auto_commit, "Sets auto-commit mode for all connections", dataSourceDescriptor != null && dataSourceDescriptor.isDefaultAutoCommit());
            autocommit.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
            autocommit.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (dataSourceDescriptor != null && dataSourceDescriptor.isConnected()) {
                        isolationLevel.setEnabled(!autocommit.getSelection());
                    }
                }
            });
            isolationLevel = UIUtils.createLabelCombo(txnGroup, "Isolation level", "Default transaction isolation level.", SWT.DROP_DOWN | SWT.READ_ONLY);
            defaultSchema = UIUtils.createLabelCombo(txnGroup, "Default schema", "Name of schema or catalog which will be set as default.", SWT.DROP_DOWN);
            keepAliveInterval = UIUtils.createLabelSpinner(txnGroup, "Keep-Alive", "Keep-alive interval (in seconds). Zero turns keep-alive off", 0, 0, Short.MAX_VALUE);
            {
                String bootstrapTooltip = "SQL queries to execute right after connection establishment";
                UIUtils.createControlLabel(txnGroup, "Bootstrap queries").setToolTipText(bootstrapTooltip);
                final Button queriesConfigButton = UIUtils.createPushButton(txnGroup, "Configure ...", DBeaverIcons.getImage(UIIcon.SQL_SCRIPT));
                queriesConfigButton.setToolTipText(bootstrapTooltip);
                if (dataSourceDescriptor != null && !CommonUtils.isEmpty(dataSourceDescriptor.getConnectionConfiguration().getBootstrap().getInitQueries())) {
                    queriesConfigButton.setFont(boldFont);
                }
                queriesConfigButton.addSelectionListener(new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        EditBootstrapQueriesDialog dialog = new EditBootstrapQueriesDialog(getShell(), bootstrapQueries, ignoreBootstrapErrors);
                        if (dialog.open() == IDialogConstants.OK_ID) {
                            bootstrapQueries = dialog.getQueries();
                            ignoreBootstrapErrors = dialog.isIgnoreErrors();
                        }
                    }
                });
            }
            if (getWizard().isNew()) {
                UIUtils.createControlLabel(txnGroup, "Shell Commands");
                eventsButton = new Button(txnGroup, SWT.PUSH);
                eventsButton.setText("Configure ...");
                eventsButton.setImage(DBeaverIcons.getImage(UIIcon.EVENT));
                eventsButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
                eventsButton.addSelectionListener(new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        configureEvents();
                    }
                });
            }
        }
        {
            Group miscGroup = UIUtils.createControlGroup(leftSide, CoreMessages.dialog_connection_wizard_final_group_misc, 1, GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL, 0);
            showSystemObjects = UIUtils.createCheckbox(miscGroup, CoreMessages.dialog_connection_wizard_final_checkbox_show_system_objects, dataSourceDescriptor == null || dataSourceDescriptor.isShowSystemObjects());
            showSystemObjects.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
            showUtilityObjects = UIUtils.createCheckbox(miscGroup, CoreMessages.dialog_connection_wizard_final_checkbox_show_util_objects, dataSourceDescriptor == null || dataSourceDescriptor.isShowUtilityObjects());
            showUtilityObjects.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
            readOnlyConnection = UIUtils.createCheckbox(miscGroup, CoreMessages.dialog_connection_wizard_final_checkbox_connection_readonly, dataSourceDescriptor != null && dataSourceDescriptor.isConnectionReadOnly());
            gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            //gd.horizontalSpan = 2;
            readOnlyConnection.setLayoutData(gd);
        }
        {
            // Filters
            filtersGroup = UIUtils.createControlGroup(leftSide, CoreMessages.dialog_connection_wizard_final_group_filters, 1, GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL, 0);
            for (int i = 0; i < filters.size(); i++) {
                final FilterInfo filterInfo = filters.get(i);
                filterInfo.link = UIUtils.createLink(filtersGroup, "<a>" + filterInfo.title + "</a>", new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        EditObjectFilterDialog dialog = new EditObjectFilterDialog(getShell(), filterInfo.title, filterInfo.filter != null ? filterInfo.filter : new DBSObjectFilter(), true);
                        if (dialog.open() == IDialogConstants.OK_ID) {
                            filterInfo.filter = dialog.getFilter();
                            if (filterInfo.filter != null && !filterInfo.filter.isNotApplicable()) {
                                filterInfo.link.setFont(boldFont);
                            } else {
                                filterInfo.link.setFont(getFont());
                            }
                        }
                    }
                });
            }
        }
    }
    {
        final Group descGroup = UIUtils.createControlGroup(group, "Description", 1, GridData.FILL_HORIZONTAL, 0);
        ((GridData) descGroup.getLayoutData()).horizontalSpan = 2;
        descriptionText = new Text(descGroup, SWT.BORDER | SWT.V_SCROLL | SWT.WRAP | SWT.MULTI);
        final GridData gd = new GridData(GridData.FILL_BOTH);
        gd.heightHint = descriptionText.getLineHeight() * 3;
        descriptionText.setLayoutData(gd);
    }
    setControl(group);
    UIUtils.setHelp(group, IHelpContextIds.CTX_CON_WIZARD_FINAL);
}
Also used : DBSObjectFilter(org.jkiss.dbeaver.model.struct.DBSObjectFilter) DBPConnectionType(org.jkiss.dbeaver.model.connection.DBPConnectionType) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) CSmartCombo(org.jkiss.dbeaver.ui.controls.CSmartCombo) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor)

Example 5 with DataSourceDescriptor

use of org.jkiss.dbeaver.registry.DataSourceDescriptor 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

DataSourceDescriptor (org.jkiss.dbeaver.registry.DataSourceDescriptor)21 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 DBException (org.jkiss.dbeaver.DBException)4 DBPConnectionConfiguration (org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)4 DriverDescriptor (org.jkiss.dbeaver.registry.driver.DriverDescriptor)4 IStatus (org.eclipse.core.runtime.IStatus)2 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)2 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)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 Composite (org.eclipse.swt.widgets.Composite)2 Control (org.eclipse.swt.widgets.Control)2 DBPConnectionEventType (org.jkiss.dbeaver.model.connection.DBPConnectionEventType)2 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)2 DBRRunnableWithProgress (org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress)2 DBSObjectContainer (org.jkiss.dbeaver.model.struct.DBSObjectContainer)2