Search in sources :

Example 41 with PaintListener

use of org.eclipse.swt.events.PaintListener in project pentaho-kettle by pentaho.

the class PropsUI method setLook.

public void setLook(final Control control, int style) {
    if (this.isOSLookShown() && style != WIDGET_STYLE_FIXED) {
        return;
    }
    final GUIResource gui = GUIResource.getInstance();
    Font font = null;
    Color background = null;
    switch(style) {
        case WIDGET_STYLE_DEFAULT:
            background = gui.getColorBackground();
            if (control instanceof Group && OS.indexOf("mac") > -1) {
                control.addPaintListener(new PaintListener() {

                    @Override
                    public void paintControl(PaintEvent paintEvent) {
                        paintEvent.gc.setBackground(gui.getColorBackground());
                        paintEvent.gc.fillRectangle(2, 0, control.getBounds().width - 8, control.getBounds().height - 20);
                    }
                });
            }
            // GUIResource.getInstance().getFontDefault();
            font = null;
            break;
        case WIDGET_STYLE_FIXED:
            if (!this.isOSLookShown()) {
                background = gui.getColorBackground();
            }
            font = gui.getFontFixed();
            break;
        case WIDGET_STYLE_TABLE:
            background = gui.getColorBackground();
            // gui.getFontGrid();
            font = null;
            break;
        case WIDGET_STYLE_NOTEPAD:
            background = gui.getColorBackground();
            font = gui.getFontNote();
            break;
        case WIDGET_STYLE_GRAPH:
            background = gui.getColorBackground();
            font = gui.getFontGraph();
            break;
        case WIDGET_STYLE_TOOLBAR:
            background = GUIResource.getInstance().getColorDemoGray();
            break;
        case WIDGET_STYLE_TAB:
            background = GUIResource.getInstance().getColorWhite();
            CTabFolder tabFolder = (CTabFolder) control;
            tabFolder.setSimple(false);
            tabFolder.setBorderVisible(true);
            // need to make a copy of the tab selection background color to get around PDI-13940
            Color c = GUIResource.getInstance().getColorTab();
            Color tabColor = new Color(c.getDevice(), c.getRed(), c.getGreen(), c.getBlue());
            tabFolder.setSelectionBackground(tabColor);
            break;
        default:
            background = gui.getColorBackground();
            // gui.getFontDefault();
            font = null;
            break;
    }
    if (font != null && !font.isDisposed()) {
        control.setFont(font);
    }
    if (background != null && !background.isDisposed()) {
        if (control instanceof Button) {
            Button b = (Button) control;
            if ((b.getStyle() & SWT.PUSH) != 0) {
                return;
            }
        }
        control.setBackground(background);
    }
}
Also used : GUIResource(org.pentaho.di.ui.core.gui.GUIResource) Group(org.eclipse.swt.widgets.Group) PaintEvent(org.eclipse.swt.events.PaintEvent) CTabFolder(org.eclipse.swt.custom.CTabFolder) PaintListener(org.eclipse.swt.events.PaintListener) Button(org.eclipse.swt.widgets.Button) Color(org.eclipse.swt.graphics.Color) Font(org.eclipse.swt.graphics.Font)

Example 42 with PaintListener

use of org.eclipse.swt.events.PaintListener in project pentaho-kettle by pentaho.

the class JobMetricsDelegate method setupContent.

