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:de.femodeling.e4.ui.progress.internal.JobInfo.java

License:Open Source License

public Image getDisplayImage() {
    int done = getPercentDone();
    if (done > 0) {
        return super.getDisplayImage();
    }/*w w  w.j  av a2  s.co  m*/
    if (isBlocked()) {
        return JFaceResources.getImage(ProgressManager.BLOCKED_JOB_KEY);
    }
    int state = getJob().getState();
    if (state == Job.SLEEPING) {
        return JFaceResources.getImage(ProgressManager.SLEEPING_JOB_KEY);
    }
    if (state == Job.WAITING) {
        return JFaceResources.getImage(ProgressManager.WAITING_JOB_KEY);
    }
    //By default return the first progress image
    return super.getDisplayImage();

}

From source file:de.femodeling.e4.ui.progress.internal.JobTreeElement.java

License:Open Source License

/**
 * Get the image for the reciever.//w w w  .  ja v  a 2 s  .co m
 * 
 * @return Image or <code>null</code>.
 */
public Image getDisplayImage() {
    return JFaceResources.getImage(ProgressInfoItem.DEFAULT_JOB_KEY);
}

From source file:de.femodeling.e4.ui.progress.internal.ProgressInfoItem.java

License:Open Source License

/**
 * Get the image for the info.//from  w w w .ja v  a2  s . co m
 * 
 * @return Image
 */
private Image getInfoImage() {

    if (!info.isJobInfo()) {
        return JFaceResources.getImage(DEFAULT_JOB_KEY);
    }

    JobInfo jobInfo = (JobInfo) info;

    ImageDescriptor descriptor = null;
    Object property = jobInfo.getJob().getProperty(IProgressConstants.ICON_PROPERTY);

    if (property instanceof ImageDescriptor) {
        descriptor = (ImageDescriptor) property;
    } else if (property instanceof URL) {
        descriptor = ImageDescriptor.createFromURL((URL) property);
    }

    Image image = null;
    if (descriptor == null) {
        image = ProgressManager.getInstance().getIconFor(jobInfo.getJob());
    } else {
        image = getResourceManager().createImageWithDefault(descriptor);
    }

    if (image == null)
        image = jobInfo.getDisplayImage();

    return image;
}

From source file:de.femodeling.e4.ui.progress.internal.ProgressInfoItem.java

License:Open Source License

/**
 * Set the images in the toolbar based on whether the receiver is finished
 * or not. Also update tooltips if required.
 * //from ww  w.j a  v a2  s . co  m
 */
private void updateToolBarValues() {
    if (isCompleted()) {
        actionButton.setImage(JFaceResources.getImage(CLEAR_FINISHED_JOB_KEY));
        actionButton.setDisabledImage(JFaceResources.getImage(DISABLED_CLEAR_FINISHED_JOB_KEY));
        actionButton.setToolTipText(ProgressMessages.NewProgressView_ClearJobToolTip);
    } else {
        actionButton.setImage(JFaceResources.getImage(STOP_IMAGE_KEY));
        actionButton.setDisabledImage(JFaceResources.getImage(DISABLED_STOP_IMAGE_KEY));

    }
    JobInfo[] infos = getJobInfos();

    for (int i = 0; i < infos.length; i++) {
        // Only disable if there is an unresponsive operation
        if (infos[i].isCanceled() && !isCompleted()) {
            actionButton.setEnabled(false);
            return;
        }
    }
    actionButton.setEnabled(true);
}

From source file:de.walware.ecommons.ui.util.StatusLineMessageManager.java

License:Open Source License

private Image getIcon(final int severity) {
    if (!this.showIcons) {
        return null;
    }/* w  w  w.j a  v  a2s . c  o  m*/
    switch (severity) {
    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 source file:de.walware.statet.r.internal.ui.pkgmanager.StatusLabelProvider.java

License:Open Source License

public Image getImage(final IStatus status) {
    switch (status.getSeverity()) {
    case IStatus.ERROR:
        return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
    case IStatus.WARNING:
        return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
    default://  w ww .j av a2 s. co m
        return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
    }
}

From source file:es.axios.udig.spatialoperations.ui.view.Message.java

License:LGPL

/**
 * @return Returns the image//from   ww  w .  j  av  a  2  s  .  c  om
 */
public final Image getImage() {

    Image image = null;

    switch (type) {
    case FAIL:
        image = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
        break;
    case INFORMATION:
    case IMPORTANT_INFO:
        image = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
        break;
    case WARNING:
        image = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
        break;
    case ERROR:
        image = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
        break;

    case NULL:
        image = null;
        break;

    default:
        assert false; // imposible!
        break;
    }

    return image;
}

From source file:es.axios.udig.ui.commons.message.InfoMessage.java

License:LGPL

/**
 * @return Returns the image/*from  w  w  w.  j a v a 2s. c o  m*/
 */
public final Image getImage() {

    Image image = null;

    switch (type) {
    case FAIL:
        image = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
        break;
    case INFORMATION:
    case IMPORTANT_INFO:
        image = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
        break;
    case WARNING:
        image = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
        break;
    case ERROR:
        image = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
        break;

    case NULL:
        image = null;
        break;

    default:
        assert false; // impossible!
        break;
    }

    return image;
}

From source file:ext.org.eclipse.jdt.internal.ui.preferences.ComplianceConfigurationBlock.java

License:Open Source License

private Composite createComplianceTabContent(Composite folder) {

    boolean hide_1_7 = JavaModelUtil.HIDE_VERSION_1_7 && !(VERSION_1_7.equals(getValue(PREF_COMPLIANCE))
            || VERSION_1_7.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM)));

    String[] values3456 = new String[] { VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7 };
    String[] values3456Labels = new String[] { PreferencesMessages.ComplianceConfigurationBlock_version13,
            PreferencesMessages.ComplianceConfigurationBlock_version14,
            PreferencesMessages.ComplianceConfigurationBlock_version15,
            PreferencesMessages.ComplianceConfigurationBlock_version16,
            PreferencesMessages.ComplianceConfigurationBlock_version17 };
    if (hide_1_7) {
        values3456 = removeLast(values3456);
        values3456Labels = removeLast(values3456Labels);
    }//from   w ww.j  a v a2  s .  c  o m

    final ScrolledPageContent sc1 = new ScrolledPageContent(folder);
    Composite composite = sc1.getBody();
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);

    fControlsComposite = new Composite(composite, SWT.NONE);
    fControlsComposite.setFont(composite.getFont());
    fControlsComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));

    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 1;
    fControlsComposite.setLayout(layout);

    int nColumns = 3;

    layout = new GridLayout();
    layout.numColumns = nColumns;

    Group group = new Group(fControlsComposite, SWT.NONE);
    group.setFont(fControlsComposite.getFont());
    group.setText(PreferencesMessages.ComplianceConfigurationBlock_compliance_group_label);
    group.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
    group.setLayout(layout);

    String[] defaultUserValues = new String[] { DEFAULT_CONF, USER_CONF };

    Control[] otherChildren = group.getChildren();
    if (fProject != null) {
        String label = PreferencesMessages.ComplianceConfigurationBlock_compliance_follows_EE_label;
        int widthHint = fPixelConverter.convertWidthInCharsToPixels(40);
        addCheckBoxWithLink(group, label, INTR_COMPLIANCE_FOLLOWS_EE, defaultUserValues, 0, widthHint,
                new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        openBuildPathPropertyPage();
                    }
                });
    }

    Control[] allChildren = group.getChildren();
    fComplianceFollowsEEControls.addAll(Arrays.asList(allChildren));
    fComplianceFollowsEEControls.removeAll(Arrays.asList(otherChildren));
    otherChildren = allChildren;

    String label = PreferencesMessages.ComplianceConfigurationBlock_compiler_compliance_label;
    addComboBox(group, label, PREF_COMPLIANCE, values3456, values3456Labels, 0);

    label = PreferencesMessages.ComplianceConfigurationBlock_default_settings_label;
    addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, defaultUserValues, 0);

    allChildren = group.getChildren();
    fComplianceControls.addAll(Arrays.asList(allChildren));
    fComplianceControls.removeAll(Arrays.asList(otherChildren));
    otherChildren = allChildren;

    int indent = fPixelConverter.convertWidthInCharsToPixels(2);

    String[] versions = new String[] { VERSION_CLDC_1_1, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4,
            VERSION_1_5, VERSION_1_6, VERSION_1_7 };
    String[] versionsLabels = new String[] { PreferencesMessages.ComplianceConfigurationBlock_versionCLDC11,
            PreferencesMessages.ComplianceConfigurationBlock_version11,
            PreferencesMessages.ComplianceConfigurationBlock_version12,
            PreferencesMessages.ComplianceConfigurationBlock_version13,
            PreferencesMessages.ComplianceConfigurationBlock_version14,
            PreferencesMessages.ComplianceConfigurationBlock_version15,
            PreferencesMessages.ComplianceConfigurationBlock_version16,
            PreferencesMessages.ComplianceConfigurationBlock_version17 };
    if (hide_1_7) {
        versions = removeLast(versions);
        versionsLabels = removeLast(versionsLabels);
    }

    boolean showJsr14 = ComplianceConfigurationBlock.VERSION_JSR14
            .equals(getValue(PREF_CODEGEN_TARGET_PLATFORM));
    if (showJsr14) {
        versions = append(versions, ComplianceConfigurationBlock.VERSION_JSR14);
        versionsLabels = append(versionsLabels, ComplianceConfigurationBlock.VERSION_JSR14);
    }

    label = PreferencesMessages.ComplianceConfigurationBlock_codegen_targetplatform_label;
    addComboBox(group, label, PREF_CODEGEN_TARGET_PLATFORM, versions, versionsLabels, indent);

    label = PreferencesMessages.ComplianceConfigurationBlock_source_compatibility_label;
    addComboBox(group, label, PREF_SOURCE_COMPATIBILITY, values3456, values3456Labels, indent);

    String[] errorWarningIgnore = new String[] { ERROR, WARNING, IGNORE };

    String[] errorWarningIgnoreLabels = new String[] { PreferencesMessages.ComplianceConfigurationBlock_error,
            PreferencesMessages.ComplianceConfigurationBlock_warning,
            PreferencesMessages.ComplianceConfigurationBlock_ignore };

    label = PreferencesMessages.ComplianceConfigurationBlock_pb_assert_as_identifier_label;
    addComboBox(group, label, PREF_PB_ASSERT_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels,
            indent);

    label = PreferencesMessages.ComplianceConfigurationBlock_pb_enum_as_identifier_label;
    addComboBox(group, label, PREF_PB_ENUM_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels, indent);

    allChildren = group.getChildren();
    fComplianceChildControls.addAll(Arrays.asList(allChildren));
    fComplianceChildControls.removeAll(Arrays.asList(otherChildren));

    layout = new GridLayout();
    layout.numColumns = nColumns;

    group = new Group(fControlsComposite, SWT.NONE);
    group.setFont(fControlsComposite.getFont());
    group.setText(PreferencesMessages.ComplianceConfigurationBlock_classfiles_group_label);
    group.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
    group.setLayout(layout);

    String[] generateValues = new String[] { GENERATE, DO_NOT_GENERATE };
    String[] enableDisableValues = new String[] { ENABLED, DISABLED };

    label = PreferencesMessages.ComplianceConfigurationBlock_variable_attr_label;
    addCheckBox(group, label, PREF_LOCAL_VARIABLE_ATTR, generateValues, 0);

    label = PreferencesMessages.ComplianceConfigurationBlock_line_number_attr_label;
    addCheckBox(group, label, PREF_LINE_NUMBER_ATTR, generateValues, 0);

    label = PreferencesMessages.ComplianceConfigurationBlock_source_file_attr_label;
    addCheckBox(group, label, PREF_SOURCE_FILE_ATTR, generateValues, 0);

    label = PreferencesMessages.ComplianceConfigurationBlock_codegen_unused_local_label;
    addCheckBox(group, label, PREF_CODEGEN_UNUSED_LOCAL, new String[] { PRESERVE, OPTIMIZE_OUT }, 0);

    label = PreferencesMessages.ComplianceConfigurationBlock_codegen_inline_jsr_bytecode_label;
    addCheckBox(group, label, PREF_CODEGEN_INLINE_JSR_BYTECODE, enableDisableValues, 0);

    Composite infoComposite = new Composite(fControlsComposite, SWT.NONE);
    infoComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    infoComposite.setLayout(new GridLayout(2, false));

    fJRE50InfoImage = new Label(infoComposite, SWT.NONE);
    fJRE50InfoImage.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
    GridData gd = new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false);
    fJRE50InfoImage.setLayoutData(gd);

    fJRE50InfoText = new Link(infoComposite, SWT.WRAP);
    fJRE50InfoText.setFont(composite.getFont());
    // set a text: not the real one, just for layouting
    fJRE50InfoText.setText(
            Messages.format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info_project,
                    new String[] { getVersionLabel(VERSION_1_3), getVersionLabel(VERSION_1_3) }));
    fJRE50InfoText.setVisible(false);
    fJRE50InfoText.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent e) {
            if ("1".equals(e.text)) { //$NON-NLS-1$
                openJREInstallPreferencePage(false);
            } else if ("2".equals(e.text)) { //$NON-NLS-1$
                openJREInstallPreferencePage(true);
            } else {
                openBuildPathPropertyPage();
            }
        }

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }
    });
    gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    gd.widthHint = fPixelConverter.convertWidthInCharsToPixels(50);
    fJRE50InfoText.setLayoutData(gd);
    validateComplianceStatus();

    return sc1;
}

