blob: 6baa3e15d8a1346c92625e8815777194b0ea40c9 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2008 IBM Corporation.
* 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:
* IBM Corporation - initial API and implementation
******************************************************************************/
package org.eclipse.ptp.rm.mpi.mpich2.ui;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ptp.rm.core.ToolsRMPlugin;
import org.eclipse.ptp.rm.mpi.mpich2.ui.launch.MPICH2LaunchConfigurationDefaults;
import org.eclipse.ptp.rm.mpi.mpich2.ui.messages.Messages;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
* @author Daniel Felix Ferber
*/
public class MPICH2UIPlugin extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.ptp.rm.mpi.mpich2.ui"; //$NON-NLS-1$
// The shared instance
private static MPICH2UIPlugin plugin;
/**
* The constructor
*/
public MPICH2UIPlugin() {
// Empty implementation.
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
MPICH2LaunchConfigurationDefaults.loadDefaults();
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#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 MPICH2UIPlugin getDefault() {
return plugin;
}
/**
* Raise core exception.
* @param message
* @return
*/
public static CoreException coreErrorException(String message) {
return new CoreException(new Status(IStatus.ERROR, ToolsRMPlugin.getDefault().getBundle().getSymbolicName(), message));
}
/**
* Raise core exception.
* @param message
* @param t
* @return
*/
public static CoreException coreErrorException(String message, Throwable t) {
return new CoreException(new Status(IStatus.ERROR, ToolsRMPlugin.getDefault().getBundle().getSymbolicName(), message, t));
}
/**
* Create log entry from an IStatus
*
* @param status
*/
public static void log(IStatus status) {
getDefault().getLog().log(status);
}
/**
* Create log entry from a string
*
* @param msg
*/
public static void log(String msg) {
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, msg, null));
}
/**
* Create log entry from a Throwable
*
* @param e
*/
public static void log(Throwable e) {
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, Messages.MPICH2UIPlugin_Exception_InternalError, e));
}
/**
* Generate a unique identifier
*
* @return unique identifier string
*/
public static String getUniqueIdentifier() {
if (getDefault() == null)
// If the default instance is not yet initialized,
// return a static identifier. This identifier must
// match the plugin id defined in plugin.xml
return PLUGIN_ID;
return getDefault().getBundle().getSymbolicName();
}
}