use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.
the class ProgressLoaderVisualizer method showProgress.
private void showProgress() {
if (progressOverlay == null) {
// Start progress visualization
cancelButton = new Button(progressPane, SWT.PUSH);
cancelButton.setText("Cancel");
GridData gd = new GridData(GridData.FILL_BOTH);
gd.verticalIndent = DBeaverIcons.getImage(UIIcon.PROGRESS0).getBounds().height * 2;
cancelButton.setLayoutData(gd);
cancelButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
cancelButton.setText("Canceled");
cancelButton.setEnabled(false);
Point buttonSize = cancelButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
progressOverlay.minimumWidth = buttonSize.x;
progressOverlay.minimumHeight = buttonSize.y;
progressOverlay.layout();
try {
loadService.cancel();
} catch (InvocationTargetException e1) {
log.error(e1.getTargetException());
}
}
});
painListener = new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
Image image = DBeaverIcons.getImage(PROGRESS_IMAGES[drawCount % PROGRESS_IMAGES.length]);
Rectangle buttonBounds = cancelButton.getBounds();
Rectangle imageBounds = image.getBounds();
e.gc.drawImage(image, (buttonBounds.x + buttonBounds.width / 2) - imageBounds.width / 2, buttonBounds.y - imageBounds.height - 5);
long elapsedTime = System.currentTimeMillis() - loadStartTime;
String elapsedString = elapsedTime > 10000 ? String.valueOf(elapsedTime / 1000) : String.valueOf(((double) (elapsedTime / 100)) / 10);
String statusMessage = CommonUtils.truncateString(progressMessage.replaceAll("\\s", " "), 64);
String status = statusMessage + " - " + elapsedString + "s";
Point statusSize = e.gc.textExtent(status);
int statusX = (buttonBounds.x + buttonBounds.width / 2) - statusSize.x / 2;
int statusY = buttonBounds.y - imageBounds.height - 10 - statusSize.y;
e.gc.setForeground(progressPane.getForeground());
e.gc.setBackground(progressPane.getBackground());
e.gc.fillRectangle(statusX - 2, statusY - 2, statusSize.x + 4, statusSize.y + 4);
e.gc.drawText(status, statusX, statusY, true);
e.gc.setForeground(shadowColor);
e.gc.drawRoundRectangle(statusX - 3, statusY - 3, statusSize.x + 5, statusSize.y + 5, 5, 5);
}
};
progressPane.addPaintListener(painListener);
progressOverlay = new ControlEditor(progressPane);
Point buttonSize = cancelButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
progressOverlay.minimumWidth = buttonSize.x;
progressOverlay.minimumHeight = buttonSize.y;
progressOverlay.setEditor(cancelButton);
}
drawCount++;
progressOverlay.layout();
progressPane.redraw();
}
use of org.eclipse.swt.layout.GridData 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.GridData in project dbeaver by serge-rider.
the class UIUtils method createLabelCombo.
public static Combo createLabelCombo(Composite parent, String label, String tooltip, int style) {
Label labelControl = createControlLabel(parent, label);
if (tooltip != null) {
labelControl.setToolTipText(tooltip);
}
final Combo combo = new Combo(parent, style);
combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if (tooltip != null) {
combo.setToolTipText(tooltip);
}
return combo;
}
use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.
the class UIUtils method createHorizontalLine.
public static Label createHorizontalLine(Composite parent) {
Label horizontalLine = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1));
return horizontalLine;
}
use of org.eclipse.swt.layout.GridData 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);
}
}
Aggregations