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;
}
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;
}
Aggregations