use of org.jkiss.dbeaver.ui.controls.VariablesHintLabel in project dbeaver by dbeaver.
the class EditBootstrapQueriesDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
getShell().setText(CoreMessages.dialog_connection_edit_wizard_general_bootstrap_query_title);
Composite composite = (Composite) super.createDialogArea(parent);
Group group = UIUtils.createControlGroup(composite, CoreMessages.dialog_connection_edit_wizard_general_bootstrap_query_sql_label, 2, GridData.FILL_BOTH, 0);
queriesTable = new Table(group, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
final GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 300;
gd.heightHint = 100;
queriesTable.setLayoutData(gd);
queriesTable.setLinesVisible(true);
final TableColumn valueColumn = UIUtils.createTableColumn(queriesTable, SWT.LEFT, "SQL");
valueColumn.setWidth(300);
for (String value : queries) {
new TableItem(queriesTable, SWT.LEFT).setText(value);
}
final CustomTableEditor tableEditor = new CustomTableEditor(queriesTable) {
@Override
protected Control createEditor(Table table, int index, TableItem item) {
Text editor = new Text(table, SWT.BORDER);
editor.setText(item.getText());
return editor;
}
@Override
protected void saveEditorValue(Control control, int index, TableItem item) {
item.setText(((Text) control).getText());
}
};
Composite buttonsGroup = UIUtils.createPlaceholder(group, 1, 5);
buttonsGroup.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
final Button addButton = new Button(buttonsGroup, SWT.PUSH);
addButton.setText(UIMessages.button_add);
addButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
addButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
tableEditor.closeEditor();
String sql = EditTextDialog.editText(getShell(), CoreMessages.dialog_connection_edit_wizard_general_bootstrap_query_sql_title, "");
if (sql != null) {
TableItem newItem = new TableItem(queriesTable, SWT.LEFT);
newItem.setText(sql);
queriesTable.setSelection(newItem);
UIUtils.packColumns(queriesTable, true);
}
}
});
final Button removeButton = new Button(buttonsGroup, SWT.PUSH);
removeButton.setText(UIMessages.button_remove);
removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
removeButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int selectionIndex = queriesTable.getSelectionIndex();
if (selectionIndex >= 0) {
tableEditor.closeEditor();
queriesTable.remove(selectionIndex);
removeButton.setEnabled(queriesTable.getSelectionIndex() >= 0);
}
}
});
removeButton.setEnabled(false);
queriesTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int selectionIndex = queriesTable.getSelectionIndex();
removeButton.setEnabled(selectionIndex >= 0);
}
});
queriesTable.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
int sbWidth = 0;
if (queriesTable.getVerticalBar() != null) {
sbWidth = queriesTable.getVerticalBar().getSize().x;
}
queriesTable.getColumn(0).setWidth(queriesTable.getSize().x - queriesTable.getBorderWidth() * 2 - sbWidth);
}
});
ignoreErrorButton = UIUtils.createCheckbox(composite, CoreMessages.dialog_connection_edit_wizard_general_bootstrap_query_ignore_error_lable, ignoreErrors);
VariablesHintLabel variablesHintLabel = new VariablesHintLabel(composite, CoreMessages.dialog_connection_edit_wizard_shell_cmd_variables_hint_label, CoreMessages.dialog_connection_edit_wizard_shell_cmd_variables_hint_title, DataSourceDescriptor.CONNECT_VARIABLES);
if (dataSourceDescriptor != null) {
variablesHintLabel.setResolver(new DataSourceVariableResolver(dataSourceDescriptor, dataSourceDescriptor.getConnectionConfiguration()));
}
UIUtils.asyncExec(() -> UIUtils.packColumns(queriesTable, true));
return composite;
}
use of org.jkiss.dbeaver.ui.controls.VariablesHintLabel in project dbeaver by serge-rider.
the class SSHTunnelConfiguratorUI method createControl.
@Override
public void createControl(Composite parent, Runnable propertyChangeListener) {
final Composite composite = new Composite(parent, SWT.NONE);
// gd.minimumHeight = 200;
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
composite.setLayout(new GridLayout(1, false));
{
Group settingsGroup = UIUtils.createControlGroup(composite, SSHUIMessages.model_ssh_configurator_group_settings, 2, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, SWT.DEFAULT);
UIUtils.createControlLabel(settingsGroup, SSHUIMessages.model_ssh_configurator_label_host_ip);
Composite hostPortComp = UIUtils.createComposite(settingsGroup, 3);
hostPortComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// $NON-NLS-2$
hostText = new Text(hostPortComp, SWT.BORDER);
hostText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
portText = UIUtils.createLabelSpinner(hostPortComp, SSHUIMessages.model_ssh_configurator_label_port, SSHConstants.DEFAULT_SSH_PORT, StandardConstants.MIN_PORT_VALUE, StandardConstants.MAX_PORT_VALUE);
GridData gdt = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gdt.widthHint = UIUtils.getFontHeight(portText) * 7;
portText.setLayoutData(gdt);
// $NON-NLS-2$
userNameText = UIUtils.createLabelText(settingsGroup, SSHUIMessages.model_ssh_configurator_label_user_name, null, SWT.BORDER, new GridData(GridData.FILL_HORIZONTAL));
authMethodCombo = UIUtils.createLabelCombo(settingsGroup, SSHUIMessages.model_ssh_configurator_combo_auth_method, SWT.DROP_DOWN | SWT.READ_ONLY);
authMethodCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
authMethodCombo.add(SSHUIMessages.model_ssh_configurator_combo_password);
authMethodCombo.add(SSHUIMessages.model_ssh_configurator_combo_pub_key);
authMethodCombo.add(SSHUIMessages.model_ssh_configurator_combo_agent);
privateKeyLabel = UIUtils.createControlLabel(settingsGroup, SSHUIMessages.model_ssh_configurator_label_private_key);
privateKeyLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
privateKeyText = new TextWithOpenFile(settingsGroup, SSHUIMessages.model_ssh_configurator_dialog_choose_private_key, new String[] { "*", "*.ssh", "*.pem", "*.*" });
privateKeyText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
{
pwdLabel = UIUtils.createControlLabel(settingsGroup, SSHUIMessages.model_ssh_configurator_label_password);
Composite passComp = UIUtils.createComposite(settingsGroup, 2);
passComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
passwordText = new Text(passComp, SWT.BORDER | SWT.PASSWORD);
passwordText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
savePasswordCheckbox = UIUtils.createCheckbox(passComp, SSHUIMessages.model_ssh_configurator_checkbox_save_pass, false);
savePasswordCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
}
}
{
Group advancedGroup = UIUtils.createControlGroup(composite, SSHUIMessages.model_ssh_configurator_group_advanced, 4, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, SWT.DEFAULT);
tunnelImplCombo = UIUtils.createLabelCombo(advancedGroup, SSHUIMessages.model_ssh_configurator_label_implementation, SWT.DROP_DOWN | SWT.READ_ONLY);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalSpan = 3;
tunnelImplCombo.setLayoutData(gd);
for (SSHImplementationDescriptor it : SSHImplementationRegistry.getInstance().getDescriptors()) {
tunnelImplCombo.add(it.getLabel());
}
localHostText = UIUtils.createLabelText(advancedGroup, SSHUIMessages.model_ssh_configurator_label_local_host, null, SWT.BORDER, new GridData(GridData.FILL_HORIZONTAL));
localHostText.setToolTipText(SSHUIMessages.model_ssh_configurator_label_local_host_description);
localHostText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
remoteHostText = UIUtils.createLabelText(advancedGroup, SSHUIMessages.model_ssh_configurator_label_remote_host, null, SWT.BORDER, new GridData(GridData.FILL_HORIZONTAL));
remoteHostText.setToolTipText(SSHUIMessages.model_ssh_configurator_label_remote_host_description);
remoteHostText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
localPortSpinner = UIUtils.createLabelSpinner(advancedGroup, SSHUIMessages.model_ssh_configurator_label_local_port, 0, StandardConstants.MIN_PORT_VALUE, StandardConstants.MAX_PORT_VALUE);
localPortSpinner.setToolTipText(SSHUIMessages.model_ssh_configurator_label_local_port_description);
localPortSpinner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
remotePortSpinner = UIUtils.createLabelSpinner(advancedGroup, SSHUIMessages.model_ssh_configurator_label_remote_port, 0, StandardConstants.MIN_PORT_VALUE, StandardConstants.MAX_PORT_VALUE);
remotePortSpinner.setToolTipText(SSHUIMessages.model_ssh_configurator_label_remote_port_description);
remotePortSpinner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
UIUtils.createHorizontalLine(advancedGroup, 4, 0);
keepAliveText = UIUtils.createLabelSpinner(advancedGroup, SSHUIMessages.model_ssh_configurator_label_keep_alive, 0, 0, Integer.MAX_VALUE);
keepAliveText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
tunnelTimeout = UIUtils.createLabelSpinner(advancedGroup, SSHUIMessages.model_ssh_configurator_label_tunnel_timeout, SSHConstants.DEFAULT_CONNECT_TIMEOUT, 0, 300000);
tunnelTimeout.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
{
Composite controlGroup = UIUtils.createComposite(composite, 2);
controlGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
UIUtils.createDialogButton(controlGroup, SSHUIMessages.model_ssh_configurator_button_test_tunnel, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
testTunnelConnection();
}
});
String hint = "You can use variables in SSH parameters.";
variablesHintLabel = new VariablesHintLabel(controlGroup, hint, hint, DataSourceDescriptor.CONNECT_VARIABLES, false);
}
authMethodCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateAuthMethodVisibility();
}
});
}
use of org.jkiss.dbeaver.ui.controls.VariablesHintLabel in project dbeaver by dbeaver.
the class SSHTunnelConfiguratorUI method createControl.
@Override
public void createControl(Composite parent, Runnable propertyChangeListener) {
final Composite composite = new Composite(parent, SWT.NONE);
// gd.minimumHeight = 200;
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
composite.setLayout(new GridLayout(1, false));
{
Group settingsGroup = UIUtils.createControlGroup(composite, SSHUIMessages.model_ssh_configurator_group_settings, 2, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, SWT.DEFAULT);
UIUtils.createControlLabel(settingsGroup, SSHUIMessages.model_ssh_configurator_label_host_ip);
Composite hostPortComp = UIUtils.createComposite(settingsGroup, 3);
hostPortComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// $NON-NLS-2$
hostText = new Text(hostPortComp, SWT.BORDER);
hostText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
portText = UIUtils.createLabelSpinner(hostPortComp, SSHUIMessages.model_ssh_configurator_label_port, SSHConstants.DEFAULT_SSH_PORT, StandardConstants.MIN_PORT_VALUE, StandardConstants.MAX_PORT_VALUE);
GridData gdt = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gdt.widthHint = UIUtils.getFontHeight(portText) * 7;
portText.setLayoutData(gdt);
// $NON-NLS-2$
userNameText = UIUtils.createLabelText(settingsGroup, SSHUIMessages.model_ssh_configurator_label_user_name, null, SWT.BORDER, new GridData(GridData.FILL_HORIZONTAL));
authMethodCombo = UIUtils.createLabelCombo(settingsGroup, SSHUIMessages.model_ssh_configurator_combo_auth_method, SWT.DROP_DOWN | SWT.READ_ONLY);
authMethodCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
authMethodCombo.add(SSHUIMessages.model_ssh_configurator_combo_password);
authMethodCombo.add(SSHUIMessages.model_ssh_configurator_combo_pub_key);
authMethodCombo.add(SSHUIMessages.model_ssh_configurator_combo_agent);
privateKeyLabel = UIUtils.createControlLabel(settingsGroup, SSHUIMessages.model_ssh_configurator_label_private_key);
privateKeyLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
privateKeyText = new TextWithOpenFile(settingsGroup, SSHUIMessages.model_ssh_configurator_dialog_choose_private_key, new String[] { "*", "*.ssh", "*.pem", "*.*" });
privateKeyText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
{
pwdLabel = UIUtils.createControlLabel(settingsGroup, SSHUIMessages.model_ssh_configurator_label_password);
Composite passComp = UIUtils.createComposite(settingsGroup, 2);
passComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
passwordText = new Text(passComp, SWT.BORDER | SWT.PASSWORD);
passwordText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
savePasswordCheckbox = UIUtils.createCheckbox(passComp, SSHUIMessages.model_ssh_configurator_checkbox_save_pass, false);
savePasswordCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
}
}
{
Group advancedGroup = UIUtils.createControlGroup(composite, SSHUIMessages.model_ssh_configurator_group_advanced, 4, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, SWT.DEFAULT);
tunnelImplCombo = UIUtils.createLabelCombo(advancedGroup, SSHUIMessages.model_ssh_configurator_label_implementation, SWT.DROP_DOWN | SWT.READ_ONLY);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalSpan = 3;
tunnelImplCombo.setLayoutData(gd);
for (SSHImplementationDescriptor it : SSHImplementationRegistry.getInstance().getDescriptors()) {
tunnelImplCombo.add(it.getLabel());
}
localHostText = UIUtils.createLabelText(advancedGroup, SSHUIMessages.model_ssh_configurator_label_local_host, null, SWT.BORDER, new GridData(GridData.FILL_HORIZONTAL));
localHostText.setToolTipText(SSHUIMessages.model_ssh_configurator_label_local_host_description);
localHostText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
remoteHostText = UIUtils.createLabelText(advancedGroup, SSHUIMessages.model_ssh_configurator_label_remote_host, null, SWT.BORDER, new GridData(GridData.FILL_HORIZONTAL));
remoteHostText.setToolTipText(SSHUIMessages.model_ssh_configurator_label_remote_host_description);
remoteHostText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
localPortSpinner = UIUtils.createLabelSpinner(advancedGroup, SSHUIMessages.model_ssh_configurator_label_local_port, 0, StandardConstants.MIN_PORT_VALUE, StandardConstants.MAX_PORT_VALUE);
localPortSpinner.setToolTipText(SSHUIMessages.model_ssh_configurator_label_local_port_description);
localPortSpinner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
remotePortSpinner = UIUtils.createLabelSpinner(advancedGroup, SSHUIMessages.model_ssh_configurator_label_remote_port, 0, StandardConstants.MIN_PORT_VALUE, StandardConstants.MAX_PORT_VALUE);
remotePortSpinner.setToolTipText(SSHUIMessages.model_ssh_configurator_label_remote_port_description);
remotePortSpinner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
UIUtils.createHorizontalLine(advancedGroup, 4, 0);
keepAliveText = UIUtils.createLabelSpinner(advancedGroup, SSHUIMessages.model_ssh_configurator_label_keep_alive, 0, 0, Integer.MAX_VALUE);
keepAliveText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
tunnelTimeout = UIUtils.createLabelSpinner(advancedGroup, SSHUIMessages.model_ssh_configurator_label_tunnel_timeout, SSHConstants.DEFAULT_CONNECT_TIMEOUT, 0, 300000);
tunnelTimeout.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
{
Composite controlGroup = UIUtils.createComposite(composite, 2);
controlGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
UIUtils.createDialogButton(controlGroup, SSHUIMessages.model_ssh_configurator_button_test_tunnel, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
testTunnelConnection();
}
});
String hint = "You can use variables in SSH parameters.";
variablesHintLabel = new VariablesHintLabel(controlGroup, hint, hint, DataSourceDescriptor.CONNECT_VARIABLES, false);
}
authMethodCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateAuthMethodVisibility();
}
});
}
use of org.jkiss.dbeaver.ui.controls.VariablesHintLabel in project dbeaver by dbeaver.
the class ConnectionPageAbstract method createDriverPanel.
protected void createDriverPanel(Composite parent) {
Composite panel = UIUtils.createComposite(parent, 4);
GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_END);
gd.horizontalSpan = ((GridLayout) parent.getLayout()).numColumns;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
panel.setLayoutData(gd);
if (DBWorkbench.getPlatform().getPreferenceStore().getBoolean(ModelPreferences.CONNECT_USE_ENV_VARS)) {
variablesHintLabel = new VariablesHintLabel(panel, UIConnectionMessages.dialog_connection_edit_connection_settings_variables_hint_label, UIConnectionMessages.dialog_connection_edit_connection_settings_variables_hint_label, DataSourceDescriptor.CONNECT_VARIABLES, false);
((GridData) variablesHintLabel.getInfoLabel().getLayoutData()).horizontalSpan = site.isNew() ? 3 : 4;
} else {
UIUtils.createEmptyLabel(panel, 3, 1);
}
if (site.isNew()) {
Button advSettingsButton = UIUtils.createDialogButton(panel, UIConnectionMessages.dialog_connection_edit_wizard_conn_conf_general_link, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
site.openSettingsPage("ConnectionPageGeneral");
}
});
advSettingsButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
}
Label divLabel = new Label(panel, SWT.SEPARATOR | SWT.HORIZONTAL);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 4;
divLabel.setLayoutData(gd);
Label driverLabel = new Label(panel, SWT.NONE);
driverLabel.setText(UIConnectionMessages.dialog_connection_driver);
driverLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
driverText = new Text(panel, SWT.READ_ONLY);
gd = new GridData(GridData.FILL_HORIZONTAL);
// gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
// gd.widthHint = 200;
driverText.setLayoutData(gd);
Button driverButton = UIUtils.createDialogButton(panel, UIConnectionMessages.dialog_connection_edit_driver_button, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (site.openDriverEditor()) {
updateDriverInfo(site.getDriver());
}
}
});
driverButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
}
Aggregations