Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

RSESamplesPlugin Class


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;
	}

}


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire