Search in sources :

Example 46 with Canvas

use of org.eclipse.swt.widgets.Canvas in project dbeaver by dbeaver.

the class ERDOutlinePage method createControl.

/* (non-Javadoc)
     * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite)
     */
@Override
public void createControl(Composite parent) {
    // create canvas and lws
    overview = new Canvas(parent, SWT.NONE);
    LightweightSystem lws = new LightweightSystem(overview);
    // create thumbnail
    thumbnail = new ScrollableThumbnail((Viewport) rootEditPart.getFigure());
    thumbnail.setBorder(new MarginBorder(3));
    thumbnail.setSource(rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS));
    lws.setContents(thumbnail);
}
Also used : Canvas(org.eclipse.swt.widgets.Canvas) MarginBorder(org.eclipse.draw2d.MarginBorder) Viewport(org.eclipse.draw2d.Viewport) LightweightSystem(org.eclipse.draw2d.LightweightSystem) ScrollableThumbnail(org.eclipse.draw2d.parts.ScrollableThumbnail)

Example 47 with Canvas

use of org.eclipse.swt.widgets.Canvas in project dbeaver by dbeaver.

the class EmptyPresentation method createPresentation.

@Override
public void createPresentation(@NotNull final IResultSetController controller, @NotNull Composite parent) {
    super.createPresentation(controller, parent);
    UIUtils.createHorizontalLine(parent);
    placeholder = new Canvas(parent, SWT.NONE);
    placeholder.setLayoutData(new GridData(GridData.FILL_BOTH));
    placeholder.setBackground(controller.getDefaultBackground());
    final Font normalFont = parent.getFont();
    FontData[] fontData = normalFont.getFontData();
    fontData[0].setStyle(fontData[0].getStyle() | SWT.BOLD);
    fontData[0].setHeight(18);
    final Font largeFont = new Font(normalFont.getDevice(), fontData[0]);
    placeholder.addDisposeListener(e -> UIUtils.dispose(largeFont));
    placeholder.addPaintListener(e -> {
        if (controller.isRefreshInProgress()) {
            return;
        }
        e.gc.setFont(largeFont);
        e.gc.setForeground(UIStyles.getDefaultTextForeground());
        // int fontSize = largeFont.getFontData()[0].getHeight();
        String emptyDataMessage = controller.getDecorator().getEmptyDataMessage();
        if (!CommonUtils.isEmpty(emptyDataMessage)) {
            Point emSize = e.gc.textExtent(emptyDataMessage);
            UIUtils.drawMessageOverControl(placeholder, e, emptyDataMessage, -emSize.y);
        }
        e.gc.setFont(normalFont);
        String emptyDataDescription = controller.getDecorator().getEmptyDataDescription();
        if (!CommonUtils.isEmpty(emptyDataDescription)) {
            UIUtils.drawMessageOverControl(placeholder, e, emptyDataDescription, 10);
        }
    });
    trackPresentationControl();
}
Also used : Canvas(org.eclipse.swt.widgets.Canvas) FontData(org.eclipse.swt.graphics.FontData) GridData(org.eclipse.swt.layout.GridData) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font)

Example 48 with Canvas

use of org.eclipse.swt.widgets.Canvas in project yamcs-studio by yamcs.

the class OPIColorDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    var parent_Composite = (Composite) super.createDialogArea(parent);
    var mainComposite = new Composite(parent_Composite, SWT.None);
    mainComposite.setLayout(new GridLayout(2, false));
    var gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.heightHint = 300;
    mainComposite.setLayoutData(gridData);
    var leftComposite = new Composite(mainComposite, SWT.None);
    leftComposite.setLayout(new GridLayout(1, false));
    var gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 220;
    leftComposite.setLayoutData(gd);
    createLabel(leftComposite, "Choose from Predefined Colors:");
    preDefinedColorsViewer = createPredefinedColorsTableViewer(leftComposite);
    preDefinedColorsViewer.setInput(MediaService.getInstance().getAllPredefinedColors());
    var rightComposite = new Composite(mainComposite, SWT.None);
    rightComposite.setLayout(new GridLayout(1, false));
    gd = new GridData(SWT.LEFT, SWT.BEGINNING, true, true);
    rightComposite.setLayoutData(gd);
    createLabel(rightComposite, "");
    var colorDialogButton = new Button(rightComposite, SWT.PUSH);
    colorDialogButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    colorDialogButton.setText("Choose from Color Dialog");
    colorDialogButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            var dialog = new ColorDialog(Display.getCurrent().getActiveShell());
            dialog.setRGB(opiColor.getRGBValue());
            var rgb = dialog.open();
            if (rgb != null) {
                opiColor.setColorValue(rgb);
                preDefinedColorsViewer.setSelection(null);
                setRGBEditValue(rgb);
                outputTextLabel.setText(opiColor.getColorName());
                colorCanvas.setBackground(CustomMediaFactory.getInstance().getColor(opiColor.getRGBValue()));
            }
        }
    });
    createRGBEditGroup(rightComposite);
    var group = new Group(rightComposite, SWT.None);
    group.setLayoutData(new GridData(SWT.FILL, SWT.END, true, true));
    group.setLayout(new GridLayout(3, false));
    group.setText("Output");
    colorCanvas = new Canvas(group, SWT.BORDER);
    colorCanvas.setBackground(CustomMediaFactory.getInstance().getColor(opiColor.getRGBValue()));
    gd = new GridData(SWT.LEFT, SWT.TOP, false, false);
    gd.widthHint = 30;
    gd.heightHint = 30;
    colorCanvas.setLayoutData(gd);
    outputTextLabel = new Label(group, SWT.None);
    outputTextLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    outputTextLabel.setText(opiColor.getColorName());
    if (opiColor.isPreDefined()) {
        preDefinedColorsViewer.setSelection(new StructuredSelection(opiColor));
    } else {
        preDefinedColorsViewer.setSelection(null);
    }
    return parent_Composite;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Canvas(org.eclipse.swt.widgets.Canvas) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) ColorDialog(org.eclipse.swt.widgets.ColorDialog) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 49 with Canvas

