/*******************************************************************************
* Copyright (c) 2012, 2015 Pivotal Software, Inc.
* 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:
* Pivotal Software, Inc. - initial API and implementation
*******************************************************************************/
package org.springsource.ide.eclipse.commons.internal.ui;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* @author Steffen Pingel
* @author Leo Dos Santos
* @author Christian Dupuis
*/
public class UiPlugin extends AbstractUIPlugin {
public static final String PLUGIN_ID = "org.springsource.ide.eclipse.commons.ui";
private static UiPlugin plugin;
public UiPlugin() {
}
@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);
}
public static UiPlugin getDefault() {
return plugin;
}
public static IWorkbenchWindow getActiveWorkbenchWindow() {
final IWorkbenchWindow[] activeWindow = new IWorkbenchWindow[1];
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
activeWindow[0] = getDefault().getWorkbench().getActiveWorkbenchWindow();
}
});
return activeWindow[0];
}
public static Shell getActiveWorkbenchShell() {
return getActiveWorkbenchWindow().getShell();
}
public static IWorkbenchPage getActiveWorkbenchPage() {
return getActiveWorkbenchWindow().getActivePage();
}
}