Example usage for org.eclipse.jface.window ToolTip RECREATE

List of usage examples for org.eclipse.jface.window ToolTip RECREATE

Introduction

In this page you can find the example usage for org.eclipse.jface.window ToolTip RECREATE.

Prototype

int RECREATE

To view the source code for org.eclipse.jface.window ToolTip RECREATE.

Click Source Link

Document

Recreate the tooltip on every mouse move

Usage

From source file:org.pentaho.big.data.kettle.plugins.formats.impl.avro.BaseAvroStepDialog.java

License:Apache License

protected void addColumnTooltip(Table table, int columnIndex) {
    final DefaultToolTip toolTip = new DefaultToolTip(table, ToolTip.RECREATE, true);
    toolTip.setRespectMonitorBounds(true);
    toolTip.setRespectDisplayBounds(true);
    toolTip.setPopupDelay(TOOLTIP_SHOW_DELAY);
    toolTip.setHideDelay(TOOLTIP_HIDE_DELAY);
    toolTip.setShift(new Point(ConstUI.TOOLTIP_OFFSET, ConstUI.TOOLTIP_OFFSET));
    table.addMouseTrackListener(new MouseTrackAdapter() {
        @Override//  w  ww.j a  v a 2 s . co m
        public void mouseHover(MouseEvent e) {
            Point coord = new Point(e.x, e.y);
            TableItem item = table.getItem(coord);
            if (item != null) {
                if (item.getBounds(columnIndex).contains(coord)) {
                    String contents = item.getText(columnIndex);
                    if (!Utils.isEmpty(contents)) {
                        toolTip.setText(contents);
                        toolTip.show(coord);
                        return;
                    }
                }
            }
            toolTip.hide();
        }

        @Override
        public void mouseExit(MouseEvent e) {
            toolTip.hide();
        }
    });
}

From source file:org.pentaho.big.data.kettle.plugins.formats.impl.orc.BaseOrcStepDialog.java

License:Apache License

protected void addColumnTooltip(Table table, int columnIndex) {
    final DefaultToolTip toolTip = new DefaultToolTip(table, ToolTip.RECREATE, true);
    toolTip.setRespectMonitorBounds(true);
    toolTip.setRespectDisplayBounds(true);
    toolTip.setPopupDelay(TOOLTIP_SHOW_DELAY);
    toolTip.setHideDelay(TOOLTIP_HIDE_DELAY);
    toolTip.setShift(new Point(ConstUI.TOOLTIP_OFFSET, ConstUI.TOOLTIP_OFFSET));
    table.addMouseTrackListener(new MouseTrackAdapter() {
        @Override/*from   www.jav  a2s  . c  o m*/

        public void mouseHover(MouseEvent e) {
            Point coord = new Point(e.x, e.y);
            TableItem item = table.getItem(coord);
            if (item != null) {
                if (item.getBounds(columnIndex).contains(coord)) {
                    String contents = item.getText(columnIndex);
                    if (!Utils.isEmpty(contents)) {
                        toolTip.setText(contents);
                        toolTip.show(coord);
                        return;
                    }
                }
            }
            toolTip.hide();
        }

        @Override
        public void mouseExit(MouseEvent e) {
            toolTip.hide();
        }
    });
}

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

License:Apache License

public CheckBoxToolTip(Control control) {
    super(control, ToolTip.RECREATE, true);
    image = control.getDisplay().getSystemImage(SWT.ICON_INFORMATION);
    listeners = new ArrayList<CheckBoxToolTipListener>();
    visible = false;/*w w w  .j  av a 2s .c  om*/
    display = control.getDisplay();

    super.setRespectMonitorBounds(true);
    super.setRespectDisplayBounds(true);
    super.setHideDelay(50000);
    super.setPopupDelay(0);
    super.setHideOnMouseDown(false);
}

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 www. ja v a2 s. c  om*/

        // 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.pentaho.di.ui.spoon.Spoon.java

License:Apache License

