Remote Systems
v6.4.1

com.ibm.etools.systems.core
Class SystemBasePlugin

java.lang.Object
  extended byAbstractUIPlugin
      extended bycom.ibm.etools.systems.core.SystemBasePlugin
Direct Known Subclasses:
LaunchPlugin, RemoteJavaLaunchPlugin, SystemEditorPlugin, SystemPlugin, UniversalSystemPlugin

public abstract class SystemBasePlugin
extends AbstractUIPlugin

A base plugin class offering common operations.

See Also:
Serialized Form

Field Summary
static String copyright
           
protected static String ICON_PATH
          Default folder for icons, relative to this plugin's install folder: "icons\".
protected static Logger log
          Logger object for logging messages for servicing purposes.
 
Constructor Summary
SystemBasePlugin()
          Constructor.
 
Method Summary
static Shell getActiveWorkbenchShell()
          Returns the active workbench shell.
static IWorkbenchWindow getActiveWorkbenchWindow()
          Returns the active workbench window.
static SystemBasePlugin getBaseDefault()
          Returns the singleton object representing the base plugin.
static String getIconPath()
          Helper to get the typical icons path ... usually just "icons\".
 Image getImage(String key)
          Easy retrieval of image by id
 ImageDescriptor getImageDescriptor(String key)
          Easy retrieval of image descriptor by id
 ImageDescriptor getImageDescriptorFromIDE(String relativePath)
          Returns an image descriptor from the base IDE.
protected  IPath getInstallLocation()
          Return the fully qualified install directory for this plugin.
 Logger getLogger()
          Get the logger for this plugin.
static SystemMessage getMessage(SystemMessageFile msgFile, String msgId)
          Retrieve a message from a message file.
static ImageDescriptor getPluginImage(org.osgi.framework.Bundle bundle, String fileName)
          Retrieve image in any plugin's directory tree, given its file name.
 ImageDescriptor getPluginImage(String fileName)
          Retrieve image in this plugin's directory tree, given its file name.
static String getString(ResourceBundle resourceBundle, String key)
          Get a string from a given resource bundle.
static String getString(ResourceBundle resourceBundle, String key, String defaultString)
          Get a string from a given resource bundle, with an english string to use a default if the given key is not found.
 String getSymbolicName()
          Returns the symbolic name of the bundle.
 IWorkbench getWorkbench()
          Returns the Platform UI workbench.
static IWorkspace getWorkspace()
          Returns the workspace.
static IWorkspaceRoot getWorkspaceRoot()
          Returns the workspace root.
protected abstract  void initializeImageRegistry()
          Initialize the image registry by declaring all of the required graphics.
 boolean isHeadless()
          Return true if we are running in a headless environment.
static SystemMessageFile loadDefaultMessageFile(org.osgi.framework.Bundle bundle, String fileName)
          Parse the given message file into memory, into a SystemMessageFile object.
 SystemMessageFile loadDefaultMessageFile(String fileName)
          Parse the given message file that is in the plugin into memory, into a SystemMessageFile object.
static ResourceBundle loadDefaultResourceBundle(org.osgi.framework.Bundle bundle, String fileName)
          Sets the default resource bundle for handling cases where strings aren't translated.
 ResourceBundle loadDefaultResourceBundle(String fileName)
          Sets the default resource bundle (so that untranslated strings can be obtained).
static SystemMessageFile loadMessageFile(org.osgi.framework.Bundle bundle, String fileName)
          Parse the given message file into memory, into a SystemMessageFile object.
 SystemMessageFile loadMessageFile(String fileName)
          Parse the given message file that is in the plugin into memory, into a SystemMessageFile object.
static ResourceBundle loadPluginResourceBundle(org.osgi.framework.Bundle bundle)
          Returns the plugin.properties resource bundle associated with the specified plugin descriptor
static ResourceBundle loadResourceBundle(org.osgi.framework.Bundle bundle, String fileName)
          Sets the resource bundle.
 ResourceBundle loadResourceBundle(String fileName)
          Sets the resource bundle.
static void logDebugMessage(String prefix, String message)
          Helper method for logging debug messages to the RSE-style logging file.
