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

  




 

 

RSE
Release 3.0

org.eclipse.rse.ui
Class SystemBasePlugin


java.lang.Object
  extended by 

org.eclipse.core.runtime.Plugin
      extended by 

org.eclipse.ui.plugin.AbstractUIPlugin
          extended by 
org.eclipse.rse.ui.SystemBasePlugin
All Implemented Interfaces:
BundleActivator
Direct Known Subclasses:
RSEUIPlugin

public abstract class SystemBasePlugin
extends AbstractUIPlugin

A base plugin class offering common operations.


Field Summary
protected static  Logger log
          Logger object for logging messages for servicing purposes.
 
Fields inherited from class org.eclipse.core.runtime. Plugin
PLUGIN_PREFERENCE_SCOPE, PREFERENCES_DEFAULT_OVERRIDE_BASE_NAME, PREFERENCES_DEFAULT_OVERRIDE_FILE_NAME
 
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 ()
           
  Image getImage ( String key)
          Retrieves or creates an image based on its id.
  ImageDescriptor getImageDescriptor ( String key)
          Returns the image descriptor that has been registered to this id.
  ImageDescriptor getImageDescriptorFromIDE ( String relativePath)
          Returns an image descriptor from the base IDE.
  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 ( Bundle bundle, String fileName)
          Retrieve image in any plugin's directory tree, given its file name.
  ImageDescriptor getPluginImage ( String imagePath)
          Retrieve an image descriptor in this plugin's directory tree given its file name.
  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 ()
          Deprecated. this method is useless right now because SystemBasePlugin is part of the rse.ui plugin which depends on workbench and therefore we can never load this class while actually being in headless mode. Normally this should return false however, because the javadoc says we "equate this to mean that the workbench is not running", it's possible early on that the method may return true if the workbench has not yet been instantiated - although it will later return false.
static  SystemMessageFile loadDefaultMessageFile ( Bundle bundle, String fileName)
          Parse the given message file into memory, into a SystemMessageFile object.
static  SystemMessageFile loadMessageFile ( Bundle bundle, String fileName)
          Parse the given message file into memory, into a SystemMessageFile object.
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)
          Construct an image descriptor from a file name and place it in the image descriptor registry.
static  URL resolveBundleNameNL ( Bundle bundle, String name)
          Resolves the bundle relative name to its URL inside a bundle if the resource named by that name exists.
static boolean scanForDuplicateMessages ( SystemMessageFile msgFile)
          Scan this plugin's message file for duplicates.
 void start ( BundleContext context)
           
 void stop ( BundleContext context)
           
 
Methods inherited from class org.eclipse.ui.plugin. AbstractUIPlugin
createImageRegistry, getDialogSettings, getImageRegistry, getPreferenceStore, imageDescriptorFromPlugin, initializeDefaultPluginPreferences, initializeDefaultPreferences, initializeImageRegistry, loadDialogSettings, loadPreferenceStore, refreshPluginActions, saveDialogSettings, savePreferenceStore, shutdown, startup
 
Methods inherited from class org.eclipse.core.runtime. Plugin
find, find, getBundle, getDescriptor, getLog, getPluginPreferences, getStateLocation, internalInitializeDefaultPluginPreferences, isDebugging, openStream, openStream, savePluginPreferences, setDebugging, toString
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

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.

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.

getIconPath

public static 
String getIconPath()
Returns:
the prefix of the path for icons, i.e. "icons/".

getPluginImage

public static 
ImageDescriptor getPluginImage(
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 bundle. Eg "icons/myicon.gif"


resolveBundleNameNL

public static final 
URL resolveBundleNameNL(
Bundle bundle,
                                            
String name)
Resolves the bundle relative name to its URL inside a bundle if the resource named by that name exists. Returns null if the resources does not exist. Looks for the resource in NL directories as well.

Parameters:
bundle - The bundle in which to look for the resource
name - The name of the resource
Returns:
The resource URL or null.

loadMessageFile

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

Parameters:
bundle - - the descriptor for this plugin
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(
Bundle bundle,
                                                             
String fileName)
Parse the given message file into memory, into a SystemMessageFile object.

Parameters:
bundle - - the descriptor for this plugin
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 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 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.

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:
prefix - - Class issuing the debug message. Typically you pass getClass().getName()
message - - Message to be written to the log file

getSymbolicName

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

Returns:
the symbolic name of the bundle.

start

public void start(
BundleContext context)
           throws 
Exception
Specified by:
start in interface BundleActivator
Overrides:
start in class AbstractUIPlugin
Throws:
Exception
See Also:
BundleActivator.start(org.osgi.framework.BundleContext)

stop

public void stop(
BundleContext context)
          throws 
Exception
Specified by:
stop in interface BundleActivator
Overrides:
stop in class AbstractUIPlugin
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.

Overrides:
getWorkbench in class AbstractUIPlugin

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 icons with their relative path.


putImageInRegistry

protected 
ImageDescriptor putImageInRegistry(
String id,
                                             
String fileName)
Construct an image descriptor from a file name and place it in the image descriptor registry. Actual image construction is delayed until first use.

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.
Returns:
the image descriptor for this particular id.

getPluginImage

public 
ImageDescriptor getPluginImage(
String imagePath)
Retrieve an image descriptor in this plugin's directory tree given its file name. The file name should be qualified relative to this plugin's bundle. For example "icons/myicon.gif"

Parameters:
imagePath - the path name to the image relative to this bundle
Returns:
the image descriptor

getImage

public 
Image getImage(
String key)
Retrieves or creates an image based on its id. The image is then stored in the image registry if it is created so that it may be retrieved again. Thus, image resources retrieved in this way need not be disposed by the caller.

Parameters:
key - the id of the image to retrieve.
Returns:
the Image resource for this id.

getImageDescriptor

public 
ImageDescriptor getImageDescriptor(
String key)
Returns the image descriptor that has been registered to this id.

Parameters:
key - the id of the image descriptor to retrieve
Returns:
an ImageDescriptor

getImageDescriptorFromIDE

public 
ImageDescriptor getImageDescriptorFromIDE(
String relativePath)
Returns an image descriptor from the base IDE. Looks only in the "icons/full/" directories.

See Also:
ResourceNavigatorActionGroup

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()
Deprecated. this method is useless right now because SystemBasePlugin is part of the rse.ui plugin which depends on workbench and therefore we can never load this class while actually being in headless mode. Normally this should return false however, because the javadoc says we "equate this to mean that the workbench is not running", it's possible early on that the method may return true if the workbench has not yet been instantiated - although it will later return false.

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


RSE
Release 3.0

Copyright (c) IBM Corporation and others 2000, 2008. All Rights Reserved.

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