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:org.eclipse.papyrus.infra.onefile.model.impl.SubResourceFile.java

License:Open Source License

public Image getImage() {
    Image image = JFaceResources.getImage(getFile().getFileExtension());
    if (image == null) {
        ImageDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry()
                .getImageDescriptor(getFile().getName());
        JFaceResources.getImageRegistry().put(getFile().getFileExtension(), desc);
    }/*from w w w  .  j  av a2  s  .c om*/
    return JFaceResources.getImage(getFile().getFileExtension());
}

From source file:org.eclipse.pde.internal.ui.editor.PDEFormPage.java

License:Open Source License

protected void createFormErrorContent(IManagedForm managedForm, String errorTitle, String errorMessage,
        Exception e) {/*  w w w.j av a  2 s  .c  o m*/

    ScrolledForm form = managedForm.getForm();
    FormToolkit toolkit = managedForm.getToolkit();
    toolkit.decorateFormHeading(form.getForm());

    Composite parent = form.getBody();
    GridLayout layout = new GridLayout();
    GridData data2 = new GridData(GridData.FILL_BOTH);
    layout.marginWidth = 7;
    layout.marginHeight = 7;
    parent.setLayout(layout);
    parent.setLayoutData(data2);
    // Set the title and image of the form
    form.setText(errorTitle);
    form.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR));

    int sectionStyle = Section.DESCRIPTION | ExpandableComposite.TITLE_BAR;
    // Create the message section
    Section messageSection = createUISection(parent, PDEUIMessages.PDEFormPage_titleMessage, errorMessage,
            sectionStyle);
    Composite messageClient = createUISectionContainer(messageSection, 1);
    // Bind the widgets
    toolkit.paintBordersFor(messageClient);
    messageSection.setClient(messageClient);
    // Ensure the exception was defined
    if (e == null) {
        return;
    }
    // Create the details section
    Section detailsSection = createUISection(parent, PDEUIMessages.PDEFormPage_titleDetails, e.getMessage(),
            sectionStyle);
    Composite detailsClient = createUISectionContainer(detailsSection, 1);
    // Create text widget holding the exception trace
    int style = SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY;
    Text text = toolkit.createText(detailsClient, getStackTrace(e), style);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 160;
    data.widthHint = 200;
    text.setLayoutData(data);
    // Bind the widgets
    toolkit.paintBordersFor(detailsClient);
    detailsSection.setClient(detailsClient);
    // Note: The veritical scrollbar fails to appear when text widget is
    // not entirely shown
}

From source file:org.eclipse.pde.internal.ui.wizards.tools.OrganizeManifestsWizardPage.java

License:Open Source License

private void createCustomBuildWarning(Composite container) {
    Composite parent = SWTFactory.createComposite(container, 2, 1, GridData.FILL_HORIZONTAL);

    Label image = new Label(parent, SWT.NONE);
    image.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    image.setLayoutData(gd);//from   w  ww.  jav  a  2 s.co m

    String message;
    if (fCustomProjects.size() == 1) {
        message = NLS.bind(PDEUIMessages.OrganizeManifestsWizardPage_ProjectsUsingCustomBuildWarning,
                ((IProject) fCustomProjects.iterator().next()).getName());
    } else {
        StringBuffer buf = new StringBuffer();
        for (Iterator<?> iterator = fCustomProjects.iterator(); iterator.hasNext();) {
            IProject project = (IProject) iterator.next();
            buf.append(project.getName());
            if (iterator.hasNext()) {
                buf.append(',').append(' ');
            }
        }
        message = NLS.bind(PDEUIMessages.OrganizeManifestsWizardPage_ProjectsUsingCustomBuildWarningPlural,
                buf.toString());
    }

    // Using a link as a wrap label appear to force the wizard to max vertical space
    Link link = new Link(parent, SWT.WRAP);
    link.setText(message);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 200;
    link.setLayoutData(gd);
}

From source file:org.eclipse.reddeer.jface.dialogs.TitleAreaDialog.java

License:Open Source License

/**
 * Return current dialog page message. //from ww w .  j a v  a2s .  co m
 * @return message type
 */
public MessageTypeEnum getMessageType() {
    checkShell();
    Image messageImage = getMessageImage();
    if (messageImage == null) {
        return MessageTypeEnum.NONE;
    } else if (messageImage.equals(JFaceResources.getImage(DLG_IMG_MESSAGE_ERROR))) {
        return MessageTypeEnum.ERROR;
    } else if (messageImage.equals(JFaceResources.getImage(DLG_IMG_MESSAGE_INFO))) {
        return MessageTypeEnum.INFO;
    } else if (messageImage.equals(JFaceResources.getImage(DLG_IMG_MESSAGE_WARNING))) {
        return MessageTypeEnum.WARNING;
    }
    return MessageTypeEnum.UNKNOWN;
}

From source file:org.eclipse.reddeer.jface.test.dialogs.TitleAreaDialogTest.java

License:Open Source License