static void logError(String message)
          Helper method for logging errors (but not exceptions) to the RSE-style logging file.
static void logError(String message, Throwable exception)
          Helper method for logging errors (exceptions) to the RSE-style logging file.
static void logInfo(String message)
          Helper method for logging information to the RSE-style logging file.
static void logMessage(SystemMessage message)
          Helper method for logging information to the RSE-style logging file.
static void logMessage(SystemMessage message, Throwable ex)
          Helper method for logging information to the RSE-style logging file.
static void logWarning(String message)
          Helper method for logging warnings to the RSE-style logging file.
static boolean printMessages(SystemMessageFile msgFile, String fullyQualifiedTargetFile)
          Generate HTML from this plugin's message file.
protected  ImageDescriptor putImageInRegistry(String id, String fileName)
          Helper method to put an image into the registry
static boolean scanForDuplicateMessages(SystemMessageFile msgFile)
          Scan this plugin's message file for duplicates.
 void showProgrammerErrorMessage(String msg)
          Put up an error message when a programming error is detected.
 void start(org.osgi.framework.BundleContext context)
           
 void stop(org.osgi.framework.BundleContext context)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

copyright

public static final String copyright
See Also:
Constant Field Values

ICON_PATH

protected static final String ICON_PATH
Default folder for icons, relative to this plugin's install folder: "icons\".


log

protected static Logger log
Logger object for logging messages for servicing purposes.

Constructor Detail

SystemBasePlugin

public SystemBasePlugin()
Constructor.

Method Detail

getBaseDefault

public static SystemBasePlugin getBaseDefault()
Returns the singleton object representing the base plugin.

Returns:
the singleton object.

getSymbolicName

public String getSymbolicName()
Returns the symbolic name of the bundle.

Returns:
the symbolic name of the bundle.

getActiveWorkbenchShell

public static Shell getActiveWorkbenchShell()
Returns the active workbench shell.

Returns:
the active workbench shell.

getActiveWorkbenchWindow

public static IWorkbenchWindow getActiveWorkbenchWindow()
Returns the active workbench window.

Returns:
the active workbench window.

getWorkspaceRoot

public static IWorkspaceRoot getWorkspaceRoot()
Returns the workspace root.

Returns:
the workspace root.

getWorkspace

public static IWorkspace getWorkspace()
Returns the workspace.

Returns:
the workspace.

getInstallLocation

protected IPath getInstallLocation()
Return the fully qualified install directory for this plugin.


start

public void start(org.osgi.framework.BundleContext context)
           throws Exception
Throws:
Exception
See Also:
BundleActivator.start(org.osgi.framework.BundleContext)

stop

public void stop(org.osgi.framework.BundleContext context)
          throws Exception
Throws:
Exception
See Also:
BundleActivator.stop(org.osgi.framework.BundleContext)

getWorkbench

public IWorkbench getWorkbench()
Returns the Platform UI workbench.

This method exists as a convenience for plugin implementors. The workbench can also be accessed by invoking PlatformUI.getWorkbench().

This is an intercept of the AbstractUIPlugin method, so we can do a try/catch around it, as it will throw an exception if we are running headless, in which case the workbench has not even been started.


initializeImageRegistry

protected abstract void initializeImageRegistry()
Initialize the image registry by declaring all of the required graphics. Typically this is a series of calls to putImageInRegistry. Use getIconPath() to qualify the file name of the icon with its relative path.


loadMessageFile

public final SystemMessageFile loadMessageFile(String fileName)
Parse the given message file that is in the plugin into memory, into a SystemMessageFile object.

Parameters:
fileName - - unqualified name of the .xml message file, inluding the .xml extension.
Returns:
SystemMessageFile (null if unable to load the file)

getIconPath

public static String getIconPath()
Helper to get the typical icons path ... usually just "icons\".


putImageInRegistry

protected ImageDescriptor putImageInRegistry(String id,
                                             String fileName)
Helper method to put an image into the registry

Parameters:
id - - an arbitrary ID to assign to this image. Used later when retrieving it.
fileName - - the name of the icon file, with extension, relative to this plugin's folder.

getPluginImage

