Search in sources :

Example 6 with DBPDataSourceProviderDescriptor

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

the class SQLContextTypeRegistry method loadContextTypes.

private void loadContextTypes() {
    addContextType(new SQLContextTypeBase());
    for (DBPDataSourceProviderDescriptor provider : DBWorkbench.getPlatform().getDataSourceProviderRegistry().getDataSourceProviders()) {
        if (!provider.isDriversManagable()) {
            SQLContextTypeProvider contextType = new SQLContextTypeProvider(provider);
            addContextType(contextType);
        // provider.loadTemplateVariableResolvers(contextType);
        } else {
            Set<String> categoriesAdded = new HashSet<>();
            for (DBPDriver driver : provider.getEnabledDrivers()) {
                if (!CommonUtils.isEmpty(driver.getCategory())) {
                    if (categoriesAdded.contains(driver.getCategory())) {
                        continue;
                    }
                    categoriesAdded.add(driver.getCategory());
                }
                SQLContextTypeDriver contextType = new SQLContextTypeDriver(driver);
                addContextType(contextType);
            // provider.loadTemplateVariableResolvers(contextType);
            }
        }
    }
}
Also used : DBPDriver(org.jkiss.dbeaver.model.connection.DBPDriver) DBPDataSourceProviderDescriptor(org.jkiss.dbeaver.model.connection.DBPDataSourceProviderDescriptor) HashSet(java.util.HashSet)

Example 7 with DBPDataSourceProviderDescriptor

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

the class DriverManagerDialog method undeleteDrivers.

private boolean undeleteDrivers() {
    List<DriverDescriptor> drivers = new ArrayList<>();
    BaseDialog dialog = new BaseDialog(getShell(), "Restore deleted driver(s)", null) {

        @Override
        protected Composite createDialogArea(Composite parent) {
            final Composite composite = super.createDialogArea(parent);
            Table driverTable = new Table(composite, SWT.CHECK | SWT.FULL_SELECTION | SWT.BORDER);
            driverTable.setLayoutData(new GridData(GridData.FILL_BOTH));
            for (DBPDataSourceProviderDescriptor dspd : DataSourceProviderRegistry.getInstance().getEnabledDataSourceProviders()) {
                for (DBPDriver dd : dspd.getDrivers()) {
                    if (dd.isDisabled()) {
                        TableItem item = new TableItem(driverTable, SWT.NONE);
                        item.setImage(DBeaverIcons.getImage(dd.getIcon()));
                        item.setText(dd.getName());
                        item.setData(dd);
                    }
                }
            }
            driverTable.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (((TableItem) e.item).getChecked()) {
                        drivers.add((DriverDescriptor) e.item.getData());
                    } else {
                        drivers.remove((DriverDescriptor) e.item.getData());
                    }
                }
            });
            return super.createDialogArea(parent);
        }
    };
    if (dialog.open() == IDialogConstants.OK_ID) {
        for (DriverDescriptor dd : drivers) {
            dd.setDisabled(false);
            dd.getProviderDescriptor().getRegistry().saveDrivers();
        }
        return true;
    }
    return false;
}
Also used : BaseDialog(org.jkiss.dbeaver.ui.dialogs.BaseDialog) DriverDescriptor(org.jkiss.dbeaver.registry.driver.DriverDescriptor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ArrayList(java.util.ArrayList) DBPDriver(org.jkiss.dbeaver.model.connection.DBPDriver) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DBPDataSourceProviderDescriptor(org.jkiss.dbeaver.model.connection.DBPDataSourceProviderDescriptor)

Example 8 with DBPDataSourceProviderDescriptor

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

the class DriverTreeViewer method initDrivers.

public void initDrivers(List<DBPDataSourceProviderDescriptor> providers, boolean expandRecent) {
    getTree().setHeaderVisible(true);
    this.providers = providers;
    if (this.providers == null) {
        this.providers = DataSourceProviderRegistry.getInstance().getEnabledDataSourceProviders();
    }
    TreeColumn nameColumn = new TreeColumn(getTree(), SWT.LEFT);
    nameColumn.setText("Name");
    nameColumn.addListener(SWT.Selection, new DriversSortListener(nameColumn, true));
    TreeColumn usersColumn = new TreeColumn(getTree(), SWT.LEFT);
    usersColumn.setText("#");
    usersColumn.addListener(SWT.Selection, new DriversSortListener(usersColumn, false));
    this.setContentProvider(new ViewContentProvider());
    this.setLabelProvider(new ViewLabelProvider());
    this.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    Collection<Object> drivers = collectDrivers();
    this.setInput(drivers);
    UIUtils.expandAll(this);
    UIUtils.packColumns(getTree(), true, new float[] { 0.9f, 0.1f });
    if (expandRecent) {
        // Expand used driver categories
        for (Object driver : drivers) {
            if (driver instanceof DriverCategory && getConnectionCount(driver) > 0) {
                expandToLevel(driver, ALL_LEVELS);
            } else {
                collapseToLevel(driver, ALL_LEVELS);
            }
        }
    } else {
        this.collapseAll();
    }
    addDoubleClickListener(event -> {
        IStructuredSelection selection = (IStructuredSelection) event.getSelection();
        if (!selection.isEmpty()) {
            Object element = selection.getFirstElement();
            if (element instanceof DriverCategory || element instanceof DataSourceProviderDescriptor) {
                if (Boolean.TRUE.equals(getExpandedState(element))) {
                    super.collapseToLevel(element, 1);
                } else {
                    super.expandToLevel(element, 1);
                }
            }
        }
    });
}
Also used : TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) DBPDataSourceProviderDescriptor(org.jkiss.dbeaver.model.connection.DBPDataSourceProviderDescriptor) DataSourceProviderDescriptor(org.jkiss.dbeaver.registry.DataSourceProviderDescriptor)

