use of org.jkiss.dbeaver.registry.DataSourceProviderDescriptor in project dbeaver by serge-rider.
the class DataTypeProviderRegistry method findTransformers.
@Override
public List<AttributeTransformerDescriptor> findTransformers(DBPDataSource dataSource, DBSTypedObject typedObject, Boolean custom) {
DBPDriver driver = dataSource.getContainer().getDriver();
if (!(driver instanceof DriverDescriptor)) {
log.warn("Bad datasource specified (driver is not recognized by registry) - " + dataSource);
return null;
}
DataSourceProviderDescriptor dsProvider = ((DriverDescriptor) driver).getProviderDescriptor();
// Find in default providers
List<AttributeTransformerDescriptor> result = null;
for (AttributeTransformerDescriptor descriptor : dataTypeTransformers) {
if ((custom == null || custom == descriptor.isCustom()) && ((!descriptor.isGlobal() && descriptor.supportsDataSource(dataSource, dsProvider) && descriptor.supportsType(typedObject)) || (descriptor.isGlobal() && descriptor.supportsType(typedObject)))) {
if (result == null) {
result = new ArrayList<>();
}
result.add(descriptor);
}
}
return result;
}
use of org.jkiss.dbeaver.registry.DataSourceProviderDescriptor in project dbeaver by dbeaver.
the class SQLContextTypeRegistry method loadContextTypes.
private void loadContextTypes() {
addContextType(new SQLContextTypeBase());
for (DataSourceProviderDescriptor provider : DataSourceProviderRegistry.getInstance().getDataSourceProviders()) {
if (!provider.isDriversManagable()) {
SQLContextTypeProvider contextType = new SQLContextTypeProvider(provider);
addContextType(contextType);
provider.loadTemplateVariableResolvers(contextType);
} else {
Set<String> categoriesAdded = new HashSet<>();
for (DriverDescriptor 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.registry.DataSourceProviderDescriptor in project dbeaver by dbeaver.
the class NewConnectionWizard method addPages.
/**
* Adding the page to the wizard.
*/
@Override
public void addPages() {
pageDrivers = new ConnectionPageDriver(this);
addPage(pageDrivers);
for (DataSourceProviderDescriptor provider : DataSourceProviderRegistry.getInstance().getEnabledDataSourceProviders()) {
availableProvides.add(provider);
DataSourceViewDescriptor view = provider.getView(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);
addPage(pageNetwork);
// Initial settings
if (selection != null && !selection.isEmpty()) {
final Object element = selection.getFirstElement();
if (element instanceof DBNLocalFolder) {
pageGeneral.setDataSourceFolder(((DBNLocalFolder) element).getFolder());
}
}
}
use of org.jkiss.dbeaver.registry.DataSourceProviderDescriptor in project dbeaver by serge-rider.
the class WorkbenchInitializerCreateSampleDatabase method createSampleDatabase.
static void createSampleDatabase(DBPDataSourceRegistry dsRegistry) {
DataSourceDescriptor dataSource = (DataSourceDescriptor) dsRegistry.getDataSource(SAMPLE_DB1_ID);
if (dataSource != null) {
return;
}
DataSourceProviderDescriptor genericDSProvider = DataSourceProviderRegistry.getInstance().getDataSourceProvider("generic");
if (genericDSProvider == null) {
log.error("Can't find generic data source provider");
return;
}
DriverDescriptor sqliteDriver = genericDSProvider.getDriver("sqlite_jdbc");
if (sqliteDriver == null) {
log.error("Can't find SQLite driver is generic provider");
return;
}
// Extract bundled database to workspace metadata
File dbFolder = new File(GeneralUtils.getMetadataFolder(), SAMPLE_DB1_FOLDER);
if (!dbFolder.exists()) {
if (!dbFolder.mkdirs()) {
log.error("Can't create target database folder " + dbFolder.getAbsolutePath());
return;
}
}
File dbFile = new File(dbFolder, SAMPLE_DB_FILE_NAME);
try (InputStream is = WorkbenchInitializerCreateSampleDatabase.class.getClassLoader().getResourceAsStream(SAMPLE_DB_SOURCE_PATH)) {
try (OutputStream os = new FileOutputStream(dbFile)) {
IOUtils.copyStream(is, os);
}
} catch (IOException e) {
log.error("Error extracting sample database to workspace", e);
return;
}
DBPConnectionConfiguration connectionInfo = new DBPConnectionConfiguration();
connectionInfo.setDatabaseName(dbFile.getAbsolutePath());
connectionInfo.setConnectionType(DBPConnectionType.DEV);
connectionInfo.setUrl(genericDSProvider.getInstance(sqliteDriver).getConnectionURL(sqliteDriver, connectionInfo));
dataSource = new DataSourceDescriptor(dsRegistry, SAMPLE_DB1_ID, sqliteDriver, connectionInfo);
dataSource.setSavePassword(true);
dataSource.getNavigatorSettings().setShowSystemObjects(true);
dataSource.setName("DBeaver Sample Database (SQLite)");
dsRegistry.addDataSource(dataSource);
}
use of org.jkiss.dbeaver.registry.DataSourceProviderDescriptor in project dbeaver by serge-rider.
the class DriverEditDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
if (newDriver) {
getShell().setText(UIConnectionMessages.dialog_edit_driver_title_create_driver);
} else {
// $NON-NLS-2$
getShell().setText(UIConnectionMessages.dialog_edit_driver_title_edit_driver + driver.getName() + "'");
getShell().setImage(DBeaverIcons.getImage(driver.getPlainIcon()));
}
boolean isReadOnly = !provider.isDriversManagable();
int advStyle = isReadOnly ? SWT.READ_ONLY : SWT.NONE;
final Composite group = (Composite) super.createDialogArea(parent);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 500;
group.setLayoutData(gd);
{
Group propsGroup = UIUtils.createControlGroup(group, UIConnectionMessages.dialog_edit_driver_setting, 4, -1, -1);
propsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
gd = new GridData(GridData.FILL_HORIZONTAL);
driverNameText = UIUtils.createLabelText(propsGroup, UIConnectionMessages.dialog_edit_driver_label_driver_name, driver.getName(), SWT.BORDER | advStyle, gd);
driverNameText.setEnabled(driver == null || driver.isCustom());
driverNameText.addModifyListener(e -> onChangeProperty());
UIUtils.createControlLabel(propsGroup, UIConnectionMessages.dialog_edit_driver_type_label);
final CSmartCombo<DataSourceProviderDescriptor> providerCombo = new CSmartCombo<>(propsGroup, SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN, new LabelProvider() {
@Override
public Image getImage(Object element) {
return DBeaverIcons.getImage(((DataSourceProviderDescriptor) element).getIcon());
}
@Override
public String getText(Object element) {
return ((DataSourceProviderDescriptor) element).getName();
}
});
providerCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if (newDriver) {
for (DataSourceProviderDescriptor provider : DataSourceProviderRegistry.getInstance().getDataSourceProviders()) {
if (provider.isDriversManagable()) {
providerCombo.addItem(provider);
}
}
providerCombo.select(provider);
providerCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
provider = providerCombo.getItem(providerCombo.getSelectionIndex());
driver = provider.createDriver();
}
});
} else {
providerCombo.addItem(provider);
providerCombo.select(provider);
}
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 3;
driverClassText = UIUtils.createLabelText(propsGroup, UIConnectionMessages.dialog_edit_driver_label_class_name, CommonUtils.notEmpty(driver.getDriverClassName()), SWT.BORDER | advStyle, gd);
driverClassText.setToolTipText(UIConnectionMessages.dialog_edit_driver_label_class_name_tip);
driverClassText.addModifyListener(e -> onChangeProperty());
driverURLText = UIUtils.createLabelText(propsGroup, UIConnectionMessages.dialog_edit_driver_label_sample_url, CommonUtils.notEmpty(driver.getSampleURL()), SWT.BORDER | advStyle, gd);
driverURLText.setToolTipText(UIConnectionMessages.dialog_edit_driver_label_sample_url_tip);
driverURLText.addModifyListener(e -> onChangeProperty());
driverURLText.setEnabled(driver == null || driver.isUseURL());
driverPortText = UIUtils.createLabelText(propsGroup, UIConnectionMessages.dialog_edit_driver_label_default_port, CommonUtils.notEmpty(driver.getDefaultPort()), SWT.BORDER | advStyle);
driverPortText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
driverPortText.addModifyListener(e -> onChangeProperty());
driverDatabaseText = UIUtils.createLabelText(propsGroup, UIConnectionMessages.dialog_edit_driver_label_default_database, CommonUtils.notEmpty(driver.getDefaultDatabase()), SWT.BORDER | advStyle);
driverDatabaseText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
driverDatabaseText.addModifyListener(e -> onChangeProperty());
driverUserText = UIUtils.createLabelText(propsGroup, UIConnectionMessages.dialog_edit_driver_label_default_user, CommonUtils.notEmpty(driver.getDefaultUser()), SWT.BORDER | advStyle);
driverUserText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
driverUserText.addModifyListener(e -> onChangeProperty());
UIUtils.createEmptyLabel(propsGroup, 2, 1);
Composite optionsPanel = new Composite(propsGroup, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 4;
optionsPanel.setLayoutData(gd);
optionsPanel.setLayout(new RowLayout());
embeddedDriverCheck = UIUtils.createCheckbox(optionsPanel, UIConnectionMessages.dialog_edit_driver_embedded_label, UIConnectionMessages.dialog_edit_driver_embedded_tip, driver.isEmbedded(), 1);
anonymousDriverCheck = UIUtils.createCheckbox(optionsPanel, UIConnectionMessages.dialog_edit_driver_anonymous_label, UIConnectionMessages.dialog_edit_driver_anonymous_tip, driver.isAnonymousAccess(), 1);
allowsEmptyPasswordCheck = UIUtils.createCheckbox(optionsPanel, UIConnectionMessages.dialog_edit_driver_allows_empty_password_label, UIConnectionMessages.dialog_edit_driver_allows_empty_password_tip, driver.isAnonymousAccess(), 1);
nonInstantiableCheck = UIUtils.createCheckbox(optionsPanel, UIConnectionMessages.dialog_edit_driver_use_legacy_instantiation_label, UIConnectionMessages.dialog_edit_driver_use_legacy_instantiation_tip, !driver.isInstantiable(), 1);
if (isReadOnly) {
embeddedDriverCheck.setEnabled(false);
anonymousDriverCheck.setEnabled(false);
allowsEmptyPasswordCheck.setEnabled(false);
nonInstantiableCheck.setEnabled(false);
}
}
{
Group infoGroup = UIUtils.createControlGroup(group, UIConnectionMessages.dialog_edit_driver_description, 4, -1, -1);
infoGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
driverCategoryCombo = UIUtils.createLabelCombo(infoGroup, UIConnectionMessages.dialog_edit_driver_label_category, SWT.BORDER | SWT.DROP_DOWN | advStyle);
driverCategoryCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
if (isReadOnly) {
driverCategoryCombo.setEnabled(false);
}
Set<String> categories = new TreeSet<>();
for (DataSourceProviderDescriptor provider : DataSourceProviderRegistry.getInstance().getDataSourceProviders()) {
for (DBPDriver drv : provider.getEnabledDrivers()) {
if (!CommonUtils.isEmpty(drv.getCategory())) {
categories.add(drv.getCategory());
}
}
}
for (String category : categories) {
driverCategoryCombo.add(category);
}
if (!CommonUtils.isEmpty(driver.getCategory())) {
driverCategoryCombo.setText(driver.getCategory());
} else if (!CommonUtils.isEmpty(defaultCategory)) {
driverCategoryCombo.setText(defaultCategory);
}
{
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING);
Text idText = UIUtils.createLabelText(infoGroup, UIConnectionMessages.dialog_edit_driver_label_id, driver.getId(), SWT.BORDER | SWT.READ_ONLY, gd);
idText.setToolTipText(UIConnectionMessages.dialog_edit_driver_label_id_tip);
}
driverDescText = UIUtils.createLabelText(infoGroup, UIConnectionMessages.dialog_edit_driver_label_description, CommonUtils.notEmpty(driver.getDescription()), SWT.BORDER | advStyle);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 3;
driverDescText.setLayoutData(gd);
if (!CommonUtils.isEmpty(driver.getWebURL())) {
UIUtils.createControlLabel(infoGroup, UIConnectionMessages.dialog_edit_driver_label_website);
Link urlLabel = UIUtils.createLink(infoGroup, "<a>" + driver.getWebURL() + "</a>", new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
UIUtils.launchProgram(driver.getWebURL());
}
});
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 3;
driverDescText.setLayoutData(gd);
urlLabel.setLayoutData(gd);
}
}
{
TabFolder tabFolder = new TabFolder(group, SWT.NONE);
tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
createLibrariesTab(tabFolder);
createConnectionPropertiesTab(tabFolder);
createParametersTab(tabFolder);
// Client homes
if (driver.getNativeClientManager() != null) {
createClientHomesTab(tabFolder);
}
final String license = driver.getLicense();
if (license != null) {
createLicenseTab(tabFolder, license);
}
tabFolder.setSelection(0);
}
loadSettings(false);
if (showAddFiles) {
getShell().getDisplay().asyncExec(this::addLibraryFiles);
}
driverNameText.setFocus();
return group;
}
Aggregations