|
|||||||||
| Home >> All >> org >> eclipse >> ui >> [ plugin overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.eclipse.ui.plugin
Class AbstractUIPlugin

java.lang.Objectorg.eclipse.core.runtime.Plugin
org.eclipse.ui.plugin.AbstractUIPlugin
- All Implemented Interfaces:
- org.osgi.framework.BundleActivator
- public abstract class AbstractUIPlugin
- extends org.eclipse.core.runtime.Plugin
Abstract base class for plug-ins that integrate with the Eclipse platform UI.
Subclasses obtain the following capabilities:
Preferences
- The platform core runtime contains general support for plug-in
preferences (
org.eclipse.core.runtime.Preferences). This class provides appropriate conversion to the older JFace preference API (org.eclipse.jface.preference.IPreferenceStore). - The method
getPreferenceStorereturns the JFace preference store (cf.Plugin.getPluginPreferenceswhich returns a core runtime preferences object. - Subclasses may reimplement
initializeDefaultPreferencesto set up any default values for preferences using JFace API. In this case,initializeDefaultPluginPreferencesshould not be overridden. - Subclasses may reimplement
initializeDefaultPluginPreferencesto set up any default values for preferences using core runtime API. In this case,initializeDefaultPreferencesshould not be overridden. - Preferences are also saved automatically on plug-in shutdown. However, saving preferences immediately after changing them is strongly recommended, since that ensures that preference settings are not lost even in the event of a platform crash.
- The dialog store is read the first time
getDialogSettingsis called. - The dialog store allows the plug-in to "record" important choices made by the user in a wizard or dialog, so that the next time the wizard/dialog is used the widgets can be defaulted to better values. A wizard could also use it to record the last 5 values a user entered into an editable combo - to show "recent values".
- The dialog store is found in the file whose name is given by the
constant
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. - Plug-in code can call
saveDialogSettingsto 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. - Dialog settings are also saved automatically on plug-in shutdown.
- A typical UI plug-in will have some images that are used very frequently and so need to be cached and shared. The plug-in's image registry provides a central place for a plug-in to store its common images. Images managed by the registry are created lazily as needed, and will be automatically disposed of when the plug-in shuts down. Note that the number of registry images should be kept to a minimum since many OSs have severe limits on the number of images that can be in memory at once.
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.
See the description on org.eclipse.core.runtime.Plugin.
| Nested Class Summary | |
private class |
AbstractUIPlugin.CompatibilityPreferenceStore
Internal implementation of a JFace preference store atop a core runtime preference store. |
| Field Summary | |
private org.osgi.framework.BundleListener |
bundleListener
The bundle listener used for kicking off refreshPluginActions(). |
private org.eclipse.jface.dialogs.DialogSettings |
dialogSettings
Storage for dialog and wizard data; null if not yet
initialized. |
private static java.lang.String |
FN_DIALOG_SETTINGS
The name of the dialog settings file (value "dialog_settings.xml"). |
private org.eclipse.jface.resource.ImageRegistry |
imageRegistry
The registry for all graphic images; null if not yet
initialized. |
private AbstractUIPlugin.CompatibilityPreferenceStore |
preferenceStore
Storage for preferences. |
| Fields inherited from class org.eclipse.core.runtime.Plugin |
PLUGIN_PREFERENCE_SCOPE, PREFERENCES_DEFAULT_OVERRIDE_BASE_NAME, PREFERENCES_DEFAULT_OVERRIDE_FILE_NAME |
| Constructor Summary | |
AbstractUIPlugin()
Creates an abstract UI plug-in runtime object. |
|
AbstractUIPlugin(org.eclipse.core.runtime.IPluginDescriptor descriptor)
Deprecated. In Eclipse 3.0 this constructor has been replaced by AbstractUIPlugin() 55 . Implementations of
MyPlugin(IPluginDescriptor descriptor) should be changed to
MyPlugin() and call super() instead of
super(descriptor).
The MyPlugin(IPluginDescriptor descriptor) constructor is
called only for plug-ins which explicitly require the
org.eclipse.core.runtime.compatibility plug-in (or, as in this case,
subclasses which might). |
|
| Method Summary | |
protected org.eclipse.jface.resource.ImageRegistry |
createImageRegistry()
Returns a new image registry for this plugin-in. |
org.eclipse.jface.dialogs.IDialogSettings |
getDialogSettings()
Returns the dialog settings for this UI plug-in. |
org.eclipse.jface.resource.ImageRegistry |
getImageRegistry()
Returns the image registry for this UI plug-in. |
org.eclipse.jface.preference.IPreferenceStore |
getPreferenceStore()
Returns the preference store for this UI plug-in. |
org.eclipse.ui.IWorkbench |
getWorkbench()
Returns the Platform UI workbench. |
static org.eclipse.jface.resource.ImageDescriptor |
imageDescriptorFromPlugin(java.lang.String pluginId,
java.lang.String imageFilePath)
Creates and returns a new image descriptor for an image file located within the specified plug-in. |
protected void |
initializeDefaultPluginPreferences()
Deprecated. this is only called if the runtime compatibility layer is present. See the deprecated comment in Plugin.initializeDefaultPluginPreferences()> Plugin.initializeDefaultPluginPreferences() 55 . |
protected void |
initializeDefaultPreferences(org.eclipse.jface.preference.IPreferenceStore store)
Deprecated. this is only called if the runtime compatibility layer is present. See initializeDefaultPluginPreferences() 55 . |
protected void |
initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry reg)
Initializes an image registry with images which are frequently used by the plugin. |
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()
Deprecated. In Eclipse 3.0, shutdown has been replaced by Plugin.stop(BundleContext context)>Plugin.stop(BundleContext context) 55 .
Implementations of shutdown should be changed to extend
stop(BundleContext context) and call super.stop(context)
instead of super.shutdown(). Unlike super.shutdown(),
super.stop(context) must be called as the very last thing rather
than as the very first thing. The shutdown method is called
only for plug-ins which explicitly require the
org.eclipse.core.runtime.compatibility plug-in;
in contrast, the stop method is always called. |
void |
start(org.osgi.framework.BundleContext context)
The AbstractUIPlugin implementation of this Plugin
method refreshes the plug-in actions. |
void |
startup()
Deprecated. In Eclipse 3.0, startup has been replaced by Plugin.start(BundleContext context)>Plugin.start(BundleContext context) 55 .
Implementations of startup should be changed to extend
start(BundleContext context) and call super.start(context)
instead of super.startup(). Like super.startup(),
super.stop(context) must be called as the very first thing.
The startup method is called only for plug-ins which explicitly require the
org.eclipse.core.runtime.compatibility plug-in; in contrast,
the start method is always called. |
void |
stop(org.osgi.framework.BundleContext context)
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). |
| Methods inherited from class org.eclipse.core.runtime.Plugin |
find, find, getBundle, getDescriptor, getLog, getPluginPreferences, getStateLocation, internalInitializeDefaultPluginPreferences, isDebugging, openStream, openStream, savePluginPreferences, setDebugging, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
FN_DIALOG_SETTINGS
private static final java.lang.String FN_DIALOG_SETTINGS
- The name of the dialog settings file (value
"dialog_settings.xml").- See Also:
- Constant Field Values
dialogSettings
private org.eclipse.jface.dialogs.DialogSettings dialogSettings
- Storage for dialog and wizard data;
nullif not yet initialized.
preferenceStore
private AbstractUIPlugin.CompatibilityPreferenceStore preferenceStore
- Storage for preferences.
imageRegistry
private org.eclipse.jface.resource.ImageRegistry imageRegistry
- The registry for all graphic images;
nullif not yet initialized.
bundleListener
private org.osgi.framework.BundleListener bundleListener
- The bundle listener used for kicking off refreshPluginActions().
- Since:
- 3.0.1
| Constructor Detail |
AbstractUIPlugin
public AbstractUIPlugin(org.eclipse.core.runtime.IPluginDescriptor descriptor)
- Deprecated. In Eclipse 3.0 this constructor has been replaced by
AbstractUIPlugin()55 . Implementations ofMyPlugin(IPluginDescriptor descriptor)should be changed toMyPlugin()and callsuper()instead ofsuper(descriptor). TheMyPlugin(IPluginDescriptor descriptor)constructor is called only for plug-ins which explicitly require the org.eclipse.core.runtime.compatibility plug-in (or, as in this case, subclasses which might).- Creates an abstract UI plug-in runtime object for the given plug-in descriptor.
Note that instances of plug-in runtime classes are automatically created by the platform in the course of plug-in activation.
- Creates an abstract UI plug-in runtime object for the given plug-in descriptor.
AbstractUIPlugin
public AbstractUIPlugin()
- Creates an abstract UI plug-in runtime object.
Plug-in runtime classes are
BundleActivatorsand so must have an default constructor. This method is called by the runtime when the associated bundle is being activated.For more details, see
Plugin's default constructor. - Since:
- 3.0
| Method Detail |
createImageRegistry
protected org.eclipse.jface.resource.ImageRegistry createImageRegistry()
- Returns a new image registry for this plugin-in. The registry will be
used to manage images which are frequently used by the plugin-in.
The default implementation of this method creates an empty registry. Subclasses may override this method if needed.
getDialogSettings
public org.eclipse.jface.dialogs.IDialogSettings getDialogSettings()
- Returns the dialog settings for this UI plug-in.
The dialog settings is used to hold persistent state data for the various
wizards and dialogs of this plug-in in the context of a workbench.
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.
getImageRegistry
public org.eclipse.jface.resource.ImageRegistry getImageRegistry()
- Returns the image registry for this UI plug-in.
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
initializeImageRegistryif they have custom graphic images to load.Subclasses may override this method but are not expected to.
getPreferenceStore
public org.eclipse.jface.preference.IPreferenceStore getPreferenceStore()
- Returns the preference store for this UI plug-in.
This preference store is used to hold persistent settings for this plug-in in
the context of a workbench. Some of these settings will be user controlled,
whereas others may be internal setting that are never exposed to the user.
If an error occurs reading the preference store, an empty preference store is quietly created, initialized with defaults, and returned.
Subclasses should reimplement
initializeDefaultPreferencesif they have custom graphic images to load.
getWorkbench
public org.eclipse.ui.IWorkbench getWorkbench()
- Returns the Platform UI workbench.
This method exists as a convenience for plugin implementors. The workbench can also be accessed by invoking
PlatformUI.getWorkbench().
initializeDefaultPreferences
protected void initializeDefaultPreferences(org.eclipse.jface.preference.IPreferenceStore store)
- Deprecated. this is only called if the runtime compatibility layer is
present. See
initializeDefaultPluginPreferences()55 .- Initializes a preference store with default preference values for this plug-in.
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(). - Initializes a preference store with default preference values for this plug-in.
initializeDefaultPluginPreferences
protected void initializeDefaultPluginPreferences()
- Deprecated. this is only called if the runtime compatibility layer is
present. See the deprecated comment in
Plugin.initializeDefaultPluginPreferences()>
Plugin.initializeDefaultPluginPreferences()55 .- The
AbstractUIPluginimplementation of thisPluginmethod forwards toinitializeDefaultPreferences(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 overrideinitializeDefaultPreferences(IPreferenceStore).- Since:
- 2.0
- The
initializeImageRegistry
protected void initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry reg)
- Initializes an image registry with images which are frequently used by the
plugin.
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.
loadDialogSettings
protected void loadDialogSettings()
- Loads the dialog settings for this plug-in.
The default implementation first looks for a standard named file in the
plug-in's read/write state area; if no such file exists, the plug-in's
install directory is checked to see if one was installed with some default
settings; if no file is found in either place, a new empty dialog settings
is created. If a problem occurs, an empty settings is silently used.
This framework method may be overridden, although this is typically unnecessary.
loadPreferenceStore
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.
- Loads the preference store for this plug-in. The default implementation looks for a standard named file in the plug-in's read/write state area. If no file is found or a problem occurs, a new empty preference store is silently created.
This framework method may be overridden, although this is typically unnecessary.
- Loads the preference store for this plug-in. The default implementation looks for a standard named file in the plug-in's read/write state area. If no file is found or a problem occurs, a new empty preference store is silently created.
refreshPluginActions
protected void refreshPluginActions()
- Refreshes the actions for the plugin.
This method is called from
startup.This framework method may be overridden, although this is typically unnecessary.
saveDialogSettings
protected void saveDialogSettings()
- Saves this plug-in's dialog settings.
Any problems which arise are silently ignored.
savePreferenceStore
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 callssavePluginPreferences, and exists only for backwards compatibility.- Saves this plug-in's preference store. Any problems which arise are silently ignored.
- Saves this plug-in's preference store. Any problems which arise are silently ignored.
startup
public void startup()
throws org.eclipse.core.runtime.CoreException
- Deprecated. In Eclipse 3.0,
startuphas been replaced by Plugin.start(BundleContext context)>Plugin.start(BundleContext context)55 . Implementations ofstartupshould be changed to extendstart(BundleContext context)and callsuper.start(context)instead ofsuper.startup(). Likesuper.startup(),super.stop(context)must be called as the very first thing. Thestartupmethod is called only for plug-ins which explicitly require the org.eclipse.core.runtime.compatibility plug-in; in contrast, thestartmethod is always called.- The
AbstractUIPluginimplementation of thisPluginmethod does nothing. 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.' - The
shutdown
public void shutdown()
throws org.eclipse.core.runtime.CoreException
- Deprecated. In Eclipse 3.0,
shutdownhas been replaced by Plugin.stop(BundleContext context)>Plugin.stop(BundleContext context)55 . Implementations ofshutdownshould be changed to extendstop(BundleContext context)and callsuper.stop(context)instead ofsuper.shutdown(). Unlikesuper.shutdown(),super.stop(context)must be called as the very last thing rather than as the very first thing. Theshutdownmethod is called only for plug-ins which explicitly require the org.eclipse.core.runtime.compatibility plug-in; in contrast, thestopmethod is always called.- The
AbstractUIPluginimplementation of thisPluginmethod does nothing. Subclasses may extend this method, but must send super first. - The
start
public void start(org.osgi.framework.BundleContext context) throws java.lang.Exception
- The
AbstractUIPluginimplementation of thisPluginmethod refreshes the plug-in actions. Subclasses may extend this method, but must send super first. null- Since:
- 3.0
stop
public void stop(org.osgi.framework.BundleContext context) throws java.lang.Exception
- The
AbstractUIPluginimplementation of thisPluginmethod 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.shutdown()is always done. null- Since:
- 3.0
imageDescriptorFromPlugin
public static org.eclipse.jface.resource.ImageDescriptor imageDescriptorFromPlugin(java.lang.String pluginId, java.lang.String imageFilePath)
- Creates and returns a new image descriptor for an image file located
within the specified plug-in.
This is a convenience method that simply locates the image file in within the plug-in (no image registries are involved). The path is relative to the root of the plug-in, and takes into account files coming from plug-in fragments. The path may include $arg$ elements. However, the path must not have a leading "." or path separator. Clients should use a path like "icons/mysample.gif" rather than "./icons/mysample.gif" or "/icons/mysample.gif".
- Since:
- 3.0
|
|||||||||
| Home >> All >> org >> eclipse >> ui >> [ plugin overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC