|
Color and font management
When using forms in a non-trivial way, it is important to share
as much as possible to conserve resources. For this reason, color management
should be separated from the toolkit when there are more than one form to
handle.
Of course, it is possible to create one toolkit per form, but
that is too wasteful if there are many forms. Instead:
-
Create one toolkit for all the forms that have the same life
cycle. For example, if creating a multi-page editor, create one toolkit per
editor and dispose it when editor is disposed. All the pages in the editor
should share this toolkit.
-
Create one color manager (FormColors ) per
plug-in. When creating the toolkit, pass the color manager to the toolkit.
The toolkit will know that the colors are shared and will not dispose them.
-
Use platform support for fonts and if possible, use
JFaceResources predefined fonts. Between default, 'banner' and
'header' fonts, you can accomplish a lot. Using many fonts is very confusing
for the user, and if you do manage your own, you must ensure alternatives
across platforms. The JFace fonts are guaranteed to work on all the
platforms Eclipse ships on.
-
Dispose the color manager on plug-in shutdown (don't assume
that plug-in shutdown also means platform shutdown - Eclipse runtime can
uninstall your plug-in dynamically while the platform is still running).
-
Use form color manager to allocate all the colors needed by
the forms.
|
|