// Copyright (c) 2021, Fr.Terrot. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package io.gitea.mylyn.ui; import java.net.MalformedURLException; import java.net.URL; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.graphics.Image; //FIXME: complete with other kind of issue public class GiteaImages { private static final URL baseURL = GiteaUIPlugin.getDefault().getBundle().getEntry("/icons/"); //$NON-NLS-1$ public static final ImageDescriptor ISSUE = create("gitea-issue.png"); //$NON-NLS-1$ public static final ImageDescriptor ISSUE_OPEN = create("gitea-issue-open.png"); //$NON-NLS-1$ public static final ImageDescriptor ISSUE_CLOSED = create("gitea-issue-closed.png"); //$NON-NLS-1$ public static final ImageDescriptor OVERLAY_FEATURE = create("overlay-feature.png"); //$NON-NLS-1$ public static final ImageDescriptor OVERLAY_STORY = create("overlay-story.png"); //$NON-NLS-1$ public static final Image LABEL = create("gitea-label.png").createImage(); public static final Image MILESTONE = create("gitea-milestone.png").createImage(); public static final Image REPOSITORY = create("gitea-repository.png").createImage(); private static ImageDescriptor create(String name) { try { return ImageDescriptor.createFromURL(makeIconFileURL(name)); } catch (MalformedURLException e) { return ImageDescriptor.getMissingImageDescriptor(); } } private static URL makeIconFileURL(String name) throws MalformedURLException { if (baseURL == null) { throw new MalformedURLException(); } StringBuilder buffer = new StringBuilder(); buffer.append(name); return new URL(baseURL, buffer.toString()); } }