2007-05-15 23:55:07 +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 >
< body >
< h1 > RSESamplesPlugin Class< / h1 >
2007-06-19 21:18:42 +00:00
< pre > < code >
package rsesamples;
2007-05-15 23:55:07 +00:00
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemMessageFile;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
2007-06-19 21:18:42 +00:00
public class RSESamplesPlugin extends SystemBasePlugin {
2007-05-15 23:55:07 +00:00
2007-06-19 21:18:42 +00:00
// The plug-in ID
public static final String PLUGIN_ID = "RSESamples";
2007-05-15 23:55:07 +00:00
2007-06-19 21:18:42 +00:00
// The shared instance
private static RSESamplesPlugin plugin;
// ResourceBundle
2007-05-15 23:55:07 +00:00
private ResourceBundle resourceBundle = null;
2007-06-19 21:18:42 +00:00
// Message file
private SystemMessageFile messageFile = null;
2007-05-15 23:55:07 +00:00
/**
2007-06-19 21:18:42 +00:00
* The constructor
2007-05-15 23:55:07 +00:00
*/
public RSESamplesPlugin() {
super();
}
2007-06-19 21:18:42 +00:00
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
2007-05-15 23:55:07 +00:00
*/
public void start(BundleContext context) throws Exception {
super.start(context);
2007-06-19 21:18:42 +00:00
plugin = this;
2007-05-15 23:55:07 +00:00
}
2007-06-19 21:18:42 +00:00
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
2007-05-15 23:55:07 +00:00
*/
public void stop(BundleContext context) throws Exception {
2007-06-19 21:18:42 +00:00
plugin = null;
2007-05-15 23:55:07 +00:00
super.stop(context);
}
2007-06-19 21:18:42 +00:00
/* (non-Javadoc)
* @see org.eclipse.rse.ui.SystemBasePlugin#initializeImageRegistry()
2007-05-15 23:55:07 +00:00
*/
2007-06-19 21:18:42 +00:00
protected void initializeImageRegistry() {
}
2007-05-15 23:55:07 +00:00
/**
2007-06-19 21:18:42 +00:00
* Retrieves the string resource bundle associated with this plugin.
* @return the ResourceBundle or null if the bundle could not be loaded.
2007-05-15 23:55:07 +00:00
*/
2007-06-19 21:18:42 +00:00
public ResourceBundle getResourceBundle() {
2007-05-15 23:55:07 +00:00
try {
2007-06-19 21:18:42 +00:00
if (resourceBundle == null) {
resourceBundle = ResourceBundle.getBundle("rseSamplesResources.properties");
}
2007-05-15 23:55:07 +00:00
} catch (MissingResourceException e) {
2007-06-19 21:18:42 +00:00
SystemBasePlugin.logError("Missing rseSamplesResources.properties", e);
2007-05-15 23:55:07 +00:00
}
2007-06-19 21:18:42 +00:00
return resourceBundle;
}
2007-05-15 23:55:07 +00:00
/**
2007-06-19 21:18:42 +00:00
* Retrieves the SystemMessageFile associated with this plugin.
* @return the SystemMessageFile or null if the message file
* could not be loaded.
2007-05-15 23:55:07 +00:00
*/
2007-06-19 21:18:42 +00:00
public SystemMessageFile getMessageFile() {
if (messageFile == null) {
messageFile = loadMessageFile(this.getBundle(), "rseSamplesMessages.xml"); //$NON-NLS-1$
2007-05-15 23:55:07 +00:00
}
2007-06-19 21:18:42 +00:00
return messageFile;
}
2007-05-15 23:55:07 +00:00
/**
2007-06-19 21:18:42 +00:00
* Retrieves the singleton workspace for this workbench.
* This is a convenience method, fully equivalent to
* ResourcesPlugin.getWorkspace().
* @return the singleton workspace
2007-05-15 23:55:07 +00:00
*/
2007-06-19 21:18:42 +00:00
public static IWorkspace getWorkspace() {
return ResourcesPlugin.getWorkspace();
2007-05-15 23:55:07 +00:00
}
2007-06-19 21:18:42 +00:00
2007-05-15 23:55:07 +00:00
/**
2007-06-19 21:18:42 +00:00
* Retrieve a string from the plugin's resource bundle.
* @param key the key to the string
* @return the retrieved string or the key if the string could not be
* found or the bundle could not be loaded.
2007-05-15 23:55:07 +00:00
*/
2007-06-19 21:18:42 +00:00
public static String getResourceString(String key) {
String result = null;
ResourceBundle bundle = RSESamplesPlugin.getDefault().getResourceBundle();
if (bundle != null) {
try {
result = bundle.getString(key);
} catch (MissingResourceException e) {
SystemBasePlugin.logError("Missing key in bundle", e);
}
}
if (result == null) {
result = key;
}
return result;
}
2007-05-15 23:55:07 +00:00
/**
2007-06-19 21:18:42 +00:00
* Retrieve the SystemMessageFile for this plugin.
* @return the SystemMessageFile or null if the message file
* could not be loaded.
2007-05-15 23:55:07 +00:00
*/
2007-06-19 21:18:42 +00:00
public static SystemMessageFile getPluginMessageFile() {
return RSESamplesPlugin.getDefault().getMessageFile();
}
/**
* Retrieve a SystemMessage from the message file for this
* plugin given its message id.
* @param messageId the message id to retrieve
* @return the retrieved SystemMessage or null if the message
* was not found in the message file or the message file
* could not be loaded.
*/
public static SystemMessage getPluginMessage(String messageId) {
SystemMessage message = null;
SystemMessageFile messageFile = getPluginMessageFile();
if (messageFile != null) {
message = messageFile.getMessage(messageId);
}
return message;
}
2007-05-15 23:55:07 +00:00
/**
2007-06-19 21:18:42 +00:00
* Returns the shared instance
*
* @return the shared instance
2007-05-15 23:55:07 +00:00
*/
2007-06-19 21:18:42 +00:00
public static RSESamplesPlugin getDefault() {
return plugin;
}
2007-05-15 23:55:07 +00:00
}
2007-09-12 19:02:08 +00:00
< / code > < / pre >
2007-05-15 23:55:07 +00:00
< / body >
< / html >