Class ResourcesPlugin

  • All Implemented Interfaces:
    BundleActivator

    public final class ResourcesPlugin
    extends Plugin
    The plug-in runtime class for the Resources plug-in. This is the starting point for all workspace and resource manipulation. A typical sequence of events would be for a dependent plug-in to track the org.eclipse.core.resources.IWorkspace service. Doing so would cause this plug-in to be activated and the workspace (if any) to be loaded from disk and initialized.
    Restriction:
    This class is not intended to be instantiated by clients.
    • Constructor Detail

      • ResourcesPlugin

        public ResourcesPlugin()
    • Method Detail

      • getEncoding

        public static String getEncoding()
        Returns the encoding to use when reading text files in the workspace. This is the value of the PREF_ENCODING preference, or the file system encoding (System.getProperty("file.encoding")) if the preference is not set, the workspace is not ready yet or any other condition where it could not be determined.

        Note that this method does not check whether the result is a supported encoding. Callers should be prepared to handle UnsupportedEncodingException where this encoding is used.

        Hint: Using this method might return different results depending on the system state. Code that don't want to be affected from this ambiguities should do the following:

        1. using any of your favorite techniques (Declarative Services, ServiceTracker, Blueprint, ...) to track the workspace
        2. Calling workspace.getRoot().getDefaultCharset(false)
        3. If null is returned take the appropriate action, e.g fall back to System.getProperty("file.encoding") or even better Charset.defaultCharset()
        Returns:
        the encoding to use when reading text files in the workspace
        See Also:
        UnsupportedEncodingException
      • getPlugin

        public static ResourcesPlugin getPlugin()
        Returns the Resources plug-in.
        Returns:
        the single instance of this plug-in runtime class
      • getWorkspace

        public static IWorkspace getWorkspace()
        Returns the workspace. The workspace is not accessible after the resources plug-in has shutdown. Hint: Accessing the Workspace in a static way is prone to start-up order problem, please consider using any of your favorite techniques (Declarative Services, ServiceTracker, Blueprint, ...) instead. Please see the documentation of IWorkspace for more information.
        Returns:
        the workspace that was created by the single instance of this plug-in class.