Class WorkbenchPlugin
- All Implemented Interfaces:
BundleActivator
-
Field Summary
Modifier and TypeFieldDescriptionstatic boolean
Global workbench ui plugin flag.static String
The workbench plugin ID.static char
The character used to separate preference page category idsFields inherited from class org.eclipse.core.runtime.Plugin
PLUGIN_PREFERENCE_SCOPE, PREFERENCES_DEFAULT_OVERRIDE_BASE_NAME, PREFERENCES_DEFAULT_OVERRIDE_FILE_NAME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
createExtension
(IConfigurationElement element, String classAttribute) Creates an extension.protected ImageRegistry
Returns the image registry for this plugin.org.eclipse.ui.internal.registry.ActionSetRegistry
Returns the action set registry for the workbench.Returns the application name.Returns the bundle context associated with the workbench plug-in.static Bundle
getBundleForExecutableExtension
(IConfigurationElement element, String extensionName) Returns the bundle that contains the class referenced by an executable extension.Bundle[]
Return an array of all bundles contained in this workbench.FOR INTERNAL WORKBENCH USE ONLY.org.eclipse.ui.internal.decorators.DecoratorManager
Get the decorator manager for the receiverstatic WorkbenchPlugin
Return the default instance of the receiver.Answer the manager that maps resource types to a the description of the editor to usegetElementFactory
(String targetID) Answer the element factory for an id, ornull
. if not found.Return the export wizard registry.Return the import wizard registry.org.eclipse.ui.internal.intro.IIntroRegistry
Returns the introduction registry.Return the new wizard registry.Returns the operation support.Return the perspective registry.Get the preference manager.Returns the name of the product.Returns the shared images for the workbench.static Shell
getSplashShell
(Display display) Get the splash shell for this workbench instance, if any.static IStatus
Return the status from throwableReturns aTestableObject
provided by a TestableObject service ornull
if a service implementation cannot be found.org.eclipse.ui.internal.themes.IThemeRegistry
Returns the theme registry for the workbench.Answer the view registry.Returns the image descriptors for the window image to use for this product.Returns the working set managerorg.eclipse.ui.internal.registry.WorkingSetRegistry
Returns the working set registrystatic 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.void
initializeContext
(IEclipseContext context) Initialized the workbench plug-in with the e4 contextprotected void
Set default preference values.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.static boolean
Return whether or not the OSGi framework has specified the handle of a splash shell.boolean
isStarting
(Bundle bundle) static void
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).static void
Logs the given message to the platform log.static void
Logs the given message and throwable to the platform log.static void
Logs the given message and status to the platform log.static void
Log the throwable.static void
Log the status to the default log.static IStatus
Create a new error from the message and the throwable.void
start
(BundleContext context) TheAbstractUIPlugin
implementation of thisPlugin
method refreshes the plug-in actions.void
stop
(BundleContext context) TheAbstractUIPlugin
implementation of thisPlugin
method saves this plug-in's preference and dialog stores and shuts down its image registry (if they are in use).static void
unsetSplashShell
(Display display) Removes any splash shell data set on the provided display and disposes the shell if necessary.Methods inherited from class org.eclipse.ui.plugin.AbstractUIPlugin
getDialogSettings, getImageRegistry, getPreferenceStore, getWorkbench, imageDescriptorFromPlugin, initializeDefaultPluginPreferences, initializeImageRegistry, loadDialogSettings, loadPreferenceStore, refreshPluginActions, saveDialogSettings, savePreferenceStore, shutdown, startup
Methods inherited from class org.eclipse.core.runtime.Plugin
find, find, getBundle, getLog, getPluginPreferences, getStateLocation, internalInitializeDefaultPluginPreferences, isDebugging, openStream, openStream, savePluginPreferences, setDebugging, toString
-
Field Details
-
DEBUG
public static boolean DEBUGGlobal 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
The workbench plugin ID. -
PREFERENCE_PAGE_CATEGORY_SEPARATOR
public static char PREFERENCE_PAGE_CATEGORY_SEPARATORThe 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 extensionclassAttribute
- the name of the attribute carrying the class- Returns:
- the extension object
- Throws:
CoreException
- if the extension cannot be created
-
hasExecutableExtension
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 testextensionName
- 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 testextensionName
- 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
- The element has an attribute with the specified name or element text in
the form
-
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 testextensionName
- 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
- The element has an attribute with the specified name or element text in
the form
-
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 classAbstractUIPlugin
- 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
Return the default instance of the receiver. This represents the runtime plugin.- Returns:
- WorkbenchPlugin
- See Also:
-
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
Answer the element factory for an id, ornull
. if not found.- Returns:
- IElementFactory
-
getPerspectiveRegistry
Return the perspective registry.- Returns:
- IPerspectiveRegistry. The registry for the receiver.
-
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
Returns the operation support.- Returns:
- the workbench operation support.
- Since:
- 3.1
-
getPreferenceManager
Get the preference manager.- Returns:
- PreferenceManager the preference manager for the receiver.
-
getThemeRegistry
public org.eclipse.ui.internal.themes.IThemeRegistry getThemeRegistry()Returns the theme registry for the workbench.- Returns:
- the theme registry
-
getViewRegistry
Answer the view registry.- Returns:
- IViewRegistry the view registry for the receiver.
-
initializeDefaultPreferences
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 classAbstractUIPlugin
- Parameters:
store
- the preference store to fill
-
log
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
Log the throwable. -
getStatus
Return the status from throwable- Parameters:
t
- throwable- Returns:
- IStatus
-
newError
Create a new error from the message and the throwable.- Returns:
- IStatus
-
log
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
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
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 benull
.status
- The status describing the problem. Must not be null.
-
log
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
Description copied from class:AbstractUIPlugin
TheAbstractUIPlugin
implementation of thisPlugin
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
Clients must never explicitly call this method.Plugin.stop(BundleContext)
may be called from separate threads, but the OSGi framework ensures that both methods will not be called simultaneously.- Specified by:
start
in interfaceBundleActivator
- Overrides:
start
in classAbstractUIPlugin
- Parameters:
context
- the bundle context for this plug-in- Throws:
Exception
- if this plug-in did not start up properly
-
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
Returns the bundle context associated with the workbench plug-in.- Returns:
- the bundle context
- Since:
- 3.1
-
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
Returns the name of the product.- Returns:
- the product name, or
null
if none - Since:
- 3.0
-
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
Description copied from class:AbstractUIPlugin
TheAbstractUIPlugin
implementation of thisPlugin
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 thatsuper.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
Clients must never explicitly call this method.Plugin.start(BundleContext)
may be called from separate threads, but the OSGi framework ensures that both methods will not be called simultaneously.- Specified by:
stop
in interfaceBundleActivator
- Overrides:
stop
in classAbstractUIPlugin
- Parameters:
context
- the bundle context for this plug-in- Throws:
Exception
- if this method fails to shut down this plug-in
-
getNewWizardRegistry
Return the new wizard registry.- Returns:
- the new wizard registry
- Since:
- 3.1
-
getImportWizardRegistry
Return the import wizard registry.- Returns:
- the import wizard registry
- Since:
- 3.1
-
getExportWizardRegistry
Return the export wizard registry.- Returns:
- the export wizard registry
- Since:
- 3.1
-
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. Returnsnull
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
-
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 providedDisplay
.- Parameters:
display
- the display to parent the shell on- Returns:
- the splash shell or
null
- Throws:
NumberFormatException
IllegalArgumentException
- Since:
- 3.4
- See Also:
-
unsetSplashShell
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
Initialized the workbench plug-in with the e4 context- Parameters:
context
- the e4 context
-
getDebugOptions
-
getTestableObject
Returns aTestableObject
provided by a TestableObject service ornull
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:
-