public void setupContent() {
    if (metricsComposite.isDisposed()) {
        return;
    }
    // 
    for (Control control : metricsComposite.getChildren()) {
        if (!control.isDisposed()) {
            control.dispose();
        }
    }
    emptyGraph = false;
    canvas = new Canvas(metricsComposite, SWT.NONE);
    spoon.props.setLook(canvas);
    FormData fdCanvas = new FormData();
    fdCanvas.left = new FormAttachment(0, 0);
    fdCanvas.right = new FormAttachment(100, 0);
    fdCanvas.top = new FormAttachment(0, 0);
    fdCanvas.bottom = new FormAttachment(100, 0);
    canvas.setLayoutData(fdCanvas);
    metricsComposite.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent event) {
            updateGraph();
        }
    });
    metricsComposite.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent event) {
            if (image != null) {
                image.dispose();
            }
        }
    });
    canvas.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent event) {
            if (jobGraph.job != null && (jobGraph.job.isFinished() || jobGraph.job.isStopped())) {
                refreshImage(event.gc);
                if (!Const.isRunningOnWebspoonMode()) {
                    if (image != null && !image.isDisposed()) {
                        event.gc.drawImage(image, 0, 0);
                    }
                }
            } else {
                Rectangle bounds = canvas.getBounds();
                if (bounds.width <= 0 || bounds.height <= 0) {
                    return;
                }
                event.gc.setForeground(GUIResource.getInstance().getColorWhite());
                event.gc.setBackground(GUIResource.getInstance().getColorWhite());
                event.gc.fillRectangle(new Rectangle(0, 0, bounds.width, bounds.height));
                event.gc.setForeground(GUIResource.getInstance().getColorBlack());
                String metricsMessage = BaseMessages.getString(PKG, "JobMetricsDelegate.JobIsNotRunning.Message");
                org.eclipse.swt.graphics.Point extent = event.gc.textExtent(metricsMessage);
                event.gc.drawText(metricsMessage, (bounds.width - extent.x) / 2, (bounds.height - extent.y) / 2);
            }
        }
    });
    // Refresh automatically every 5 seconds as well.
    // 
    final Timer timer = new Timer("JobMetricsDelegate Timer");
    timer.schedule(new TimerTask() {

        public void run() {
            updateGraph();
        }
    }, 0, 5000);
    // When the tab is closed, we remove the update timer
    // 
    jobMetricsTab.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent arg0) {
            timer.cancel();
        }
    });
    if (Const.isRunningOnWebspoonMode()) {
        // When the browser tab/window is closed, we remove the update timer
        jobMetricsTab.getDisplay().disposeExec(new Runnable() {

            @Override
            public void run() {
                timer.cancel();
            }
        });
    }
    // Show tool tips with details...
    // 
    canvas.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent event) {
            if (drawAreas == null) {
                return;
            }
            for (int i = drawAreas.size() - 1; i >= 0; i--) {
                MetricsDrawArea drawArea = drawAreas.get(i);
                if (drawArea.getArea().contains(event.x, event.y)) {
                    MetricsDuration duration = drawArea.getDuration();
                    if (duration == null) {
                        continue;
                    }
                    System.out.println(duration.toString());
                    LoggingObjectInterface loggingObject = LoggingRegistry.getInstance().getLoggingObject(duration.getLogChannelId());
                    if (loggingObject == null) {
                        return;
                    }
                    System.out.println(loggingObject.getObjectType() + " : " + loggingObject.getObjectName());
                }
            }
        }
    });
    canvas.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent arg0) {
            // force a refresh
            lastRefreshTime = 0;
        }
    });
}
Also used : FormData(org.eclipse.swt.layout.FormData) MetricsDrawArea(org.pentaho.di.core.logging.MetricsPainter.MetricsDrawArea) DisposeListener(org.eclipse.swt.events.DisposeListener) PaintEvent(org.eclipse.swt.events.PaintEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) ControlAdapter(org.eclipse.swt.events.ControlAdapter) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) Rectangle(org.eclipse.swt.graphics.Rectangle) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Point(org.pentaho.di.core.gui.Point) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Control(org.eclipse.swt.widgets.Control) Timer(java.util.Timer) TimerTask(java.util.TimerTask) ControlEvent(org.eclipse.swt.events.ControlEvent) LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface) MetricsDuration(org.pentaho.di.core.metrics.MetricsDuration) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 43 with PaintListener

use of org.eclipse.swt.events.PaintListener in project pentaho-kettle by pentaho.

the class EnterPrintDialog method open.

public int open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    retval = SWT.OK;
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.SHEET | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "EnterPrintDialog.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Canvas
    wlCanvas = new Label(shell, SWT.NONE);
    wlCanvas.setText(BaseMessages.getString(PKG, "EnterPrintDialog.PrintArea.Label"));
    props.setLook(wlCanvas);
    fdlCanvas = new FormData();
    fdlCanvas.left = new FormAttachment(0, 0);
    fdlCanvas.top = new FormAttachment(0, margin);
    wlCanvas.setLayoutData(fdlCanvas);
    wCanvas = new Canvas(shell, SWT.BORDER);
    props.setLook(wCanvas);
    wCanvas.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent pe) {
            repaint(pe.gc, pe.width, pe.height);
        }
    });
    fdCanvas = new FormData();
    fdCanvas.left = new FormAttachment(0, 0);
    fdCanvas.top = new FormAttachment(wlCanvas, margin);
    fdCanvas.right = new FormAttachment(100, 0);
    fdCanvas.bottom = new FormAttachment(100, -220);
    wCanvas.setLayoutData(fdCanvas);
    // Rows
    wlRows = new Label(shell, SWT.NONE);
    wlRows.setText(BaseMessages.getString(PKG, "EnterPrintDialog.Rows.Label"));
    props.setLook(wlRows);
    fdlRows = new FormData();
    fdlRows.left = new FormAttachment(0, 0);
    fdlRows.right = new FormAttachment(middle, -margin);
    fdlRows.top = new FormAttachment(wCanvas, margin);
    wlRows.setLayoutData(fdlRows);
    wRows = new Slider(shell, SWT.HORIZONTAL);
    wRows.setIncrement(1);
    wRows.setMinimum(1);
    wRows.setMaximum(11);
    wRows.setThumb(1);
    wRows.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent se) {
            Slider sl = (Slider) se.widget;
            nrrows = sl.getSelection();
            wCanvas.redraw();
        }
    });
    props.setLook(wRows);
    fdRows = new FormData();
    fdRows.left = new FormAttachment(middle, 0);
    fdRows.top = new FormAttachment(wCanvas, margin);
    fdRows.right = new FormAttachment(100, 0);
    wRows.setLayoutData(fdRows);
    // Cols
    wlCols = new Label(shell, SWT.NONE);
    wlCols.setText(BaseMessages.getString(PKG, "EnterPrintDialog.Cols.Label"));
    props.setLook(wlCols);
    fdlCols = new FormData();
    fdlCols.left = new FormAttachment(0, 0);
    fdlCols.right = new FormAttachment(middle, -margin);
    fdlCols.top = new FormAttachment(wRows, margin);
    wlCols.setLayoutData(fdlCols);
    wCols = new Slider(shell, SWT.HORIZONTAL);
    wCols.setIncrement(1);
    wCols.setMinimum(1);
    wCols.setMaximum(11);
    wCols.setThumb(1);
    wCols.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent se) {
            Slider sl = (Slider) se.widget;
            nrcols = sl.getSelection();
            wCanvas.redraw();
        }
    });
    props.setLook(wCols);
    fdCols = new FormData();
    fdCols.left = new FormAttachment(middle, 0);
    fdCols.top = new FormAttachment(wRows, margin);
    fdCols.right = new FormAttachment(100, 0);
    wCols.setLayoutData(fdCols);
    // Scale
    wlScale = new Label(shell, SWT.NONE);
    wlScale.setText(BaseMessages.getString(PKG, "EnterPrintDialog.Scaling.Label"));
    props.setLook(wlScale);
    fdlScale = new FormData();
    fdlScale.left = new FormAttachment(0, 0);
    fdlScale.right = new FormAttachment(middle, -margin);
    fdlScale.top = new FormAttachment(wCols, margin);
    wlScale.setLayoutData(fdlScale);
    wScale = new Slider(shell, SWT.HORIZONTAL);
    wScale.setIncrement(10);
    wScale.setMinimum(10);
    wScale.setMaximum(500);
    wScale.setThumb(10);
    wScale.setPageIncrement(25);
    wScale.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent se) {
            Slider sl = (Slider) se.widget;
            scale = sl.getSelection();
            wCanvas.redraw();
        }
    });
    props.setLook(wScale);
    fdScale = new FormData();
    fdScale.left = new FormAttachment(middle, 0);
    fdScale.top = new FormAttachment(wCols, margin);
    fdScale.right = new FormAttachment(100, 0);
    wScale.setLayoutData(fdScale);
    // Left
    wlLeft = new Label(shell, SWT.NONE);
    wlLeft.setText(BaseMessages.getString(PKG, "EnterPrintDialog.LeftMargin.Label"));
    props.setLook(wlLeft);
    fdlLeft = new FormData();
    fdlLeft.left = new FormAttachment(0, 0);
    fdlLeft.right = new FormAttachment(middle, -margin);
    fdlLeft.top = new FormAttachment(wScale, margin);
    wlLeft.setLayoutData(fdlLeft);
    wLeft = new Text(shell, SWT.BORDER);
    wLeft.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            Text w = (Text) e.widget;
            leftMargin = Const.toDouble(w.getText(), 0.00);
        }
    });
    props.setLook(wLeft);
    fdLeft = new FormData();
    fdLeft.left = new FormAttachment(middle, 0);
    fdLeft.top = new FormAttachment(wScale, margin);
    fdLeft.right = new FormAttachment(100, 0);
    wLeft.setLayoutData(fdLeft);
    // Right
    wlRight = new Label(shell, SWT.NONE);
    wlRight.setText(BaseMessages.getString(PKG, "EnterPrintDialog.RightMargin.Label"));
    props.setLook(wlRight);
    fdlRight = new FormData();
    fdlRight.left = new FormAttachment(0, 0);
    fdlRight.right = new FormAttachment(middle, -margin);
    fdlRight.top = new FormAttachment(wLeft, margin);
    wlRight.setLayoutData(fdlRight);
    wRight = new Text(shell, SWT.BORDER);
    wRight.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            Text w = (Text) e.widget;
            rightMargin = Const.toDouble(w.getText(), 0.00);
        }
    });
    props.setLook(wRight);
    fdRight = new FormData();
    fdRight.left = new FormAttachment(middle, 0);
    fdRight.top = new FormAttachment(wLeft, margin);
    fdRight.right = new FormAttachment(100, 0);
    wRight.setLayoutData(fdRight);
    // Top
    wlTop = new Label(shell, SWT.NONE);
    wlTop.setText(BaseMessages.getString(PKG, "EnterPrintDialog.TopMargin.Label"));
    props.setLook(wlTop);
    fdlTop = new FormData();
    fdlTop.left = new FormAttachment(0, 0);
    fdlTop.right = new FormAttachment(middle, -margin);
    fdlTop.top = new FormAttachment(wRight, margin);
    wlTop.setLayoutData(fdlTop);
    wTop = new Text(shell, SWT.BORDER);
    wTop.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            Text w = (Text) e.widget;
            topMargin = Const.toDouble(w.getText(), 0.00);
        }
    });
    props.setLook(wTop);
    fdTop = new FormData();
    fdTop.left = new FormAttachment(middle, 0);
    fdTop.top = new FormAttachment(wRight, margin);
    fdTop.right = new FormAttachment(100, 0);
    wTop.setLayoutData(fdTop);
    // Bottom
    wlBottom = new Label(shell, SWT.NONE);
    wlBottom.setText(BaseMessages.getString(PKG, "EnterPrintDialog.BottomMargin.Label"));
    props.setLook(wlBottom);
    fdlBottom = new FormData();
    fdlBottom.left = new FormAttachment(0, 0);
    fdlBottom.right = new FormAttachment(middle, -margin);
    fdlBottom.top = new FormAttachment(wTop, margin);
    wlBottom.setLayoutData(fdlBottom);
    wBottom = new Text(shell, SWT.BORDER);
    wBottom.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            Text w = (Text) e.widget;
            bottomMargin = Const.toDouble(w.getText(), 0.00);
        }
    });
    props.setLook(wBottom);
    fdBottom = new FormData();
    fdBottom.left = new FormAttachment(middle, 0);
    fdBottom.top = new FormAttachment(wTop, margin);
    fdBottom.right = new FormAttachment(100, 0);
    wBottom.setLayoutData(fdBottom);
    // Some buttons
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    fdOK = new FormData();
    fdOK.left = new FormAttachment(33, 0);
    fdOK.bottom = new FormAttachment(100, 0);
    wOK.setLayoutData(fdOK);
    fdCancel = new FormData();
    fdCancel.left = new FormAttachment(66, 0);
    fdCancel.bottom = new FormAttachment(100, 0);
    wCancel.setLayoutData(fdCancel);
    // Add listeners
    lsCancel = new Listener() {

        public void handleEvent(Event e) {
            cancel();
        }
    };
    lsOK = new Listener() {

        public void handleEvent(Event e) {
            ok();
        }
    };
    wOK.addListener(SWT.Selection, lsOK);
    wCancel.addListener(SWT.Selection, lsCancel);
    // Detect [X] or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    getData();
    BaseStepDialog.setSize(shell);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return retval;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ShellAdapter(org.eclipse.swt.events.ShellAdapter) PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) Slider(org.eclipse.swt.widgets.Slider) ModifyListener(org.eclipse.swt.events.ModifyListener) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ShellEvent(org.eclipse.swt.events.ShellEvent) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) Shell(org.eclipse.swt.widgets.Shell) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) PaintEvent(org.eclipse.swt.events.PaintEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display)

