List of usage examples for org.eclipse.jface.resource JFaceResources getImage
public static Image getImage(String key)
null
if none. From source file:org.eclipse.jdt.internal.ui.preferences.ComplianceConfigurationBlock.java
License:Open Source License
private Composite createComplianceTabContent(Composite folder) { 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 }; final ScrolledPageContent sc1 = new ScrolledPageContent(folder); Composite composite = sc1.getBody(); GridLayout layout = new GridLayout(); layout.marginHeight = 0;//from ww w .j a v a 2 s. c om 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 }; 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: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;/* ww w.java 2 s . co 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; } } fJRE50InfoText.setVisible(isVisible); fJRE50InfoImage.setImage(isVisible ? JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING) : null); fJRE50InfoImage.getParent().layout(); } }
From source file:org.eclipse.jst.jsf.common.ui.internal.dialogs.TreeViewerSelectionDialog.java
License:Open Source License
/** * Get the different message according the message type. * @param imageType //from w w w. j a va 2s.com * * @return Image - the message image */ protected Image getMessageImage(int imageType) { switch (imageType) { case STYLE_ERROR: return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR); case STYLE_WARNING: return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING); case STYLE_INFORMATION: return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO); default: return null; } }
From source file:org.eclipse.jst.jsf.facesconfig.ui.dialog.StatusDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { Composite area = (Composite) super.createDialogArea(parent); area.setLayout(new GridLayout(2, false)); Composite contents = new Composite(area, SWT.NONE); GridData gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 2;// w w w . j a v a 2 s . c om contents.setLayoutData(gd); createDialogContents(contents); statusImage = createLabel(area); statusImage.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR)); statusLabel = createLabel(area); statusImage.setVisible(false); return area; }
From source file:org.eclipse.languageserver.outline.SymbolsLabelProvider.java
License:Open Source License
@Override public Image getImage(Object element) { if (element == null) { return null; }//from w ww . ja v a 2 s. c o m if (element == LSSymbolsContentProvider.COMPUTING) { return JFaceResources.getImage(ProgressManager.WAITING_JOB_KEY); } if (element instanceof Throwable) { return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); } SymbolInformation symbolInformation = (SymbolInformation) element; Image res = LSPImages.imageFromSymbolKind(symbolInformation.getKind()); IResource resource = LSPEclipseUtils.findResourceFor(symbolInformation.getLocation().getUri()); if (resource != null) { try { IDocument doc = LSPEclipseUtils.getDocument(resource); int maxSeverity = -1; for (IMarker marker : resource.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ZERO)) { int offset = marker.getAttribute(IMarker.CHAR_START, -1); if (offset != -1 && offset >= LSPEclipseUtils .toOffset(symbolInformation.getLocation().getRange().getStart(), doc) && offset <= LSPEclipseUtils .toOffset(symbolInformation.getLocation().getRange().getEnd(), doc)) { maxSeverity = Math.max(maxSeverity, marker.getAttribute(IMarker.SEVERITY, -1)); } } if (maxSeverity > IMarker.SEVERITY_INFO) { return getOverlay(res, maxSeverity); } } catch (CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (BadLocationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return res; }
From source file:org.eclipse.lsp4e.outline.SymbolsLabelProvider.java
License:Open Source License
@Override public Image getImage(Object element) { if (element == null) { return null; }/*w ww. j ava 2 s .c o m*/ if (element == LSSymbolsContentProvider.COMPUTING) { return JFaceResources.getImage(ProgressManager.WAITING_JOB_KEY); } if (element instanceof Throwable) { return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); } SymbolInformation symbolInformation = (SymbolInformation) element; Image res = LSPImages.imageFromSymbolKind(symbolInformation.getKind()); IResource resource = LSPEclipseUtils.findResourceFor(symbolInformation.getLocation().getUri()); if (resource != null) { try { int maxSeverity = getMaxSeverity(resource, symbolInformation); if (maxSeverity > IMarker.SEVERITY_INFO) { return getOverlay(res, maxSeverity); } } catch (CoreException | BadLocationException e) { LanguageServerPlugin.logError(e); } } return res; }
From source file:org.eclipse.m2e.core.ui.internal.components.NestedProjectsComposite.java
License:Open Source License
private void createOutOfDateProjectsWarning(Composite composite) { if (!showOutOfDateUI) { return;//from w w w . j a va2 s . com } warningArea = new Composite(composite, SWT.NONE); warningArea.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1)); warningArea.setLayout(new RowLayout(SWT.HORIZONTAL)); Label warningImg = new Label(warningArea, SWT.NONE); warningImg.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING)); includeOutDateProjectslink = new Link(warningArea, SWT.NONE); includeOutDateProjectslink.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { includeOutOfDateProjects(); } @Override public void widgetDefaultSelected(SelectionEvent e) { includeOutOfDateProjects(); } }); }
From source file:org.eclipse.m2e.profiles.ui.internal.dialog.SelectProfilesDialog.java
License:Open Source License
private void displayWarning(Composite container) { warningImg = new Label(container, SWT.CENTER); warningLabel = new Label(container, SWT.NONE); warningLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(warningImg); warningImg.setImage(JFaceResources.getImage(DLG_IMG_MESSAGE_WARNING)); warningLabel.setText(Messages.SelectProfilesDialog_Warning_Common_profiles); }
From source file:org.eclipse.nebula.widgets.nattable.util.GUIHelper.java
License:Open Source License
public static Image getImage(String key) { Image image = JFaceResources.getImage(key); if (image == null) { URL imageUrl = getImageUrl(key); if (imageUrl != null) { ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(imageUrl); JFaceResources.getImageRegistry().put(key, imageDescriptor.createImage()); image = JFaceResources.getImage(key); }/*from w w w . ja v a2s .c o m*/ } return image; }
From source file:org.eclipse.nebula.widgets.nattable.util.GUIHelper.java
License:Open Source License
public static Image getImage(ImageData data) { if (JFaceResources.getImage(data.toString()) == null) { JFaceResources.getImageRegistry().put(data.toString(), ImageDescriptor.createFromImageData(data)); }/*from w w w.ja va 2 s . c om*/ return JFaceResources.getImage(data.toString()); }