| java.lang.Object org.eclipse.ui.internal.util.Descriptors
Descriptors | final public class Descriptors (Code) | | Contains a bunch of helper methods that allow JFace resource descriptors to be passed
directly to SWT widgets without worrying about resource allocation. This class is internal,
but it should be moved into JFace if the pattern is found generally useful. The current
implementation uses a lot of reflection to save repeated code, but this could all be inlined
(without reflection) if performance turns out to be a problem.
For example, an Image might be passed to a TableItem as follows:
ImageDescriptor someDescriptor = ...;
TableItem someTableItem = ...;
ResourceManager manager = JFaceResources.getResources();
Image actualImage = manager.createImage(someDescriptor);
someTableItem.setImage(actualImage);
// do something with the table item
someTableItem.dispose();
manager.destroyImage(someDescriptor);
It is much more convenient to do the following:
ImageDescriptor someDescriptor = ...;
TableItem someTableItem = ...;
Descriptors.setImage(someTableItem, someDescriptor);
// do something with the table item
someTableItem.dispose();
This class tries to behave as if the table item itself had a set method that took a descriptor.
Resource allocation and deallocation happens for free. All the methods are leakproof. That is,
if any images, colors, etc. need to be allocated and passed to the SWT widget, they will be
deallocated automatically when the widget goes away (the implementation hooks a dispose listener
on the widget which cleans up as soon as the widget is disposed).
since: 3.1 |
Method Summary | |
public static void | setBackground(TableItem item, ColorDescriptor descriptor) | public static void | setBackground(Control control, ColorDescriptor descriptor) | public static void | setDisabledImage(ToolItem item, ImageDescriptor descriptor) | public static void | setFont(TableItem item, FontDescriptor descriptor) | public static void | setForeground(TableItem item, ColorDescriptor descriptor) | public static void | setForeground(Control control, ColorDescriptor descriptor) | public static void | setHotImage(ToolItem item, ImageDescriptor descriptor) | public static void | setImage(Item item, ImageDescriptor descriptor) Sets the image on the given ToolItem. | public static void | setImage(Button button, ImageDescriptor descriptor) | public static void | setImage(Label label, ImageDescriptor descriptor) |
setBackground | public static void setBackground(TableItem item, ColorDescriptor descriptor)(Code) | | |
setBackground | public static void setBackground(Control control, ColorDescriptor descriptor)(Code) | | |
setDisabledImage | public static void setDisabledImage(ToolItem item, ImageDescriptor descriptor)(Code) | | |
setFont | public static void setFont(TableItem item, FontDescriptor descriptor)(Code) | | |
setForeground | public static void setForeground(TableItem item, ColorDescriptor descriptor)(Code) | | |
setForeground | public static void setForeground(Control control, ColorDescriptor descriptor)(Code) | | |
setHotImage | public static void setHotImage(ToolItem item, ImageDescriptor descriptor)(Code) | | |
setImage | public static void setImage(Item item, ImageDescriptor descriptor)(Code) | | Sets the image on the given ToolItem. The image will be automatically allocated and
disposed as needed.
since: 3.1 Parameters: item - Parameters: descriptor - |
setImage | public static void setImage(Button button, ImageDescriptor descriptor)(Code) | | |
setImage | public static void setImage(Label label, ImageDescriptor descriptor)(Code) | | |
|
|