2006-05-30 15:32:53 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
< html >
< head >
< META HTTP-EQUIV = "Content-Type" CONTENT = "text/html; charset=UTF-8" >
< META HTTP-EQUIV = "Content-Style-Type" CONTENT = "text/css" >
< meta name = "copyright" content = "Copyright (c) IBM Corporation and others 2002, 2006. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
< LINK REL = "STYLESHEET" HREF = "../../book.css" TYPE = "text/css" >
< title > RSESamplesPlugin Class< / title >
< / head >
2006-08-04 20:37:05 +00:00
< body >
2006-05-30 15:32:53 +00:00
< h1 > RSESamplesPlugin Class< / h1 >
< pre > < samp >
2006-08-04 20:37:05 +00:00
package samples;
2006-05-30 15:32:53 +00:00
2006-08-04 20:37:05 +00:00
import java.util.MissingResourceException;
import java.util.ResourceBundle;
2006-05-30 15:32:53 +00:00
2006-08-04 20:37:05 +00:00
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Platform;
import org.eclipse.rse.core.SystemBasePlugin;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemMessageFile;
import org.osgi.framework.BundleContext;
2006-05-30 15:32:53 +00:00
/**
2006-08-04 20:37:05 +00:00
* The activator class controls the plug-in life cycle
2006-05-30 15:32:53 +00:00
*/
2006-08-04 20:37:05 +00:00
public class RSESamplesPlugin extends SystemBasePlugin {
//The shared instance.
2006-05-30 15:32:53 +00:00
private static RSESamplesPlugin plugin;
2006-08-04 20:37:05 +00:00
//Resource bundle.
private ResourceBundle resourceBundle = null;
private static SystemMessageFile messageFile = null;
2006-05-30 15:32:53 +00:00
/**
* The constructor.
*/
2006-08-04 20:37:05 +00:00
public RSESamplesPlugin() {
super();
}
/**
* This method is called upon plug-in activation
*/
public void start(BundleContext context) throws Exception {
super.start(context);
< strong > plugin = this;
messageFile = getMessageFile("rseSamplesMessages.xml");< / strong >
}
/**
* This method is called when the plug-in is stopped
*/
public void stop(BundleContext context) throws Exception {
< strong > plugin = null;
resourceBundle = null;< / strong >
super.stop(context);
2006-05-30 15:32:53 +00:00
}
/**
* Returns the shared instance.
*/
2006-08-04 20:37:05 +00:00
< strong > public static RSESamplesPlugin getDefault() {
2006-05-30 15:32:53 +00:00
return plugin;
2006-08-04 20:37:05 +00:00
}< / strong >
2006-05-30 15:32:53 +00:00
/**
* Returns the workspace instance.
*/
2006-08-04 20:37:05 +00:00
< strong > public static IWorkspace getWorkspace() {
2006-05-30 15:32:53 +00:00
return ResourcesPlugin.getWorkspace();
2006-08-04 20:37:05 +00:00
}< / strong >
2006-05-30 15:32:53 +00:00
/**
* Returns the string from the plugin's resource bundle,
* or 'key' if not found.
*/
2006-08-04 20:37:05 +00:00
< strong > public static String getResourceString(String key) {
2006-05-30 15:32:53 +00:00
ResourceBundle bundle= RSESamplesPlugin.getDefault().getResourceBundle();
2006-08-04 20:37:05 +00:00
try {
return (bundle != null) ? bundle.getString(key) : key;
} catch (MissingResourceException e) {
return key;
}
}< / strong >
2006-05-30 15:32:53 +00:00
/**
* Returns the plugin's resource bundle,
*/
2006-08-04 20:37:05 +00:00
< strong > public ResourceBundle getResourceBundle() {
try {
if (resourceBundle == null)
resourceBundle = ResourceBundle.getBundle("samples.rseSamplesResources");
} catch (MissingResourceException x) {
resourceBundle = null;
}
2006-05-30 15:32:53 +00:00
return resourceBundle;
2006-08-04 20:37:05 +00:00
}< / strong >
2006-05-30 15:32:53 +00:00
/**
* Initialize the image registry by declaring all of the required graphics.
*/
2006-08-04 20:37:05 +00:00
protected void initializeImageRegistry()
2006-05-30 15:32:53 +00:00
{
}
2006-08-04 20:37:05 +00:00
2006-05-30 15:32:53 +00:00
/**
2006-08-04 20:37:05 +00:00
* Load a message file for this plugin.
* @param messageFileName - the name of the message xml file. Will look for it in this plugin's install folder.
* @return a message file object containing the parsed contents of the message file, or null if not found.
2006-05-30 15:32:53 +00:00
*/
2006-08-04 20:37:05 +00:00
< strong > public SystemMessageFile getMessageFile(String messageFileName)
2006-05-30 15:32:53 +00:00
{
2006-08-04 20:37:05 +00:00
return loadMessageFile(getBundle(), messageFileName);
}< / strong >
2006-05-30 15:32:53 +00:00
/**
* Return our message file
*/
2006-08-04 20:37:05 +00:00
< strong > public static SystemMessageFile getPluginMessageFile()
2006-05-30 15:32:53 +00:00
{
return messageFile;
2006-08-04 20:37:05 +00:00
}< / strong >
2006-05-30 15:32:53 +00:00
/**
* Retrieve a message from this plugin's message file
*/
2006-08-04 20:37:05 +00:00
< strong > public static SystemMessage getPluginMessage(String msgId)
2006-05-30 15:32:53 +00:00
{
return getMessage(messageFile, msgId);
2006-08-04 20:37:05 +00:00
}< / strong >
2006-05-30 15:32:53 +00:00
}
< / samp > < / pre >
< / p >
< / body >
< / html >