Search in sources :

Example 16 with DataSourceDescriptor

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

the class ConnectionPageSettings method activatePage.

@Override
public void activatePage() {
    if (connectionEditor == null) {
        createProviderPage(getControl().getParent());
    //UIUtils.resizeShell(getWizard().getContainer().getShell());
    }
    setMessage(NLS.bind(CoreMessages.dialog_connection_message, getDriver().getFullName()));
    DataSourceDescriptor connectionInfo = getActiveDataSource();
    if (!activated.contains(connectionInfo)) {
        if (this.connectionEditor != null) {
            this.connectionEditor.loadSettings();
        }
        if (subPages != null) {
            for (IDialogPage page : subPages) {
                Control pageControl = page.getControl();
                //                    }
                if (pageControl != null && page instanceof IDataSourceConnectionEditor) {
                    ((IDataSourceConnectionEditor) page).loadSettings();
                }
            }
        }
        activated.add(connectionInfo);
    } else if (connectionEditor != null) {
        connectionEditor.loadSettings();
    }
    activateCurrentItem();
    getContainer().updateTitleBar();
}
Also used : Control(org.eclipse.swt.widgets.Control) IDialogPage(org.eclipse.jface.dialogs.IDialogPage) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor)

Example 17 with DataSourceDescriptor

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

the class DriverPropertiesDialogPage method setVisible.

@Override
public void setVisible(boolean visible) {
    super.setVisible(visible);
    // Set props model
    if (visible && propsControl != null) {
        final DBPDataSourceContainer activeDataSource = site.getActiveDataSource();
        if (prevConnectionInfo == activeDataSource.getConnectionConfiguration()) {
            return;
        }
        final DBPConnectionConfiguration tmpConnectionInfo = new DBPConnectionConfiguration();
        final DataSourceDescriptor tempDataSource = new DataSourceDescriptor(site.getDataSourceRegistry(), activeDataSource.getId(), (DriverDescriptor) activeDataSource.getDriver(), tmpConnectionInfo);
        hostPage.saveSettings(tempDataSource);
        tmpConnectionInfo.getProperties().putAll(activeDataSource.getConnectionConfiguration().getProperties());
        try {
            getSite().getRunnableContext().run(true, true, new DBRRunnableWithProgress() {

                @Override
                public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    monitor.beginTask("Loading driver properties", 1);
                    try {
                        propertySource = propsControl.makeProperties(monitor, site.getDriver(), tmpConnectionInfo);
                    } finally {
                        monitor.done();
                    }
                }
            });
        } catch (InvocationTargetException e) {
            setErrorMessage(e.getTargetException().getMessage());
        } catch (InterruptedException e) {
        // ignore
        }
        propsControl.loadProperties(propertySource);
        prevConnectionInfo = activeDataSource.getConnectionConfiguration();
        tempDataSource.dispose();
    }
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DBRRunnableWithProgress(org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) InvocationTargetException(java.lang.reflect.InvocationTargetException) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor)

Example 18 with DataSourceDescriptor

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

the class NewConnectionWizard method performFinish.

/**
     * This method is called when 'Finish' button is pressed in
     * the wizard. We will create an operation and run it
     * using wizard as execution context.
     */
@Override
public boolean performFinish() {
    DriverDescriptor driver = getSelectedDriver();
    ConnectionPageSettings pageSettings = getPageSettings();
    DataSourceDescriptor dataSourceTpl = pageSettings == null ? getActiveDataSource() : pageSettings.getActiveDataSource();
    DBPDataSourceRegistry dataSourceRegistry = getDataSourceRegistry();
    DataSourceDescriptor dataSourceNew = new DataSourceDescriptor(dataSourceRegistry, dataSourceTpl.getId(), driver, dataSourceTpl.getConnectionConfiguration());
    dataSourceNew.copyFrom(dataSourceTpl);
    saveSettings(dataSourceNew);
    dataSourceRegistry.addDataSource(dataSourceNew);
    return true;
}
Also used : DriverDescriptor(org.jkiss.dbeaver.registry.driver.DriverDescriptor) DBPDataSourceRegistry(org.jkiss.dbeaver.model.app.DBPDataSourceRegistry) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor)

Example 19 with DataSourceDescriptor

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

the class DriverManagerDialog method deleteDriver.

private void deleteDriver() {
    List<DataSourceDescriptor> usedDS = selectedDriver.getUsedBy();
    if (!usedDS.isEmpty()) {
        StringBuilder message = new StringBuilder(NLS.bind(CoreMessages.dialog_driver_manager_message_cant_delete_text, selectedDriver.getName()));
        for (DataSourceDescriptor ds : usedDS) {
            message.append("\n - ").append(ds.getName());
        }
        UIUtils.showMessageBox(getShell(), CoreMessages.dialog_driver_manager_message_cant_delete_title, message.toString(), SWT.ICON_ERROR);
        return;
    }
    if (UIUtils.confirmAction(getShell(), CoreMessages.dialog_driver_manager_message_delete_driver_title, CoreMessages.dialog_driver_manager_message_delete_driver_text + selectedDriver.getName() + "'?")) {
        selectedDriver.getProviderDescriptor().removeDriver(selectedDriver);
        selectedDriver.getProviderDescriptor().getRegistry().saveDrivers();
        treeControl.getViewer().refresh();
    }
}
Also used : DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor)

Example 20 with DataSourceDescriptor

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

the class ScriptsImportWizardPage method createControl.

@Override
public void createControl(Composite parent) {
    String externalDir = DBeaverCore.getGlobalPreferenceStore().getString(ScriptsExportWizardPage.PREF_SCRIPTS_EXPORT_OUT_DIR);
    if (CommonUtils.isEmpty(externalDir)) {
        externalDir = RuntimeUtils.getUserHomeDir().getAbsolutePath();
    }
    Composite placeholder = UIUtils.createPlaceholder(parent, 1);
    placeholder.setLayout(new GridLayout(1, false));
    // Input settings
    Composite generalSettings = UIUtils.createPlaceholder(placeholder, 3);
    generalSettings.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    {
        UIUtils.createControlLabel(generalSettings, CoreMessages.dialog_scripts_import_wizard_label_input_directory);
        directoryText = new Text(generalSettings, SWT.BORDER);
        directoryText.setText(externalDir);
        directoryText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        directoryText.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                updateState();
            }
        });
        Button openFolder = new Button(generalSettings, SWT.PUSH);
        openFolder.setImage(DBeaverIcons.getImage(DBIcon.TREE_FOLDER));
        openFolder.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE);
                dialog.setMessage(CoreMessages.dialog_scripts_import_wizard_dialog_choose_dir_message);
                dialog.setText(CoreMessages.dialog_scripts_import_wizard_dialog_choose_dir_text);
                String directory = directoryText.getText();
                if (!CommonUtils.isEmpty(directory)) {
                    dialog.setFilterPath(directory);
                }
                directory = dialog.open();
                if (directory != null) {
                    directoryText.setText(directory);
                }
            }
        });
        //$NON-NLS-2$
        extensionsText = UIUtils.createLabelText(generalSettings, CoreMessages.dialog_scripts_import_wizard_label_file_mask, "*.sql,*.txt");
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        extensionsText.setLayoutData(gd);
        UIUtils.createControlLabel(generalSettings, CoreMessages.dialog_scripts_import_wizard_label_default_connection);
        scriptsDataSources = new CSmartCombo<>(generalSettings, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY, new ConnectionLabelProvider());
        for (DataSourceDescriptor dataSourceDescriptor : DataSourceRegistry.getAllDataSources()) {
            scriptsDataSources.addItem(dataSourceDescriptor);
        }
        if (scriptsDataSources.getItemCount() > 0) {
            scriptsDataSources.select(0);
        }
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        gd.verticalIndent = 2;
        scriptsDataSources.setLayoutData(gd);
    }
    UIUtils.createControlLabel(placeholder, CoreMessages.dialog_scripts_import_wizard_label_root_folder);
    importRoot = DBeaverCore.getInstance().getNavigatorModel().getRoot();
    final DatabaseNavigatorTree scriptsNavigator = new DatabaseNavigatorTree(placeholder, importRoot, SWT.BORDER | SWT.SINGLE, false);
    scriptsNavigator.setLayoutData(new GridData(GridData.FILL_BOTH));
    scriptsNavigator.getViewer().addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            if (sel == null || sel.isEmpty()) {
                importRoot = null;
            } else {
                importRoot = (DBNNode) sel.getFirstElement();
            }
            updateState();
        }
    });
    scriptsNavigator.getViewer().addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            return element instanceof DBNResource && ((DBNResource) element).getResource() instanceof IContainer;
        }
    });
    scriptsNavigator.getViewer().expandToLevel(2);
    overwriteCheck = UIUtils.createCheckbox(placeholder, CoreMessages.dialog_project_export_wizard_page_checkbox_overwrite_files, false);
    GridData gd = new GridData(GridData.BEGINNING);
    gd.horizontalSpan = 3;
    overwriteCheck.setLayoutData(gd);
    setControl(placeholder);
    updateState();
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) CSmartCombo(org.jkiss.dbeaver.ui.controls.CSmartCombo) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IContainer(org.eclipse.core.resources.IContainer) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree) DBNResource(org.jkiss.dbeaver.model.navigator.DBNResource) GridData(org.eclipse.swt.layout.GridData)

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