blob: de679229a6e839f6b3e50cf45ea96669aebaf8ea [file] [log] [blame]
/**
********************************************************************************
* Copyright (c) 2017 - 2018 Robert Bosch GmbH.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Robert Bosch GmbH - initial API and implementation
********************************************************************************
*/
package org.eclipse.app4mc.emfutils.metamodelviewer.utils;
import java.io.IOException;
import java.net.URL;
import org.eclipse.app4mc.emfutils.metamodelviewer.base.Activator;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.jface.resource.ImageDescriptor;
public class PluginUtils {
public static ImageDescriptor getImageDescriptor(final String location) {
final URL entry = Activator.getDefault().getBundle().getEntry(location);
if (entry != null) {
URL fileURL;
try {
fileURL = FileLocator.toFileURL(entry);
if (fileURL != null) {
return ImageDescriptor.createFromURL(fileURL);
}
}
catch (final IOException e) {
e.printStackTrace();
}
}
return null;
}
}