use of org.eclipse.swt.widgets.Canvas in project yamcs-studio by yamcs.

the class OverviewOutlinePage method createControl.

@Override
public void createControl(Composite parent) {
    overview = new Canvas(parent, SWT.NONE);
    var lws = new LightweightSystem(overview);
    thumbnail = new ScrollableThumbnail((Viewport) rootEP.getFigure());
    thumbnail.setBorder(new MarginBorder(3));
    thumbnail.setSource(rootEP.getLayer(LayerConstants.PRINTABLE_LAYERS));
    lws.setContents(thumbnail);
    disposeListener = e -> {
        if (thumbnail != null) {
            thumbnail.deactivate();
            thumbnail = null;
        }
    };
    rootEP.getViewer().getControl().addDisposeListener(disposeListener);
}
Also used : Canvas(org.eclipse.swt.widgets.Canvas) MarginBorder(org.eclipse.draw2d.MarginBorder) Viewport(org.eclipse.draw2d.Viewport) LightweightSystem(org.eclipse.draw2d.LightweightSystem) ScrollableThumbnail(org.eclipse.draw2d.parts.ScrollableThumbnail)

Example 50 with Canvas

use of org.eclipse.swt.widgets.Canvas in project pentaho-kettle by pentaho.

the class Sleak method create.

public void create(Composite parent) {
    list = new List(parent, SWT.BORDER | SWT.V_SCROLL);
    list.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            refreshObject();
        }
    });
    text = new Text(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    canvas = new Canvas(parent, SWT.BORDER);
    canvas.addListener(SWT.Paint, new Listener() {

        public void handleEvent(Event event) {
            paintCanvas(event);
        }
    });
    check = new Button(parent, SWT.CHECK);
    check.setText("Stack");
    check.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            toggleStackTrace();
        }
    });
    start = new Button(parent, SWT.PUSH);
    start.setText("Snap");
    start.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            refreshAll();
        }
    });
    stop = new Button(parent, SWT.PUSH);
    stop.setText("Diff");
    stop.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            refreshDifference();
        }
    });
    label = new Label(parent, SWT.BORDER);
    label.setText("0 object(s)");
    parent.addListener(SWT.Resize, new Listener() {

        public void handleEvent(Event e) {
            layout();
        }
    });
    check.setSelection(false);
    text.setVisible(false);
    layout();
}
Also used : Listener(org.eclipse.swt.widgets.Listener) Button(org.eclipse.swt.widgets.Button) Canvas(org.eclipse.swt.widgets.Canvas) Label(org.eclipse.swt.widgets.Label) Event(org.eclipse.swt.widgets.Event) List(org.eclipse.swt.widgets.List) Text(org.eclipse.swt.widgets.Text)

Aggregations

Canvas (org.eclipse.swt.widgets.Canvas)111 GridData (org.eclipse.swt.layout.GridData)47 GridLayout (org.eclipse.swt.layout.GridLayout)38 Composite (org.eclipse.swt.widgets.Composite)38 PaintEvent (org.eclipse.swt.events.PaintEvent)36 PaintListener (org.eclipse.swt.events.PaintListener)35 Point (org.eclipse.swt.graphics.Point)32 Rectangle (org.eclipse.swt.graphics.Rectangle)32 Label (org.eclipse.swt.widgets.Label)31 Text (org.eclipse.swt.widgets.Text)24 Button (org.eclipse.swt.widgets.Button)22 Color (org.eclipse.swt.graphics.Color)20 Shell (org.eclipse.swt.widgets.Shell)20 MouseEvent (org.eclipse.swt.events.MouseEvent)18 GC (org.eclipse.swt.graphics.GC)17 FillLayout (org.eclipse.swt.layout.FillLayout)17 Event (org.eclipse.swt.widgets.Event)17 SelectionEvent (org.eclipse.swt.events.SelectionEvent)16 Listener (org.eclipse.swt.widgets.Listener)16 Display (org.eclipse.swt.widgets.Display)15