blob: efb6a24878cf3a7edf26cd77a1756ef952e0c9ac [file] [log] [blame]
/*******************************************************************************
* Copyright (C) 2017 ANSYS medini Technologies AG
*
* 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:
* ANSYS medini Technologies AG - initial API and implementation
******************************************************************************/
package org.eclipse.opencert.elastic.ui;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* Public bundle activator, no special..
*/
public class Activator extends AbstractUIPlugin {
/**
* The plug-in ID
*/
public static final String PLUGIN_ID = "org.eclipse.opencert.elastic.ui"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
/**
* Returns the image for the given key or null.
*
* @param imagePath
* relative image path
* @return an Image or null
*/
public Image getImage(String imagePath) {
ImageRegistry imageRegistry = super.getImageRegistry();
// the path is treated as unique key
Image image = imageRegistry.get(imagePath);
if (image == null) {
ImageDescriptor descriptor = Activator.imageDescriptorFromPlugin(PLUGIN_ID, imagePath);
image = descriptor.createImage();
imageRegistry.put(imagePath, image);
return image;
}
return image;
}
}