KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > fieldassist > FieldDecoration


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jface.fieldassist;
12
13 import org.eclipse.swt.graphics.Image;
14
15 /**
16  * FieldDecoration is a simple data structure class for specifying a decoration
17  * for a field. A decoration may be rendered in different ways depending on the
18  * type of field it is used with.
19  *
20  * @see FieldDecorationRegistry
21  *
22  * @since 3.2
23  */

24 public class FieldDecoration {
25
26     /*
27      * The image to be shown in the decoration.
28      */

29     private Image image;
30
31     /*
32      * The description to show in the decoration's hover.
33      */

34     private String JavaDoc description;
35
36     /**
37      * Create a decoration for a field with the specified image and description
38      * text.
39      *
40      * @param image
41      * the image shown in the decoration. A <code>null</code> image
42      * will result in a blank decoration, which may be used to
43      * reserve space near the field.
44      * @param description
45      * the description shown when the user hovers over the
46      * decoration. A <code>null</code> description indicates that
47      * there will be no hover for the decoration.
48      */

49     public FieldDecoration(Image image, String JavaDoc description) {
50         this.image = image;
51         this.description = description;
52     }
53
54     /**
55      * Return the image shown in the decoration, or <code>null</code> if no
56      * image is specified.
57      *
58      * @return the image shown in the decoration. A return value of
59      * <code>null</code> signifies a blank decoration.
60      */

61     public Image getImage() {
62         return image;
63     }
64
65     /**
66      * Set the image shown in the decoration, or <code>null</code> if no image
67      * is specified. It is up to the caller to update any decorated fields that
68      * are showing the description in order to display the new image.
69      *
70      * @param image
71      * the image shown in the decoration. A value of
72      * <code>null</code> signifies a blank decoration.
73      */

74     public void setImage(Image image) {
75         this.image = image;
76     }
77
78     /**
79      * Return the description for the decoration shown when the user hovers over
80      * the decoration.
81      *
82      * @return the String description of the decoration. A return value of
83      * <code>null</code> indicates that no description will be shown.
84      */

85     public String JavaDoc getDescription() {
86         return description;
87     }
88
89     /**
90      * Set the description for the decoration shown when the user hovers over
91      * the decoration. It is up to the caller to update any decorated fields
92      * showing the description.
93      *
94      * @param description
95      * the String description of the decoration. A value of
96      * <code>null</code> indicates that no description will be
97      * shown.
98      */

99     public void setDescription(String JavaDoc description) {
100         this.description = description;
101     }
102 }
103
Popular Tags