public ImageDescriptor getPluginImage(String fileName)
Retrieve image in this plugin's directory tree, given its file name. The file name should be qualified relative to this plugin's folder. Eg "icons\myicon.gif"


getPluginImage

public static ImageDescriptor getPluginImage(org.osgi.framework.Bundle bundle,
                                             String fileName)
Retrieve image in any plugin's directory tree, given its file name. The file name should be qualified relative to this plugin's folder. Eg "icons\myicon.gif"


getImage

public Image getImage(String key)
Easy retrieval of image by id


getImageDescriptor

public ImageDescriptor getImageDescriptor(String key)
Easy retrieval of image descriptor by id


getImageDescriptorFromIDE

public ImageDescriptor getImageDescriptorFromIDE(String relativePath)
Returns an image descriptor from the base IDE.

See Also:
ResourceNavigatorActionGroup

loadResourceBundle

public static final ResourceBundle loadResourceBundle(org.osgi.framework.Bundle bundle,
                                                      String fileName)
Sets the resource bundle. Called by child class in their constructor, say, to load in their resource bundle. Handles rare case when not found by telling user, then dying. Note: This is NOT to be used for plugin.properties since Eclipse handles that file differently.

Returns:
ResourceBundle if loaded successfully, null if not.

loadPluginResourceBundle

public static final ResourceBundle loadPluginResourceBundle(org.osgi.framework.Bundle bundle)
Returns the plugin.properties resource bundle associated with the specified plugin descriptor

Returns:
ResourceBundle if loaded successfully, null if not.

loadDefaultResourceBundle

public static final ResourceBundle loadDefaultResourceBundle(org.osgi.framework.Bundle bundle,
                                                             String fileName)
Sets the default resource bundle for handling cases where strings aren't translated. Called by child class in their constructor, say, to load in their resource bundle. Handles rare case when not found by telling user, then dying. Note: This is NOT to be used for plugin.properties since Eclipse handles that file differently.

Returns:
ResourceBundle if loaded successfully, null if not.

loadResourceBundle

public final ResourceBundle loadResourceBundle(String fileName)
Sets the resource bundle. Called by child class in their constructor, say, to load in their resource bundle. Handles rare case when not found by telling user, then dying. Note: This is NOT to be used for plugin.properties since Eclipse handles that file differently.

Returns:
ResourceBundle if loaded successfully, null if not.

loadDefaultResourceBundle

public final ResourceBundle loadDefaultResourceBundle(String fileName)
Sets the default resource bundle (so that untranslated strings can be obtained). Called by child class in their constructor, say, to load in their resource bundle. Handles rare case when not found by telling user, then dying. Note: This is NOT to be used for plugin.properties since Eclipse handles that file differently.

Returns:
ResourceBundle if loaded successfully, null if not.

getString

public static String getString(ResourceBundle resourceBundle,
                               String key)
Get a string from a given resource bundle. If not found, stack trace info is placed in the plugin's log file to help pinpoint the offending code.


getString

public static String getString(ResourceBundle resourceBundle,
                               String key,
                               String defaultString)
Get a string from a given resource bundle, with an english string to use a default if the given key is not found.

If not found, stack trace info is placed in the plugin's log file to help pinpoint the offending code.


loadMessageFile

public static final SystemMessageFile loadMessageFile(org.osgi.framework.Bundle bundle,
                                                      String fileName)
Parse the given message file into memory, into a SystemMessageFile object.

Parameters:
fileName - - unqualified name of the .xml message file, inluding the .xml extension.
Returns:
SystemMessageFile (null if unable to load the file)

loadDefaultMessageFile

public static final SystemMessageFile loadDefaultMessageFile(org.osgi.framework.Bundle bundle,
                                                             String fileName)
Parse the given message file into memory, into a SystemMessageFile object.

Parameters:
fileName - - unqualified name of the .xml message file, inluding the .xml extension.
Returns:
SystemMessageFile (null if unable to load the file)

loadDefaultMessageFile

public final SystemMessageFile loadDefaultMessageFile(String fileName)
Parse the given message file that is in the plugin into memory, into a SystemMessageFile object.

