use of org.eclipse.swt.layout.GridLayout in project dbeaver by serge-rider.
the class ProgressPageControl method createProgressPanel.
public Composite createProgressPanel(Composite container) {
if (this.ownerPageControl != null) {
//$NON-NLS-1$
throw new IllegalStateException("Can't create page control while substitution control already set");
}
if (showDivider) {
Label separator = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
Composite infoGroup = new Composite(container, SWT.NONE);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
infoGroup.setLayoutData(gd);
GridLayout gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
infoGroup.setLayout(gl);
listInfoLabel = new Label(infoGroup, SWT.NONE);
//listInfoLabel.setCursor(infoGroup.getDisplay().getSystemCursor(SWT.CURSOR_HELP));
//listInfoLabel.setBackground(container.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalIndent = 5;
gd.minimumWidth = 100;
listInfoLabel.setLayoutData(gd);
Composite controlsComposite = UIUtils.createPlaceholder(infoGroup, 2, 5);
controlsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
searchControlsComposite = UIUtils.createPlaceholder(controlsComposite, 1);
//gd.heightHint = listInfoLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, false).y + gl.verticalSpacing;
searchControlsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Placeholder toolbar (need to set initial height of search composite)
new ToolBar(searchControlsComposite, SWT.NONE);
customControlsComposite = new Composite(controlsComposite, SWT.NONE);
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
//gd.verticalIndent = 3;
customControlsComposite.setLayoutData(gd);
gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
customControlsComposite.setLayout(gl);
defaultToolbarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
customToolbarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
hideControls(true);
return customControlsComposite;
}
use of org.eclipse.swt.layout.GridLayout in project dbeaver by serge-rider.
the class UIUtils method createPlaceholder.
public static Composite createPlaceholder(Composite parent, int columns, int spacing) {
Composite ph = new Composite(parent, SWT.NONE);
GridLayout gl = new GridLayout(columns, false);
gl.verticalSpacing = spacing;
gl.horizontalSpacing = spacing;
gl.marginHeight = 0;
gl.marginWidth = 0;
ph.setLayout(gl);
return ph;
}
use of org.eclipse.swt.layout.GridLayout in project dbeaver by serge-rider.
the class CSmartCombo method createPopup.
void createPopup() {
Shell oldPopup = this.popup;
if (oldPopup != null) {
oldPopup.dispose();
}
// create shell and list
this.popup = new Shell(getShell(), SWT.RESIZE | SWT.ON_TOP);
int style = getStyle();
int listStyle = SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION;
if ((style & SWT.FLAT) != 0) {
listStyle |= SWT.FLAT;
}
if ((style & SWT.RIGHT_TO_LEFT) != 0) {
listStyle |= SWT.RIGHT_TO_LEFT;
}
if ((style & SWT.LEFT_TO_RIGHT) != 0) {
listStyle |= SWT.LEFT_TO_RIGHT;
}
GridLayout gl = new GridLayout(1, true);
gl.marginHeight = 0;
gl.marginWidth = 0;
gl.verticalSpacing = 0;
gl.horizontalSpacing = 0;
this.popup.setLayout(gl);
if (tableFilter != null) {
final Button filterButton = new Button(this.popup, SWT.PUSH | SWT.FLAT | SWT.CENTER);
filterButton.setText("Show " + (tableFilter.isEnabled() ? tableFilter.getDefaultLabel() : tableFilter.getFilterLabel()));
filterButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
filterButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
tableFilter.setEnabled(!tableFilter.isEnabled());
filterButton.setText("Show " + (tableFilter.isEnabled() ? tableFilter.getDefaultLabel() : tableFilter.getFilterLabel()));
updateTableItems();
}
});
}
// create a table instead of a list.
Table table = new Table(this.popup, listStyle);
table.setLayoutData(new GridData(GridData.FILL_BOTH));
this.dropDownControl = table;
if (this.font != null) {
table.setFont(this.font);
}
new TableColumn(table, SWT.LEFT);
createTableItems(table);
int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate };
for (int popupEvent : popupEvents) {
this.popup.addListener(popupEvent, this.listener);
}
int[] listEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose, SWT.Resize };
for (int listEvent : listEvents) {
table.addListener(listEvent, this.listener);
}
}
use of org.eclipse.swt.layout.GridLayout 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.GridLayout in project dbeaver by serge-rider.
the class EditShellCommandsDialogPage method createControl.
@Override
public void createControl(Composite parent) {
Composite group = UIUtils.createPlaceholder(parent, 2);
group.setLayoutData(new GridData(GridData.FILL_BOTH));
{
Composite eventGroup = new Composite(group, SWT.NONE);
eventGroup.setLayout(new GridLayout(1, false));
eventGroup.setLayoutData(new GridData(GridData.FILL_VERTICAL));
UIUtils.createControlLabel(eventGroup, CoreMessages.dialog_connection_events_label_event);
eventTypeTable = new Table(eventGroup, SWT.BORDER | SWT.CHECK | SWT.SINGLE | SWT.FULL_SELECTION);
eventTypeTable.setLayoutData(new GridData(GridData.FILL_VERTICAL));
eventTypeTable.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (event.detail == SWT.CHECK) {
eventTypeTable.select(eventTypeTable.indexOf((TableItem) event.item));
}
}
});
for (DBPConnectionEventType eventType : DBPConnectionEventType.values()) {
DBRShellCommand command = eventsCache.get(eventType);
TableItem item = new TableItem(eventTypeTable, SWT.NONE);
item.setData(eventType);
item.setText(eventType.getTitle());
item.setImage(DBeaverIcons.getImage(UIIcon.EVENT));
item.setChecked(command != null && command.isEnabled());
}
eventTypeTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DBPConnectionEventType eventType = getSelectedEventType();
selectEventType(eventType);
DBRShellCommand command = eventType == null ? null : eventsCache.get(eventType);
boolean enabled = ((TableItem) e.item).getChecked();
if (enabled || (command != null && enabled != command.isEnabled())) {
updateEvent(false);
}
}
});
}
{
Composite detailsGroup = new Composite(group, SWT.NONE);
detailsGroup.setLayout(new GridLayout(1, false));
detailsGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
//UIUtils.createControlGroup(group, "Event", 1, GridData.FILL_BOTH | GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
UIUtils.createControlLabel(detailsGroup, CoreMessages.dialog_connection_events_label_command);
commandText = new Text(detailsGroup, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
commandText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
updateEvent(true);
}
});
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 60;
gd.widthHint = 300;
commandText.setLayoutData(gd);
SelectionAdapter eventEditAdapter = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateEvent(false);
}
};
showProcessCheck = UIUtils.createCheckbox(detailsGroup, CoreMessages.dialog_connection_events_checkbox_show_process, false);
showProcessCheck.addSelectionListener(eventEditAdapter);
waitFinishCheck = UIUtils.createCheckbox(detailsGroup, CoreMessages.dialog_connection_events_checkbox_wait_finish, false);
waitFinishCheck.addSelectionListener(eventEditAdapter);
terminateCheck = UIUtils.createCheckbox(detailsGroup, CoreMessages.dialog_connection_events_checkbox_terminate_at_disconnect, false);
terminateCheck.addSelectionListener(eventEditAdapter);
Group helpGroup = new Group(detailsGroup, SWT.NONE);
helpGroup.setText("Command parameters");
helpGroup.setLayout(new GridLayout(2, false));
helpGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
Label infoLabel = new Label(helpGroup, SWT.NONE);
infoLabel.setText("You may use following variables:");
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
infoLabel.setLayoutData(gd);
addVariableLegend(helpGroup, RegistryConstants.VARIABLE_HOST, "target host");
addVariableLegend(helpGroup, RegistryConstants.VARIABLE_PORT, "target port");
addVariableLegend(helpGroup, RegistryConstants.VARIABLE_SERVER, "target server name");
addVariableLegend(helpGroup, RegistryConstants.VARIABLE_DATABASE, "target database");
addVariableLegend(helpGroup, RegistryConstants.VARIABLE_USER, "user name");
addVariableLegend(helpGroup, RegistryConstants.VARIABLE_PASSWORD, "password (plain)");
addVariableLegend(helpGroup, RegistryConstants.VARIABLE_URL, "JDBC URL");
}
selectEventType(null);
setControl(group);
}
Aggregations