// Copyright (c) 2009-2010 by the projectusus.org contributors
// This software is released under the terms and conditions
// of the Eclipse Public License (EPL) 1.0.
// See http://www.eclipse.org/legal/epl-v10.html for details.
package org.projectusus.ui.internal;
import static org.eclipse.core.runtime.IStatus.ERROR;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import org.projectusus.adapter.ForcedRecompute;
import org.projectusus.core.statistics.UsusModelProvider;
public class UsusUIPlugin extends AbstractUIPlugin {
private static UsusUIPlugin plugin;
public static UsusUIPlugin getDefault() {
return plugin;
}
public static String getPluginId() {
return getDefault().getBundle().getSymbolicName();
}
@Override
public void start( BundleContext context ) throws Exception {
super.start( context );
if( UsusModelProvider.ususModel().needsFullRecompute() ) {
new ForcedRecompute().schedule();
}
plugin = this;
}
@Override
public void stop( BundleContext context ) throws Exception {
plugin = null;
super.stop( context );
}
public void log( Exception ex ) {
String msg = ex.getMessage() == null ? "[No details.]" : ex.getMessage(); //$NON-NLS-1$
IStatus status = new Status( ERROR, getPluginId(), 0, msg, ex );
getDefault().getLog().log( status );
}
public static ImageDescriptor getImageDescriptor( String imageFilePath ) {
return imageDescriptorFromPlugin( getPluginId(), imageFilePath );
}
}