org.eclipse.emf.common
Class EMFPlugin

java.lang.Object
  extended byorg.eclipse.emf.common.EMFPlugin
All Implemented Interfaces:
Logger, ResourceLocator
Direct Known Subclasses:
ChangeEditPlugin, ChangePlugin, CodeGenEcorePlugin, CodeGenPlugin, CommonPlugin, CommonUIPlugin, ConverterPlugin, Ecore2EcoreEditorPlugin, Ecore2EcorePlugin, Ecore2XMLUIPlugin, EcoreEditorPlugin, EcoreEditPlugin, EcoreImporterPlugin, EcorePlugin, EMFEditPlugin, EMFEditUIPlugin, ExporterPlugin, GenModelEditPlugin, ImporterPlugin, JavaImporterPlugin, MappingPlugin, RoseImporterPlugin, XMIPlugin

public abstract class EMFPlugin
extends Object
implements ResourceLocator, Logger

EMF must run within an Eclipse workbench, within a headless Eclipse workspace, or just stand-alone as part of some other application. To support this, all resource access (e.g., NL strings, images, and so on) is directed to the resource locator methods, which can redirect the service as appopriate to the runtime. During Eclipse invocation, the implementation delegates to a plugin implementation. During stand-alone invocation, no plugin initialization takes place, so the implementation delegates to a resource JAR on the CLASSPATH. The resource jar will typically not be on the CLASSPATH during Eclipse invocation. It will contain things like the icons and the .properties, which are available in a different way during Eclipse invocation.

See Also:
ResourceLocator, Logger

Nested Class Summary
static class EMFPlugin.EclipsePlugin
          The actual implementation of an Eclipse Plugin.
static interface EMFPlugin.InternalEclipsePlugin
          This just provides a common interface for the Eclipse plugins supported by EMF.
static class EMFPlugin.InternalHelper
          This just provides a common delegate for non-UI and UI plug-in classes.
 
Field Summary
protected  URL baseURL
           
protected  ResourceLocator[] delegateResourceLocators
           
protected  Map images
           
static boolean IS_ECLIPSE_RUNNING
           
protected  ResourceBundle resourceBundle
           
protected  boolean shouldTranslate
           
protected  Map strings
           
protected  ResourceBundle untranslatedResourceBundle
           
protected  Map untranslatedStrings
           
 
Constructor Summary
EMFPlugin(ResourceLocator[] delegateResourceLocators)
           
 
Method Summary
protected  Object delegatedGetImage(String key)
          Does the work of fetching the image associated with the key, when the image resource is not available locally.
protected  String delegatedGetString(String key, boolean translate)
          Does the work of fetching the string associated with the key, when the string resource is not available locally.
protected  Object doGetImage(String key)
          Does the work of fetching the image associated with the key.
 URL getBaseURL()
          Returns the URL from which all resources are based.
 Object getImage(String key)
          Returns the description that can be used to create the image resource associated with the key.
 Logger getPluginLogger()
          Returns an Eclipse plugin implementation of a logger.
abstract  ResourceLocator getPluginResourceLocator()
          Returns an Eclipse plugin implementation of a resource locator.
 String getString(String key)
          Returns the string resource associated with the key.
 String getString(String key, boolean translate)
          Returns the string resource associated with the key.
 String getString(String key, Object[] substitutions)
          Returns a string resource associated with the key, and peforms substitutions.
 String getString(String key, Object[] substitutions, boolean translate)
          Returns a string resource associated with the key, and peforms substitutions.
 String getSymbolicName()
           
 void log(Object logEntry)
          Logs an entry.
static void main(String[] args)
           
 void setShouldTranslate(boolean shouldTranslate)
          Sets whether strings should be translated by default.
 boolean shouldTranslate()
          Indicates whether strings should be translated by default.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IS_ECLIPSE_RUNNING

public static final boolean IS_ECLIPSE_RUNNING

delegateResourceLocators

protected ResourceLocator[] delegateResourceLocators

baseURL

protected URL baseURL

untranslatedResourceBundle

protected ResourceBundle untranslatedResourceBundle

resourceBundle

protected ResourceBundle resourceBundle

strings

protected Map strings

