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