Example usage for org.eclipse.jface.resource JFaceColors getErrorBackground

List of usage examples for org.eclipse.jface.resource JFaceColors getErrorBackground

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceColors getErrorBackground.

Prototype

public static Color getErrorBackground(Display display) 

Source Link

Usage

From source file:cc.warlock.rcp.stormfront.ui.prefs.AccountEditDialog.java

License:Open Source License

@Override
protected void buttonPressed(int buttonId) {
    if (buttonId == TEST_ACCOUNT) {
        AccountVerifier verifier = new AccountVerifier(usernameField.getText(), passwordField.getText());

        boolean verified = verifier.verify();
        if (!verified) {
            statusLabel.setBackground(JFaceColors.getErrorBackground(getShell().getDisplay()));
            statusLabel.setForeground(JFaceColors.getErrorText(getShell().getDisplay()));
            String loginError = LoginUtil.getAuthenticationError(verifier.getErrorCode());
            statusLabel.setText(loginError);

            getButton(OK).setEnabled(false);
        } else {/*from   w  w w. java2  s  .  c  om*/
            statusLabel.setBackground(getShell().getBackground());
            statusLabel.setForeground(new Color(getShell().getDisplay(), 0, 128, 0));
            statusLabel.setText("Succesfully logged in to the server");

            getButton(OK).setEnabled(true);
        }
    } else {
        super.buttonPressed(buttonId);
    }
}

From source file:net.tourbook.ui.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./* w  w w.  j av 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(final String newMessage, final 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.bonitasoft.studio.common.jface.databinding.CustomTextEMFObservableValueEditingSupport.java

License:Open Source License

protected void updateTextEditorFeedback(final IStatus status) {
    if (cellEditor != null && cellEditor.getControl() != null && !cellEditor.getControl().isDisposed()) {
        final Control control = cellEditor.getControl();
        if (status.getSeverity() == IStatus.ERROR) {
            control.setBackground(JFaceColors.getErrorBackground(control.getDisplay()));
            control.setForeground(JFaceColors.getErrorText(control.getDisplay()));
        } else {/*from   ww w. j av  a 2s  . c o  m*/
            control.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_WHITE));
            control.setForeground(control.getDisplay().getSystemColor(SWT.COLOR_BLACK));
        }
    }
}

From source file:org.eclipse.birt.report.designer.internal.ui.dialogs.MessageLine.java

License:Open Source License

/**
 * Sets the message and image to the given status. <code>null</code> is a
 * valid argument and will set the empty text and no image
 *//*  w w w  .  ja  va  2 s.  c o m*/
public void setErrorStatus(IStatus status) {
    if (status != null && !status.isOK()) {
        String message = status.getMessage();
        if (message != null && message.length() > 0) {
            setText(message);
            setImage(findImage(status));
            setBackground(JFaceColors.getErrorBackground(getDisplay()));
            return;
        }
    }
    setText(""); //$NON-NLS-1$   
    setImage(null);
    setBackground(fNormalMsgAreaBackground);
}

From source file:org.eclipse.cdt.internal.autotools.ui.MessageLine.java

License:Open Source License

/**
  * Display the given error message. A currently displayed message
  * is saved and will be redisplayed when the error message is cleared.
  *//*w  ww .j a  v a2  s.  co  m*/
public void setErrorMessage(String message) {
    if (message != null && message.length() > 0) {
        hasErrorMessage = true;
        clabel.setText(message);
        clabel.setImage(MakeUIImages.getImage(MakeUIImages.IMG_OBJS_ERROR));
        clabel.setBackground(JFaceColors.getErrorBackground(clabel.getDisplay()));
        return;
    }
    hasErrorMessage = false;
    clabel.setText(fMessage);
    clabel.setImage(null);
    clabel.setBackground(fNormalMsgAreaBackground);
}

From source file:org.eclipse.cdt.make.internal.ui.MessageLine.java

License:Open Source License

/**
  * Display the given error message. A currently displayed message
  * is saved and will be redisplayed when the error message is cleared.
  *///  w w  w.ja va  2 s.c o m
public void setErrorMessage(String message) {
    if (message != null && message.length() > 0) {
        hasErrorMessage = true;
        setText(message);
        setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK));
        setBackground(JFaceColors.getErrorBackground(getDisplay()));
        return;
    }
    hasErrorMessage = false;
    setText(fMessage);
    setImage(null);
    setBackground(fNormalMsgAreaBackground);
}

From source file:org.eclipse.contribution.visualiser.internal.preference.VisualiserPreferencesDialog.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>./*from www.  ja  v a2 s .  c om*/
 *
 * @param newErrorMessage the errorMessage to display or <code>null</code>
 */