Parameters:
fileName - - unqualified name of the .xml message file, inluding the .xml extension.
Returns:
SystemMessageFile (null if unable to load the file)

getMessage

public static SystemMessage getMessage(SystemMessageFile msgFile,
                                       String msgId)
Retrieve a message from a message file.

Parameters:
msgFile - - the system message file containing the message.
msgId - - the ID of the message to retrieve. This is the concatenation of the message's component abbreviation, subcomponent abbreviation, and message ID as declared in the message xml file.

scanForDuplicateMessages

public static boolean scanForDuplicateMessages(SystemMessageFile msgFile)
Scan this plugin's message file for duplicates. This just calls the com.ibm.etools.systems.core.ui.messages.SystemMessageFile#scanForDuplicates() method on the SystemMessageFile object.

Parameters:
msgFile - - the message file to scan
Returns:
true if duplicates found. The duplicates are written to standard out and the system core log file.

printMessages

public static boolean printMessages(SystemMessageFile msgFile,
                                    String fullyQualifiedTargetFile)
Generate HTML from this plugin's message file. This is handy for documentation purposes. This just calls the com.ibm.etools.systems.core.ui.messages.SystemMessageFile#printHTML(String) method on the SystemMessageFile object.

Parameters:
msgFile - - the message file to print
Returns:
true if all went well, false if it failed for some reason.

showProgrammerErrorMessage

public void showProgrammerErrorMessage(String msg)
Put up an error message when a programming error is detected. Please note this should never happen in production so we don't translate!


logMessage

public static void logMessage(SystemMessage message)
Helper method for logging information to the RSE-style logging file. This file is located in the .metadata subfolder for this plugin.

Parameters:
message - - System message to be written to the log file

logMessage

public static void logMessage(SystemMessage message,
                              Throwable ex)
Helper method for logging information to the RSE-style logging file. This file is located in the .metadata subfolder for this plugin.

Parameters:
message - - System message to be written to the log file
ex - - Exception to log. If not applicable, this can be null.

logInfo

public static void logInfo(String message)
Helper method for logging information to the RSE-style logging file. This file is located in the .metadata subfolder for this plugin.

Because this is an information message, it will only actually be logged if the user has enabled logging of information messages via the Logging preferences page within the Remote Systems preference pages tree.

Parameters:
message - - Message to be written to the log file

logWarning

public static void logWarning(String message)
Helper method for logging warnings to the RSE-style logging file. This file is located in the .metadata subfolder for this plugin.

Because this is a warning message, it will only actually be logged if the user has enabled logging of warning messages via the Logging preferences page within the Remote Systems preference pages tree.

Parameters:
message - - Message to be written to the log file Because these messages are only used for servicing purposes, the message typically is not translated.

logError

public static void logError(String message)
Helper method for logging errors (but not exceptions) to the RSE-style logging file. This file is located in the .metadata subfolder for this plugin.

Because this is an error message, it is always logged, no matter what the preferences settings for the logger.

Parameters:
message - - Message to be written to the log file Because these messages are only used for servicing purposes, the message typically is not translated.

logError

public static void logError(String message,
                            Throwable exception)
Helper method for logging errors (exceptions) to the RSE-style logging file. This file is located in the .metadata subfolder for this plugin.

Because this is an error message, it is always logged, no matter what the preferences settings for the logger.

Parameters:
message - - Message to be written to the log file. Because these messages are only used for servicing purposes, the message typically is not translated.
exception - - Any exception that generated the error condition. Used to print a stack trace in the log file. If you pass null, it is the same as calling logError(String)

logDebugMessage

public static void logDebugMessage(String prefix,
                                   String message)
Helper method for logging debug messages to the RSE-style logging file. This file is located in the .metadata subfolder for this plugin.

Debug messages are only logged when running this plugin in the workbench, and when Logger.DEBUG has been set to true.

Parameters:
message - - Message to be written to the log file

getLogger

public Logger getLogger()
Get the logger for this plugin. You should not have to directly access the logger, since helper methods are already provided in this class. Use with care.


isHeadless

public boolean isHeadless()
Return true if we are running in a headless environment. We equate this to mean that the workbench is not running.


Remote Systems
v6.4.1

Copyright © 2005 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.