@Test
public void titleAreaMessagesAndImages() {
    openTitleAreaDialog();/*w  ww .  j av  a 2  s  . co m*/
    TitleAreaDialogImpl dialog = new TitleAreaDialogImpl();
    assertEquals(TestingTitleAreaDialog.DEFAULT_MESSAGE, dialog.getMessage());
    assertEquals(MessageTypeEnum.NONE, dialog.getMessageType());
    assertEquals(TestingTitleAreaDialog.TITLE, dialog.getTitle());
    assertNull(dialog.getMessageImage());
    assertEquals(Activator.getDefault().getImageRegistry().get(Activator.REDDEER_ICON), dialog.getTitleImage());

    dialog.errorButton();
    assertEquals(TestingTitleAreaDialog.ERROR_MESSAGE, dialog.getMessage());
    assertEquals(MessageTypeEnum.ERROR, dialog.getMessageType());
    assertEquals(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR), dialog.getMessageImage());

    dialog.warningButton();
    assertEquals(TestingTitleAreaDialog.WARNING_MESSAGE, dialog.getMessage());
    assertEquals(MessageTypeEnum.WARNING, dialog.getMessageType());
    assertEquals(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING), dialog.getMessageImage());

    dialog.infoButton();
    assertEquals(TestingTitleAreaDialog.INFO_MESSAGE, dialog.getMessage());
    assertEquals(MessageTypeEnum.INFO, dialog.getMessageType());
    assertEquals(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO), dialog.getMessageImage());

    dialog.noneButton();
    assertEquals(TestingTitleAreaDialog.NONE_MESSAGE, dialog.getMessage());
    assertEquals(MessageTypeEnum.NONE, dialog.getMessageType());
    assertNull(dialog.getMessageImage());

    dialog.errorWithoutProviderButton();
    assertEquals(TestingTitleAreaDialog.ERROR_MESSAGE_WITHOUT_PROVIDER, dialog.getMessage());
    assertEquals(MessageTypeEnum.ERROR, dialog.getMessageType());

}

From source file:org.eclipse.scada.configuration.component.tools.wizard.PreviewPage.java

License:Open Source License

protected void renderResult(final ViewerCell cell, final Entry element) {
    if (element.getException() != null) {
        cell.setText(ExceptionHelper.getMessage(element.getException()));
        cell.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR));
    } else {/*  w w w  .  j a va 2s.  co  m*/
        cell.setText(element.getNewName());
        cell.setImage(null);
    }
}

From source file:org.eclipse.sirius.ui.tools.api.dialogs.AbstractExportRepresentationsAsImagesDialog.java

License:Open Source License

/**
 * Create the message group in the dialog used to display error messages.
 * /*from   w  w w.ja  v a2  s .  c om*/
 * @param parent
 *            the parent widget
 */
private void createMessageGroup(final Composite parent) {
    final Composite composite = SWTUtil.createCompositeHorizontalFill(parent, 2, false);

    messageImageLabel = new Label(composite, SWT.NONE);
    messageImageLabel.setImage(JFaceResources.getImage(DLG_IMG_MESSAGE_ERROR));
    messageImageLabel.setVisible(false);

    messageLabel = new Label(composite, SWT.NONE);
    final GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_HORIZONTAL);
    gridData.widthHint = 300;
    messageLabel.setLayoutData(gridData);
    messageLabel.setVisible(false);
}

From source file:org.eclipse.tcf.te.ui.jface.dialogs.OptionalMessageDialog.java

License:Open Source License

private Control createHelpControl(Composite parent) {
    Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
    if (helpImage != null) {
        return createHelpImageButton(parent, helpImage);
    }//from   w ww.j a va 2  s.  com
    return createHelpLink(parent);
}

From source file:org.eclipse.tcf.te.ui.views.editor.pages.AbstractEditorPage.java

License:Open Source License

/**
 * Get the image for the given message type.
 * @param messageType The message type./*from   w  w w . ja v a  2s  .co m*/
 * @return The image.
 */
protected Image getMessageImage(int messageType) {
    switch (messageType) {
    case IMessageProvider.INFORMATION:
        return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
    case IMessageProvider.WARNING:
        return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
    case IMessageProvider.ERROR:
        return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
    default:
        return null;
    }
}

From source file:org.eclipse.team.svn.ui.dialog.DefaultDialog.java

License:Open Source License

protected ToolBar createHelpImageButton(Composite parent) {
    ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
    ((GridLayout) parent.getLayout()).numColumns++;
    toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
    toolBar.setCursor(cursor);/*w ww. j av a  2  s .c o m*/
    toolBar.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            cursor.dispose();
        }
    });
    ToolItem item = new ToolItem(toolBar, SWT.NONE);
    item.setImage(JFaceResources.getImage(DLG_IMG_HELP));
    item.setToolTipText(JFaceResources.getString("helpToolTip")); //$NON-NLS-1$
    item.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            DefaultDialog.this.mainComposite.notifyListeners(SWT.Help, new Event());
        }
    });
    return toolBar;
}