Example 9 with DBPDataSourceProviderDescriptor

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

the class SQLContextTypeRegistry method loadContextTypes.

private void loadContextTypes() {
    addContextType(new SQLContextTypeBase());
    for (DBPDataSourceProviderDescriptor provider : DBWorkbench.getPlatform().getDataSourceProviderRegistry().getDataSourceProviders()) {
        if (!provider.isDriversManagable()) {
            SQLContextTypeProvider contextType = new SQLContextTypeProvider(provider);
            addContextType(contextType);
        // provider.loadTemplateVariableResolvers(contextType);
        } else {
            Set<String> categoriesAdded = new HashSet<>();
            for (DBPDriver driver : provider.getEnabledDrivers()) {
                if (!CommonUtils.isEmpty(driver.getCategory())) {
                    if (categoriesAdded.contains(driver.getCategory())) {
                        continue;
                    }
                    categoriesAdded.add(driver.getCategory());
                }
                SQLContextTypeDriver contextType = new SQLContextTypeDriver(driver);
                addContextType(contextType);
            // provider.loadTemplateVariableResolvers(contextType);
            }
        }
    }
}
Also used : DBPDriver(org.jkiss.dbeaver.model.connection.DBPDriver) DBPDataSourceProviderDescriptor(org.jkiss.dbeaver.model.connection.DBPDataSourceProviderDescriptor) HashSet(java.util.HashSet)

Example 10 with DBPDataSourceProviderDescriptor

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

the class NewConnectionWizard method addPages.

/**
 * Adding the page to the wizard.
 */
@Override
public void addPages() {
    /*if (initialDriver == null) */
    {
        // We need drivers page always as it contains some settings
        pageDrivers = new ConnectionPageDriver(this);
        if (initialDriver != null) {
            pageDrivers.setSelectedDriver(initialDriver);
        }
        addPage(pageDrivers);
    }
    for (DBPDataSourceProviderDescriptor provider : DataSourceProviderRegistry.getInstance().getEnabledDataSourceProviders()) {
        availableProvides.add(provider);
        DataSourceViewDescriptor view = DataSourceViewRegistry.getInstance().findView(provider, IActionConstants.NEW_CONNECTION_POINT);
        if (view != null) {
            ConnectionPageSettings pageSettings = new ConnectionPageSettings(NewConnectionWizard.this, view);
            settingsPages.put(provider, pageSettings);
            addPage(pageSettings);
        }
    }
    pageGeneral = new ConnectionPageGeneral(this);
    // pageNetwork = new ConnectionPageNetwork(this);
    addPage(pageGeneral);
    // Initial settings
    if (selection != null && !selection.isEmpty()) {
        final Object element = selection.getFirstElement();
        if (element instanceof DBNLocalFolder) {
            pageGeneral.setDataSourceFolder(((DBNLocalFolder) element).getFolder());
        }
    }
}
Also used : DBNLocalFolder(org.jkiss.dbeaver.model.navigator.DBNLocalFolder) DataSourceViewDescriptor(org.jkiss.dbeaver.registry.DataSourceViewDescriptor) DBPDataSourceProviderDescriptor(org.jkiss.dbeaver.model.connection.DBPDataSourceProviderDescriptor)

Aggregations

DBPDataSourceProviderDescriptor (org.jkiss.dbeaver.model.connection.DBPDataSourceProviderDescriptor)22 DBPDriver (org.jkiss.dbeaver.model.connection.DBPDriver)14 GridData (org.eclipse.swt.layout.GridData)10 ArrayList (java.util.ArrayList)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 DBPNamedObject (org.jkiss.dbeaver.model.DBPNamedObject)6 BaseDialog (org.jkiss.dbeaver.ui.dialogs.BaseDialog)6 List (java.util.List)4 IDialogConstants (org.eclipse.jface.dialogs.IDialogConstants)4 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)4 org.eclipse.jface.viewers (org.eclipse.jface.viewers)4 SWT (org.eclipse.swt.SWT)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 Composite (org.eclipse.swt.widgets.Composite)4 Shell (org.eclipse.swt.widgets.Shell)4 DBPImage (org.jkiss.dbeaver.model.DBPImage)4 DBUtils (org.jkiss.dbeaver.model.DBUtils)4 DataSourceProviderDescriptor (org.jkiss.dbeaver.registry.DataSourceProviderDescriptor)4 DriverDescriptor (org.jkiss.dbeaver.registry.driver.DriverDescriptor)4