/*******************************************************************************
* Copyright (c) 2015 Red Hat, Inc. and others.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is 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:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.websockets.ui;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.jboss.tools.foundation.core.plugin.log.IPluginLog;
import org.jboss.tools.foundation.ui.plugin.BaseUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class WebsocketsUIPlugin extends BaseUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.jboss.tools.ws.ui"; //$NON-NLS-1$
// The shared instance
private static WebsocketsUIPlugin plugin;
/**
* The constructor
*/
public WebsocketsUIPlugin() {
}
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static WebsocketsUIPlugin getDefault() {
return plugin;
}
public static ImageDescriptor getImageDescriptor(String path) {
path = "icons/" + path; //$NON-NLS-1$
return AbstractUIPlugin.imageDescriptorFromPlugin("org.jboss.tools.websockets.ui", path); //$NON-NLS-1$
}
/**
* Get the IPluginLog for this plugin. This method
* helps to make logging easier, for example:
*
* FoundationCorePlugin.pluginLog().logError(etc)
*
* @return IPluginLog object
*/
public static IPluginLog pluginLog() {
return getDefault().pluginLogInternal();
}
private IWorkbenchPage internalGetActivePage() {
IWorkbenchWindow window= getWorkbench().getActiveWorkbenchWindow();
if (window == null)
return null;
return window.getActivePage();
}
private IWorkbenchWindow internalGetActiveWorkbenchWindow() {
IWorkbenchWindow window= getWorkbench().getActiveWorkbenchWindow();
if (window == null)
return null;
return window;
}
public static IWorkbenchPage getActivePage() {
return getDefault().internalGetActivePage();
}
public static IWorkbenchWindow getActiveWorkbenchWindow() {
return getDefault().internalGetActiveWorkbenchWindow();
}
}