Search in sources :

Example 21 with GridData

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();
}
Also used : ControlEditor(org.eclipse.swt.custom.ControlEditor) PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) Image(org.eclipse.swt.graphics.Image) InvocationTargetException(java.lang.reflect.InvocationTargetException) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 22 with GridData

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;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 23 with GridData

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;
}
Also used : GridData(org.eclipse.swt.layout.GridData)

Example 24 with GridData

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;
}
Also used : GridData(org.eclipse.swt.layout.GridData)

Example 25 with GridData

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);
    }
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData)

Aggregations

GridData (org.eclipse.swt.layout.GridData)1831 GridLayout (org.eclipse.swt.layout.GridLayout)1286 Composite (org.eclipse.swt.widgets.Composite)1136 Label (org.eclipse.swt.widgets.Label)709 SelectionEvent (org.eclipse.swt.events.SelectionEvent)602 Button (org.eclipse.swt.widgets.Button)526 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)512 Text (org.eclipse.swt.widgets.Text)427 Group (org.eclipse.swt.widgets.Group)383 ModifyListener (org.eclipse.swt.events.ModifyListener)184 ModifyEvent (org.eclipse.swt.events.ModifyEvent)181 Combo (org.eclipse.swt.widgets.Combo)171 Table (org.eclipse.swt.widgets.Table)140 TableViewer (org.eclipse.jface.viewers.TableViewer)136 Point (org.eclipse.swt.graphics.Point)107 SelectionListener (org.eclipse.swt.events.SelectionListener)100 FillLayout (org.eclipse.swt.layout.FillLayout)93 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)85 TableColumn (org.eclipse.swt.widgets.TableColumn)80 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)76