public void setErrorMessage(String newErrorMessage) {
    // Any change?
    if (errorMessage == null ? newErrorMessage == null : errorMessage.equals(newErrorMessage))
        return;

    errorMessage = newErrorMessage;
    if (errorMessage == null) {
        if (showingError) {
            // we were previously showing an error
            showingError = false;
            messageLabel.setBackground(normalMsgAreaBackground);
            messageLabel.setImage(null);
            titleImage.setImage(JFaceResources.getImage(PREF_DLG_TITLE_IMG));
        }

        // avoid calling setMessage in case it is overridden to call setErrorMessage, 
        // which would result in a recursive infinite loop
        if (message == null)
            //this should probably never happen since setMessage does this conversion....
            message = ""; //$NON-NLS-1$
        messageLabel.setText(message);
        messageLabel.setImage(messageImage);
        messageLabel.setToolTipText(message);
    } else {
        messageLabel.setText(errorMessage);
        messageLabel.setToolTipText(errorMessage);
        if (!showingError) {
            // we were not previously showing an error
            showingError = true;

            // lazy initialize the error background color and image
            if (errorMsgAreaBackground == null) {
                errorMsgAreaBackground = JFaceColors.getErrorBackground(messageLabel.getDisplay());
                errorMsgImage = JFaceResources.getImage(PREF_DLG_IMG_TITLE_ERROR);
            }

            // show the error   
            normalMsgAreaBackground = messageLabel.getBackground();
            messageLabel.setBackground(errorMsgAreaBackground);
            messageLabel.setImage(errorMsgImage);
            titleImage.setImage(null);
        }
    }
    titleArea.layout(true);
}

From source file:org.eclipse.scada.hd.ui.views.QueryDataView.java

License:Open Source License

@Override
public void createPartControl(final Composite parent) {
    addListener();/*from w w  w .j a v a  2 s .c  o  m*/

    parent.setLayout(new FillLayout());
    this.table = new Table(parent, SWT.FULL_SELECTION);
    this.table.setHeaderVisible(true);

    this.indexCol = new TableColumn(this.table, SWT.NONE);
    this.indexCol.setText(Messages.QueryDataView_ColIndex);
    this.indexCol.setWidth(50);

    this.qualityCol = new TableColumn(this.table, SWT.NONE);
    this.qualityCol.setText(Messages.QueryDataView_ColQuality);
    this.qualityCol.setWidth(75);

    this.manualCol = new TableColumn(this.table, SWT.NONE);
    this.manualCol.setText(Messages.QueryDataView_ColManual);
    this.manualCol.setWidth(75);

    this.invalidColor = JFaceColors.getErrorBackground(getDisplay());
}

From source file:org.eclipse.team.internal.ui.dialogs.PreferencePageContainerDialog.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>.//from  w  w  w  . j av a  2  s  . c  o m
 *
 * @param errorMessage the errorMessage to display or <code>null</code>
 */
public void setErrorMessage(String errorMessage) {
    if (errorMessage == null) {
        if (fMessageLabel.getImage() != null) {
            // we were previously showing an error
            fMessageLabel.setBackground(fNormalMsgAreaBackground);
            fMessageLabel.setImage(null);
            fTitleImage.setImage(TeamUIPlugin.getPlugin().getImageRegistry().get(PREF_DLG_TITLE_IMG));
            fTitleArea.layout(true);
        }

        // show the message
        setMessage(fMessage);

    } else {
        fMessageLabel.setText(errorMessage);
        if (fMessageLabel.getImage() == null) {
            // we were not previously showing an error

            // lazy initialize the error background color and image
            if (fErrorMsgImage == null) {
                fErrorMsgImage = TeamUIPlugin.getPlugin().getImageRegistry().get(PREF_DLG_IMG_TITLE_ERROR);
            }

            // show the error   
            fNormalMsgAreaBackground = fMessageLabel.getBackground();
            fMessageLabel.setBackground(JFaceColors.getErrorBackground(fMessageLabel.getDisplay()));
            fMessageLabel.setImage(fErrorMsgImage);
            fTitleImage.setImage(null);
            fTitleArea.layout(true);
        }
    }
}

From source file:org.eclipse.ui.ide.markers.compatibility.internal.MarkerPreferencesDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {

    Composite dialogArea = (Composite) super.createDialogArea(parent);

    boolean checked = IDEWorkbenchPlugin.getDefault().getPreferenceStore()
            .getBoolean(IDEInternalPreferences.USE_MARKER_LIMITS);
    enablementButton = new Button(dialogArea, SWT.CHECK);
    enablementButton.setText(MarkerMessages.MarkerPreferences_MarkerLimits);
    enablementButton.setSelection(checked);

    editArea = new Composite(dialogArea, SWT.NONE);
    editArea.setLayout(new GridLayout());
    GridData editData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
    editData.horizontalIndent = 10;/*from www  .ja  va 2s . c  om*/
    editArea.setLayoutData(editData);

    limitEditor = new IntegerFieldEditor("limit", MarkerMessages.MarkerPreferences_VisibleItems, editArea) { //$NON-NLS-1$
        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.jface.preference.IntegerFieldEditor#checkState()
         */
        protected boolean checkState() {
            boolean state = super.checkState();
            setValid(state, getErrorMessage());
            return state;
        }
    };
    limitEditor.setPreferenceStore(IDEWorkbenchPlugin.getDefault().getPreferenceStore());
    limitEditor.setPreferenceName(IDEInternalPreferences.MARKER_LIMITS_VALUE);
    limitEditor.load();

    GridData checkedData = new GridData(SWT.FILL, SWT.NONE, true, false);
    checkedData.horizontalSpan = limitEditor.getNumberOfControls();
    enablementButton.setLayoutData(checkedData);

    enablementButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            setLimitEditorEnablement(editArea, enablementButton.getSelection());
        }
    });

    setLimitEditorEnablement(editArea, checked);

    messageLabel = new Label(dialogArea, SWT.NONE);

    messageLabel.setBackground(JFaceColors.getErrorBackground(dialogArea.getDisplay()));
    messageLabel.setForeground(JFaceColors.getErrorText(dialogArea.getDisplay()));
    messageLabel.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));

    applyDialogFont(dialogArea);
    return dialogArea;
}