use of org.eclipse.swt.events.MouseAdapter in project dbeaver by serge-rider.
the class AboutBoxDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Color background = JFaceColors.getBannerBackground(parent.getDisplay());
//Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());
parent.setBackground(background);
Composite group = new Composite(parent, SWT.NONE);
group.setBackground(background);
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 20;
layout.marginWidth = 20;
group.setLayout(layout);
GridData gd;
IProduct product = Platform.getProduct();
{
Label nameLabel = new Label(group, SWT.NONE);
nameLabel.setBackground(background);
nameLabel.setFont(NAME_FONT);
nameLabel.setText(product.getName());
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.CENTER;
nameLabel.setLayoutData(gd);
}
Label titleLabel = new Label(group, SWT.NONE);
titleLabel.setBackground(background);
titleLabel.setFont(TITLE_FONT);
titleLabel.setText(product.getProperty(PRODUCT_PROP_SUB_TITLE));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.CENTER;
titleLabel.setLayoutData(gd);
titleLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
@Override
public void run() {
// Do not create InstallationDialog directly
// but execute "org.eclipse.ui.help.installationDialog" command
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IHandlerService service = workbenchWindow.getService(IHandlerService.class);
if (service != null) {
try {
//$NON-NLS-1$
service.executeCommand("org.eclipse.ui.help.installationDialog", null);
} catch (Exception e1) {
// just ignore error
}
}
}
});
}
});
Label imageLabel = new Label(group, SWT.NONE);
imageLabel.setBackground(background);
gd = new GridData();
gd.verticalAlignment = GridData.BEGINNING;
gd.horizontalAlignment = GridData.CENTER;
gd.grabExcessHorizontalSpace = true;
imageLabel.setLayoutData(gd);
imageLabel.setImage(ABOUT_IMAGE);
Label versionLabel = new Label(group, SWT.NONE);
versionLabel.setBackground(background);
versionLabel.setText(CoreMessages.dialog_about_label_version + GeneralUtils.getProductVersion().toString());
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.CENTER;
versionLabel.setLayoutData(gd);
Label releaseTimeLabel = new Label(group, SWT.NONE);
releaseTimeLabel.setBackground(background);
releaseTimeLabel.setText(DateFormat.getDateInstance(DateFormat.LONG).format(GeneralUtils.getProductReleaseDate()));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.CENTER;
releaseTimeLabel.setLayoutData(gd);
Label authorLabel = new Label(group, SWT.NONE);
authorLabel.setBackground(background);
authorLabel.setText(product.getProperty(PRODUCT_PROP_COPYRIGHT));
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.CENTER;
authorLabel.setLayoutData(gd);
Link siteLink = UIUtils.createLink(group, UIUtils.makeAnchor(product.getProperty(PRODUCT_PROP_WEBSITE)), new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
UIUtils.launchProgram(e.text);
}
});
siteLink.setBackground(background);
gd = new GridData();
gd.horizontalAlignment = GridData.CENTER;
siteLink.setLayoutData(gd);
return parent;
}
use of org.eclipse.swt.events.MouseAdapter in project dbeaver by serge-rider.
the class StatusDetailsDialog method createDialogArea.
@Override
protected Composite createDialogArea(Composite parent) {
Composite composite = super.createDialogArea(parent);
if (!CommonUtils.isEmpty(warnings)) {
// Create warnings table
UIUtils.createControlLabel(composite, "Warnings");
warnTable = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
TableColumn exColumn = UIUtils.createTableColumn(warnTable, SWT.NONE, "Exception");
TableColumn msgColumn = UIUtils.createTableColumn(warnTable, SWT.NONE, "Message");
warnTable.setLinesVisible(true);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.minimumHeight = 100;
warnTable.setLayoutData(gd);
for (Throwable ex : warnings) {
TableItem warnItem = new TableItem(warnTable, SWT.NONE);
warnItem.setText(0, ex.getClass().getName());
if (ex.getMessage() != null) {
warnItem.setText(1, ex.getMessage());
}
warnItem.setData(ex);
}
exColumn.pack();
msgColumn.pack();
warnTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
openWarning();
}
});
warnTable.addTraverseListener(new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_RETURN) {
openWarning();
e.doit = false;
}
}
});
}
return composite;
}
use of org.eclipse.swt.events.MouseAdapter in project dbeaver by serge-rider.
the class PrefPageProjectSettings method createContents.
@Override
protected Control createContents(final Composite parent) {
Composite composite = UIUtils.createPlaceholder(parent, 1, 5);
{
UIUtils.createControlLabel(composite, "Resource locations");
resourceTable = new Table(composite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
resourceTable.setLayoutData(new GridData(GridData.FILL_BOTH));
resourceTable.setHeaderVisible(true);
resourceTable.setLinesVisible(true);
UIUtils.createTableColumn(resourceTable, SWT.LEFT, "Resource");
UIUtils.createTableColumn(resourceTable, SWT.LEFT, "Folder");
resourceTable.setHeaderVisible(true);
resourceTable.setLayoutData(new GridData(GridData.FILL_BOTH));
handlerTableEditor = new TableEditor(resourceTable);
handlerTableEditor.verticalAlignment = SWT.TOP;
handlerTableEditor.horizontalAlignment = SWT.RIGHT;
handlerTableEditor.grabHorizontal = true;
handlerTableEditor.grabVertical = true;
resourceTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
disposeOldEditor();
final TableItem item = resourceTable.getItem(new Point(0, e.y));
if (item == null) {
return;
}
int columnIndex = UIUtils.getColumnAtPos(item, e.x, e.y);
if (columnIndex <= 0) {
return;
}
if (columnIndex == 1) {
final String resourcePath = item.getText(1);
if (project != null) {
final IFolder folder = project.getFolder(resourcePath);
ContainerSelectionDialog dialog = new ContainerSelectionDialog(resourceTable.getShell(), folder, true, "Select " + item.getText(0) + " root folder");
dialog.showClosedProjects(false);
dialog.setValidator(new ISelectionValidator() {
@Override
public String isValid(Object selection) {
if (selection instanceof IPath) {
final File file = ((IPath) selection).toFile();
if (file.isHidden() || file.getName().startsWith(".")) {
return "Can't use hidden folders";
}
final String[] segments = ((IPath) selection).segments();
if (!project.getName().equals(segments[0])) {
return "Can't store resources in another project";
}
}
return null;
}
});
if (dialog.open() == IDialogConstants.OK_ID) {
final Object[] result = dialog.getResult();
if (result.length == 1 && result[0] instanceof IPath) {
final IPath plainPath = ((IPath) result[0]).removeFirstSegments(1).removeTrailingSeparator();
item.setText(1, plainPath.toString());
}
}
} else {
final Text editor = new Text(resourceTable, SWT.NONE);
editor.setText(resourcePath);
editor.selectAll();
handlerTableEditor.setEditor(editor, item, 1);
editor.setFocus();
editor.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
item.setText(1, editor.getText());
}
});
}
}
}
});
}
performDefaults();
return composite;
}
use of org.eclipse.swt.events.MouseAdapter in project dbeaver by serge-rider.
the class MySQLScriptExecuteWizardPageSettings method createControl.
@Override
public void createControl(Composite parent) {
Composite composite = UIUtils.createPlaceholder(parent, 1);
Group outputGroup = UIUtils.createControlGroup(composite, MySQLMessages.tools_script_execute_wizard_page_settings_group_input, 3, GridData.FILL_HORIZONTAL, 0);
inputFileText = UIUtils.createLabelText(outputGroup, MySQLMessages.tools_script_execute_wizard_page_settings_label_input_file, "", //$NON-NLS-2$
SWT.BORDER | SWT.READ_ONLY);
inputFileText.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
chooseInputFile();
}
});
Button browseButton = new Button(outputGroup, SWT.PUSH);
browseButton.setImage(DBeaverIcons.getImage(DBIcon.TREE_FOLDER));
browseButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
chooseInputFile();
}
});
if (wizard.getInputFile() != null) {
inputFileText.setText(wizard.getInputFile().getName());
}
Group settingsGroup = UIUtils.createControlGroup(composite, MySQLMessages.tools_script_execute_wizard_page_settings_group_settings, 2, GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
logLevelCombo = UIUtils.createLabelCombo(settingsGroup, MySQLMessages.tools_script_execute_wizard_page_settings_label_log_level, SWT.DROP_DOWN | SWT.READ_ONLY);
for (MySQLScriptExecuteWizard.LogLevel logLevel : MySQLScriptExecuteWizard.LogLevel.values()) {
logLevelCombo.add(logLevel.name());
}
logLevelCombo.select(wizard.getLogLevel().ordinal());
logLevelCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
wizard.setLogLevel(MySQLScriptExecuteWizard.LogLevel.valueOf(logLevelCombo.getText()));
}
});
createSecurityGroup(composite);
setControl(composite);
//updateState();
}
use of org.eclipse.swt.events.MouseAdapter in project translationstudio8 by heartsome.
the class NatCombo method createTextControl.
private void createTextControl() {
text = new Text(this, HorizontalAlignmentEnum.getSWTStyle(cellStyle));
text.setBackground(cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
text.setForeground(cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
text.setFont(cellStyle.getAttributeValue(CellStyleAttributes.FONT));
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
text.setLayoutData(gridData);
text.forceFocus();
text.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
if (event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_UP) {
showDropdownControl();
int selectionIndex = dropdownList.getSelectionIndex();
selectionIndex += event.keyCode == SWT.ARROW_DOWN ? 1 : -1;
if (selectionIndex < 0) {
selectionIndex = 0;
}
dropdownList.select(selectionIndex);
text.setText(dropdownList.getSelection()[0]);
}
}
});
iconImage = GUIHelper.getImage("down_2");
final Canvas iconCanvas = new Canvas(this, SWT.NONE) {
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
Rectangle iconImageBounds = iconImage.getBounds();
return new Point(iconImageBounds.width + 2, iconImageBounds.height + 2);
}
};
gridData = new GridData(GridData.BEGINNING, SWT.FILL, false, true);
iconCanvas.setLayoutData(gridData);
iconCanvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent event) {
GC gc = event.gc;
Rectangle iconCanvasBounds = iconCanvas.getBounds();
Rectangle iconImageBounds = iconImage.getBounds();
int horizontalAlignmentPadding = CellStyleUtil.getHorizontalAlignmentPadding(HorizontalAlignmentEnum.CENTER, iconCanvasBounds, iconImageBounds.width);
int verticalAlignmentPadding = CellStyleUtil.getVerticalAlignmentPadding(VerticalAlignmentEnum.MIDDLE, iconCanvasBounds, iconImageBounds.height);
gc.drawImage(iconImage, horizontalAlignmentPadding, verticalAlignmentPadding);
Color originalFg = gc.getForeground();
gc.setForeground(GUIHelper.COLOR_WIDGET_BORDER);
gc.drawRectangle(0, 0, iconCanvasBounds.width - 1, iconCanvasBounds.height - 1);
gc.setForeground(originalFg);
}
});
iconCanvas.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
showDropdownControl();
}
});
}
Aggregations