Search in sources :

Example 1 with DBPDataSourceProviderDescriptor

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

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)

Example 2 with DBPDataSourceProviderDescriptor

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

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 3 with DBPDataSourceProviderDescriptor

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

the class DriverTreeViewer method collectDrivers.

private Collection<Object> collectDrivers() {
    for (DriverCategory category : categories.values()) {
        category.drivers.clear();
    }
    driverList.clear();
    for (DBPDataSourceProviderDescriptor provider : providers) {
        List<? extends DBPDriver> drivers = provider.getEnabledDrivers();
        for (DBPDriver driver : drivers) {
            String category = driver.getCategory();
            if (CommonUtils.isEmpty(category)) {
                driverList.add(driver);
            } else {
                DriverCategory driverCategory = categories.get(category);
                if (driverCategory == null) {
                    driverCategory = new DriverCategory(category);
                    categories.put(category, driverCategory);
                }
                if (!driverList.contains(driverCategory)) {
                    driverList.add(driverCategory);
                }
                driverCategory.drivers.add((DriverDescriptor) driver);
            }
        }
    }
    driverList.sort((o1, o2) -> {
        int count1 = getConnectionCount(o1);
        int count2 = getConnectionCount(o2);
        if (sortByName || count1 == count2) {
            String name1 = o1 instanceof DriverDescriptor ? ((DriverDescriptor) o1).getName() : ((DriverCategory) o1).getName();
            String name2 = o2 instanceof DriverDescriptor ? ((DriverDescriptor) o2).getName() : ((DriverCategory) o2).getName();
            return name1.compareToIgnoreCase(name2);
        } else {
            return count2 - count1;
        }
    });
    for (DriverCategory category : categories.values()) {
        category.drivers.sort((o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()));
    }
    return driverList;
}
Also used : DriverDescriptor(org.jkiss.dbeaver.registry.driver.DriverDescriptor) DBPDriver(org.jkiss.dbeaver.model.connection.DBPDriver) DBPDataSourceProviderDescriptor(org.jkiss.dbeaver.model.connection.DBPDataSourceProviderDescriptor)

Example 4 with DBPDataSourceProviderDescriptor

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

the class DriverManagerDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    List<DBPDataSourceProviderDescriptor> enabledProviders = DataSourceProviderRegistry.getInstance().getEnabledDataSourceProviders();
    {
        DBPDataSourceProviderDescriptor manProvider = null;
        for (DBPDataSourceProviderDescriptor provider : DataSourceProviderRegistry.getInstance().getEnabledDataSourceProviders()) {
            if (provider.isDriversManagable()) {
                if (manProvider != null) {
                    manProvider = null;
                    break;
                }
                manProvider = provider;
            }
        }
        if (manProvider != null) {
            onlyManagableProvider = (DataSourceProviderDescriptor) manProvider;
        }
    }
    getShell().setText(UIConnectionMessages.dialog_driver_manager_title);
    getShell().setMinimumSize(300, 300);
    dialogImage = DBeaverIcons.getImageDescriptor(UIIcon.DRIVER_MANAGER);
    getShell().setImage(dialogImage.createImage());
    Composite group = UIUtils.createPlaceholder((Composite) super.createDialogArea(parent), 2);
    group.setLayoutData(new GridData(GridData.FILL_BOTH));
    {
        treeControl = new DriverSelectViewer(group, this, enabledProviders, false, true);
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.heightHint = 300;
        gd.widthHint = 300;
        treeControl.getControl().setLayoutData(gd);
    }
    {
        Composite buttonBar = new Composite(group, SWT.TOP);
        buttonBar.setLayout(new GridLayout(1, false));
        GridData gd = new GridData(GridData.FILL_VERTICAL);
        buttonBar.setLayoutData(gd);
        newButton = UIUtils.createPushButton(buttonBar, UIConnectionMessages.dialog_driver_manager_button_new, null, new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                createDriver();
            }
        });
        newButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        copyButton = UIUtils.createPushButton(buttonBar, UIConnectionMessages.dialog_driver_manager_button_copy, null, new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                copyDriver();
            }
        });
        copyButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        editButton = UIUtils.createPushButton(buttonBar, UIConnectionMessages.dialog_driver_manager_button_edit, null, new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                editDriver();
            }
        });
        editButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        deleteButton = UIUtils.createPushButton(buttonBar, UIConnectionMessages.dialog_driver_manager_button_delete, null, new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                deleteDriver();
            }
        });
        deleteButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        Button unDeleteButton = UIUtils.createPushButton(buttonBar, "Un-delete", null, new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (undeleteDrivers()) {
                    treeControl.refresh();
                }
            }
        });
        unDeleteButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        {
            final Composite legend = UIUtils.createPlaceholder(buttonBar, 2, 5);
            gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.verticalIndent = 5;
            gd.horizontalSpan = 2;
            legend.setLayoutData(gd);
            UIUtils.createLabel(legend, DBIcon.OVER_LAMP);
            UIUtils.createLabel(legend, UIConnectionMessages.dialog_driver_manager_label_user_defined);
            UIUtils.createLabel(legend, DBIcon.OVER_ERROR);
            UIUtils.createLabel(legend, UIConnectionMessages.dialog_driver_manager_label_unavailable);
        }
        if (SHOW_EXPORT) {
            UIUtils.createPushButton(buttonBar, "Export", null, new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    exportDriverList();
                }
            });
        }
    }
    descText = new Text(group, SWT.READ_ONLY);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.verticalIndent = 5;
    gd.horizontalSpan = 2;
    gd.grabExcessHorizontalSpace = true;
    descText.setLayoutData(gd);
    /*
        monitorPart = new ProgressMonitorPart(group, null, true);
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.verticalIndent = 5;
        gd.horizontalSpan = 2;
        gd.grabExcessHorizontalSpace = true;
        monitorPart.setLayoutData(gd);
        monitorPart.setVisible(false);
*/
    setDefaultSelection();
    this.updateButtons();
    return group;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DataSourceProviderDescriptor(org.jkiss.dbeaver.registry.DataSourceProviderDescriptor) DBPDataSourceProviderDescriptor(org.jkiss.dbeaver.model.connection.DBPDataSourceProviderDescriptor) DBPDataSourceProviderDescriptor(org.jkiss.dbeaver.model.connection.DBPDataSourceProviderDescriptor)

Example 5 with DBPDataSourceProviderDescriptor

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

the class DriverUtils method getAllDrivers.

public static List<DBPDriver> getAllDrivers() {
    List<? extends DBPDataSourceProviderDescriptor> providers = DBWorkbench.getPlatform().getDataSourceProviderRegistry().getEnabledDataSourceProviders();
    List<DBPDriver> allDrivers = new ArrayList<>();
    for (DBPDataSourceProviderDescriptor dpd : providers) {
        allDrivers.addAll(dpd.getEnabledDrivers());
    }
    allDrivers.sort(Comparator.comparing(DBPNamedObject::getName));
    return allDrivers;
}
Also used : DBPDriver(org.jkiss.dbeaver.model.connection.DBPDriver) ArrayList(java.util.ArrayList) 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