use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.
the class HexEditControl method initialize.
/**
* This method initializes composite
*/
private void initialize() {
GridLayout gridLayout1 = new GridLayout();
gridLayout1.numColumns = 3;
gridLayout1.marginHeight = 0;
gridLayout1.verticalSpacing = 0;
gridLayout1.horizontalSpacing = 0;
gridLayout1.marginWidth = 0;
setLayout(gridLayout1);
FocusListener myFocusAdapter = new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
drawUnfocusedCaret(false);
lastFocusedTextArea = 1;
if (e.widget == previewText)
lastFocusedTextArea = 2;
DBeaverUI.asyncExec(new Runnable() {
@Override
public void run() {
drawUnfocusedCaret(true);
}
});
}
};
Caret defaultCaret;
Caret nonDefaultCaret;
{
// Lines
Composite linesColumn = new Composite(this, SWT.NONE);
GridLayout columnLayout = new GridLayout();
columnLayout.marginHeight = 0;
columnLayout.verticalSpacing = 1;
columnLayout.horizontalSpacing = 0;
columnLayout.marginWidth = 0;
linesColumn.setLayout(columnLayout);
//linesColumn.setBackground(COLOR_LIGHT_SHADOW);
GridData gridDataColumn = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
linesColumn.setLayoutData(gridDataColumn);
GridData gridDataTextSeparator = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
gridDataTextSeparator.widthHint = 10;
linesTextSeparator = new Text(linesColumn, SWT.SEPARATOR);
linesTextSeparator.setEnabled(false);
linesTextSeparator.setBackground(COLOR_LIGHT_SHADOW);
linesTextSeparator.setLayoutData(gridDataTextSeparator);
linesText = new StyledText(linesColumn, SWT.MULTI | SWT.READ_ONLY);
linesText.setEditable(false);
linesText.setEnabled(false);
//linesText.setBackground(COLOR_LIGHT_SHADOW);
//linesText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
fontDefault = new Font(Display.getCurrent(), DEFAULT_FONT_DATA);
fontCurrent = fontDefault;
linesText.setFont(fontCurrent);
GC styledTextGC = new GC(linesText);
fontCharWidth = styledTextGC.getFontMetrics().getAverageCharWidth();
styledTextGC.dispose();
GridData gridDataAddresses = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
gridDataAddresses.heightHint = numberOfLines * linesText.getLineHeight();
linesText.setLayoutData(gridDataAddresses);
setAddressesGridDataWidthHint();
linesText.setContent(new DisplayedContent(charsForAddress, numberOfLines));
}
{
// Hex
Composite hexColumn = new Composite(this, SWT.NONE);
GridLayout column1Layout = new GridLayout();
column1Layout.marginHeight = 0;
column1Layout.verticalSpacing = 1;
column1Layout.horizontalSpacing = 0;
column1Layout.marginWidth = 0;
hexColumn.setLayout(column1Layout);
//hexColumn.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
GridData gridDataColumn1 = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
hexColumn.setLayoutData(gridDataColumn1);
Composite hexHeaderGroup = new Composite(hexColumn, SWT.NONE);
//hexHeaderGroup.setBackground(COLOR_LIGHT_SHADOW);
GridLayout column1HeaderLayout = new GridLayout();
column1HeaderLayout.marginHeight = 0;
column1HeaderLayout.marginWidth = 0;
hexHeaderGroup.setLayout(column1HeaderLayout);
GridData gridDataColumn1Header = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
hexHeaderGroup.setLayoutData(gridDataColumn1Header);
GridData gridData = new GridData();
gridData.horizontalIndent = 1;
hexHeaderText = new StyledText(hexHeaderGroup, SWT.SINGLE | SWT.READ_ONLY);
hexHeaderText.setEditable(false);
hexHeaderText.setEnabled(false);
hexHeaderText.setBackground(COLOR_LIGHT_SHADOW);
//hexHeaderText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
hexHeaderText.setLayoutData(gridData);
hexHeaderText.setFont(fontCurrent);
refreshHeader();
hexText = new StyledText(hexColumn, SWT.MULTI);
hexText.setFont(fontCurrent);
if (readOnly) {
hexText.setEditable(false);
}
styledText1GC = new GC(hexText);
int width = bytesPerLine * 3 * fontCharWidth;
textGridData = new GridData();
textGridData.horizontalIndent = 1;
textGridData.verticalAlignment = SWT.FILL;
textGridData.widthHint = hexText.computeTrim(0, 0, width, 0).width;
textGridData.grabExcessVerticalSpace = true;
hexText.setLayoutData(textGridData);
hexText.addKeyListener(keyAdapter);
hexText.addFocusListener(myFocusAdapter);
hexText.addMouseListener(new ControlMouseAdapter(true));
hexText.addPaintListener(new ControlPaintAdapter(true));
hexText.addTraverseListener(new ControlTraverseAdapter());
hexText.addVerifyKeyListener(new ControlVerifyKeyAdapter());
hexText.setContent(new DisplayedContent(bytesPerLine * 3, numberOfLines));
hexText.setDoubleClickEnabled(false);
hexText.addSelectionListener(new ControlSelectionAdapter(true));
// StyledText.setCaretOffset() version 3.448 bug resets the caret size if using the default one,
// so we use not the default one.
defaultCaret = hexText.getCaret();
nonDefaultCaret = new Caret(defaultCaret.getParent(), defaultCaret.getStyle());
nonDefaultCaret.setBounds(defaultCaret.getBounds());
hexText.setCaret(nonDefaultCaret);
}
{
// Preview
Composite previewColumn = new Composite(this, SWT.NONE);
GridLayout column2Layout = new GridLayout();
column2Layout.marginHeight = 0;
column2Layout.verticalSpacing = 1;
column2Layout.horizontalSpacing = 0;
column2Layout.marginWidth = 0;
previewColumn.setLayout(column2Layout);
//previewColumn.setBackground(hexText.getBackground());
GridData gridDataColumn2 = new GridData(SWT.FILL, SWT.FILL, true, true);
previewColumn.setLayoutData(gridDataColumn2);
GridData gridDataTextSeparator2 = new GridData();
gridDataTextSeparator2.horizontalAlignment = SWT.FILL;
gridDataTextSeparator2.verticalAlignment = SWT.FILL;
gridDataTextSeparator2.grabExcessHorizontalSpace = true;
previewTextSeparator = new Text(previewColumn, SWT.SEPARATOR);
previewTextSeparator.setEnabled(false);
previewTextSeparator.setBackground(COLOR_LIGHT_SHADOW);
previewTextSeparator.setLayoutData(gridDataTextSeparator2);
makeFirstRowSameHeight();
previewText = new StyledText(previewColumn, SWT.MULTI);
previewText.setFont(fontCurrent);
if (readOnly) {
previewText.setEditable(false);
}
// one pixel for caret in last linesColumn
int width = bytesPerLine * fontCharWidth + 1;
previewGridData = new GridData();
previewGridData.verticalAlignment = SWT.FILL;
previewGridData.widthHint = previewText.computeTrim(0, 0, width, 0).width;
previewGridData.grabExcessVerticalSpace = true;
previewText.setLayoutData(previewGridData);
previewText.addKeyListener(keyAdapter);
previewText.addFocusListener(myFocusAdapter);
previewText.addMouseListener(new ControlMouseAdapter(false));
previewText.addPaintListener(new ControlPaintAdapter(false));
previewText.addTraverseListener(new ControlTraverseAdapter());
previewText.addVerifyKeyListener(new ControlVerifyKeyAdapter());
previewText.setContent(new DisplayedContent(bytesPerLine, numberOfLines));
previewText.setDoubleClickEnabled(false);
previewText.addSelectionListener(new ControlSelectionAdapter(false));
// StyledText.setCaretOffset() version 3.448 bug resets the caret size if using the default one,
// so we use not the default one.
defaultCaret = previewText.getCaret();
nonDefaultCaret = new Caret(defaultCaret.getParent(), defaultCaret.getStyle());
nonDefaultCaret.setBounds(defaultCaret.getBounds());
previewText.setCaret(nonDefaultCaret);
styledText2GC = new GC(previewText);
setCharset(null);
}
super.setFont(fontCurrent);
ScrollBar vertical = getVerticalBar();
vertical.setSelection(0);
vertical.setMinimum(0);
vertical.setIncrement(1);
vertical.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
e.doit = false;
long previousStart = textAreasStart;
textAreasStart = (((long) getVerticalBar().getSelection()) << verticalBarFactor) * (long) bytesPerLine;
if (previousStart == textAreasStart)
return;
Runnable delayed = new Runnable() {
@Override
public void run() {
redrawTextAreas(false);
setFocus();
runnableEnd();
}
};
runnableAdd(delayed);
}
});
updateScrollBar();
addMouseListener(new org.eclipse.swt.events.MouseAdapter() {
@Override
public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
setFocus();
}
});
addControlListener(new org.eclipse.swt.events.ControlAdapter() {
@Override
public void controlResized(org.eclipse.swt.events.ControlEvent e) {
updateTextsMetrics();
}
});
addDisposeListener(new org.eclipse.swt.events.DisposeListener() {
@Override
public void widgetDisposed(org.eclipse.swt.events.DisposeEvent e) {
if (content != null)
content.dispose();
}
});
}
use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.
the class DriverManagerDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
List<DataSourceProviderDescriptor> providers = DataSourceProviderRegistry.getInstance().getDataSourceProviders();
{
DataSourceProviderDescriptor manProvider = null;
for (DataSourceProviderDescriptor provider : providers) {
if (provider.isDriversManagable()) {
if (manProvider != null) {
manProvider = null;
break;
}
manProvider = provider;
}
}
if (manProvider != null) {
onlyManagableProvider = manProvider;
}
}
getShell().setText(CoreMessages.dialog_driver_manager_title);
getShell().setMinimumSize(300, 300);
//$NON-NLS-1$
dialogImage = DBeaverActivator.getImageDescriptor("/icons/driver_manager.png").createImage();
getShell().setImage(dialogImage);
Composite group = UIUtils.createPlaceholder((Composite) super.createDialogArea(parent), 2);
group.setLayoutData(new GridData(GridData.FILL_BOTH));
{
treeControl = new DriverTreeControl(group, this, providers, false);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 300;
gd.widthHint = 300;
treeControl.setLayoutData(gd);
}
{
Composite buttonBar = new Composite(group, SWT.TOP);
buttonBar.setLayout(new GridLayout(1, false));
GridData gd = new GridData(GridData.FILL_VERTICAL);
gd.minimumWidth = 100;
buttonBar.setLayoutData(gd);
newButton = new Button(buttonBar, SWT.FLAT | SWT.PUSH);
newButton.setText(CoreMessages.dialog_driver_manager_button_new);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = 100;
newButton.setLayoutData(gd);
newButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
createDriver();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
editButton = new Button(buttonBar, SWT.FLAT | SWT.PUSH);
editButton.setText(CoreMessages.dialog_driver_manager_button_edit);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = 100;
editButton.setLayoutData(gd);
editButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
editDriver();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
deleteButton = new Button(buttonBar, SWT.FLAT | SWT.PUSH);
deleteButton.setText(CoreMessages.dialog_driver_manager_button_delete);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = 100;
deleteButton.setLayoutData(gd);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
deleteDriver();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
{
final Composite legend = UIUtils.createPlaceholder(buttonBar, 2, 5);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalIndent = 5;
gd.horizontalSpan = 2;
legend.setLayoutData(gd);
UIUtils.createLabel(legend, DBIcon.OVER_LAMP);
UIUtils.createLabel(legend, CoreMessages.dialog_driver_manager_label_user_defined);
UIUtils.createLabel(legend, DBIcon.OVER_ERROR);
UIUtils.createLabel(legend, CoreMessages.dialog_driver_manager_label_unavailable);
}
}
descText = new Text(group, SWT.READ_ONLY);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalIndent = 5;
gd.horizontalSpan = 2;
gd.grabExcessHorizontalSpace = true;
descText.setLayoutData(gd);
/*
monitorPart = new ProgressMonitorPart(group, null, true);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalIndent = 5;
gd.horizontalSpan = 2;
gd.grabExcessHorizontalSpace = true;
monitorPart.setLayoutData(gd);
monitorPart.setVisible(false);
*/
setDefaultSelection();
this.updateButtons();
return group;
}
use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.
the class EditMavenArtifactDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
getShell().setText("Edit Maven Artifact");
Composite composite = (Composite) super.createDialogArea(parent);
((GridLayout) composite.getLayout()).numColumns = 2;
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = 200;
groupText = UIUtils.createLabelText(composite, "Group Id", artifact.getGroupId());
groupText.setLayoutData(gd);
artifactText = UIUtils.createLabelText(composite, "Artifact Id", artifact.getArtifactId());
artifactText.setLayoutData(gd);
classifierText = UIUtils.createLabelText(composite, "Classifier", CommonUtils.notEmpty(artifact.getClassifier()));
classifierText.setLayoutData(gd);
versionText = UIUtils.createLabelCombo(composite, "Version", SWT.DROP_DOWN | SWT.BORDER);
versionText.setLayoutData(gd);
versionText.setText(artifact.getVersion());
versionText.add(MavenArtifactReference.VERSION_PATTERN_RELEASE);
versionText.add(MavenArtifactReference.VERSION_PATTERN_LATEST);
ModifyListener ml = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
updateButtons();
}
};
groupText.addModifyListener(ml);
artifactText.addModifyListener(ml);
classifierText.addModifyListener(ml);
versionText.addModifyListener(ml);
return composite;
}
use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.
the class ViewClasspathDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
getShell().setText(CoreMessages.dialog_view_classpath_title);
Composite group = (Composite) super.createDialogArea(parent);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 300;
gd.widthHint = 400;
group.setLayoutData(gd);
{
ListViewer libsTable = new ListViewer(group, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
libsTable.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
//$NON-NLS-1$
String classPath = System.getProperty(StandardConstants.ENV_JAVA_CLASSPATH);
//$NON-NLS-1$
StringTokenizer st = new StringTokenizer(classPath, ";");
while (st.hasMoreTokens()) {
libsTable.getList().add(st.nextToken());
}
}
return group;
}
use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.
the class SSHTunnelConfiguratorUI method createControl.
@Override
public void createControl(Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.minimumHeight = 200;
composite.setLayoutData(gd);
composite.setLayout(new GridLayout(2, false));
//$NON-NLS-2$
hostText = UIUtils.createLabelText(composite, CoreMessages.model_ssh_configurator_label_host_ip, null);
hostText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
portText = UIUtils.createLabelSpinner(composite, CoreMessages.model_ssh_configurator_label_port, SSHConstants.DEFAULT_SSH_PORT, 0, 65535);
//$NON-NLS-2$
userNameText = UIUtils.createLabelText(composite, CoreMessages.model_ssh_configurator_label_user_name, null);
userNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
authMethodCombo = UIUtils.createLabelCombo(composite, CoreMessages.model_ssh_configurator_combo_auth_method, SWT.DROP_DOWN | SWT.READ_ONLY);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.minimumWidth = 130;
authMethodCombo.setLayoutData(gd);
authMethodCombo.add(CoreMessages.model_ssh_configurator_combo_password);
authMethodCombo.add(CoreMessages.model_ssh_configurator_combo_pub_key);
privateKeyLabel = UIUtils.createControlLabel(composite, CoreMessages.model_ssh_configurator_label_private_key);
privateKeyLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
pkControlGroup = UIUtils.createPlaceholder(composite, 1);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.minimumWidth = 130;
pkControlGroup.setLayoutData(gd);
privateKeyText = new TextWithOpenFile(pkControlGroup, CoreMessages.model_ssh_configurator_dialog_choose_private_key, new String[] { "*", "*.ssh", "*.pem", "*.*" });
privateKeyText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
pwdLabel = UIUtils.createControlLabel(composite, CoreMessages.model_ssh_configurator_label_password);
pwdControlGroup = UIUtils.createPlaceholder(composite, 3);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.minimumWidth = 200;
pwdControlGroup.setLayoutData(gd);
passwordText = new Text(pwdControlGroup, SWT.BORDER | SWT.PASSWORD);
new Label(pwdControlGroup, SWT.NONE).setText(" ");
savePasswordCheckbox = UIUtils.createCheckbox(pwdControlGroup, CoreMessages.model_ssh_configurator_checkbox_save_pass, false);
keepAliveText = UIUtils.createLabelSpinner(composite, CoreMessages.model_ssh_configurator_label_keep_alive, 0, 0, Integer.MAX_VALUE);
tunnelTimeout = UIUtils.createLabelSpinner(composite, CoreMessages.model_ssh_configurator_label_tunnel_timeout, SSHConstants.DEFAULT_CONNECT_TIMEOUT, 0, 300000);
authMethodCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updatePrivateKeyVisibility();
composite.layout();
}
});
}
Aggregations