use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.
the class ConnectionPageGeneral method createControl.
@Override
public void createControl(Composite parent) {
boldFont = UIUtils.makeBoldFont(parent.getFont());
Composite group = new Composite(parent, SWT.NONE);
GridLayout gl = new GridLayout(2, false);
group.setLayout(gl);
//$NON-NLS-1$
String connectionName = dataSourceDescriptor == null ? "" : dataSourceDescriptor.getName();
connectionNameText = UIUtils.createLabelText(group, CoreMessages.dialog_connection_wizard_final_label_connection_name, CommonUtils.toString(connectionName));
connectionNameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
connectionNameChanged = true;
ConnectionPageGeneral.this.getContainer().updateButtons();
}
});
{
UIUtils.createControlLabel(group, "Connection type");
Composite ctGroup = UIUtils.createPlaceholder(group, 2, 5);
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());
autocommit.setSelection(type.isAutocommit());
}
});
Button pickerButton = new Button(ctGroup, SWT.PUSH);
pickerButton.setText("Edit");
pickerButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DataSourceDescriptor dataSource = getActiveDataSource();
UIUtils.showPreferencesFor(getControl().getShell(), dataSource.getConnectionConfiguration().getConnectionType(), PrefPageConnectionTypes.PAGE_ID);
loadConnectionTypes();
DBPConnectionType connectionType = dataSource.getConnectionConfiguration().getConnectionType();
connectionTypeCombo.select(connectionType);
autocommit.setSelection(connectionType.isAutocommit());
}
});
}
{
UIUtils.createControlLabel(group, "Connection folder");
connectionFolderCombo = new CSmartCombo<>(group, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY, new ConnectionFolderLabelProvider());
//connectionFolderCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
loadConnectionFolders();
connectionFolderCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dataSourceFolder = connectionFolderCombo.getItem(connectionFolderCombo.getSelectionIndex());
}
});
}
{
Composite optionsGroup = new Composite(group, SWT.NONE);
gl = new GridLayout(2, true);
gl.verticalSpacing = 0;
gl.horizontalSpacing = 5;
gl.marginHeight = 0;
gl.marginWidth = 0;
optionsGroup.setLayout(gl);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
optionsGroup.setLayoutData(gd);
Composite leftSide = UIUtils.createPlaceholder(optionsGroup, 1, 5);
leftSide.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
Composite rightSide = UIUtils.createPlaceholder(optionsGroup, 1, 5);
rightSide.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
{
Group securityGroup = UIUtils.createControlGroup(leftSide, CoreMessages.dialog_connection_wizard_final_group_security, 1, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, 0);
savePasswordCheck = UIUtils.createCheckbox(securityGroup, CoreMessages.dialog_connection_wizard_final_checkbox_save_password_locally, dataSourceDescriptor == null || dataSourceDescriptor.isSavePassword());
savePasswordCheck.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
}
{
Group txnGroup = UIUtils.createControlGroup(rightSide, "Connection", 2, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, 0);
autocommit = UIUtils.createLabelCheckbox(txnGroup, CoreMessages.dialog_connection_wizard_final_checkbox_auto_commit, "Sets auto-commit mode for all connections", dataSourceDescriptor != null && dataSourceDescriptor.isDefaultAutoCommit());
autocommit.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
autocommit.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (dataSourceDescriptor != null && dataSourceDescriptor.isConnected()) {
isolationLevel.setEnabled(!autocommit.getSelection());
}
}
});
isolationLevel = UIUtils.createLabelCombo(txnGroup, "Isolation level", "Default transaction isolation level.", SWT.DROP_DOWN | SWT.READ_ONLY);
defaultSchema = UIUtils.createLabelCombo(txnGroup, "Default schema", "Name of schema or catalog which will be set as default.", SWT.DROP_DOWN);
keepAliveInterval = UIUtils.createLabelSpinner(txnGroup, "Keep-Alive", "Keep-alive interval (in seconds). Zero turns keep-alive off", 0, 0, Short.MAX_VALUE);
{
String bootstrapTooltip = "SQL queries to execute right after connection establishment";
UIUtils.createControlLabel(txnGroup, "Bootstrap queries").setToolTipText(bootstrapTooltip);
final Button queriesConfigButton = UIUtils.createPushButton(txnGroup, "Configure ...", DBeaverIcons.getImage(UIIcon.SQL_SCRIPT));
queriesConfigButton.setToolTipText(bootstrapTooltip);
if (dataSourceDescriptor != null && !CommonUtils.isEmpty(dataSourceDescriptor.getConnectionConfiguration().getBootstrap().getInitQueries())) {
queriesConfigButton.setFont(boldFont);
}
queriesConfigButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
EditBootstrapQueriesDialog dialog = new EditBootstrapQueriesDialog(getShell(), bootstrapQueries, ignoreBootstrapErrors);
if (dialog.open() == IDialogConstants.OK_ID) {
bootstrapQueries = dialog.getQueries();
ignoreBootstrapErrors = dialog.isIgnoreErrors();
}
}
});
}
if (getWizard().isNew()) {
UIUtils.createControlLabel(txnGroup, "Shell Commands");
eventsButton = new Button(txnGroup, SWT.PUSH);
eventsButton.setText("Configure ...");
eventsButton.setImage(DBeaverIcons.getImage(UIIcon.EVENT));
eventsButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
eventsButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
configureEvents();
}
});
}
}
{
Group miscGroup = UIUtils.createControlGroup(leftSide, CoreMessages.dialog_connection_wizard_final_group_misc, 1, GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL, 0);
showSystemObjects = UIUtils.createCheckbox(miscGroup, CoreMessages.dialog_connection_wizard_final_checkbox_show_system_objects, dataSourceDescriptor == null || dataSourceDescriptor.isShowSystemObjects());
showSystemObjects.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
showUtilityObjects = UIUtils.createCheckbox(miscGroup, CoreMessages.dialog_connection_wizard_final_checkbox_show_util_objects, dataSourceDescriptor == null || dataSourceDescriptor.isShowUtilityObjects());
showUtilityObjects.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
readOnlyConnection = UIUtils.createCheckbox(miscGroup, CoreMessages.dialog_connection_wizard_final_checkbox_connection_readonly, dataSourceDescriptor != null && dataSourceDescriptor.isConnectionReadOnly());
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
//gd.horizontalSpan = 2;
readOnlyConnection.setLayoutData(gd);
}
{
// Filters
filtersGroup = UIUtils.createControlGroup(leftSide, CoreMessages.dialog_connection_wizard_final_group_filters, 1, GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL, 0);
for (int i = 0; i < filters.size(); i++) {
final FilterInfo filterInfo = filters.get(i);
filterInfo.link = UIUtils.createLink(filtersGroup, "<a>" + filterInfo.title + "</a>", new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
EditObjectFilterDialog dialog = new EditObjectFilterDialog(getShell(), 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());
}
}
}
});
}
}
}
{
final Group descGroup = UIUtils.createControlGroup(group, "Description", 1, GridData.FILL_HORIZONTAL, 0);
((GridData) descGroup.getLayoutData()).horizontalSpan = 2;
descriptionText = new Text(descGroup, SWT.BORDER | SWT.V_SCROLL | SWT.WRAP | SWT.MULTI);
final GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = descriptionText.getLineHeight() * 3;
descriptionText.setLayoutData(gd);
}
setControl(group);
UIUtils.setHelp(group, IHelpContextIds.CTX_CON_WIZARD_FINAL);
}
use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.
the class SelectDataSourceDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
getShell().setText(CoreMessages.dialog_select_datasource_title);
Composite group = (Composite) super.createDialogArea(parent);
GridData gd = new GridData(GridData.FILL_BOTH);
group.setLayoutData(gd);
DBeaverCore core = DBeaverCore.getInstance();
DBNNode rootNode = null;
if (project != null) {
DBNProject projectNode = core.getNavigatorModel().getRoot().getProject(project);
if (projectNode != null) {
rootNode = projectNode.getDatabases();
}
}
if (rootNode == null) {
rootNode = core.getNavigatorModel().getRoot();
}
DatabaseNavigatorTree dataSourceTree = new DatabaseNavigatorTree(group, rootNode, SWT.SINGLE | SWT.BORDER, false);
dataSourceTree.setLayoutData(new GridData(GridData.FILL_BOTH));
final Text descriptionText = new Text(group, SWT.READ_ONLY);
descriptionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
dataSourceTree.getViewer().addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return element instanceof DBNProject || element instanceof DBNProjectDatabases || element instanceof DBNLocalFolder || element instanceof DBNDataSource;
}
});
dataSourceTree.getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection structSel = (IStructuredSelection) event.getSelection();
Object selNode = structSel.isEmpty() ? null : structSel.getFirstElement();
if (selNode instanceof DBNDataSource) {
dataSource = ((DBNDataSource) selNode).getObject();
getButton(IDialogConstants.OK_ID).setEnabled(true);
String description = dataSource.getDescription();
if (description == null) {
description = dataSource.getName();
}
descriptionText.setText(description);
} else {
dataSource = null;
getButton(IDialogConstants.OK_ID).setEnabled(false);
}
}
});
dataSourceTree.getViewer().addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
if (getButton(IDialogConstants.OK_ID).isEnabled()) {
okPressed();
}
}
});
return group;
}
use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.
the class CursorViewDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
final IValueController valueController = getValueController();
value = (DBDCursor) valueController.getValue();
Composite dialogGroup = (Composite) super.createDialogArea(parent);
if (value != null) {
DBPPreferenceStore globalPreferenceStore = DBeaverCore.getGlobalPreferenceStore();
if (!globalPreferenceStore.getBoolean(DBeaverPreferences.KEEP_STATEMENT_OPEN)) {
if (ConfirmationDialog.showConfirmDialog(getShell(), DBeaverPreferences.CONFIRM_KEEP_STATEMENT_OPEN, ConfirmationDialog.QUESTION) == IDialogConstants.YES_ID) {
globalPreferenceStore.setValue(DBeaverPreferences.KEEP_STATEMENT_OPEN, true);
if (valueController.getValueSite().getPart() instanceof IResultSetContainer) {
IResultSetController rsv = ((IResultSetContainer) valueController.getValueSite().getPart()).getResultSetController();
if (rsv != null) {
rsv.refresh();
}
}
}
DBeaverUI.asyncExec(new Runnable() {
@Override
public void run() {
close();
}
});
}
}
resultSetViewer = new ResultSetViewer(dialogGroup, valueController.getValueSite(), this);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 300;
gd.grabExcessVerticalSpace = true;
resultSetViewer.getControl().setLayoutData(gd);
resultSetViewer.refresh();
return dialogGroup;
}
use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.
the class DefaultValueViewDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogGroup = (Composite) super.createDialogArea(parent);
Label label = new Label(dialogGroup, SWT.NONE);
label.setText(CoreMessages.dialog_data_label_value);
Composite editorPlaceholder = UIUtils.createPlaceholder(dialogGroup, 1);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.minimumHeight = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).y + 4;
editorPlaceholder.setLayoutData(gd);
editorPlaceholder.setLayout(new FillLayout());
try {
panelEditor = createPanelEditor(editorPlaceholder);
if (panelEditor == null) {
return dialogGroup;
}
panelEditor.primeEditorValue(getValueController().getValue());
} catch (DBException e) {
log.error(e);
return dialogGroup;
}
ReferenceValueEditor referenceValueEditor = new ReferenceValueEditor(getValueController(), this);
if (referenceValueEditor.isReferenceValue()) {
referenceValueEditor.createEditorSelector(dialogGroup);
}
return dialogGroup;
}
use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.
the class TextViewDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogGroup = (Composite) super.createDialogArea(parent);
ReferenceValueEditor referenceValueEditor = new ReferenceValueEditor(getValueController(), this);
boolean isForeignKey = referenceValueEditor.isReferenceValue();
Label label = new Label(dialogGroup, SWT.NONE);
label.setText(CoreMessages.dialog_data_label_value);
boolean readOnly = getValueController().isReadOnly();
boolean useHex = !isForeignKey;
final DBSTypedObject valueType = getValueController().getValueType();
long maxSize = valueType.getMaxLength();
if (useHex) {
editorContainer = new CTabFolder(dialogGroup, SWT.FLAT | SWT.TOP);
editorContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
lengthLabel = new Label(editorContainer, SWT.RIGHT);
lengthLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
editorContainer.setTopRight(lengthLabel, SWT.FILL);
}
int selectedType = 0;
if (getDialogSettings().get(VALUE_TYPE_SELECTOR) != null) {
selectedType = getDialogSettings().getInt(VALUE_TYPE_SELECTOR);
}
{
int style = SWT.NONE;
if (readOnly) {
style |= SWT.READ_ONLY;
}
if (useHex) {
style |= SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP;
} else {
// Use border only for plain text editor, otherwise tab folder's border will be used
style |= SWT.BORDER;
}
textEdit = new StyledText(useHex ? editorContainer : dialogGroup, style);
textEdit.setMargins(3, 3, 3, 3);
if (maxSize > 0 && valueType.getDataKind() == DBPDataKind.STRING) {
textEdit.setTextLimit((int) maxSize);
}
if (readOnly) {
//textEdit.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
}
GridData gd = new GridData(isForeignKey ? GridData.FILL_HORIZONTAL : GridData.FILL_BOTH);
gd.widthHint = 300;
if (!isForeignKey) {
gd.heightHint = 200;
gd.grabExcessVerticalSpace = true;
}
textEdit.setLayoutData(gd);
textEdit.setFocus();
textEdit.setEditable(!readOnly);
textEdit.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
dirty = true;
updateValueLength();
}
});
UIUtils.fillDefaultStyledTextContextMenu(textEdit);
if (useHex) {
CTabItem item = new CTabItem(editorContainer, SWT.NO_FOCUS);
item.setText("Text");
item.setImage(DBeaverIcons.getImage(DBIcon.TYPE_TEXT));
item.setControl(textEdit);
}
}
Point minSize = null;
if (useHex) {
hexEditControl = new HexEditControl(editorContainer, readOnly ? SWT.READ_ONLY : SWT.NONE, 6, 8);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 200;
gd.minimumWidth = hexEditControl.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
hexEditControl.setLayoutData(gd);
minSize = hexEditControl.computeSize(SWT.DEFAULT, SWT.DEFAULT);
minSize.x += 50;
minSize.y += 50;
CTabItem item = new CTabItem(editorContainer, SWT.NO_FOCUS);
item.setText("Hex");
item.setImage(DBeaverIcons.getImage(DBIcon.TYPE_BINARY));
item.setControl(hexEditControl);
if (selectedType >= editorContainer.getItemCount()) {
selectedType = 0;
}
editorContainer.setSelection(selectedType);
editorContainer.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
getDialogSettings().put(VALUE_TYPE_SELECTOR, editorContainer.getSelectionIndex());
}
});
hexEditControl.addListener(SWT.Modify, new Listener() {
@Override
public void handleEvent(Event event) {
dirty = true;
}
});
updateValueLength();
}
primeEditorValue(getValueController().getValue());
if (isForeignKey) {
referenceValueEditor.createEditorSelector(dialogGroup);
}
if (minSize != null) {
// Set default size as minimum
getShell().setMinimumSize(minSize);
}
return dialogGroup;
}
Aggregations