Example usage for org.eclipse.jface.window DefaultToolTip setImage

List of usage examples for org.eclipse.jface.window DefaultToolTip setImage

Introduction

In this page you can find the example usage for org.eclipse.jface.window DefaultToolTip setImage.

Prototype

public void setImage(Image image) 

Source Link

Document

The Image displayed in the CLabel in the default implementation implementation

Usage

From source file:org.pentaho.di.ui.core.widget.ControlSpaceKeyAdapter.java

License:Apache License

public void keyPressed(KeyEvent e) {
    // CTRL-<SPACE> --> Insert a variable
    if (isHotKey(e)) {
        e.doit = false;//from   ww w.  j av  a 2s  .  c  o  m

        // textField.setData(TRUE) indicates we have transitioned from the textbox to list mode...
        // This will be set to false when the list selection has been processed
        // and the list is being disposed of.
        control.setData(Boolean.TRUE);

        final int position;
        if (getCaretPositionInterface != null) {
            position = getCaretPositionInterface.getCaretPosition();
        } else {
            position = -1;
        }

        // Drop down a list of variables...
        //
        Rectangle bounds = control.getBounds();
        Point location = GUIResource.calculateControlPosition(control);

        final Shell shell = new Shell(control.getShell(), SWT.NONE);
        shell.setSize(bounds.width > 300 ? bounds.width : 300, 200);
        shell.setLocation(location.x, location.y + bounds.height);
        shell.setLayout(new FillLayout());
        final List list = new List(shell, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
        props.setLook(list);
        list.setItems(getVariableNames(variables));
        final DefaultToolTip toolTip = new DefaultToolTip(list, ToolTip.RECREATE, true);
        toolTip.setImage(GUIResource.getInstance().getImageVariable());
        toolTip.setHideOnMouseDown(true);
        toolTip.setRespectMonitorBounds(true);
        toolTip.setRespectDisplayBounds(true);
        toolTip.setPopupDelay(350);

        list.addSelectionListener(new SelectionAdapter() {
            // Enter or double-click: picks the variable
            //
            public synchronized void widgetDefaultSelected(SelectionEvent e) {
                applyChanges(shell, list, control, position, insertTextInterface);
            }

            // Select a variable name: display the value in a tool tip
            //
            public void widgetSelected(SelectionEvent event) {
                if (list.getSelectionCount() <= 0) {
                    return;
                }
                String name = list.getSelection()[0];
                String value = variables.getVariable(name);
                Rectangle shellBounds = shell.getBounds();
                String message = BaseMessages.getString(PKG, "TextVar.VariableValue.Message", name, value);
                if (name.startsWith(Const.INTERNAL_VARIABLE_PREFIX)) {
                    message += BaseMessages.getString(PKG, "TextVar.InternalVariable.Message");
                }
                toolTip.setText(message);
                toolTip.hide();
                toolTip.show(new Point(shellBounds.width, 0));
            }
        });

        list.addKeyListener(new KeyAdapter() {

            public synchronized void keyPressed(KeyEvent e) {
                if (e.keyCode == SWT.CR && ((e.keyCode & SWT.CONTROL) == 0) && ((e.keyCode & SWT.SHIFT) == 0)) {
                    applyChanges(shell, list, control, position, insertTextInterface);
                }
            }

        });

        list.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent event) {
                shell.dispose();
                if (!control.isDisposed()) {
                    control.setData(Boolean.FALSE);
                }
            }
        });

        shell.open();
    }
}

From source file:org.robotframework.ide.eclipse.main.plugin.tableeditor.HeaderFilterSupport.java

License:Apache License

private void showProperTooltip(final HeaderFilterMatchesCollection matches) {
    final DefaultToolTip filterTip = new DefaultToolTip(filter, ToolTip.RECREATE, true);
    if (matches != null) {
        final int allMatches = matches.getNumberOfAllMatches();
        final int rowsMatching = matches.getNumberOfMatchingElement();
        final String elementForm = rowsMatching == 1 ? "element" : "elements";
        filterTip/*from   w w  w  . j  av  a  2  s .c  o  m*/
                .setText("Filtering on: found " + allMatches + " match in " + rowsMatching + " " + elementForm);

        final Color filterSuccessFg = ColorsManager.getColor(0, 200, 0);
        final Color filterFailureFg = ColorsManager.getColor(255, 0, 0);
        filter.setForeground(allMatches == 0 ? filterFailureFg : filterSuccessFg);
        if (form.getMessage() == null) {
            form.setMessage("Filtering is enabled", IMessageProvider.INFORMATION);
        }
    } else {
        if (form.getMessage() != null && form.getMessage().startsWith("Filtering")) {
            form.setMessage(null);
        }
        filterTip.setText("Filtering off");
    }
    filterTip.setHideDelay(3000);
    filterTip.setImage(ImagesManager.getImage(RedImages.getFilterImage()));
    filterTip.show(new Point(0, filter.getSize().y));
}