|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.core.runtime.Plugin | +--org.eclipse.ui.plugin.AbstractUIPlugin
Abstract base class for plug-ins that integrate with the Eclipse platform UI.
Subclasses obtain the following capabilities:
Preferences
org.eclipse.core.runtime.Preferences
).
This class provides appropriate conversion to the older JFace preference
API (org.eclipse.jface.preference.IPreferenceStore
).getPreferenceStore
returns the JFace preference
store (cf. Plugin.getPluginPreferences
which returns
a core runtime preferences object.initializeDefaultPreferences
to set up any default values for preferences using JFace API. In this
case, initializeDefaultPluginPreferences
should not be
overridden.initializeDefaultPluginPreferences
to set up any default
values for preferences using core runtime API. In this
case, initializeDefaultPreferences
should not be
overridden.getDialogSettings
is called.FN_DIALOG_STORE
. A dialog store file is first
looked for in the plug-in's read/write state area; if not found there,
the plug-in's install directory is checked.
This allows a plug-in to ship with a read-only copy of a dialog store
file containing initial values for certain settings.saveDialogSettings
to cause settings to
be saved in the plug-in's read/write state area. A plug-in may opt to do
this each time a wizard or dialog is closed to ensure the latest
information is always safe on disk.
For easy access to your plug-in object, use the singleton pattern. Declare a
static variable in your plug-in class for the singleton. Store the first
(and only) instance of the plug-in class in the singleton when it is created.
Then access the singleton when needed through a static getDefault
method.
Field Summary |
Fields inherited from class org.eclipse.core.runtime.Plugin |
PREFERENCES_DEFAULT_OVERRIDE_BASE_NAME, PREFERENCES_DEFAULT_OVERRIDE_FILE_NAME |
Constructor Summary | |
AbstractUIPlugin(IPluginDescriptor descriptor)
Creates an abstract UI plug-in runtime object for the given plug-in descriptor. |
Method Summary | |
protected ImageRegistry |
createImageRegistry()
Returns a new image registry for this plugin-in. |
IDialogSettings |
getDialogSettings()
Returns the dialog settings for this UI plug-in. |
ImageRegistry |
getImageRegistry()
Returns the image registry for this UI plug-in. |
IPreferenceStore |
getPreferenceStore()
Returns the preference store for this UI plug-in. |
IWorkbench |
getWorkbench()
Returns the Platform UI workbench. |
protected void |
initializeDefaultPluginPreferences()
The AbstractUIPlugin implementation of this
Plugin method forwards to
initializeDefaultPreferences(IPreferenceStore) . |
protected void |
initializeDefaultPreferences(IPreferenceStore store)
Initializes a preference store with default preference values for this plug-in. |
protected void |
initializeImageRegistry(ImageRegistry reg)
Initializes an image registry with images which are frequently used by the plugin-in. |
protected void |
loadDialogSettings()
Loads the dialog settings for this plug-in. |
protected void |
loadPreferenceStore()
Deprecated. As of Eclipse 2.0, a basic preference store exists for all plug-ins. This method now exists only for backwards compatibility. It is called as the plug-in's preference store is being initialized. The plug-ins preferences are loaded from the file regardless of what this method does. |
protected void |
refreshPluginActions()
Refreshes the actions for the plugin. |
protected void |
saveDialogSettings()
Saves this plug-in's dialog settings. |
protected void |
savePreferenceStore()
Deprecated. As of Eclipse 2.0, preferences exist for all plug-ins. The equivalent of this method is Plugin.savePluginPreferences .
This method now calls savePluginPreferences , and exists only for
backwards compatibility. |
void |
shutdown()
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). |
void |
startup()
The AbstractUIPlugin implementation of this Plugin
method refreshes the plug-in actions. |
Methods inherited from class org.eclipse.core.runtime.Plugin |
find, find, getDescriptor, getLog, getPluginPreferences, getStateLocation, isDebugging, openStream, openStream, savePluginPreferences, setDebugging, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public AbstractUIPlugin(IPluginDescriptor descriptor)
Note that instances of plug-in runtime classes are automatically created by the platform in the course of plug-in activation.
descriptor
- the plug-in descriptorMethod Detail |
protected ImageRegistry createImageRegistry()
The default implementation of this method creates an empty registry. Subclasses may override this method if needed.
getImageRegistry()
public IDialogSettings getDialogSettings()
If an error occurs reading the dialog store, an empty one is quietly created and returned.
Subclasses may override this method but are not expected to.
public ImageRegistry getImageRegistry()
The image registry contains the images used by this plug-in that are very frequently used and so need to be globally shared within the plug-in. Since many OSs have a severe limit on the number of images that can be in memory at any given time, a plug-in should only keep a small number of images in their registry.
Subclasses should reimplement initializeImageRegistry
if they have
custom graphic images to load.
Subclasses may override this method but are not expected to.
public IPreferenceStore getPreferenceStore()
If an error occurs reading the preference store, an empty preference store is quietly created, initialized with defaults, and returned.
Subclasses should reimplement initializeDefaultPreferences
if
they have custom graphic images to load.
public IWorkbench getWorkbench()
This method exists as a convenience for plugin implementors. The
workbench can also be accessed by invoking PlatformUI.getWorkbench()
.
protected void initializeDefaultPreferences(IPreferenceStore store)
This method is called after the preference store is initially loaded (default values are never stored in preference stores).
The default implementation of this method does nothing. Subclasses should reimplement this method if the plug-in has any preferences.
A subclass may reimplement this method to set default values for the
preference store using JFace API. This is the older way of initializing
default values. If this method is reimplemented, do not override
initializeDefaultPluginPreferences()
.
store
- the preference store to fillprotected void initializeDefaultPluginPreferences()
AbstractUIPlugin
implementation of this
Plugin
method forwards to
initializeDefaultPreferences(IPreferenceStore)
.
A subclass may reimplement this method to set default values for the core
runtime preference store in the standard way. This is the recommended way
to do this.
The older initializeDefaultPreferences(IPreferenceStore)
method
serves a similar purpose. If this method is reimplemented, do not send super,
and do not override initializeDefaultPreferences(IPreferenceStore)
.
initializeDefaultPluginPreferences
in class Plugin
initializeDefaultPreferences(org.eclipse.jface.preference.IPreferenceStore)
protected void initializeImageRegistry(ImageRegistry reg)
The image registry contains the images used by this plug-in that are very frequently used and so need to be globally shared within the plug-in. Since many OSs have a severe limit on the number of images that can be in memory at any given time, each plug-in should only keep a small number of images in its registry.
Implementors should create a JFace image descriptor for each frequently used image. The descriptors describe how to create/find the image should it be needed. The image described by the descriptor is not actually allocated until someone retrieves it.
Subclasses may override this method to fill the image registry.
getImageRegistry()
protected void loadDialogSettings()
This framework method may be overridden, although this is typically unnecessary.
protected void loadPreferenceStore()
This framework method may be overridden, although this is typically unnecessary.
protected void refreshPluginActions()
startup
.
This framework method may be overridden, although this is typically unnecessary.
protected void saveDialogSettings()
protected void savePreferenceStore()
Plugin.savePluginPreferences
.
This method now calls savePluginPreferences
, and exists only for
backwards compatibility.
Plugin.savePluginPreferences()
public void startup() throws CoreException
AbstractUIPlugin
implementation of this Plugin
method refreshes the plug-in actions. Subclasses may extend this method,
but must send super first.
WARNING: Plug-ins may not be started in the UI thread.
The startup()
method should not assume that its code runs in
the UI thread, otherwise SWT thread exceptions may occur on startup.
startup
in class Plugin
CoreException
- if this plug-in did not start up properlypublic void shutdown() throws CoreException
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 first.
shutdown
in class Plugin
CoreException
- if this method fails to shut down
this plug-in
|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |