/***************************************************************************** * Copyright (c) 2010 CEA LIST. * * * 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 * * Contributors: * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation */ package org.eclipse.papyrus.infra.gmfdiag.navigation; import org.eclipse.papyrus.infra.gmfdiag.navigation.preference.NavigationPreferenceInitializer; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; public class Activator extends AbstractUIPlugin { // The plug-in ID public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.gmfdiag.navigation"; //$NON-NLS-1$ // The shared instance private static Activator plugin; /** * The constructor */ public Activator() { } /* * (non-Javadoc) * * @see * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) */ @Override public void start(BundleContext context) throws Exception { super.start(context); plugin = this; NavigationPreferenceInitializer preferenceInitializer = new NavigationPreferenceInitializer(); preferenceInitializer.initializeDefaultPreferences(); } /* * (non-Javadoc) * * @see * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) */ @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 active workbench shell * * @return the active workbench shell */ public static Shell getActiveWorkbenchShell() { IWorkbenchWindow workBenchWindow = getActiveWorkbenchWindow(); if(workBenchWindow == null) { return null; } return workBenchWindow.getShell(); } /** * Returns the active workbench window * * @return the active workbench window */ public static IWorkbenchWindow getActiveWorkbenchWindow() { if(getDefault() == null) { return null; } IWorkbench workBench = getDefault().getWorkbench(); if(workBench == null) { return null; } return workBench.getActiveWorkbenchWindow(); } }