mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 22:22:11 +02:00
172 lines
4.7 KiB
HTML
Executable file
172 lines
4.7 KiB
HTML
Executable file
<!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>
|
|
<pre><code>
|
|
package rsesamples;
|
|
|
|
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
|
|
*/
|
|
public class RSESamplesPlugin extends SystemBasePlugin {
|
|
|
|
// The plug-in ID
|
|
public static final String PLUGIN_ID = "RSESamples";
|
|
|
|
// The shared instance
|
|
private static RSESamplesPlugin plugin;
|
|
|
|
// ResourceBundle
|
|
private ResourceBundle resourceBundle = null;
|
|
|
|
// Message file
|
|
private SystemMessageFile messageFile = null;
|
|
|
|
/**
|
|
* The constructor
|
|
*/
|
|
public RSESamplesPlugin() {
|
|
super();
|
|
}
|
|
|
|
/*
|
|
* (non-Javadoc)
|
|
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
|
*/
|
|
public void start(BundleContext context) throws Exception {
|
|
super.start(context);
|
|
plugin = this;
|
|
}
|
|
|
|
/*
|
|
* (non-Javadoc)
|
|
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
|
*/
|
|
public void stop(BundleContext context) throws Exception {
|
|
plugin = null;
|
|
super.stop(context);
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see org.eclipse.rse.ui.SystemBasePlugin#initializeImageRegistry()
|
|
*/
|
|
protected void initializeImageRegistry() {
|
|
}
|
|
|
|
/**
|
|
* Retrieves the string resource bundle associated with this plugin.
|
|
* @return the ResourceBundle or null if the bundle could not be loaded.
|
|
*/
|
|
public ResourceBundle getResourceBundle() {
|
|
try {
|
|
if (resourceBundle == null) {
|
|
resourceBundle = ResourceBundle.getBundle("rseSamplesResources.properties");
|
|
}
|
|
} catch (MissingResourceException e) {
|
|
SystemBasePlugin.logError("Missing rseSamplesResources.properties", e);
|
|
}
|
|
return resourceBundle;
|
|
}
|
|
|
|
/**
|
|
* Retrieves the SystemMessageFile associated with this plugin.
|
|
* @return the SystemMessageFile or null if the message file
|
|
* could not be loaded.
|
|
*/
|
|
public SystemMessageFile getMessageFile() {
|
|
if (messageFile == null) {
|
|
messageFile = loadMessageFile(this.getBundle(), "rseSamplesMessages.xml"); //$NON-NLS-1$
|
|
}
|
|
return messageFile;
|
|
}
|
|
|
|
/**
|
|
* Retrieves the singleton workspace for this workbench.
|
|
* This is a convenience method, fully equivalent to
|
|
* ResourcesPlugin.getWorkspace().
|
|
* @return the singleton workspace
|
|
*/
|
|
public static IWorkspace getWorkspace() {
|
|
return ResourcesPlugin.getWorkspace();
|
|
}
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
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;
|
|
}
|
|
|
|
/**
|
|
* Retrieve the SystemMessageFile for this plugin.
|
|
* @return the SystemMessageFile or null if the message file
|
|
* could not be loaded.
|
|
*/
|
|
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;
|
|
}
|
|
|
|
/**
|
|
* Returns the shared instance
|
|
*
|
|
* @return the shared instance
|
|
*/
|
|
public static RSESamplesPlugin getDefault() {
|
|
return plugin;
|
|
}
|
|
|
|
}
|
|
</code></pre>
|
|
</body>
|
|
</html>
|