Search in sources :

Example 21 with DBPDataSourceProviderDescriptor

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

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

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

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