Class ResourcesPlugin

java.lang.Object
org.eclipse.core.runtime.Plugin
org.eclipse.core.resources.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.
  • Field Details

  • Constructor Details

    • ResourcesPlugin

      public ResourcesPlugin()
  • Method Details

    • 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. If the preference is not set, the workspace is not ready yet or any other condition where it could not be determined, returns native file system encoding, as specified by
      • System.getProperty("native.encoding") on Java 18 and later
      • System.getProperty("sun.jnu.encoding") on previous Java versions

      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 Platform.getSystemCharset()
      Returns:
      the encoding to use when reading text files in the workspace
      See Also:
    • 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.
    • stop

      public void stop(BundleContext context) throws Exception
      This implementation of the corresponding BundleActivator method closes the workspace without saving.
      Specified by:
      stop in interface BundleActivator
      Overrides:
      stop in class Plugin
      Parameters:
      context - the bundle context for this plug-in
      Throws:
      Exception - if this method fails to shut down this plug-in
      See Also:
    • start

      public void start(BundleContext context) throws Exception
      This implementation of the corresponding BundleActivator method opens the workspace.
      Specified by:
      start in interface BundleActivator
      Overrides:
      start in class Plugin
      Parameters:
      context - the bundle context for this plug-in
      Throws:
      Exception - if this plug-in did not start up properly
      See Also: