List of usage examples for org.eclipse.jface.resource ImageDescriptor createImage
public Image createImage()
From source file:com.ibm.etools.mft.pattern.bpm.integration.code.designer.ResourceManager.java
License:Open Source License
public static Image getImage(ImageDescriptor descriptor) { if (descriptor == null) { return null; }//from w w w. j a v a 2 s. c o m Image image = (Image) descriptorImageMap.get(descriptor); if (image == null) { image = descriptor.createImage(); descriptorImageMap.put(descriptor, image); } return image; }
From source file:com.ibm.research.tours.content.ToursContentPlugin.java
License:Open Source License
public Image getFavIcon(String url) { // favicon code removed - cannot be released try {//from ww w . j a v a2 s. c o m ImageDescriptor desc = getImageDescriptor(PATH_WEB); Image img = (Image) fgImages2.get(desc); if (img == null) { fgImages2.put(desc, desc.createImage()); } return img; } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:com.ibm.research.tours.content.ToursContentPlugin.java
License:Open Source License
/** * Returns a shared image for the given adaptable. * This convenience method queries the given adaptable * for its <code>IWorkbenchAdapter.getImageDescriptor</code>, which it * uses to create an image if it does not already have one. * <p>//from www .j a v a 2s . c om * Note: Images returned from this method will be automitically disposed * of when this plug-in shuts down. Callers must not dispose of these * images themselves. * </p> * * @param adaptable the adaptable for which to find an image * @return an image */ public static Image getImage(IAdaptable adaptable) { if (adaptable != null) { Object o = adaptable.getAdapter(IWorkbenchAdapter.class); if (o instanceof IWorkbenchAdapter) { ImageDescriptor id = ((IWorkbenchAdapter) o).getImageDescriptor(adaptable); if (id != null) { Image image = (Image) fgImages2.get(id); if (image == null) { image = id.createImage(); try { fgImages2.put(id, image); } catch (NullPointerException ex) { // NeedWork } fgDisposeOnShutdownImages.add(image); } return image; } } } return null; }
From source file:com.ibm.xsp.extlib.designer.bluemix.BluemixPlugin.java
License:Open Source License
public static Image getImage(String location) { Image ret = getDefault().getImageRegistry().get(location); if (ret == null) { ImageDescriptor imgDesc = getImageDescriptor(location); if (imgDesc != null) { ret = imgDesc.createImage(); getDefault().getImageRegistry().put(location, ret); }/*from w ww . j a v a 2s .c om*/ } return ret; }
From source file:com.ibm.xsp.extlib.designer.tooling.palette.applicationlayout.AlwStartPage.java
License:Open Source License
private void populateConfigurationList() { // Find all the app layout configurations List<FacesDefinition> list = ExtLibRegistryUtil .getConfigNodes(StandardRegistryMaintainer.getStandardRegistry()); for (FacesDefinition def : list) { // Create a new LayoutConfig LayoutConfig lc = new LayoutConfig(); lc.tagName = def.getTagName();/* w w w .j a v a2s . co m*/ lc.facesDef = def; DesignerExtension de = DesignerExtensionUtil.getExtension(def); if (de != null) { // There's a <designer-extension> lc.title = de.getDisplayName(); lc.description = de.getDescription(); } ExtLibLayoutExtension le = (ExtLibLayoutExtension) def.getExtension(LAYOUT_EXTENSION); if (le != null) { // There is a <layout-extension> lc.responsive = le.isResponsive(); lc.sampleURL = le.getSampleURL(); if (le.getImage() != null) { // Get the image if any ImageDescriptor id = ImageDescriptor.createFromURL(le.getImage()); lc.image = id.createImage(); } } if (lc.image == null) { // If there's no image add a default one lc.image = _defImage; } if (StringUtil.isEmpty(lc.title)) { // Use the tagName if there's no title lc.title = lc.facesDef.getFirstDefaultPrefix() + ":" + lc.tagName; } // Add this configuration to the list _configList.add(lc); } // Sort the list Collections.sort(_configList, new Comparator<LayoutConfig>() { @Override public int compare(LayoutConfig lc1, LayoutConfig lc2) { return lc1.title.compareToIgnoreCase(lc2.title); } }); }
From source file:com.ibm.xsp.extlib.designer.xspprops.XSPGenPage.java
License:Open Source License
public void initProject() { getDataNode().notifyInvalidate(null); enableOptions();/*from w ww. j av a 2 s. c om*/ if (treeComposite != null) { final DataNode root = getDataNode().getRootNode(); if (root != null) { //get our bean reference to xsp.properties object IMember member = root.getMember("xspProperties"); // $NON-NLS-1$ if (member instanceof IAttribute) { //Jackpot! try { Object xsp = root.getObject(root.getCurrentObject(), (IAttribute) member); if (xsp instanceof XSPAllProperties) { _xpageLibraries.addCheckStateListener( new XPageLibraryCheckStateListener(getDataNode(), (XSPAllProperties) xsp)); _xpageLibraries.setInput(xsp); String dep = ((XSPAllProperties) xsp).getDependencies(); if (StringUtil.isNotEmpty(dep)) { String[] ids = dep.split(","); Object[] elements = ((ITreeContentProvider) _xpageLibraries.getContentProvider()) .getElements(xsp); List<LibraryWrapper> libs = new ArrayList<LibraryWrapper>(); if (elements != null && elements.length > 0) { for (Object o : elements) { if (o instanceof LibraryWrapper) { libs.add((LibraryWrapper) o); } } } List<String> libIds = new ArrayList<String>(); if (!libs.isEmpty()) { List<LibraryWrapper> selected = new ArrayList<LibraryWrapper>(); for (LibraryWrapper lib : libs) { if (Arrays.asList(ids).contains(lib.getLibraryId())) { selected.add(lib); } if (!(lib instanceof MissingLibraryWrapper)) { libIds.add(lib.getLibraryId()); } } _xpageLibraries.setCheckedElements(selected.toArray(new LibraryWrapper[0])); List<String> missingLibs = new ArrayList<String>(); for (String id : ids) { if (!libIds.contains(id)) { missingLibs.add(id); } } if (!missingLibs.isEmpty()) { String warn = "The current application depends on the libraries listed below.\nThese libraries are not installed in {0}. Including\nthese libraries and controls from these libraries in your XPages will\ncause errors in your application at runtime.\n\nMissing Libraries:\n{1}"; // $NLX-XSPGenPage.Thecurrentapplicationdependsonthe-1$ StringBuffer missingBuff = new StringBuffer(); for (String libId : missingLibs) { missingBuff.append(" -" + libId + "\n"); // $NON-NLS-1$ // $NON-NLS-2$ } warn = StringUtil.format(warn, ProductUtil.getProductNameWithoutIBM(), missingBuff.toString()); ImageDescriptor desc = Activator.imageDescriptorFromPlugin( Activator.PLUGIN_ID, "icons/warning_overlay.gif"); // $NON-NLS-1$ if (desc != null) { final Image warningImg = desc.createImage(); // $NON-NLS-1$ missingLibrariesImg.setImage(warningImg); missingLibrariesImg.addDisposeListener(new DisposeListener() { /* * (non-Javadoc) * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent) */ public void widgetDisposed(DisposeEvent arg0) { if (warningImg != null && !warningImg.isDisposed()) { warningImg.dispose(); } } }); } missingLibrariesTxt.setText(warn); } } } } } catch (NodeException e) { } } } } }
From source file:com.ibm.xsp.extlib.designer.xspprops.xsplibs.XPageLibraryLabelProvider.java
License:Open Source License
public Image getColumnImage(Object element, int column) { if (element instanceof MissingLibraryWrapper) { if (warningImg == null) { ImageDescriptor desc = Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/warning_overlay.gif"); // $NON-NLS-1$ if (desc != null) { warningImg = desc.createImage(); }//from w w w . j a v a2 s.co m } return warningImg; } return null; }
From source file:com.intel.tools.utils.about.AboutDialog.java
/** * Create contents of the dialog.// w ww . ja v a 2 s .co m * * @param parent */ @Override protected Control createDialogArea(Composite parent) { if (product != null) { URL url = getUrl(product.getProperty("aboutImage"), product.getDefiningBundle()); ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(url); if (imageDescriptor != null && url != null) { aboutImage = imageDescriptor.createImage(); } } Composite container = (Composite) super.createDialogArea(parent); container.setBackgroundMode(SWT.INHERIT_DEFAULT); container.setBackground(IntelPalette.WHITE); GridLayout gl_container = new GridLayout(2, false); gl_container.marginLeft = 16; gl_container.marginHeight = 0; gl_container.verticalSpacing = 0; gl_container.marginWidth = 0; container.setLayout(gl_container); Label lblNewLabel_1 = new Label(container, SWT.NONE); lblNewLabel_1.setFont(SWTResourceManager.getFont("Segoe UI", 13, SWT.BOLD)); if (aboutImage != null) { lblNewLabel_1.setImage(aboutImage); } else { lblNewLabel_1.setText(productName); lblNewLabel_1.setForeground(IntelPalette.LIGHT_BLUE); } GridData gd_lblNewLabel_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblNewLabel_1.verticalIndent = 16; lblNewLabel_1.setLayoutData(gd_lblNewLabel_1); Label lblNewLabel = new Label(container, SWT.NONE); lblNewLabel.setImage(ResourceManager.getPluginImage("com.intel.tools.utils", "images/vertical_banner.png")); GridData gd_lblNewLabel = new GridData(SWT.LEFT, SWT.TOP, false, true, 1, 2 + urlList.size()); gd_lblNewLabel.widthHint = 150; lblNewLabel.setLayoutData(gd_lblNewLabel); StyledText styledText = new StyledText(container, SWT.WRAP); styledText.setEnabled(false); styledText.setEditable(false); GridData gd_styledText = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gd_styledText.verticalIndent = 16; styledText.setLayoutData(gd_styledText); if (product != null) { styledText.setText(getAboutText(product)); } for (LabelUrl labelUrl : urlList) { Label licenseLink = new Label(container, SWT.NONE); licenseLink.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); licenseLink.setForeground(IntelPalette.LIGHT_BLUE); licenseLink.setText(labelUrl.getLabel()); licenseLink.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_HAND)); licenseLink.addMouseListener(new LabelURLMouseListener(labelUrl)); } new Label(container, SWT.NONE); new Label(container, SWT.NONE); new Label(container, SWT.NONE); new Label(container, SWT.NONE); return container; }
From source file:com.isb.datamodeler.internal.ui.views.actions.workingset.WorkingSetMenuContributionItem.java
License:Open Source License
/** * Adds a menu item for the working set. * Overrides method from ContributionItem. * /*from www. j av a 2 s. c o m*/ * @see org.eclipse.jface.action.ContributionItem#fill(Menu,int) */ public void fill(Menu menu, int index) { MenuItem mi = new MenuItem(menu, SWT.RADIO, index); mi.setText("&" + id + " " + workingSet.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$ mi.setSelection(workingSet.equals(actionGroup.getWorkingSet())); mi.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager(); actionGroup.setWorkingSet(workingSet); manager.addRecentWorkingSet(workingSet); } }); if (image == null) { ImageDescriptor imageDescriptor = workingSet.getImageDescriptor(); if (imageDescriptor != null) image = imageDescriptor.createImage(); } mi.setImage(image); }
From source file:com.isencia.passerelle.workbench.model.editor.ui.views.ActorTreeProvider.java
License:Open Source License
public Image getImage(Object element) { if (element instanceof PaletteItemDefinition) { ImageDescriptor icon = (ImageDescriptor) ((PaletteItemDefinition) element).getIcon(); if (icon == null) { return ActorEditPart.IMAGE_DESCRIPTOR_ACTOR.createImage(); }//www . j a va 2 s . c o m return icon.createImage(); } if (element instanceof PaletteGroup) { if (((PaletteGroup) element).getIcon() != null) { return ((ImageDescriptor) ((PaletteGroup) element).getIcon()).createImage(); } else { Activator.getImageDescriptor("icons/folder.gif").createImage(); } } return null; }