untranslatedStrings

protected Map untranslatedStrings

shouldTranslate

protected boolean shouldTranslate

images

protected Map images
Constructor Detail

EMFPlugin

public EMFPlugin(ResourceLocator[] delegateResourceLocators)
Method Detail

getPluginResourceLocator

public abstract ResourceLocator getPluginResourceLocator()
Returns an Eclipse plugin implementation of a resource locator.

Returns:
an Eclipse plugin implementation of a resource locator.

getPluginLogger

public Logger getPluginLogger()
Returns an Eclipse plugin implementation of a logger.

Returns:
an Eclipse plugin implementation of a logger.

getSymbolicName

public String getSymbolicName()

getBaseURL

public URL getBaseURL()
Description copied from interface: ResourceLocator
Returns the URL from which all resources are based.

Specified by:
getBaseURL in interface ResourceLocator
Returns:
the URL from which all resources are based.

getImage

public Object getImage(String key)
Description copied from interface: ResourceLocator
Returns the description that can be used to create the image resource associated with the key. The description will typically be in the form of a URL to the image data. Creation of an actual image depends on the GUI environment; within Eclipse, org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry can be used.

Specified by:
getImage in interface ResourceLocator
Parameters:
key - the key of the image resource.
Returns:
the description on the image resource.

doGetImage

protected Object doGetImage(String key)
                     throws IOException
Does the work of fetching the image associated with the key. It ensures that the image exists.

Parameters:
key - the key of the image to fetch.
Returns:
the description of the image associated with the key.
Throws:
IOException - if an image doesn't exist.

delegatedGetImage

protected Object delegatedGetImage(String key)
                            throws MissingResourceException
Does the work of fetching the image associated with the key, when the image resource is not available locally.

Parameters:
key - the key of the image to fetch.
Throws:
MissingResourceException - if the image resource doesn't exist anywhere.
See Also:
delegateResourceLocators

shouldTranslate

public boolean shouldTranslate()
Indicates whether strings should be translated by default.

Returns:
true if strings should be translated by default; false otherwise.

setShouldTranslate

public void setShouldTranslate(boolean shouldTranslate)
Sets whether strings should be translated by default.

Parameters:
shouldTranslate - whether strings should be translated by default.

getString

public String getString(String key)
Description copied from interface: ResourceLocator
Returns the string resource associated with the key.

Specified by:
getString in interface ResourceLocator
Parameters:
key - the key of the string resource.
Returns:
the string resource associated with the key.

getString

public String getString(String key,
                        boolean translate)
Description copied from interface: ResourceLocator
Returns the string resource associated with the key.

Specified by:
getString in interface ResourceLocator
Parameters:
key - the key of the string resource.
translate - whether the result is to be translated to the current locale.
Returns:
the string resource associated with the key.

delegatedGetString

protected String delegatedGetString(String key,
                                    boolean translate)
Does the work of fetching the string associated with the key, when the string resource is not available locally.

Parameters:
key - the key of the string to fetch.
Throws:
MissingResourceException - if the string resource doesn't exist anywhere.
See Also:
delegateResourceLocators

getString

public String getString(String key,
                        Object[] substitutions)
Description copied from interface: ResourceLocator
Returns a string resource associated with the key, and peforms substitutions.

Specified by:
getString in interface ResourceLocator
Parameters:
key - the key of the string.
substitutions - the message substitutions.
Returns:
a string resource associated with the key.
See Also:
ResourceLocator.getString(String), MessageFormat.format(String, Object[])

getString

public String getString(String key,
                        Object[] substitutions,
                        boolean translate)
Description copied from interface: ResourceLocator
Returns a string resource associated with the key, and peforms substitutions.

Specified by:
getString in interface ResourceLocator
Parameters:
key - the key of the string.
substitutions - the message substitutions.
translate - whether the result is to be translated to the current locale.
Returns:
a string resource associated with the key.
See Also:
ResourceLocator.getString(String), MessageFormat.format(String, Object[])

log

public void log(Object logEntry)
Description copied from interface: Logger
Logs an entry.

Specified by:
log in interface Logger
Parameters:
logEntry - a plastic entry to log.

main

public static void main(String[] args)

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.