use of org.jkiss.dbeaver.registry.DataSourceDescriptor in project dbeaver by serge-rider.
the class ConnectionPageSettings method activatePage.
@Override
public void activatePage() {
if (connectionEditor == null) {
createProviderPage(getControl().getParent());
//UIUtils.resizeShell(getWizard().getContainer().getShell());
}
setMessage(NLS.bind(CoreMessages.dialog_connection_message, getDriver().getFullName()));
DataSourceDescriptor connectionInfo = getActiveDataSource();
if (!activated.contains(connectionInfo)) {
if (this.connectionEditor != null) {
this.connectionEditor.loadSettings();
}
if (subPages != null) {
for (IDialogPage page : subPages) {
Control pageControl = page.getControl();
// }
if (pageControl != null && page instanceof IDataSourceConnectionEditor) {
((IDataSourceConnectionEditor) page).loadSettings();
}
}
}
activated.add(connectionInfo);
} else if (connectionEditor != null) {
connectionEditor.loadSettings();
}
activateCurrentItem();
getContainer().updateTitleBar();
}
use of org.jkiss.dbeaver.registry.DataSourceDescriptor in project dbeaver by serge-rider.
the class DriverPropertiesDialogPage method setVisible.
@Override
public void setVisible(boolean visible) {
super.setVisible(visible);
// Set props model
if (visible && propsControl != null) {
final DBPDataSourceContainer activeDataSource = site.getActiveDataSource();
if (prevConnectionInfo == activeDataSource.getConnectionConfiguration()) {
return;
}
final DBPConnectionConfiguration tmpConnectionInfo = new DBPConnectionConfiguration();
final DataSourceDescriptor tempDataSource = new DataSourceDescriptor(site.getDataSourceRegistry(), activeDataSource.getId(), (DriverDescriptor) activeDataSource.getDriver(), tmpConnectionInfo);
hostPage.saveSettings(tempDataSource);
tmpConnectionInfo.getProperties().putAll(activeDataSource.getConnectionConfiguration().getProperties());
try {
getSite().getRunnableContext().run(true, true, new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Loading driver properties", 1);
try {
propertySource = propsControl.makeProperties(monitor, site.getDriver(), tmpConnectionInfo);
} finally {
monitor.done();
}
}
});
} catch (InvocationTargetException e) {
setErrorMessage(e.getTargetException().getMessage());
} catch (InterruptedException e) {
// ignore
}
propsControl.loadProperties(propertySource);
prevConnectionInfo = activeDataSource.getConnectionConfiguration();
tempDataSource.dispose();
}
}
use of org.jkiss.dbeaver.registry.DataSourceDescriptor in project dbeaver by serge-rider.
the class NewConnectionWizard method performFinish.
/**
* This method is called when 'Finish' button is pressed in
* the wizard. We will create an operation and run it
* using wizard as execution context.
*/
@Override
public boolean performFinish() {
DriverDescriptor driver = getSelectedDriver();
ConnectionPageSettings pageSettings = getPageSettings();
DataSourceDescriptor dataSourceTpl = pageSettings == null ? getActiveDataSource() : pageSettings.getActiveDataSource();
DBPDataSourceRegistry dataSourceRegistry = getDataSourceRegistry();
DataSourceDescriptor dataSourceNew = new DataSourceDescriptor(dataSourceRegistry, dataSourceTpl.getId(), driver, dataSourceTpl.getConnectionConfiguration());
dataSourceNew.copyFrom(dataSourceTpl);
saveSettings(dataSourceNew);
dataSourceRegistry.addDataSource(dataSourceNew);
return true;
}
use of org.jkiss.dbeaver.registry.DataSourceDescriptor in project dbeaver by serge-rider.
the class DriverManagerDialog method deleteDriver.
private void deleteDriver() {
List<DataSourceDescriptor> usedDS = selectedDriver.getUsedBy();
if (!usedDS.isEmpty()) {
StringBuilder message = new StringBuilder(NLS.bind(CoreMessages.dialog_driver_manager_message_cant_delete_text, selectedDriver.getName()));
for (DataSourceDescriptor ds : usedDS) {
message.append("\n - ").append(ds.getName());
}
UIUtils.showMessageBox(getShell(), CoreMessages.dialog_driver_manager_message_cant_delete_title, message.toString(), SWT.ICON_ERROR);
return;
}
if (UIUtils.confirmAction(getShell(), CoreMessages.dialog_driver_manager_message_delete_driver_title, CoreMessages.dialog_driver_manager_message_delete_driver_text + selectedDriver.getName() + "'?")) {
selectedDriver.getProviderDescriptor().removeDriver(selectedDriver);
selectedDriver.getProviderDescriptor().getRegistry().saveDrivers();
treeControl.getViewer().refresh();
}
}
use of org.jkiss.dbeaver.registry.DataSourceDescriptor in project dbeaver by serge-rider.
the class ScriptsImportWizardPage method createControl.
@Override
public void createControl(Composite parent) {
String externalDir = DBeaverCore.getGlobalPreferenceStore().getString(ScriptsExportWizardPage.PREF_SCRIPTS_EXPORT_OUT_DIR);
if (CommonUtils.isEmpty(externalDir)) {
externalDir = RuntimeUtils.getUserHomeDir().getAbsolutePath();
}
Composite placeholder = UIUtils.createPlaceholder(parent, 1);
placeholder.setLayout(new GridLayout(1, false));
// Input settings
Composite generalSettings = UIUtils.createPlaceholder(placeholder, 3);
generalSettings.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
{
UIUtils.createControlLabel(generalSettings, CoreMessages.dialog_scripts_import_wizard_label_input_directory);
directoryText = new Text(generalSettings, SWT.BORDER);
directoryText.setText(externalDir);
directoryText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
directoryText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
updateState();
}
});
Button openFolder = new Button(generalSettings, SWT.PUSH);
openFolder.setImage(DBeaverIcons.getImage(DBIcon.TREE_FOLDER));
openFolder.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE);
dialog.setMessage(CoreMessages.dialog_scripts_import_wizard_dialog_choose_dir_message);
dialog.setText(CoreMessages.dialog_scripts_import_wizard_dialog_choose_dir_text);
String directory = directoryText.getText();
if (!CommonUtils.isEmpty(directory)) {
dialog.setFilterPath(directory);
}
directory = dialog.open();
if (directory != null) {
directoryText.setText(directory);
}
}
});
//$NON-NLS-2$
extensionsText = UIUtils.createLabelText(generalSettings, CoreMessages.dialog_scripts_import_wizard_label_file_mask, "*.sql,*.txt");
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
extensionsText.setLayoutData(gd);
UIUtils.createControlLabel(generalSettings, CoreMessages.dialog_scripts_import_wizard_label_default_connection);
scriptsDataSources = new CSmartCombo<>(generalSettings, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY, new ConnectionLabelProvider());
for (DataSourceDescriptor dataSourceDescriptor : DataSourceRegistry.getAllDataSources()) {
scriptsDataSources.addItem(dataSourceDescriptor);
}
if (scriptsDataSources.getItemCount() > 0) {
scriptsDataSources.select(0);
}
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
gd.verticalIndent = 2;
scriptsDataSources.setLayoutData(gd);
}
UIUtils.createControlLabel(placeholder, CoreMessages.dialog_scripts_import_wizard_label_root_folder);
importRoot = DBeaverCore.getInstance().getNavigatorModel().getRoot();
final DatabaseNavigatorTree scriptsNavigator = new DatabaseNavigatorTree(placeholder, importRoot, SWT.BORDER | SWT.SINGLE, false);
scriptsNavigator.setLayoutData(new GridData(GridData.FILL_BOTH));
scriptsNavigator.getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
if (sel == null || sel.isEmpty()) {
importRoot = null;
} else {
importRoot = (DBNNode) sel.getFirstElement();
}
updateState();
}
});
scriptsNavigator.getViewer().addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return element instanceof DBNResource && ((DBNResource) element).getResource() instanceof IContainer;
}
});
scriptsNavigator.getViewer().expandToLevel(2);
overwriteCheck = UIUtils.createCheckbox(placeholder, CoreMessages.dialog_project_export_wizard_page_checkbox_overwrite_files, false);
GridData gd = new GridData(GridData.BEGINNING);
gd.horizontalSpan = 3;
overwriteCheck.setLayoutData(gd);
setControl(placeholder);
updateState();
}
Aggregations