/** * This file is protected by Copyright. * Please refer to the COPYRIGHT file distributed with this source distribution. * * This file is part of REDHAWK IDE. * * All rights reserved. This program and the accompanying materials are made available under * the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html. * */ package gov.redhawk.sca.sad.diagram; import org.eclipse.gmf.runtime.diagram.ui.preferences.AppearancePreferencePage; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; import mil.jpeojtrs.sca.sad.diagram.part.SadDiagramEditorPlugin; /** * The activator class controls the plug-in life cycle */ public class RedhawkSadDiagramPlugin extends AbstractUIPlugin { // The plug-in ID public static final String PLUGIN_ID = "gov.redhawk.sca.sad.diagram"; //$NON-NLS-1$ // The shared instance private static RedhawkSadDiagramPlugin plugin; /** * The constructor */ public RedhawkSadDiagramPlugin() { } /* * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ @Override public void start(final BundleContext context) throws Exception { super.start(context); plugin = this; // Initialize defaults for the Appearance Preference Page that we provide in this plugin. final IPreferenceStore store = SadDiagramEditorPlugin.getInstance().getPreferenceStore(); AppearancePreferencePage.initDefaults(store); store.setDefault(SadDiagramPreferenceConstants.PREF_SHOW_PORT_LABELS, true); } /* * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ @Override public void stop(final BundleContext context) throws Exception { plugin = null; super.stop(context); } /** * Returns the shared instance * * @return the shared instance */ public static RedhawkSadDiagramPlugin getDefault() { return plugin; } /** * Returns an image for the image file at the given plug-in relative path. * Client do not need to dispose this image. Images will be disposed automatically. * * @param path the path * @return image instance */ public Image getBundledImage(final String path) { Image image = getImageRegistry().get(path); if (image == null) { getImageRegistry().put(path, getBundledImageDescriptor(path)); image = getImageRegistry().get(path); } return image; } /** * Returns an image descriptor for the image file at the given * plug-in relative path. * * @param path the path * @return the image descriptor */ public static ImageDescriptor getBundledImageDescriptor(final String path) { return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path); } }