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

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

Introduction

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

Prototype

String DLG_IMG_MESSAGE_ERROR

To view the source code for org.eclipse.jface.dialogs Dialog DLG_IMG_MESSAGE_ERROR.

Click Source Link

Document

Image registry key for info message image (value "dialog_message_error_image").

Usage

From source file:org.eclipse.ui.texteditor.MessageRegion.java

License:Open Source License

/**
 * Create the contents for the receiver.
 *
 * @param parent the Composite that the children will be created in
 *///w  w  w  .  j a  va2  s. c om
public void createContents(Composite parent) {
    messageComposite = new Composite(parent, SWT.NONE);
    GridLayout messageLayout = new GridLayout();
    messageLayout.numColumns = 2;
    messageLayout.marginWidth = 0;
    messageLayout.marginHeight = 0;
    messageLayout.makeColumnsEqualWidth = false;
    messageComposite.setLayout(messageLayout);
    messageImageLabel = new Label(messageComposite, SWT.NONE);

    GridData imageData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
    Image sizingImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
    Rectangle imageBounds;
    if (sizingImage == null)
        imageBounds = new Rectangle(0, 0, IDialogConstants.VERTICAL_MARGIN * 2,
                IDialogConstants.VERTICAL_MARGIN * 2);
    else
        imageBounds = sizingImage.getBounds();
    imageData.heightHint = imageBounds.height + IDialogConstants.VERTICAL_SPACING;
    imageData.widthHint = imageBounds.width + IDialogConstants.HORIZONTAL_SPACING;
    messageImageLabel.setLayoutData(imageData);

    messageText = new Text(messageComposite, SWT.NONE);
    messageText.setEditable(false);
    messageText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));

    GridData textData = new GridData(
            GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
    messageText.setLayoutData(textData);
    hideRegion();

}

From source file:org.eclipse.ui.texteditor.MessageRegion.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 v a2 s  . c  o  m
 *
 * @param newMessage The new value for the message
 * @param newType One of the IMessageProvider constants. If newType is IMessageProvider.NONE
 *            show the title.
 * @see IMessageProvider
 */
public void updateText(String newMessage, int newType) {
    Image newImage = null;
    boolean showingError = false;
    switch (newType) {
    case IMessageProvider.NONE:
        hideRegion();
        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);
        showingError = true;
        break;
    }

    if (newMessage == null) {//No message so clear the area
        hideRegion();
        return;
    }
    showRegion();
    // Any more updates required
    if (newMessage.equals(messageText.getText()) && newImage == messageImageLabel.getImage())
        return;
    messageImageLabel.setImage(newImage);
    messageText.setText(newMessage);
    if (showingError)
        setMessageColors(JFaceColors.getErrorBackground(messageComposite.getDisplay()));
    else {
        lastMessageText = newMessage;
        setMessageColors(JFaceColors.getBannerBackground(messageComposite.getDisplay()));
    }

}

From source file:org.eclipse.xtext.xtext.ui.wizard.project.StatusWidget.java

License:Open Source License

private Image imageFor(final int type) {
    Image _switchResult = null;/*from   w w  w .  j  a  v  a  2 s. c o  m*/
    switch (type) {
    case IMessageProvider.NONE:
        _switchResult = null;
        break;
    case IMessageProvider.INFORMATION:
        _switchResult = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
        break;
    case IMessageProvider.WARNING:
        _switchResult = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
        break;
    case IMessageProvider.ERROR:
        _switchResult = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
        break;
    }
    return _switchResult;
}

From source file:org.jboss.tools.jst.css.properties.MessageCSSSection.java

License:Open Source License

@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);

    aggregateStatus = new AggregateValidationStatus(getBindingContext().getValidationStatusProviders(),
            AggregateValidationStatus.MAX_SEVERITY);
    aggregateStatus.addValueChangeListener(new IValueChangeListener() {
        public void handleValueChange(ValueChangeEvent event) {

            handleStatusChanged((IStatus) event.diff.getNewValue());
        }//from  www. j a v a 2s  .c  o m
    });

    messageComposite = new Composite(parent, SWT.None);
    GridLayout gridLayout = new GridLayout(2, false);
    gridLayout.marginHeight = 0;
    gridLayout.verticalSpacing = 0;
    messageComposite.setLayout(gridLayout);
    messageImageLabel = new Label(messageComposite, SWT.CENTER);
    messageImageLabel.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR));
    messageLabel = new Text(messageComposite, SWT.WRAP | SWT.READ_ONLY);
    messageComposite.setVisible(false);
}

From source file:org.jboss.tools.openshift.internal.ui.server.ServerSettingsWizardPage.java

License:Open Source License