From source file:ext.org.eclipse.jdt.internal.ui.preferences.ComplianceConfigurationBlock.java

License:Open Source License

private void validateComplianceStatus() {
    if (fJRE50InfoText != null && !fJRE50InfoText.isDisposed()) {
        boolean isVisible = false;
        String compliance = getStoredValue(PREF_COMPLIANCE); // get actual value
        IVMInstall install = null;//from w  ww  . j ava 2  s. c  o  m
        if (fProject != null) { // project specific settings: only test if a 50 JRE is installed
            try {
                install = JavaRuntime.getVMInstall(JavaCore.create(fProject));
            } catch (CoreException e) {
                JavaPlugin.log(e);
            }
        } else {
            install = JavaRuntime.getDefaultVMInstall();
        }
        if (install instanceof IVMInstall2) {
            String compilerCompliance = JavaModelUtil.getCompilerCompliance((IVMInstall2) install, compliance);
            if (!compilerCompliance.equals(compliance)) { // Discourage using compiler with version other than compliance
                String[] args = { getVersionLabel(compliance), getVersionLabel(compilerCompliance) };
                if (fProject == null) {
                    fJRE50InfoText.setText(Messages
                            .format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info, args));
                } else {
                    fJRE50InfoText.setText(Messages.format(
                            PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info_project, args));
                }
                isVisible = true;
                if (JavaModelUtil.HIDE_VERSION_1_7 && VERSION_1_7.equals(compliance)) {
                    String javaVersion = ((IVMInstall2) install).getJavaVersion();
                    if (javaVersion != null && javaVersion.startsWith(VERSION_1_7)) {
                        isVisible = false;
                    }
                }
            }
        }
        String complianceFollowsEE = getValue(INTR_COMPLIANCE_FOLLOWS_EE);
        if (JavaModelUtil.HIDE_VERSION_1_7 && DEFAULT_CONF.equals(complianceFollowsEE)) {
            if (getEE().getId().indexOf(JavaCore.VERSION_1_7) != -1) {
                isVisible = true;
                fJRE50InfoText.setText(PreferencesMessages.ComplianceConfigurationBlock_17_ee_warning);
            }
        }
        fJRE50InfoText.setVisible(isVisible);
        fJRE50InfoImage.setImage(isVisible ? JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING) : null);
        fJRE50InfoImage.getParent().layout();
    }
}