/*- * Copyright © 2011 Diamond Light Source Ltd. * * This file is part of GDA. * * GDA is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License version 3 as published by the Free * Software Foundation. * * GDA is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along * with GDA. If not, see <http://www.gnu.org/licenses/>. */ package uk.ac.gda.common.rcp; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; public class CommonRCPActivator extends AbstractUIPlugin { // The plug-in ID - corresponds to name in plugin.xml file /** * */ public static final String PLUGIN_ID = "uk.ac.gda.common.rcp"; // The shared instance private static CommonRCPActivator plugin; /** * The constructor */ public CommonRCPActivator() { } @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 CommonRCPActivator getDefault() { return plugin; } public static IWorkbenchWindow getActiveWorkbenchWindow() { return getDefault().getWorkbench().getActiveWorkbenchWindow(); } public static Shell getActiveWorkbenchShell() { IWorkbenchWindow window = getActiveWorkbenchWindow(); if (window != null) { return window.getShell(); } return null; } @Override protected void initializeImageRegistry(ImageRegistry reg) { super.initializeImageRegistry(reg); for (String imgPath : ImageConstants.IMAGES) { reg.put(imgPath, imageDescriptorFromPlugin(PLUGIN_ID, imgPath)); } } }