Example usage for org.eclipse.jface.dialogs TitleAreaDialog DLG_IMG_TITLE_ERROR

List of usage examples for org.eclipse.jface.dialogs TitleAreaDialog DLG_IMG_TITLE_ERROR

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs TitleAreaDialog DLG_IMG_TITLE_ERROR.

Prototype

String DLG_IMG_TITLE_ERROR

To view the source code for org.eclipse.jface.dialogs TitleAreaDialog DLG_IMG_TITLE_ERROR.

Click Source Link

Document

Image registry key for error message image.

Usage

From source file:org.kalypso.contribs.eclipse.jface.wizard.view.WizardView.java

License:Open Source License

/**
 * Display the given error message. The currently displayed message is saved and will be redisplayed when the error
 * message is set to <code>null</code>.
 *
 * @param newErrorMessage//  www  .  ja  va  2  s  . c o m
 *          the newErrorMessage to display or <code>null</code>
 */
public void setErrorMessage(final String newErrorMessage) {
    // Any change?
    if (m_errorMessage == null ? newErrorMessage == null : m_errorMessage.equals(newErrorMessage))
        return;
    m_errorMessage = newErrorMessage;

    if (m_messageLabel.isDisposed())
        return;

    if (m_errorMessage == null) {
        if (m_showingError) {
            // we were previously showing an error
            m_showingError = false;
            setMessageBackgrounds(false);
        }
        // show the message
        // avoid calling setMessage in case it is overridden to call
        // setErrorMessage,
        // which would result in a recursive infinite loop
        if (m_message == null) // this should probably never happen since
            // setMessage does this conversion....
            m_message = ""; //$NON-NLS-1$

        updateMessage(m_message);
        m_messageImageLabel.setImage(m_messageImage);
        setImageLabelVisible(m_messageImage != null);
        m_messageLabel.setToolTipText(m_message);
    } else {
        // Add in a space for layout purposes but do not
        // change the instance variable
        final String displayedErrorMessage = " " + m_errorMessage; //$NON-NLS-1$
        updateMessage(displayedErrorMessage);
        m_messageLabel.setToolTipText(m_errorMessage);
        if (!m_showingError) {
            // we were not previously showing an error
            m_showingError = true;
            // lazy initialize the error background color and image
            if (m_errorMsgAreaBackground == null) {
                m_errorMsgAreaBackground = JFaceColors.getErrorBackground(m_messageLabel.getDisplay());
                m_errorMsgImage = JFaceResources.getImage(TitleAreaDialog.DLG_IMG_TITLE_ERROR);
            }
            // show the error
            m_normalMsgAreaBackground = m_messageLabel.getBackground();

            setMessageBackgrounds(!m_useNormalBackground);

            m_messageImageLabel.setImage(m_errorMsgImage);
            setImageLabelVisible(true);
        }
    }
    layoutForNewMessage();
}