use of org.jkiss.dbeaver.ui.controls.CSmartCombo in project dbeaver by dbeaver.
the class ExasolCreateForeignKeyDialog method createSchemaSelector.
private void createSchemaSelector(Composite tableGroup) throws DBException {
// Here is a trick - we need to find schema/catalog container node and list its children
DBNDatabaseNode schemaContainerNode = null;
for (DBNNode node = ownerTableNode.getParentNode(); node != null; node = node.getParentNode()) {
if (node instanceof DBNDatabaseNode) {
DBSObject nodeObject = ((DBNDatabaseNode) node).getObject();
if (nodeObject instanceof DBSSchema || nodeObject instanceof DBSCatalog) {
if (node.getParentNode() instanceof DBNDatabaseNode) {
schemaContainerNode = (DBNDatabaseNode) node.getParentNode();
break;
}
}
}
}
if (schemaContainerNode != null) {
ILabelProvider labelProvider = new LabelProvider() {
@Override
public Image getImage(Object element) {
return DBeaverIcons.getImage(((DBNDatabaseNode) element).getNodeIcon());
}
@Override
public String getText(Object element) {
return ((DBNDatabaseNode) element).getNodeName();
}
};
boolean isSchema = (ownTable.getParentObject() instanceof DBSSchema);
DBPDataSourceInfo dsInfo = ownTable.getDataSource().getInfo();
UIUtils.createControlLabel(tableGroup, isSchema ? dsInfo.getSchemaTerm() : dsInfo.getCatalogTerm());
final CSmartCombo<DBNDatabaseNode> schemaCombo = new CSmartCombo<>(tableGroup, SWT.BORDER, labelProvider);
schemaCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
DBNDatabaseNode selectedNode = null;
for (DBNNode node : schemaContainerNode.getChildren(new VoidProgressMonitor())) {
if (node instanceof DBNDatabaseNode && ((DBNDatabaseNode) node).getObject() instanceof DBSObjectContainer) {
schemaCombo.addItem((DBNDatabaseNode) node);
if (((DBNDatabaseNode) node).getObject() == ownTable.getParentObject()) {
selectedNode = (DBNDatabaseNode) node;
}
}
}
if (selectedNode != null) {
schemaCombo.select(selectedNode);
}
schemaCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// Here is another trick
// We need to find table container node
// This node is a child of schema node and has the same meta as our original table parent node
DBNDatabaseNode newContainerNode = null;
DBXTreeNode tableContainerMeta = ((DBNDatabaseNode) ownerTableNode.getParentNode()).getMeta();
DBNDatabaseNode schemaNode = schemaCombo.getSelectedItem();
if (schemaNode.getMeta() == tableContainerMeta) {
newContainerNode = schemaNode;
} else {
try {
for (DBNNode child : schemaNode.getChildren(new VoidProgressMonitor())) {
if (child instanceof DBNDatabaseNode && ((DBNDatabaseNode) child).getMeta() == tableContainerMeta) {
newContainerNode = (DBNDatabaseNode) child;
break;
}
}
} catch (DBException e1) {
log.debug(e1);
// Shouldn't be here
}
}
if (newContainerNode != null) {
tableList.setRootNode(newContainerNode);
tableList.loadData();
}
}
});
}
}
use of org.jkiss.dbeaver.ui.controls.CSmartCombo 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;
}
use of org.jkiss.dbeaver.ui.controls.CSmartCombo in project dbeaver by serge-rider.
the class ConnectionPageGeneral method createControl.
@Override
public void createControl(Composite parent) {
boldFont = UIUtils.makeBoldFont(parent.getFont());
Composite group = UIUtils.createComposite(parent, 1);
{
Composite miscGroup = UIUtils.createControlGroup(group, CoreMessages.pref_page_ui_general_group_general, 2, GridData.FILL_HORIZONTAL, 0);
// $NON-NLS-1$
String connectionName = dataSourceDescriptor == null ? "" : dataSourceDescriptor.getName();
connectionNameText = UIUtils.createLabelText(miscGroup, CoreMessages.dialog_connection_wizard_final_label_connection_name, CommonUtils.toString(connectionName));
connectionNameText.addModifyListener(e -> {
connectionNameChanged = true;
ConnectionPageGeneral.this.getContainer().updateButtons();
});
{
UIUtils.createControlLabel(miscGroup, CoreMessages.dialog_connection_wizard_final_label_connection_type);
Composite ctGroup = UIUtils.createComposite(miscGroup, 2);
connectionTypeCombo = new CSmartCombo<>(ctGroup, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY, new ConnectionTypeLabelProvider());
loadConnectionTypes();
connectionTypeCombo.select(0);
connectionTypeCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DBPConnectionType type = connectionTypeCombo.getItem(connectionTypeCombo.getSelectionIndex());
getWizard().firePropertyChangeEvent(ConnectionWizard.PROP_CONNECTION_TYPE, getActiveDataSource().getConnectionConfiguration().getConnectionType(), type);
}
});
final GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.widthHint = UIUtils.getFontHeight(connectionTypeCombo) * 20;
connectionTypeCombo.setLayoutData(gd);
UIUtils.createDialogButton(ctGroup, CoreMessages.dialog_connection_wizard_final_label_connection_types_edit, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DBPConnectionType curConType = connectionTypeCombo.getSelectedItem();
DataSourceDescriptor dataSource = getActiveDataSource();
UIUtils.showPreferencesFor(getControl().getShell(), dataSource.getConnectionConfiguration().getConnectionType(), PrefPageConnectionTypes.PAGE_ID);
loadConnectionTypes();
if (!connectionTypeCombo.getItems().contains(curConType)) {
curConType = connectionTypeCombo.getItems().get(0);
}
connectionTypeCombo.select(curConType);
getWizard().firePropertyChangeEvent(ConnectionWizard.PROP_CONNECTION_TYPE, curConType, curConType);
}
});
}
{
UIUtils.createControlLabel(miscGroup, CoreMessages.dialog_connection_wizard_final_label_navigator_settings);
Composite ctGroup = UIUtils.createComposite(miscGroup, 2);
navigatorSettingsCombo = new Combo(ctGroup, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
final GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.widthHint = UIUtils.getFontHeight(navigatorSettingsCombo) * 20;
navigatorSettingsCombo.setLayoutData(gd);
for (String ncPresetName : DataSourceNavigatorSettings.PRESETS.keySet()) {
navigatorSettingsCombo.add(ncPresetName);
}
navigatorSettingsCombo.select(0);
navigatorSettingsCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (navigatorSettingsCombo.getSelectionIndex() == navigatorSettingsCombo.getItemCount() - 1) {
// Custom - no changes
} else {
DataSourceNavigatorSettings.Preset newSettings = DataSourceNavigatorSettings.PRESETS.get(navigatorSettingsCombo.getText());
if (newSettings == null) {
throw new IllegalStateException("Invalid preset name: " + navigatorSettingsCombo.getText());
}
ConnectionPageGeneral.this.navigatorSettings = newSettings.getSettings();
}
}
});
UIUtils.createDialogButton(ctGroup, CoreMessages.dialog_connection_wizard_final_label_navigator_settings_customize, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
editNavigatorSettings();
}
});
}
{
UIUtils.createControlLabel(miscGroup, CoreMessages.dialog_connection_wizard_final_label_connection_folder);
connectionFolderCombo = new Combo(miscGroup, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.widthHint = UIUtils.getFontHeight(connectionFolderCombo) * 20;
connectionFolderCombo.setLayoutData(gd);
loadConnectionFolders();
connectionFolderCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dataSourceFolder = connectionFolders.get(connectionFolderCombo.getSelectionIndex());
}
});
}
{
Label descLabel = UIUtils.createControlLabel(miscGroup, CoreMessages.dialog_connection_wizard_description);
descLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
descriptionText = new Text(miscGroup, SWT.BORDER | SWT.V_SCROLL | SWT.WRAP | SWT.MULTI);
final GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = descriptionText.getLineHeight() * 3;
descriptionText.setLayoutData(gd);
}
}
Composite refsGroup = UIUtils.createComposite(group, 3);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
refsGroup.setLayoutData(gd);
{
// Security
Group securityGroup = UIUtils.createControlGroup(refsGroup, CoreMessages.dialog_connection_wizard_final_group_security, 1, GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
readOnlyConnection = UIUtils.createCheckbox(securityGroup, CoreMessages.dialog_connection_wizard_final_checkbox_connection_readonly, dataSourceDescriptor != null && dataSourceDescriptor.isConnectionReadOnly());
readOnlyConnection.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
UIUtils.createDialogButton(securityGroup, "Edit permissions ...", new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
editPermissions();
}
});
}
{
// Filters
filtersGroup = UIUtils.createControlGroup(refsGroup, CoreMessages.dialog_connection_wizard_final_group_filters, 1, GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
for (final FilterInfo filterInfo : filters) {
filterInfo.link = UIUtils.createLink(filtersGroup, "<a>" + filterInfo.title + "</a>", new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
EditObjectFilterDialog dialog = new EditObjectFilterDialog(getShell(), getWizard().getDataSourceRegistry(), filterInfo.title, filterInfo.filter != null ? filterInfo.filter : new DBSObjectFilter(), true);
if (dialog.open() == IDialogConstants.OK_ID) {
filterInfo.filter = dialog.getFilter();
if (filterInfo.filter != null && !filterInfo.filter.isNotApplicable()) {
filterInfo.link.setFont(boldFont);
} else {
filterInfo.link.setFont(getFont());
}
}
}
});
filterInfo.link.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
}
{
Composite linkGroup = UIUtils.createComposite(refsGroup, 1);
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalSpan = 2;
linkGroup.setLayoutData(gd);
Link initConfigLink = new Link(linkGroup, SWT.NONE);
initConfigLink.setText("<a>" + CoreMessages.dialog_connection_wizard_connection_init_description + "</a>");
initConfigLink.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (getWizard().isNew()) {
DataSourceDescriptor dataSource = getActiveDataSource();
EditWizardPageDialog dialog = new EditWizardPageDialog(getWizard(), new ConnectionPageInitialization(dataSource), dataSource);
dialog.open();
} else {
getWizard().openSettingsPage(ConnectionPageInitialization.PAGE_NAME);
}
}
});
initConfigLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
Link shellConfigLink = new Link(linkGroup, SWT.NONE);
shellConfigLink.setText("<a>" + CoreMessages.dialog_connection_edit_wizard_shell_cmd + "</a>");
shellConfigLink.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (getWizard().isNew()) {
DataSourceDescriptor dataSource = getActiveDataSource();
EditWizardPageDialog dialog = new EditWizardPageDialog(getWizard(), new ConnectionPageShellCommands(dataSource), dataSource);
dialog.open();
} else {
getWizard().openSettingsPage(ConnectionPageShellCommands.PAGE_NAME);
}
}
});
shellConfigLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
}
setControl(group);
UIUtils.setHelp(group, IHelpContextIds.CTX_CON_WIZARD_FINAL);
}
use of org.jkiss.dbeaver.ui.controls.CSmartCombo in project dbeaver by serge-rider.
the class DataSourceManagementToolbar method createControl.
Control createControl(Composite parent) {
workbenchWindow.addPageListener(pageListener);
IWorkbenchPage activePage = workbenchWindow.getActivePage();
if (activePage != null) {
pageListener.pageOpened(activePage);
}
// Register as datasource listener in all datasources
// We need it because at this moment there could be come already loaded registries (on startup)
DataSourceProviderRegistry.getInstance().addDataSourceRegistryListener(DataSourceManagementToolbar.this);
for (DataSourceRegistry registry : DataSourceRegistry.getAllRegistries()) {
handleRegistryLoad(registry);
}
Composite comboGroup = new Composite(parent, SWT.NONE);
RowLayout layout = new RowLayout(SWT.HORIZONTAL);
layout.marginTop = 0;
layout.marginBottom = 0;
layout.marginWidth = 5;
layout.marginHeight = 0;
comboGroup.setLayout(layout);
final int fontHeight = UIUtils.getFontHeight(parent);
int comboWidth = fontHeight * 20;
connectionCombo = new CSmartCombo<>(comboGroup, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER, new ConnectionLabelProvider());
RowData rd = new RowData();
rd.width = comboWidth;
connectionCombo.setLayoutData(rd);
connectionCombo.setVisibleItemCount(15);
connectionCombo.setWidthHint(comboWidth);
connectionCombo.setToolTipText(CoreMessages.toolbar_datasource_selector_combo_datasource_tooltip);
connectionCombo.addItem(null);
connectionCombo.select(0);
connectionCombo.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
changeDataSourceSelection();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
connectionCombo.setTableFilter(new CSmartCombo.TableFilter<DBPDataSourceContainer>() {
boolean enabled = false;
@Override
public String getFilterLabel() {
return "Connected";
}
@Override
public String getDefaultLabel() {
return "All";
}
@Override
public boolean isEnabled() {
return enabled;
}
@Override
public boolean setEnabled(boolean enabled) {
this.enabled = enabled;
return enabled;
}
@Override
public boolean filter(DBPDataSourceContainer item) {
return item != null && item.isConnected();
}
});
comboWidth = fontHeight * 16;
databaseCombo = new CSmartCombo<>(comboGroup, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER, new DatabaseLabelProvider());
rd = new RowData();
rd.width = comboWidth;
databaseCombo.setLayoutData(rd);
databaseCombo.setVisibleItemCount(15);
databaseCombo.setWidthHint(comboWidth);
databaseCombo.setToolTipText(CoreMessages.toolbar_datasource_selector_combo_database_tooltip);
databaseCombo.addItem(null);
databaseCombo.select(0);
databaseCombo.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
changeDataBaseSelection();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
resultSetSize = new Text(comboGroup, SWT.BORDER);
resultSetSize.setTextLimit(10);
rd = new RowData();
rd.width = fontHeight * 4;
resultSetSize.setLayoutData(rd);
resultSetSize.setToolTipText(CoreMessages.toolbar_datasource_selector_resultset_segment_size);
final DBPDataSourceContainer dataSourceContainer = getDataSourceContainer();
if (dataSourceContainer != null) {
resultSetSize.setText(String.valueOf(dataSourceContainer.getPreferenceStore().getInt(DBeaverPreferences.RESULT_SET_MAX_ROWS)));
}
//resultSetSize.setDigits(7);
resultSetSize.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.getDefault()));
resultSetSize.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
@Override
public void focusLost(FocusEvent e) {
changeResultSetSize();
}
});
comboGroup.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
DataSourceManagementToolbar.this.dispose();
}
});
DBeaverUI.asyncExec(new Runnable() {
@Override
public void run() {
if (workbenchWindow != null && workbenchWindow.getActivePage() != null) {
setActivePart(workbenchWindow.getActivePage().getActivePart());
}
}
});
return comboGroup;
}
use of org.jkiss.dbeaver.ui.controls.CSmartCombo in project dbeaver by serge-rider.
the class ScriptsImportWizardPage method createControl.
@Override
public void createControl(Composite parent) {
String externalDir = DBWorkbench.getPlatform().getPreferenceStore().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 (DBPDataSourceContainer 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 = DBWorkbench.getPlatform().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