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

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

Introduction

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

Prototype

public void setPopupDelay(int popupDelay) 

Source Link

Document

Set the popup delay.

Usage

From source file:net.bioclipse.cdk.jchempaint.widgets.JChemPaintEditorWidget.java

License:Open Source License

public JChemPaintEditorWidget(Composite parent, int style) {
    super(parent, style | SWT.H_SCROLL | SWT.V_SCROLL | SWT.DOUBLE_BUFFERED);

    setupScrollbars();/*from w  w  w  .  j a  v  a 2 s .  com*/

    // Commented becaus of bug 1100 selectioncolor not good on windows
    //java.awt.Color color = createFromSWT( SWT.COLOR_LIST_SELECTION );
    java.awt.Color color = new java.awt.Color(0xc2deff);
    getRenderer().getRenderer2DModel().setSelectedPartColor(color);

    setupControllerHub();

    addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {

            resizeControl();
            redraw();
        }
    });

    int ops = DND.DROP_COPY;
    final TextTransfer textTransfer = TextTransfer.getInstance();
    Transfer[] transfers = new Transfer[] { textTransfer };
    this.addDropSupport(ops, transfers, new DropTargetListener() {

        public void dragEnter(DropTargetEvent event) {
            event.detail = DND.DROP_COPY;
        }

        public void dragLeave(DropTargetEvent event) {

            // TODO Auto-generated method stub

        }

        public void dragOperationChanged(DropTargetEvent event) {
            event.detail = DND.DROP_COPY;
        }

        public void dragOver(DropTargetEvent event) {

            event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL;
            if (textTransfer.isSupportedType(event.currentDataType)) {
                // NOTE: on unsupported platforms this will return null
                Object o = textTransfer.nativeToJava(event.currentDataType);
                String t = (String) o;
                if (t != null)
                    System.out.println(t);
            }

        }

        public void drop(DropTargetEvent event) {
            if (textTransfer.isSupportedType(event.currentDataType)) {
                String text = (String) event.data;

                //                    ICDKManager cdk = net.bioclipse.cdk.business.Activator
                //                                        .getDefault().getJavaCDKManager();
                //                    try {
                //                        ICDKMolecule mol = cdk.fromSMILES( text );
                //                        IAtomContainer ac = mol.getAtomContainer();
                //                        if(ac.getAtomCount()==1) {
                //                            IJChemPaintManager jcp = Activator.getDefault()
                //                                                            .getJavaManager();
                //                            Point2d point = new Point2d(event.x,event.y);
                //                            jcp.addAtom( ac.getAtom( 0 ), point);
                //                        }
                //                    } catch ( BioclipseException e ) {
                //                        logger.debug( "Could not create molecuel form text" );
                //                    }
                IJChemPaintManager jcp = Activator.getDefault().getJavaManager();
                Point p = JChemPaintEditorWidget.this.toControl(event.x, event.y);
                Point2d point = getRenderer().toModelCoordinates(p.x, p.y);
                jcp.addAtom(text, point);
            }
        }

        public void dropAccept(DropTargetEvent event) {

            // TODO Auto-generated method stub

        }

    });

    // create a tooltip
    ToolTip tooltip = new DefaultToolTip(this) {
        @Override
        protected String getText(Event event) {

            RendererModel rmodel = getRenderer2DModel();
            IAtom atom = rmodel.getHighlightedAtom();
            if (atom != null && rmodel.getToolTipTextMap().isEmpty()) {
                List<IAtomContainer> acs = ChemModelManipulator
                        .getAllAtomContainers(getControllerHub().getIChemModel());
                int num = -1;
                for (IAtomContainer ac : acs) {
                    num = ac.getAtomNumber(atom);
                    if (num > -1)
                        break;
                }
                if (num < 0)
                    return "";
                String atomType = atom.getAtomTypeName();
                if (atomType != null)
                    atomType = atomType.replaceFirst("^[^\\.]+\\.", "");
                return String.format("%s%d, [%s]", atom.getSymbol(), num, atomType);
            } else {
                return rmodel.getToolTipText(atom);
            }
        }
    };
    tooltip.setShift(new Point(10, 0));
    tooltip.setPopupDelay(200);

}

From source file:net.heartsome.cat.common.ui.wizard.TSTitleAreaDialog.java

License:Open Source License

/**
 * Re-layout the labels for the new message.
 * //from  ww w  . j  av a  2  s  .  c om
 * @param forceLayout
 *            <code>true</code> to force a layout of the shell
 */