Example 44 with PaintListener

use of org.eclipse.swt.events.PaintListener in project pentaho-kettle by pentaho.

the class CheckBoxToolTip method createToolTipContentArea.

protected Composite createToolTipContentArea(Event event, Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    FormLayout compLayout = new FormLayout();
    compLayout.marginHeight = 5;
    compLayout.marginWidth = 5;
    composite.setLayout(compLayout);
    composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    Label imageLabel = new Label(composite, SWT.NONE);
    imageLabel.setImage(image);
    imageLabel.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    FormData fdImageLabel = new FormData();
    fdImageLabel.left = new FormAttachment(0, 0);
    fdImageLabel.top = new FormAttachment(0, 0);
    imageLabel.setLayoutData(fdImageLabel);
    Label titleLabel = new Label(composite, SWT.LEFT);
    titleLabel.setText(title);
    titleLabel.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    titleLabel.setFont(GUIResource.getInstance().getFontBold());
    FormData fdTitleLabel = new FormData();
    fdTitleLabel.left = new FormAttachment(imageLabel, 20);
    fdTitleLabel.top = new FormAttachment(0, 0);
    titleLabel.setLayoutData(fdTitleLabel);
    Label line = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
    line.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    FormData fdLine = new FormData();
    fdLine.left = new FormAttachment(imageLabel, 5);
    fdLine.right = new FormAttachment(100, -5);
    fdLine.top = new FormAttachment(titleLabel, 5);
    line.setLayoutData(fdLine);
    // Text messageLabel = new Text(composite, SWT.LEFT | ( showingScrollBars ? SWT.H_SCROLL | SWT.V_SCROLL : SWT.NONE )
    // );
    /*
     * Text messageLabel = new Text(composite, SWT.SINGLE | SWT.LEFT); messageLabel.setText(message);
     * messageLabel.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); FormData fdMessageLabel = new
     * FormData(); fdMessageLabel.left = new FormAttachment(imageLabel, 20); fdMessageLabel.top = new
     * FormAttachment(line, 5); if (showingScrollBars) { fdMessageLabel.right = new FormAttachment(imageLabel, 500);
     * fdMessageLabel.bottom= new FormAttachment(line, 400); } messageLabel.setLayoutData(fdMessageLabel);
     */
    Label messageLabel = new Label(composite, SWT.LEFT);
    messageLabel.setText(message);
    messageLabel.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    FormData fdMessageLabel = new FormData();
    fdMessageLabel.left = new FormAttachment(imageLabel, 20);
    fdMessageLabel.top = new FormAttachment(line, 5);
    messageLabel.setLayoutData(fdMessageLabel);
    final Button disable = new Button(composite, SWT.CHECK);
    disable.setText(checkBoxMessage);
    disable.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    disable.setSelection(false);
    FormData fdDisable = new FormData();
    fdDisable.left = new FormAttachment(0, 0);
    fdDisable.top = new FormAttachment(messageLabel, 20);
    fdDisable.bottom = new FormAttachment(100, 0);
    disable.setLayoutData(fdDisable);
    disable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            for (CheckBoxToolTipListener listener : listeners) {
                listener.checkBoxSelected(false);
            }
            hide();
        }
    });
    disable.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent arg0) {
            checkBoxBounds = disable.getBounds();
        }
    });
    composite.layout();
    checkBoxBounds = disable.getBounds();
    return composite;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) PaintEvent(org.eclipse.swt.events.PaintEvent) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) PaintListener(org.eclipse.swt.events.PaintListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 45 with PaintListener

use of org.eclipse.swt.events.PaintListener in project translationstudio8 by heartsome.

the class Grid method initListeners.

/**
     * Initialize all listeners.
     */
private void initListeners() {
    disposeListener = new Listener() {

        public void handleEvent(Event e) {
            onDispose(e);
        }
    };
    addListener(SWT.Dispose, disposeListener);
    addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent e) {
            onPaint(e);
        }
    });
    addListener(SWT.Resize, new Listener() {

        public void handleEvent(Event e) {
            onResize();
        }
    });
    if (getVerticalBar() != null) {
        getVerticalBar().addListener(SWT.Selection, new Listener() {

            public void handleEvent(Event e) {
                onScrollSelection();
            }
        });
    }
    if (getHorizontalBar() != null) {
        getHorizontalBar().addListener(SWT.Selection, new Listener() {

            public void handleEvent(Event e) {
                onScrollSelection();
            }
        });
    }
    addListener(SWT.KeyDown, new Listener() {

        public void handleEvent(Event e) {
            onKeyDown(e);
        }
    });
    addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent e) {
            e.doit = true;
        }
    });
    addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent e) {
            onMouseDoubleClick(e);
        }

        public void mouseDown(MouseEvent e) {
            onMouseDown(e);
        }

        public void mouseUp(MouseEvent e) {
            onMouseUp(e);
        }
    });
    addMouseMoveListener(new MouseMoveListener() {

        public void mouseMove(MouseEvent e) {
            onMouseMove(e);
        }
    });
    addMouseTrackListener(new MouseTrackListener() {

        public void mouseEnter(MouseEvent e) {
        }

        public void mouseExit(MouseEvent e) {
            onMouseExit(e);
        }

        public void mouseHover(MouseEvent e) {
        }
    });
    addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
            onFocusIn();
            redraw();
        }

        public void focusLost(FocusEvent e) {
            redraw();
        }
    });
    // Special code to reflect mouse wheel events if using an external
    // scroller
    addListener(SWT.MouseWheel, new Listener() {

        public void handleEvent(Event e) {
            onMouseWheel(e);
        }
    });
}
Also used : MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) TraverseListener(org.eclipse.swt.events.TraverseListener) MouseListener(org.eclipse.swt.events.MouseListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) SelectionListener(org.eclipse.swt.events.SelectionListener) PaintListener(org.eclipse.swt.events.PaintListener) FocusListener(org.eclipse.swt.events.FocusListener) TypedListener(org.eclipse.swt.widgets.TypedListener) Listener(org.eclipse.swt.widgets.Listener) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) TreeListener(org.eclipse.swt.events.TreeListener) PaintEvent(org.eclipse.swt.events.PaintEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) MouseListener(org.eclipse.swt.events.MouseListener) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintListener(org.eclipse.swt.events.PaintListener) TraverseListener(org.eclipse.swt.events.TraverseListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) FocusEvent(org.eclipse.swt.events.FocusEvent) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent) Event(org.eclipse.swt.widgets.Event) AccessibleControlEvent(org.eclipse.swt.accessibility.AccessibleControlEvent) TreeEvent(org.eclipse.swt.events.TreeEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Aggregations

PaintListener (org.eclipse.swt.events.PaintListener)89 PaintEvent (org.eclipse.swt.events.PaintEvent)88 Canvas (org.eclipse.swt.widgets.Canvas)32 Composite (org.eclipse.swt.widgets.Composite)29 MouseEvent (org.eclipse.swt.events.MouseEvent)26 GridData (org.eclipse.swt.layout.GridData)26 Rectangle (org.eclipse.swt.graphics.Rectangle)25 Point (org.eclipse.swt.graphics.Point)23 GridLayout (org.eclipse.swt.layout.GridLayout)22 MouseAdapter (org.eclipse.swt.events.MouseAdapter)15 SelectionEvent (org.eclipse.swt.events.SelectionEvent)15 DisposeEvent (org.eclipse.swt.events.DisposeEvent)14 DisposeListener (org.eclipse.swt.events.DisposeListener)14 FillLayout (org.eclipse.swt.layout.FillLayout)14 Control (org.eclipse.swt.widgets.Control)14 ControlEvent (org.eclipse.swt.events.ControlEvent)13 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 Event (org.eclipse.swt.widgets.Event)11 GC (org.eclipse.swt.graphics.GC)10 Button (org.eclipse.swt.widgets.Button)10