private void createInfoControls(Composite container, ServerSettingsWizardPageModel model,
        DataBindingContext dbc) {//from  w  ww  . ja  v a  2 s.c om
    Composite composite = new Composite(container, SWT.NONE);
    GridDataFactory.fillDefaults().span(4, 1).applyTo(composite);
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite);

    ValueBindingBuilder.bind(WidgetProperties.visible().observe(composite))
            .to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model))
            .converting(new Converter(IStatus.class, Boolean.class) {

                @Override
                public Object convert(Object fromObject) {
                    return !((IStatus) fromObject).isOK();
                }

            }).in(dbc);

    Label label = new Label(composite, SWT.NONE);
    ValueBindingBuilder.bind(WidgetProperties.image().observe(label))
            .to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model))
            .converting(new Converter(IStatus.class, Image.class) {

                @Override
                public Object convert(Object fromObject) {
                    switch (((IStatus) fromObject).getSeverity()) {
                    case IStatus.WARNING:
                        return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
                    case IStatus.ERROR:
                        return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
                    }
                    return null;
                }
            }).in(dbc);

    Link link = new Link(composite, SWT.WRAP);
    ValueBindingBuilder.bind(WidgetProperties.text().observe(link))
            .to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model))
            .converting(new Converter(IStatus.class, String.class) {

                @Override
                public Object convert(Object fromObject) {
                    return ((IStatus) fromObject).getMessage();
                }

            }).in(dbc);
    link.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if ("download".equals(e.text)) {
                new BrowserUtility().checkedCreateExternalBrowser(DOWNLOAD_INSTRUCTIONS_URL,
                        OpenShiftUIActivator.PLUGIN_ID, OpenShiftUIActivator.getDefault().getLog());
            } else {
                int rc = PreferencesUtil.createPreferenceDialogOn(getShell(), OPEN_SHIFT_PREFERENCE_PAGE_ID,
                        new String[] { OPEN_SHIFT_PREFERENCE_PAGE_ID }, null).open();
                if (rc == Dialog.OK) {
                    new Job("Checking oc binary") {

                        @Override
                        protected IStatus run(IProgressMonitor monitor) {
                            OCBinary ocBinary = OCBinary.getInstance();
                            boolean valid = ocBinary.isCompatibleForPublishing(monitor);
                            ServerSettingsWizardPage.this.model
                                    .setOCBinaryStatus(getOCBinaryStatus(valid, ocBinary.getLocation()));
                            return Status.OK_STATUS;
                        }
                    }.schedule();
                }
            }
        }
    });
    GridDataFactory.fillDefaults().hint(600, SWT.DEFAULT).applyTo(link);
    MultiValidator validator = new MultiValidator() {

        @Override
        protected IStatus validate() {
            IObservableValue<IStatus> observable = BeanProperties
                    .value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model);
            Status status = (Status) observable.getValue();
            switch (status.getSeverity()) {
            case IStatus.ERROR:
                return OpenShiftUIActivator.statusFactory()
                        .errorStatus(OpenShiftUIMessages.OCBinaryErrorMessage);
            case IStatus.WARNING:
                return OpenShiftUIActivator.statusFactory()
                        .warningStatus(OpenShiftUIMessages.OCBinaryWarningMessage);
            }
            return status;
        }
    };
    dbc.addValidationStatusProvider(validator);
}

From source file:org.jkiss.dbeaver.ui.controls.resultset.StatusLabel.java

License:Apache License

public void setStatus(String message, DBPMessageType messageType) {
    if (statusText.isDisposed()) {
        return;/*from   www .  ja  v  a2  s . c  o m*/
    }
    this.messageType = messageType;

    Color fg;
    String statusIconId;
    switch (messageType) {
    case ERROR:
        fg = colorError;
        statusIconId = Dialog.DLG_IMG_MESSAGE_ERROR;
        break;
    case WARNING:
        fg = colorWarning;
        statusIconId = Dialog.DLG_IMG_MESSAGE_WARNING;
        break;
    default:
        fg = colorDefault;
        statusIconId = Dialog.DLG_IMG_MESSAGE_INFO;
        break;
    }
    statusText.setForeground(fg);
    if (message == null) {
        message = "???"; //$NON-NLS-1$
    }
    statusIcon.setImage(JFaceResources.getImage(statusIconId));
    statusText.setText(TextUtils.getSingleLineString(message));
    if (messageType != DBPMessageType.INFORMATION) {
        statusText.setToolTipText(message);
    } else {
        statusText.setToolTipText(null);
    }
}

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

License:Open Source License

/**
 * Sets the message for this dialog with an indication of what type of message it is.
 * <p>//from   w ww.  ja v  a 2 s .  c  o m
 * The valid message types are one of <code>NONE</code>,<code>INFORMATION</code>,<code>WARNING</code>, or
 * <code>ERROR</code>.
 * </p>
 * <p>
 * Note that for backward compatibility, a message of type <code>ERROR</code> is different than an error message (set
 * using <code>setErrorMessage</code>). An error message overrides the current message until the error message is
 * cleared. This method replaces the current message and does not affect the error message.
 * </p>
 *
 * @param newMessage
 *          the message, or <code>null</code> to clear the message
 * @param newType
 *          the message type
 * @since 2.0
 */
public void setMessage(final String newMessage, final int newType) {
    Image newImage = null;
    if (newMessage != null) {
        switch (newType) {
        case IMessageProvider.NONE:
            break;
        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;
        }
    }
    showMessage(newMessage, newImage);
}

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  w w w. j av  a 2 s .c  o  m
 * @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.springframework.ide.eclipse.wizard.ui.BeanChildDialog.java

License:Open Source License

protected void updateMessage() {
    String message = getMessage();
    if (message != null) {
        if (BeanWizard.getIgnoreError()) {
            messageLabel.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
        } else {//from w  ww .java 2s.c o  m
            messageLabel.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR));
        }
        messageLabel.setText(message);
    } else {
        messageLabel.setImage(null);
        messageLabel.setText(getDefaultMessage());
    }

    messageLabel.redraw();

}