public void addCoreObjectsTree() {

    if (designTreeComposite == null) {
        return;//from w ww.j a v  a 2s  .c o m
    }

    // Now create a new expand bar inside that item
    // We're going to put the core object in there
    //
    coreObjectsTree = new Tree(designTreeComposite, SWT.V_SCROLL | SWT.SINGLE);
    props.setLook(coreObjectsTree);

    coreObjectsTree.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            // expand the selected tree item, collapse the rest
            //
            if (props.getAutoCollapseCoreObjectsTree()) {
                TreeItem[] selection = coreObjectsTree.getSelection();
                if (selection.length == 1) {
                    // expand if clicked on the the top level entry only...
                    //
                    TreeItem top = selection[0];
                    while (top.getParentItem() != null) {
                        top = top.getParentItem();
                    }
                    if (top == selection[0]) {
                        boolean expanded = top.getExpanded();
                        for (TreeItem item : coreObjectsTree.getItems()) {
                            item.setExpanded(false);
                        }
                        top.setExpanded(!expanded);
                    }
                }
            }
        }
    });

    coreObjectsTree.addTreeListener(new TreeAdapter() {
        @Override
        public void treeExpanded(TreeEvent treeEvent) {
            if (props.getAutoCollapseCoreObjectsTree()) {
                TreeItem treeItem = (TreeItem) treeEvent.item;
                /*
                 * Trick for WSWT on Windows systems: a SelectionEvent is called after the TreeEvent if setSelection() is not
                 * used here. Otherwise the first item in the list is selected as default and collapsed again but wrong, see
                 * PDI-1480
                 */
                coreObjectsTree.setSelection(treeItem);
                // expand the selected tree item, collapse the rest
                //
                for (TreeItem item : coreObjectsTree.getItems()) {
                    if (item != treeItem) {
                        item.setExpanded(false);
                    } else {
                        treeItem.setExpanded(true);
                    }
                }
            }
        }
    });

    coreObjectsTree.addMouseMoveListener(new MouseMoveListener() {

        @Override
        public void mouseMove(MouseEvent move) {
            // don't show tooltips in the tree if the option is not set
            if (!getProperties().showToolTips()) {
                return;
            }

            toolTip.hide();
            TreeItem item = searchMouseOverTreeItem(coreObjectsTree.getItems(), move.x, move.y);
            if (item != null) {
                String name = item.getText();
                String tip = coreStepToolTipMap.get(name);
                if (tip != null) {
                    PluginInterface plugin = PluginRegistry.getInstance()
                            .findPluginWithName(StepPluginType.class, name);
                    if (plugin != null) {
                        Image image = GUIResource.getInstance().getImagesSteps().get(plugin.getIds()[0])
                                .getAsBitmapForSize(display, ConstUI.ICON_SIZE, ConstUI.ICON_SIZE);
                        if (image == null) {
                            toolTip.hide();
                        }
                        toolTip.setImage(image);
                        toolTip.setText(name + Const.CR + Const.CR + tip);
                        toolTip.setBackgroundColor(GUIResource.getInstance().getColor(255, 254, 225));
                        toolTip.setForegroundColor(GUIResource.getInstance().getColor(0, 0, 0));
                        toolTip.show(new org.eclipse.swt.graphics.Point(move.x + 10, move.y + 10));
                    }
                }
                tip = coreJobToolTipMap.get(name);
                if (tip != null) {
                    PluginInterface plugin = PluginRegistry.getInstance()
                            .findPluginWithName(JobEntryPluginType.class, name);
                    if (plugin != null) {
                        Image image = GUIResource.getInstance().getImagesJobentries().get(plugin.getIds()[0])
                                .getAsBitmapForSize(display, ConstUI.ICON_SIZE, ConstUI.ICON_SIZE);
                        toolTip.setImage(image);
                        toolTip.setText(name + Const.CR + Const.CR + tip);
                        toolTip.setBackgroundColor(GUIResource.getInstance().getColor(255, 254, 225));
                        toolTip.setForegroundColor(GUIResource.getInstance().getColor(0, 0, 0));
                        toolTip.show(new org.eclipse.swt.graphics.Point(move.x + 10, move.y + 10));
                    }
                }
            }
        }
    });

    addDragSourceToTree(coreObjectsTree);
    addDefaultKeyListeners(coreObjectsTree);
    coreObjectsTree.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDoubleClick(MouseEvent event) {
            boolean shift = (event.stateMask & SWT.SHIFT) != 0;
            doubleClickedInTree(coreObjectsTree, shift);
        }
    });

    toolTip = new DefaultToolTip(viewTreeComposite, ToolTip.RECREATE, true);
    toolTip.setRespectMonitorBounds(true);
    toolTip.setRespectDisplayBounds(true);
    toolTip.setPopupDelay(350);
    toolTip.setHideDelay(5000);
    toolTip.setShift(new org.eclipse.swt.graphics.Point(ConstUI.TOOLTIP_OFFSET, ConstUI.TOOLTIP_OFFSET));
}

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 a v 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));
}

From source file:org.sonarlint.eclipse.ui.internal.properties.AboutPropertyPage.java

License:Open Source License

@Override
protected Control createContents(final Composite parent) {

    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    gridLayout.marginWidth = 0;//from  ww  w.  ja va  2 s  . co m
    gridLayout.marginHeight = 0;
    composite.setLayout(gridLayout);

    Link text = new Link(composite, SWT.NONE);
    GridData textGd = new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1);
    text.setLayoutData(textGd);
    text.setText(
            "By sharing anonymous SonarLint usage statistics, you help us understand how SonarLint is used so "
                    + "we can improve the plugin to work even better for you.\nWe don't collect source code, IP addresses, or any personally identifying "
                    + "information. And we don't share the data with anyone else.\n\nSee a <a href=\"#\">sample of the data.</a>");

    final DefaultToolTip tip = new DefaultToolTip(text, ToolTip.RECREATE, true);
    tip.setText("{\n" + "    \"days_since_installation\": 120,\n" + "    \"days_of_use\": 40,\n"
            + "    \"sonarlint_version\": \"3.0.0\",\n" + "    \"sonarlint_product\": \"SonarLint Eclipse\",\n"
            + "    \"connected_mode_used\": true\n" + "}");

    text.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Point cursorLocation = PlatformUI.getWorkbench().getDisplay().getCursorLocation();
            tip.show(
                    PlatformUI.getWorkbench().getDisplay().map(null, text, cursorLocation.x, cursorLocation.y));
        }
    });

    enabledBtn = new Button(composite, SWT.CHECK);
    enabledBtn.setText("Share anonymous SonarLint statistics");
    enabledBtn.setSelection(SonarLintCorePlugin.getTelemetry().enabled());
    GridData layoutData = new GridData();
    layoutData.horizontalSpan = 2;
    enabledBtn.setLayoutData(layoutData);

    return composite;
}

From source file:sernet.gs.ui.rcp.main.bsi.editors.LinkMaker.java

License:Open Source License

public void createPartControl(Boolean isWriteAllowed) {

    this.writeable = isWriteAllowed;

    createLabel();//from ww  w. ja  v  a2s  .c  o m
    createElementTypeCombo();
    createRelationCombo();
    createButtonAddLink();
    createButtonRemoveLink();
    initLinkTableViewer();

    // listeners to reload view:
    CnAElementFactory.getLoadedModel().addBSIModelListener(relationViewContentProvider);
    CnAElementFactory.getInstance().getISO27kModel().addISO27KModelListener(relationViewContentProvider);
    // listeners to remove stale links from currently open object in editor
    // to prevent conflicts when saving:
    linkRemover = new LinkRemover(this);
    CnAElementFactory.getLoadedModel().addBSIModelListener(linkRemover);
    CnAElementFactory.getInstance().getISO27kModel().addISO27KModelListener(linkRemover);

    // init tooltip provider
    ColumnViewerToolTipSupport.enableFor(viewer, ToolTip.RECREATE);
    List<RelationTableCellLabelProvider> cellLabelProviders = viewer.initToolTips(relationViewLabelProvider,
            this);
    // register resize listener for cutting the tooltips
    addResizeListener(cellLabelProviders);

    linkAction = new CreateLinkSelectionListener(this);
    unlinkAction = new RemoveLinkSelectionListener(this);
    this.addLinkButton.addSelectionListener(linkAction);
    this.removeLinkButton.addSelectionListener(unlinkAction);

    createFilter();

    createDoubleClickAction();
    hookDoubleClickAction();
}