Class WorkbenchPlugin

All Implemented Interfaces:
BundleActivator

public class WorkbenchPlugin extends AbstractUIPlugin
This class represents the TOP of the workbench UI world A plugin class is effectively an application wrapper for a plugin & its classes. This class should be thought of as the workbench UI's application class. This class is responsible for tracking various registries font, preference, graphics, dialog store. This class is explicitly referenced by the workbench plugin's "plugin.xml" and places it into the UI start extension point of the main overall application harness When is this class started? When the Application calls createExecutableExtension to create an executable instance of our workbench class.
  • Field Details

    • DEBUG

      public static boolean DEBUG
      Global workbench ui plugin flag. Only workbench implementation is allowed to use this flag All other plugins, examples, or test cases must *not* use this flag.
    • PI_WORKBENCH

      public static String PI_WORKBENCH
      The workbench plugin ID.
    • PREFERENCE_PAGE_CATEGORY_SEPARATOR

      public static char PREFERENCE_PAGE_CATEGORY_SEPARATOR
      The character used to separate preference page category ids
  • Constructor Details

    • WorkbenchPlugin

      public WorkbenchPlugin()
      Create an instance of the WorkbenchPlugin. The workbench plugin is effectively the "application" for the workbench UI. The entire UI operates as a good plugin citizen.
  • Method Details

    • createExtension

      public static Object createExtension(IConfigurationElement element, String classAttribute) throws CoreException
      Creates an extension. If the extension plugin has not been loaded a busy cursor will be activated during the duration of the load.
      Parameters:
      element - the config element defining the extension
      classAttribute - the name of the attribute carrying the class
      Returns:
      the extension object
      Throws:
      CoreException - if the extension cannot be created
    • hasExecutableExtension

      public static boolean hasExecutableExtension(IConfigurationElement element, String extensionName)
      Answers whether the provided element either has an attribute with the given name or a child element with the given name with an attribute called class.
      Parameters:
      element - the element to test
      extensionName - the name of the extension to test for
      Returns:
      whether or not the extension is declared
      Since:
      3.3
    • isBundleLoadedForExecutableExtension

      public static boolean isBundleLoadedForExecutableExtension(IConfigurationElement element, String extensionName)
      Checks to see if the provided element has the syntax for an executable extension with a given name that resides in a bundle that is already active. Determining the bundle happens in one of two ways:
      • The element has an attribute with the specified name or element text in the form bundle.id/class.name[:optional attributes]
      • The element has a child element with the specified name that has a plugin attribute
      Parameters:
      element - the element to test
      extensionName - the name of the extension to test for
      Returns:
      whether or not the bundle expressed by the above criteria is active. If the bundle cannot be determined then the state of the bundle that declared the element is returned.
      Since:
      3.3
    • getBundleForExecutableExtension

      public static Bundle getBundleForExecutableExtension(IConfigurationElement element, String extensionName)
      Returns the bundle that contains the class referenced by an executable extension. Determining the bundle happens in one of two ways:
      • The element has an attribute with the specified name or element text in the form bundle.id/class.name[:optional attributes]
      • The element has a child element with the specified name that has a plugin attribute
      Parameters:
      element - the element to test
      extensionName - the name of the extension to test for
      Returns:
      the bundle referenced by the extension. If that bundle cannot be determined the bundle that declared the element is returned. Note that this may be null.
      Since:
      3.3
    • createImageRegistry

      protected ImageRegistry createImageRegistry()
      Returns the image registry for this plugin. Where are the images? The images (typically gifs) are found in the same plugins directory.
      Overrides:
      createImageRegistry in class AbstractUIPlugin
      Returns:
      ImageRegistry the resulting registry.
      See Also:
    • getActionSetRegistry

      public org.eclipse.ui.internal.registry.ActionSetRegistry getActionSetRegistry()
      Returns the action set registry for the workbench.
      Returns:
      the workbench action set registry
    • getDefault

      public static WorkbenchPlugin getDefault()
      Return the default instance of the receiver. This represents the runtime plugin.
      Returns:
      WorkbenchPlugin
      See Also:
    • getEditorRegistry

      public IEditorRegistry getEditorRegistry()
      Answer the manager that maps resource types to a the description of the editor to use
      Returns:
      IEditorRegistry the editor registry used by this plug-in.
    • getElementFactory

      public IElementFactory getElementFactory(String targetID)
      Answer the element factory for an id, or null. if not found.
      Returns:
      IElementFactory
    • getPerspectiveRegistry

      public IPerspectiveRegistry getPerspectiveRegistry()
      Return the perspective registry.
      Returns:
      IPerspectiveRegistry. The registry for the receiver.
    • getWorkingSetManager

      public IWorkingSetManager getWorkingSetManager()
      Returns the working set manager
      Returns:
      the working set manager
      Since:
      2.0
    • getWorkingSetRegistry

      public org.eclipse.ui.internal.registry.WorkingSetRegistry getWorkingSetRegistry()
      Returns the working set registry
      Returns:
      the working set registry
      Since:
      2.0
    • getIntroRegistry

      public org.eclipse.ui.internal.intro.IIntroRegistry getIntroRegistry()
      Returns the introduction registry.
      Returns:
      the introduction registry.
      Since:
      3.0
    • getOperationSupport

      public IWorkbenchOperationSupport getOperationSupport()
      Returns the operation support.
      Returns:
      the workbench operation support.
      Since:
      3.1
    • getPreferenceManager

      public PreferenceManager getPreferenceManager()
      Get the preference manager.
      Returns:
      PreferenceManager the preference manager for the receiver.
    • getSharedImages

      public ISharedImages getSharedImages()
      Returns the shared images for the workbench.
      Returns:
      the shared image manager
    • getThemeRegistry

      public org.eclipse.ui.internal.themes.IThemeRegistry getThemeRegistry()
      Returns the theme registry for the workbench.
      Returns:
      the theme registry
    • getViewRegistry

      public IViewRegistry getViewRegistry()
      Answer the view registry.
      Returns:
      IViewRegistry the view registry for the receiver.
    • initializeDefaultPreferences

      protected void initializeDefaultPreferences(IPreferenceStore store)
      Set default preference values. This method must be called whenever the preference store is initially loaded because the default values are not stored in the preference store.
      Overrides:
      initializeDefaultPreferences in class AbstractUIPlugin
      Parameters:
      store - the preference store to fill
    • log

      public static void log(String message)
      Logs the given message to the platform log. If you have an exception in hand, call log(String, Throwable) instead. If you have a status object in hand call log(String, IStatus) instead. This convenience method is for internal use by the Workbench only and must not be called outside the Workbench.
      Parameters:
      message - A high level UI message describing when the problem happened.
    • log

      public static void log(Throwable t)
      Log the throwable.
    • getStatus

      public static IStatus getStatus(Throwable t)
      Return the status from throwable
      Parameters:
      t - throwable
      Returns:
      IStatus
    • newError

      public static IStatus newError(String message, Throwable t)
      Create a new error from the message and the throwable.
      Returns:
      IStatus
    • log

      public static void log(String message, Throwable t)
      Logs the given message and throwable to the platform log. If you have a status object in hand call log(String, IStatus) instead. This convenience method is for internal use by the Workbench only and must not be called outside the Workbench.
      Parameters:
      message - A high level UI message describing when the problem happened.
      t - The throwable from where the problem actually occurred.
    • log

      public static void log(Class clazz, String methodName, Throwable t)
      Logs the given throwable to the platform log, indicating the class and method from where it is being logged (this is not necessarily where it occurred). This convenience method is for internal use by the Workbench only and must not be called outside the Workbench.
      Parameters:
      clazz - The calling class.
      methodName - The calling method name.
      t - The throwable from where the problem actually occurred.
    • log

      public static void log(String message, IStatus status)
      Logs the given message and status to the platform log. This convenience method is for internal use by the Workbench only and must not be called outside the Workbench.
      Parameters:
      message - A high level UI message describing when the problem happened. May be null.
      status - The status describing the problem. Must not be null.
    • log

      public static void log(IStatus status)
      Log the status to the default log.
    • getDecoratorManager

      public org.eclipse.ui.internal.decorators.DecoratorManager getDecoratorManager()
      Get the decorator manager for the receiver
      Returns:
      DecoratorManager the decorator manager for the receiver.
    • start

      public void start(BundleContext context) throws Exception
      Description copied from class: AbstractUIPlugin
      The AbstractUIPlugin implementation of this Plugin method refreshes the plug-in actions. Subclasses may extend this method, but must send super first. Starts up this plug-in.

      This method should be overridden in subclasses that need to do something when this plug-in is started. Implementors should call the inherited method at the first possible point to ensure that any system requirements can be met.

      If this method throws an exception, it is taken as an indication that plug-in initialization has failed; as a result, the plug-in will not be activated; moreover, the plug-in will be marked as disabled and ineligible for activation for the duration.

      Note 1: This method is automatically invoked by the platform the first time any code in the plug-in is executed.

      Note 2: This method is intended to perform simple initialization of the plug-in environment. The platform may terminate initializers that do not complete in a timely fashion.

      Note 3: The class loader typically has monitors acquired during invocation of this method. It is strongly recommended that this method avoid synchronized blocks or other thread locking mechanisms, as this would lead to deadlock vulnerability.

      Note 4: The supplied bundle context represents the plug-in to the OSGi framework. For security reasons, it is strongly recommended that this object should not be divulged.

      Note 5: This method and the Plugin.stop(BundleContext) may be called from separate threads, but the OSGi framework ensures that both methods will not be called simultaneously.

      Clients must never explicitly call this method.
      Specified by:
      start in interface BundleActivator
      Overrides:
      start in class AbstractUIPlugin
      Parameters:
      context - the bundle context for this plug-in
      Throws:
      Exception - if this plug-in did not start up properly
    • getBundles

      public Bundle[] getBundles()
      Return an array of all bundles contained in this workbench.
      Returns:
      an array of bundles in the workbench or an empty array if none
      Since:
      3.0
    • getBundleContext

      public BundleContext getBundleContext()
      Returns the bundle context associated with the workbench plug-in.
      Returns:
      the bundle context
      Since:
      3.1
    • getAppName

      public String getAppName()
      Returns the application name.

      Note this is never shown to the user. It is used to initialize the SWT Display. On Motif, for example, this can be used to set the name used for resource lookup.

      Returns:
      the application name, or null
      Since:
      3.0
      See Also:
    • getProductName

      public String getProductName()
      Returns the name of the product.
      Returns:
      the product name, or null if none
      Since:
      3.0
    • getWindowImages

      public ImageDescriptor[] getWindowImages()
      Returns the image descriptors for the window image to use for this product.
      Returns:
      an array of the image descriptors for the window image, or null if none
      Since:
      3.0
    • stop

      public void stop(BundleContext context) throws Exception
      Description copied from class: AbstractUIPlugin
      The AbstractUIPlugin implementation of this Plugin method saves this plug-in's preference and dialog stores and shuts down its image registry (if they are in use). Subclasses may extend this method, but must send super last. A try-finally statement should be used where necessary to ensure that super.stop() is always done. Stops this plug-in.

      This method should be re-implemented in subclasses that need to do something when the plug-in is shut down. Implementors should call the inherited method as late as possible to ensure that any system requirements can be met.

      Plug-in shutdown code should be robust. In particular, this method should always make an effort to shut down the plug-in. Furthermore, the code should not assume that the plug-in was started successfully.

      Note 1: If a plug-in has been automatically started, this method will be automatically invoked by the platform when the platform is shut down.

      Note 2: This method is intended to perform simple termination of the plug-in environment. The platform may terminate invocations that do not complete in a timely fashion.

      Note 3: The supplied bundle context represents the plug-in to the OSGi framework. For security reasons, it is strongly recommended that this object should not be divulged.

      Note 4: This method and the Plugin.start(BundleContext) may be called from separate threads, but the OSGi framework ensures that both methods will not be called simultaneously.

      Clients must never explicitly call this method.
      Specified by:
      stop in interface BundleActivator
      Overrides:
      stop in class AbstractUIPlugin
      Parameters:
      context - the bundle context for this plug-in
      Throws:
      Exception - if this method fails to shut down this plug-in
    • getNewWizardRegistry

      public IWizardRegistry getNewWizardRegistry()
      Return the new wizard registry.
      Returns:
      the new wizard registry
      Since:
      3.1
    • getImportWizardRegistry

      public IWizardRegistry getImportWizardRegistry()
      Return the import wizard registry.
      Returns:
      the import wizard registry
      Since:
      3.1
    • getExportWizardRegistry

      public IWizardRegistry getExportWizardRegistry()
      Return the export wizard registry.
      Returns:
      the export wizard registry
      Since:
      3.1
    • getDataLocation

      public IPath getDataLocation()
      FOR INTERNAL WORKBENCH USE ONLY. Returns the path to a location in the file system that can be used to persist/restore state between workbench invocations. If the location did not exist prior to this call it will be created. Returns null if no such location is available.
      Returns:
      path to a location in the file system where this plug-in can persist data between sessions, or null if no such location is available.
      Since:
      3.1
    • isStarting

      public boolean isStarting(Bundle bundle)
    • isSplashHandleSpecified

      public static boolean isSplashHandleSpecified()
      Return whether or not the OSGi framework has specified the handle of a splash shell.
      Returns:
      whether or not the OSGi framework has specified the handle of a splash shell
      Since:
      3.4
    • getSplashShell

      public static Shell getSplashShell(Display display) throws NumberFormatException, IllegalArgumentException
      Get the splash shell for this workbench instance, if any. This will find the splash created by the launcher (native) code and wrap it in a SWT shell. This may have the side effect of setting data on the provided Display.
      Parameters:
      display - the display to parent the shell on
      Returns:
      the splash shell or null
      Throws:
      NumberFormatException
      IllegalArgumentException
      Since:
      3.4
      See Also:
    • unsetSplashShell

      public static void unsetSplashShell(Display display)
      Removes any splash shell data set on the provided display and disposes the shell if necessary.
      Parameters:
      display - the display to parent the shell on
      Since:
      3.4
    • initializeContext

      public void initializeContext(IEclipseContext context)
      Initialized the workbench plug-in with the e4 context
      Parameters:
      context - the e4 context
    • getDebugOptions

      public DebugOptions getDebugOptions()
    • getTestableObject

      public TestableObject getTestableObject()
      Returns a TestableObject provided by a TestableObject service or null if a service implementation cannot be found. The TestableObject is used to hook tests into the application lifecycle.

      It is recommended the testable object is obtained via service over Workbench.getWorkbenchTestable() to avoid the tests having a dependency on the Workbench.

      Returns:
      TestableObject provided via service or null
      See Also: