Example usage for org.eclipse.jface.resource JFaceResources getImage

List of usage examples for org.eclipse.jface.resource JFaceResources getImage

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceResources getImage.

Prototype

public static Image getImage(String key) 

Source Link

Document

Returns the image in JFace's image registry with the given key, or null if none.

Usage

From source file:ext.org.eclipse.jdt.internal.ui.wizards.buildpaths.NewVariableEntryDialog.java

License:Open Source License

private void updateDeprecationWarning() {
    if (fWarning == null || fWarning.isDisposed())
        return;/* ww  w.jav a  2s.c  o  m*/

    for (Iterator<CPVariableElement> iter = fVariablesList.getSelectedElements().iterator(); iter.hasNext();) {
        CPVariableElement element = iter.next();
        String deprecationMessage = element.getDeprecationMessage();
        if (deprecationMessage != null) {
            fWarning.setText(deprecationMessage);
            fWarning.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
            return;
        }
    }
    fWarning.setText(null);
    fWarning.setImage(null);
}

From source file:ext.org.eclipse.jdt.internal.ui.wizards.buildpaths.VariableBlock.java

License:Open Source License

private void updateDeprecationWarning() {
    if (fWarning == null || fWarning.isDisposed())
        return;//from   ww w .j ava2 s.  c  om

    for (Iterator<CPVariableElement> iter = fSelectedElements.iterator(); iter.hasNext();) {
        CPVariableElement element = iter.next();
        String deprecationMessage = element.getDeprecationMessage();
        if (deprecationMessage != null) {
            fWarning.setText(deprecationMessage);
            fWarning.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
            return;
        }
    }
    fWarning.setText(null);
    fWarning.setImage(null);
}

From source file:fr.imag.adele.cadse.si.workspace.uiplatform.swt.SWTUIPlatform.java

License:Apache License

public void setMessage(String newMessage, int newType) {
    if (_pageSite != null) {
        IStatusLineManager statusLine = _pageSite.getActionBars().getStatusLineManager();
        if (statusLine != null) {
            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;
                }/*  ww  w  .  j a va2 s  .  c o  m*/
                if (newType == UIPlatform.ERROR) {
                    statusLine.setErrorMessage(newImage, newMessage);

                } else {
                    statusLine.setMessage(newImage, newMessage);
                }
            } else {
                statusLine.setErrorMessage(null);
                statusLine.setMessage(null);
            }
        }
    } else if (dialog != null) {
        if (newMessage != null) {
            if (newType == UIPlatform.ERROR) {
                dialog.setErrorMessage(newMessage);
                IWizardPage page = dialog.getCurrentPage();
                if (page instanceof WizardPage)
                    ((WizardPage) page).setPageComplete(false);
            } else {
                dialog.setMessage(newMessage, newType);
                IWizardPage page = dialog.getCurrentPage();
                if (page instanceof WizardPage)
                    ((WizardPage) page).setPageComplete(true);
            }
        } else {
            dialog.setErrorMessage(null);
            dialog.setMessage(null);

            IWizardPage page = dialog.getCurrentPage();
            if (page instanceof WizardPage)
                ((WizardPage) page).setPageComplete(true);

        }
    }
}

From source file:gov.redhawk.ide.sdr.internal.ui.navigator.SdrNavigatorLabelProvider.java

License:Open Source License

@Override
public Image getToolTipImage(final Object object) {
    if (object instanceof SdrRoot) {
        final SdrRoot root = (SdrRoot) object;
        final IStatus status = root.getLoadStatus();
        if (status != null && !status.isOK()) {
            switch (status.getSeverity()) {
            case IStatus.INFO:
                return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
            case IStatus.WARNING:
                return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
            case IStatus.ERROR:
                return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
            default:
                return null;
            }/* w ww.j  ava  2  s.  co m*/
        }
    }
    return null;
}

From source file:gov.redhawk.sca.ui.ScaLabelProvider.java

License:Open Source License

@Override
public Image getToolTipImage(final Object element) {
    if (element instanceof IStatusProvider) {
        final IStatusProvider dpo = (IStatusProvider) element;
        final IStatus status = dpo.getStatus();
        if (status != null && !status.isOK()) {
            switch (status.getSeverity()) {
            case IStatus.INFO:
                return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
            case IStatus.WARNING:
                return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
            case IStatus.ERROR:
                return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
            default:
                return null;
            }//from   ww w. ja  va 2s.  c  om
        }
    }
    return null;
}

From source file:greclipse.org.eclipse.jdt.junit.wizards.NewTestCaseWizardPageOne.java

License:Open Source License

/**
 * Creates the controls for the JUnit 4 toggle control. Expects a <code>GridLayout</code> with
 * at least 3 columns.//ww w.j  a  v a  2 s .c  o m
 *
 * @param composite the parent composite
 * @param nColumns number of columns to span
 *
 * @since 3.2
 */
protected void createBuildPathConfigureControls(Composite composite, int nColumns) {
    Composite inner = new Composite(composite, SWT.NONE);
    inner.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false, nColumns, 1));
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    inner.setLayout(layout);

    fImage = new Label(inner, SWT.NONE);
    fImage.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
    fImage.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false, 1, 1));

    fLink = new Link(inner, SWT.WRAP);
    fLink.setText("\n\n"); //$NON-NLS-1$
    fLink.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            performBuildpathConfiguration(e.text);
        }
    });
    GridData gd = new GridData(GridData.FILL, GridData.BEGINNING, true, false, 1, 1);
    gd.widthHint = convertWidthInCharsToPixels(60);
    fLink.setLayoutData(gd);
    updateBuildPathMessage();
}

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

License:Open Source License

/**
 * Creates the dialog's title area.//from  w  w w .j a  v  a2s .  c  o  m
 * 
 * @param parent
 *            the SWT parent for the title area widgets
 * @return Control with the highest x axis value.
 */
private Control createTitleArea(Composite parent) {

    // add a dispose listener
    parent.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            if (titleAreaColor != null) {
                titleAreaColor.dispose();
            }
        }
    });
    // Determine the background color of the title bar
    Display display = parent.getDisplay();
    Color background;
    Color foreground;
    if (titleAreaRGB != null) {
        titleAreaColor = new Color(display, titleAreaRGB);
        background = titleAreaColor;
        foreground = null;
    } else {
        background = JFaceColors.getBannerBackground(display);
        foreground = JFaceColors.getBannerForeground(display);
    }

    parent.setBackground(background);
    int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    // Dialog image @ right
    titleImageLabel = new Label(parent, SWT.CENTER);
    titleImageLabel.setBackground(background);
    if (titleAreaImage == null)
        titleImageLabel.setImage(JFaceResources.getImage(DLG_IMG_TITLE_BANNER));
    else
        titleImageLabel.setImage(titleAreaImage);

    FormData imageData = new FormData();
    imageData.top = new FormAttachment(0, 0);
    // Note: do not use horizontalSpacing on the right as that would be a
    // regression from
    // the R2.x style where there was no margin on the right and images are
    // flush to the right
    // hand side. see reopened comments in 41172
    imageData.right = new FormAttachment(100, 0); // horizontalSpacing
    titleImageLabel.setLayoutData(imageData);
    // Title label @ top, left
    titleLabel = new Label(parent, SWT.LEFT);
    JFaceColors.setColors(titleLabel, foreground, background);
    titleLabel.setFont(JFaceResources.getBannerFont());
    titleLabel.setText(" ");//$NON-NLS-1$
    FormData titleData = new FormData();
    titleData.top = new FormAttachment(0, verticalSpacing);
    titleData.right = new FormAttachment(titleImageLabel);
    titleData.left = new FormAttachment(0, horizontalSpacing);
    titleLabel.setLayoutData(titleData);
    // Message image @ bottom, left
    messageImageLabel = new Label(parent, SWT.CENTER);
    messageImageLabel.setBackground(background);
    // Message label @ bottom, center
    messageLabel = new Label(parent, SWT.WRAP | SWT.READ_ONLY);
    JFaceColors.setColors(messageLabel, foreground, background);
    messageLabel.setText(" \n "); // two lines//$NON-NLS-1$
    messageLabel.setFont(JFaceResources.getDialogFont());
    messageLabel.setBackground(JFaceColors.getBannerBackground(Display.getDefault()));

    messageLabelHeight = messageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
    // Filler labels
    leftFillerLabel = new Label(parent, SWT.CENTER);
    leftFillerLabel.setBackground(background);
    bottomFillerLabel = new Label(parent, SWT.CENTER);
    bottomFillerLabel.setBackground(background);
    setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing);
    determineTitleImageLargest();
    if (titleImageLargest)
        return titleImageLabel;
    return messageLabel;
}

From source file:net.heartsome.cat.common.ui.wizard.TSTitleAreaDialog.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>.// w  w  w.j av  a2 s  .  c  o  m
 * 
 * @param newErrorMessage
 *            the newErrorMessage to display or <code>null</code>
 */
public void setErrorMessage(String newErrorMessage) {
    // Any change?
    if (errorMessage == null ? newErrorMessage == null : errorMessage.equals(newErrorMessage))
        return;
    errorMessage = newErrorMessage;

    // Clear or set error message.
    if (errorMessage == null) {
        if (showingError) {
            // we were previously showing an error
            showingError = false;
        }
        // show the message
        // 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$
        updateMessage(message);
        messageImageLabel.setImage(messageImage);
        setImageLabelVisible(messageImage != null);
    } else {
        // Add in a space for layout purposes but do not
        // change the instance variable
        String displayedErrorMessage = " " + errorMessage; //$NON-NLS-1$
        updateMessage(displayedErrorMessage);
        if (!showingError) {
            // we were not previously showing an error
            showingError = true;
            messageImageLabel.setImage(JFaceResources.getImage(DLG_IMG_TITLE_ERROR));
            setImageLabelVisible(true);
        }
    }
    layoutForNewMessage(false);
}

From source file:net.tourbook.ui.MessageRegion.java

License:Open Source License

/**
 * Create the contents for the receiver.
 * //from   ww w. j a v  a2s  . com
 * @param parent
 *            the Composite that the children will be created in
 */
public void createContents(final Composite parent) {
    messageComposite = new Composite(parent, SWT.NONE);
    final 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);

    final GridData imageData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
    final 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));

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

}

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.//from   w  w  w .j a va 2s.  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()));
    }

}