Example usage for org.eclipse.jface.dialogs Dialog shortenText

List of usage examples for org.eclipse.jface.dialogs Dialog shortenText

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs Dialog shortenText.

Prototype

public static String shortenText(String textValue, Control control) 

Source Link

Document

Try to shorten the given text textValue so that its width in pixels does not exceed the width of the given control.

Usage

From source file:org.eclipse.rcptt.ui.controls.StatusBarComposite.java

License:Open Source License

private void setMessage(String messageString, boolean force) {
    // must not set null text in a label
    message = messageString == null ? "" : messageString; //$NON-NLS-1$
    if (messageLabel == null || messageLabel.isDisposed()) {
        return;//from ww  w .j  av  a  2 s  . co m
    }
    if (force || messageLabel.isVisible()) {
        messageLabel.setToolTipText(message);
        messageLabel.setText(Dialog.shortenText(message, messageLabel));
        layout();
    }
}

From source file:org.mailster.gui.prefs.widgets.DialogMessageArea.java

License:Open Source License

/**
 * Show the new message in the message text and update the image. Base the
 * background color on whether or not there are errors.
 * /*from ww w. j a va2s  .com*/
 * @param newMessage The new value for the message
 * @param newType One of the IMessageProvider constants. If newType is
 *            IMessageProvider.NONE show the title.
 * @see org.eclipse.jface.dialogs.IMessageProvider
 */
public void updateText(String newMessage, int newType) {
    Image newImage = null;
    switch (newType) {
    case IMessageProvider.NONE:
        if (newMessage == null) {
            this.restoreTitle();
        } else {
            this.showTitle(newMessage, null);
        }
        return;
    case IMessageProvider.INFORMATION:
        newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
        break;
    case IMessageProvider.WARNING:
        newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
        break;
    case IMessageProvider.ERROR:
        newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
        break;
    }

    this.messageComposite.setVisible(true);
    this.titleLabel.setVisible(false);
    // Any more updates required?
    // If the message text equals the tooltip (i.e. non-shortened text is
    // the same)
    // and shortened text is the same (i.e. not a resize)
    // and the image is the same then nothing to do
    String shortText = Dialog.shortenText(newMessage, messageText);
    if (newMessage.equals(messageText.getToolTipText()) && newImage == messageImageLabel.getImage()
            && shortText.equals(messageText.getText())) {
        return;
    }
    this.messageImageLabel.setImage(newImage);
    this.messageText.setText(Dialog.shortenText(newMessage, messageText));
    this.messageText.setToolTipText(newMessage);
    this.lastMessageText = newMessage;
}

From source file:org.org.eclipse.core.utils.platform.dialogs.selection.ProgressMonitorDialog.java

License:Open Source License

/**
 * Set the message in the message label.
 * //from   w  w w. j  a va  2 s.  c o m
 * @param messageString
 *            The string for the new message.
 */
private void setMessage(String messageString) {
    // must not set null text in a label
    message = messageString == null ? "" : messageString; //$NON-NLS-1$
    if (messageLabel == null || messageLabel.isDisposed())
        return;
    messageLabel.setText(Dialog.shortenText(message, messageLabel), false, false);
}