private void layoutForNewMessage(boolean forceLayout) {
    int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    // If there are no images then layout as normal
    if (errorMessage == null && messageImage == null) {
        setImageLabelVisible(false);
        setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing);
    } else {
        messageImageLabel.setVisible(true);
        bottomFillerLabel.setVisible(true);
        leftFillerLabel.setVisible(true);
        /**
         * Note that we do not use horizontalSpacing here as when the
         * background of the messages changes there will be gaps between the
         * icon label and the message that are the background color of the
         * shell. We add a leading space elsewhere to compendate for this.
         */
        FormData data = new FormData();
        data.left = new FormAttachment(0, H_GAP_IMAGE);
        data.top = new FormAttachment(titleLabel, verticalSpacing);
        messageImageLabel.setLayoutData(data);
        data = new FormData();
        data.top = new FormAttachment(messageImageLabel, 0);
        data.left = new FormAttachment(0, 0);
        data.bottom = new FormAttachment(messageLabel, 0, SWT.BOTTOM);
        data.right = new FormAttachment(messageImageLabel, 0, SWT.RIGHT);
        bottomFillerLabel.setLayoutData(data);
        data = new FormData();
        data.top = new FormAttachment(messageImageLabel, 0, SWT.TOP);
        data.left = new FormAttachment(0, 0);
        data.bottom = new FormAttachment(messageImageLabel, 0, SWT.BOTTOM);
        data.right = new FormAttachment(messageImageLabel, 0);
        leftFillerLabel.setLayoutData(data);
        FormData messageLabelData = new FormData();
        messageLabelData.top = new FormAttachment(titleLabel, verticalSpacing);
        messageLabelData.right = new FormAttachment(titleImageLabel);
        messageLabelData.left = new FormAttachment(messageImageLabel, 0);
        messageLabelData.height = messageLabelHeight;
        if (titleImageLargest)
            messageLabelData.bottom = new FormAttachment(titleImageLabel, 0, SWT.BOTTOM);
        messageLabel.setLayoutData(messageLabelData);
    }

    if (forceLayout) {
        getShell().layout();
    } else {
        // Do not layout before the dialog area has been created
        // to avoid incomplete calculations.
        if (dialogArea != null)
            workArea.getParent().layout(true);
    }

    int messageLabelUnclippedHeight = messageLabel.computeSize(messageLabel.getSize().x - xTrim, SWT.DEFAULT,
            true).y;
    boolean messageLabelClipped = messageLabelUnclippedHeight > messageLabel.getSize().y - yTrim;
    if (messageLabel.getData() instanceof ToolTip) {
        ToolTip toolTip = (ToolTip) messageLabel.getData();
        toolTip.hide();
        toolTip.deactivate();
        messageLabel.setData(null);
    }
    if (messageLabelClipped) {
        ToolTip tooltip = new ToolTip(messageLabel, ToolTip.NO_RECREATE, false) {

            protected Composite createToolTipContentArea(Event event, Composite parent) {
                Composite result = new Composite(parent, SWT.NONE);
                result.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
                result.setLayout(new GridLayout());
                Text text = new Text(result, SWT.WRAP);
                text.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
                text.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
                text.setText(messageLabel.getText());
                GridData gridData = new GridData();
                gridData.widthHint = messageLabel.getSize().x;
                text.setLayoutData(gridData);
                Dialog.applyDialogFont(result);
                return result;
            }

            public Point getLocation(Point tipSize, Event event) {
                return messageLabel.getShell().toDisplay(messageLabel.getLocation());
            }
        };
        messageLabel.setData(tooltip);
        tooltip.setPopupDelay(0);
        tooltip.activate();
    }
}

From source file:org.eclipse.ecf.internal.example.collab.ui.LineChatClientView.java

License:Open Source License

public LineChatClientView(EclipseCollabSharedObject lch, LineChatView view, String name, String initText,
        String downloaddir) {//from  w ww  .  ja v  a  2s .c o m
    super();
    this.lch = lch;
    this.view = view;
    this.name = name;
    this.teamChat = new TeamChat(this, view.tabFolder, SWT.NULL, initText);
    this.userdata = lch.getUser();
    this.downloaddir = downloaddir;
    users = new ArrayList();
    teamChat.getTableViewer().setInput(users);
    if (userdata != null)
        addUser(userdata);

    ClientPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(ClientPlugin.PREF_DISPLAY_TIMESTAMP)) {
                showTimestamp = ((Boolean) event.getNewValue()).booleanValue();
            }
        }

    });

    JFaceResources.getColorRegistry().put(ViewerToolTip.HEADER_BG_COLOR, new RGB(255, 255, 255));
    JFaceResources.getFontRegistry().put(ViewerToolTip.HEADER_FONT, JFaceResources.getFontRegistry()
            .getBold(JFaceResources.getDefaultFont().getFontData()[0].getName()).getFontData());

    final ToolTip toolTip = new ViewerToolTip(teamChat.getTableViewer().getControl());
    toolTip.setHideOnMouseDown(false);
    toolTip.setPopupDelay(200);
}

From source file:org.eclipse.ecf.presence.ui.MultiRosterView.java

License:Open Source License

protected void setupTreeViewer(Composite parent) {
    treeViewer = new TreeViewer(parent, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
    getSite().setSelectionProvider(treeViewer);
    presenceListener = new PresenceListener();
    treeViewer.setContentProvider(new MultiRosterContentProvider());
    treeViewer.setLabelProvider(new MultiRosterLabelProvider());
    treeViewer.addFilter(hideOfflineFilter);
    treeViewer.addFilter(hideEmptyGroupsFilter);
    treeViewer.setInput(rosterAccounts);
    treeViewer.addOpenListener(new IOpenListener() {
        public void open(OpenEvent e) {
            message((IStructuredSelection) e.getSelection());
        }// ww  w. ja va 2 s.c om
    });

    ToolTip toolTip = new ViewerToolTip(treeViewer.getControl());
    toolTip.setHideOnMouseDown(false);
    toolTip.setPopupDelay(200);
    toolTip.setShift(new Point(5, 5));

    makeActions();
    hookContextMenu();
    contributeToActionBars();
    hookDropSupport();
    retrieveServices();
    treeViewer.expandToLevel(DEFAULT_EXPAND_LEVEL);

}