Class PlatformUI

  • public final class PlatformUI
    extends Object
    The central class for access to the Eclipse Platform User Interface. This class cannot be instantiated; all functionality is provided by static methods. Features provided:
    • creation of the workbench.
    • access to the workbench.
    See Also:
    • Method Detail

      • getWorkbench

        public static IWorkbench getWorkbench()
        Returns the workbench. Fails if the workbench has not been created yet.
        the workbench
      • isWorkbenchRunning

        public static boolean isWorkbenchRunning()
        Returns whether createAndRunWorkbench has been called to create the workbench, and the workbench has yet to terminate.

        Note that this method may return true while the workbench is still being initialized, so it may not be safe to call workbench API methods even if this method returns true. See bug 49316 for details.

        true if the workbench has been created and is still running, and false if the workbench has not yet been created or has completed
      • createAndRunWorkbench

        public static int createAndRunWorkbench​(Display display,
                                                WorkbenchAdvisor advisor)
        Creates the workbench and associates it with the given display and workbench advisor, and runs the workbench UI. This entails processing and dispatching events until the workbench is closed or restarted.

        This method is intended to be called by the main class (the "application"). Fails if the workbench UI has already been created.

        Use createDisplay to create the display to pass in.

        Note that this method is intended to be called by the application. It must be called exactly once, and early on before anyone else asks getWorkbench() for the workbench.

        display - the display to be used for all UI interactions with the workbench
        advisor - the application-specific advisor that configures and specializes the workbench
        return code RETURN_OK for normal exit; RETURN_RESTART if the workbench was terminated with a call to IWorkbench.restart; RETURN_UNSTARTABLE if the workbench could not be started; RETURN_EMERGENCY_CLOSE if the UI quit because of an emergency; other values reserved for future use
      • createDisplay

        public static Display createDisplay()
        Creates the Display to be used by the workbench. It is the caller's responsibility to dispose the resulting Display, not the workbench's.
        the display
      • getTestableObject

        public static TestableObject getTestableObject()
        Returns the testable object facade, for use by the test harness.

        IMPORTANT: This method is only for use by the test harness. Applications and regular plug-ins should not call this method.

        To avoid depending on the the Workbench a TestableObject can be obtained via OSGi service.

        the testable object facade
      • getPreferenceStore

        public static IPreferenceStore getPreferenceStore()
        Returns the preference store used for publicly settable workbench preferences. Constants for these preferences are defined on IWorkbenchPreferenceConstants.
        the workbench public preference store
      • getDialogSettingsProvider

        public static IDialogSettingsProvider getDialogSettingsProvider​(Bundle bundle)
        Returns the dialog settings provider for the passed bundle. The dialog settings is used to hold persistent state data for the various wizards and dialogs of the bundle in the context of a workbench.

        If an error occurs reading the dialog store, an empty one is quietly created and returned (errors are logged).

        bundle - the bundle for which the dialog settings are to be returned
        the dialog settings provider
      • createPreferenceStore

        public static IPreferenceStore createPreferenceStore​(Class<?> clazz)
        Creates a IPreferenceStore store for the bundle that loaded that class
        clazz - the class to use for determining the responsible bundle
        the instance scoped preference store for the given class