Search in sources :

Example 1 with DefaultToolTip

use of org.eclipse.jface.window.DefaultToolTip in project pentaho-kettle by pentaho.

the class ControlSpaceKeyAdapter method keyPressed.

public void keyPressed(KeyEvent e) {
    // CTRL-<SPACE> --> Insert a variable
    if (isHotKey(e)) {
        e.doit = false;
        // 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();
    }
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) DefaultToolTip(org.eclipse.jface.window.DefaultToolTip) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) FillLayout(org.eclipse.swt.layout.FillLayout) FocusEvent(org.eclipse.swt.events.FocusEvent) Point(org.eclipse.swt.graphics.Point) KeyEvent(org.eclipse.swt.events.KeyEvent) Shell(org.eclipse.swt.widgets.Shell) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(org.eclipse.swt.widgets.List)

Example 2 with DefaultToolTip

use of org.eclipse.jface.window.DefaultToolTip in project pentaho-kettle by pentaho.

the class Spoon method addCoreObjectsTree.

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

        @Override
        public void widgetSelected(SelectionEvent event) {
            // 
            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);
                // 
                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(variableComposite, 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));
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) DefaultToolTip(org.eclipse.jface.window.DefaultToolTip) TreeItem(org.eclipse.swt.widgets.TreeItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) MouseAdapter(org.eclipse.swt.events.MouseAdapter) TreeAdapter(org.eclipse.swt.events.TreeAdapter) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) Image(org.eclipse.swt.graphics.Image) JobEntryPluginType(org.pentaho.di.core.plugins.JobEntryPluginType) TreeEvent(org.eclipse.swt.events.TreeEvent) MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) StepPluginType(org.pentaho.di.core.plugins.StepPluginType) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree)

Example 3 with DefaultToolTip

use of org.eclipse.jface.window.DefaultToolTip in project nebula.widgets.nattable by eclipse.

the class Tooltips method attachToolTip.

private void attachToolTip(NatTable natTable) {
    DefaultToolTip toolTip = new ExampleNatTableToolTip(natTable);
    toolTip.setBackgroundColor(natTable.getDisplay().getSystemColor(SWT.COLOR_RED));
    toolTip.setPopupDelay(500);
    toolTip.activate();
    toolTip.setShift(new Point(10, 10));
}
Also used : DefaultToolTip(org.eclipse.jface.window.DefaultToolTip) Point(org.eclipse.swt.graphics.Point)

Example 4 with DefaultToolTip

use of org.eclipse.jface.window.DefaultToolTip in project jbosstools-openshift by jbosstools.

the class NewApplicationSummaryFromTemplateDialog method notifyCopied.

private void notifyCopied(Control control, String notification) {
    DefaultToolTip copiedNotification = new DefaultToolTip(control, ToolTip.NO_RECREATE, true);
    copiedNotification.setText(notification);
    copiedNotification.setHideDelay(COPIED_NOTIFICATION_SHOW_DURATION);
    copiedNotification.show(control.getLocation());
    copiedNotification.deactivate();
}
Also used : DefaultToolTip(org.eclipse.jface.window.DefaultToolTip)

Example 5 with DefaultToolTip

use of org.eclipse.jface.window.DefaultToolTip in project jbosstools-openshift by jbosstools.

the class WebHooksComponent method notifyCopied.

private void notifyCopied(final Text uriText) {
    DefaultToolTip copiedNotification = new DefaultToolTip(uriText, ToolTip.NO_RECREATE, true);
    copiedNotification.setText("Webhook copied to clipboard");
    copiedNotification.setHideDelay(COPIED_NOTIFICATION_SHOW_DURATION);
    copiedNotification.show(uriText.getLocation());
    copiedNotification.deactivate();
}
Also used : DefaultToolTip(org.eclipse.jface.window.DefaultToolTip)

Aggregations

DefaultToolTip (org.eclipse.jface.window.DefaultToolTip)6 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 Point (org.eclipse.swt.graphics.Point)3 FocusAdapter (org.eclipse.swt.events.FocusAdapter)2 FocusEvent (org.eclipse.swt.events.FocusEvent)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 FocusListener (org.eclipse.swt.events.FocusListener)1 KeyAdapter (org.eclipse.swt.events.KeyAdapter)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 MouseMoveListener (org.eclipse.swt.events.MouseMoveListener)1 TreeAdapter (org.eclipse.swt.events.TreeAdapter)1 TreeEvent (org.eclipse.swt.events.TreeEvent)1 Image (org.eclipse.swt.graphics.Image)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1