List of usage examples for org.eclipse.jface.resource ImageDescriptor createFromURL
public static ImageDescriptor createFromURL(URL url)
From source file:de.enough.polish.plugin.eclipse.css.CssEditorPlugin.java
License:Open Source License
protected void initializeImageRegistry(ImageRegistry reg) { super.initializeImageRegistry(reg); URL iconDirectoryURL = this.bundleContext.getBundle().getEntry("/icons/"); String[] iconNames = { "sample.gif", "book.gif" }; ImageDescriptor imageDescriptor = null; for (int i = 0; i < iconNames.length; i++) { imageDescriptor = null;// w w w .j a va 2 s . c o m try { URL url = new URL(iconDirectoryURL, iconNames[i]); imageDescriptor = ImageDescriptor.createFromURL(url); } catch (MalformedURLException e) { // We miss some icons. imageDescriptor = ImageDescriptor.getMissingImageDescriptor(); System.out.println("ERROR:CssEditorPlugin.initializeImageRegistry():Icon not found.Exception:" + e.getMessage()); } reg.put(iconNames[i], imageDescriptor); } }
From source file:de.femodeling.e4.ui.progress.internal.ProgressInfoItem.java
License:Open Source License
/** * Get the image for the info./*from ww w.j av a 2 s. c o 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.ProgressManager.java
License:Open Source License
private void setUpImages() { URL iconsRoot = ProgressManagerUtil.getIconsRoot(); try {/* ww w . j av a 2 s .c o m*/ setUpImage(iconsRoot, SLEEPING_JOB, SLEEPING_JOB_KEY); setUpImage(iconsRoot, WAITING_JOB, WAITING_JOB_KEY); setUpImage(iconsRoot, BLOCKED_JOB, BLOCKED_JOB_KEY); ImageDescriptor errorImage = ImageDescriptor.createFromURL(new URL(iconsRoot, ERROR_JOB)); JFaceResources.getImageRegistry().put(ERROR_JOB_KEY, errorImage); } catch (MalformedURLException e) { ProgressManagerUtil.logException(e); } }
From source file:de.femodeling.e4.ui.progress.internal.ProgressManager.java
License:Open Source License
/** * Set up the image in the image regsitry. * /*from w w w. ja va 2s . c o m*/ * @param iconsRoot * @param fileName * @param key * @throws MalformedURLException */ private void setUpImage(URL iconsRoot, String fileName, String key) throws MalformedURLException { JFaceResources.getImageRegistry().put(key, ImageDescriptor.createFromURL(new URL(iconsRoot, fileName))); }
From source file:de.fhg.igd.eclipse.ui.util.extension.AbstractFactoryAction.java
License:Apache License
/** * Constructor//from w ww .ja va 2s. co m * * @param factory the extension object factory * @param style the action style, e.g. {@link IAction#AS_CHECK_BOX} */ public AbstractFactoryAction(F factory, int style) { super(factory.getDisplayName(), style); URL iconURL = factory.getIconURL(); if (iconURL != null) { try { setImageDescriptor(ImageDescriptor.createFromURL(iconURL)); } catch (Exception e) { // ignore } } this.factory = factory; }
From source file:de.fhg.igd.mapviewer.view.MapToolAction.java
License:Open Source License
/** * Creates an action that activates the given tool * //from w w w . j a va 2 s. co m * @param tool the map tool * @param mapKit the map kit * @param checked if the map tool shall be activated initially */ public MapToolAction(AbstractMapTool tool, BasicMapKit mapKit, boolean checked) { super(tool.getName(), Action.AS_RADIO_BUTTON); tool.setMapKit(mapKit); tool.setActivator(this); // set icon if (tool.getIconURL() != null) { try { setImageDescriptor(ImageDescriptor.createFromURL(tool.getIconURL())); } catch (Exception e) { log.warn("Error creating action icon", e); //$NON-NLS-1$ } } // set tool tip setToolTipText(tool.getDescription()); this.tool = tool; this.mapKit = mapKit; if (checked) { setChecked(true); mapKit.setMapTool(tool); } }
From source file:de.fips.plugin.tinyaudioplayer.notifier.NotifierCoverProvider.java
License:Open Source License
public Image loadCoverFor(final URI location) { Image thumbnail = null;/*from w w w . ja v a2s . c o m*/ File parent = null; try { val file = new File(location); parent = file.getParentFile(); } catch (IllegalArgumentException ignore) { // File(URI) preconditions did not hold } if (parent != null) { String[] coverNames = parent.list(new FilenameFilter() { @Override public boolean accept(File file, String s) { val matcher = COVER_DETECTION_PATTERN.matcher(s.toLowerCase()); return matcher.matches(); } }); if (coverNames.length > 0) { try { val coverFile = new File(parent, coverNames[0]).getCanonicalFile().getAbsoluteFile(); thumbnail = TinyAudioPlayerPlugin.getDefaultImageRegistry().get(coverFile.getPath()); if (thumbnail == null) { val imageURL = coverFile.toURI().toURL(); val descriptor = ImageDescriptor.createFromURL(imageURL); thumbnail = descriptor.createImage(); thumbnail = new Image(Display.getDefault(), thumbnail.getImageData().scaledTo(80, 80)); TinyAudioPlayerPlugin.getDefaultImageRegistry().put(coverFile.getPath(), thumbnail); } } catch (IOException ignore) { } } } return thumbnail; }
From source file:de.fkoeberle.autocommit.AutocommitIconDecorator.java
License:Open Source License
public AutocommitIconDecorator() { listener = new IAutoCommitEnabledStateListener() { @Override/*from ww w .ja v a2 s. co m*/ public void handleEnabledStateChanged(IProject project) { fireLabelProviderChanged(new LabelProviderChangedEvent(AutocommitIconDecorator.this, project)); } }; AutoCommitPluginActivator.getDefault().addAutoCommitEnabledStateListener(listener); URL iconURL = getClass().getResource("/icon8x8.png"); this.icon = ImageDescriptor.createFromURL(iconURL); }
From source file:de.fu_berlin.inf.jtourbus.utility.IconManager.java
License:Open Source License
public static void setImageDescriptors(IAction action, String type) { try {// w ww . j ava 2 s .c om ImageDescriptor id = ImageDescriptor.createFromURL(makeIconFileURL("dlcl16", type)); //$NON-NLS-1$ if (id != null) action.setDisabledImageDescriptor(id); } catch (MalformedURLException e) { } try { ImageDescriptor id = ImageDescriptor.createFromURL(makeIconFileURL("elcl16", type)); //$NON-NLS-1$ if (id != null) { action.setHoverImageDescriptor(id); action.setImageDescriptor(id); } } catch (MalformedURLException e) { } action.setImageDescriptor(create("e", type)); //$NON-NLS-1$ }
From source file:de.fu_berlin.inf.jtourbus.utility.IconManager.java
License:Open Source License
private static ImageDescriptor create(String path, String name) { try {// w w w. j a v a 2 s. co m return ImageDescriptor.createFromURL(makeIconFileURL(path, name)); } catch (MalformedURLException e) { return ImageDescriptor.getMissingImageDescriptor(); } }