KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > explorer > core > menu > lib > BasicItemDescription


1 /*====================================================================
2
3 Objectweb Explorer Framework
4 Copyright (C) 2000-2004 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Moroy, Philippe Merle.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 package org.objectweb.util.explorer.core.menu.lib;
27
28 import org.objectweb.util.explorer.ExplorerUtils;
29 import org.objectweb.util.explorer.core.code.api.CodeDescription;
30 import org.objectweb.util.explorer.core.common.api.Description;
31 import org.objectweb.util.explorer.core.icon.api.IconDescription;
32 import org.objectweb.util.explorer.core.menu.api.AcceleratorDescription;
33 import org.objectweb.util.explorer.core.menu.api.ItemDescription;
34 import org.objectweb.util.explorer.core.menu.api.MnemonicDescription;
35
36 /**
37  * Basic implementation of the <code>ItemDescription</code> interface.
38  *
39  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jérôme Moroy</a>,
40  * <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>.
41  *
42  * @version 0.1
43  */

44 public class BasicItemDescription
45   implements ItemDescription
46 {
47
48     //==================================================================
49
//
50
// Internal States.
51
//
52
// ==================================================================
53

54     protected String JavaDoc label_;
55     protected boolean treeChildVisible_ = false;
56     protected boolean typeChildVisible_ = true;
57     protected CodeDescription codeDesc_;
58     protected IconDescription iconDesc_;
59     protected AcceleratorDescription acceleratorDesc_;
60     protected MnemonicDescription mnemonicDesc_;
61     
62     // ==================================================================
63
//
64
// Constructors.
65
//
66
// ==================================================================
67

68     // ==================================================================
69
//
70
// Internal methods.
71
//
72
// ==================================================================
73

74     /**
75      * Two ItemDescription are considered as equals if and only if
76      * they have the same label and the same CodeDescription.
77      */

78     protected boolean equals(BasicItemDescription itemDesc){
79         return ExplorerUtils.compareObjects(label_, itemDesc.label_)
80             && ExplorerUtils.compareObjects(codeDesc_, itemDesc.codeDesc_);
81     }
82   
83     // ==================================================================
84
//
85
// Public methods for Description interface.
86
//
87
// ==================================================================
88

89     /* (non-Javadoc)
90      * @see org.objectweb.util.explorer.core.common.api.Description#getDescriptionType()
91      */

92     public String JavaDoc getDescriptionType() {
93         return Description.ITEM_DESCRIPTION;
94     }
95
96
97     /* (non-Javadoc)
98      * @see boolean#isNull()
99      */

100     public boolean isEmpty() {
101         return label_==null || label_.equals("") || codeDesc_==null || codeDesc_.isEmpty();
102     }
103     
104     // ==================================================================
105
//
106
// Public methods for ItemDescription interface.
107
//
108
// ==================================================================
109

110     /* (non-Javadoc)
111      * @see org.objectweb.util.explorer.core.menu.api.ItemDescription#setLabel(java.lang.String)
112      */

113     public void setLabel(String JavaDoc label) {
114         label_ = label;
115     }
116
117     /* (non-Javadoc)
118      * @see org.objectweb.util.explorer.core.menu.api.ItemDescription#getLabel()
119      */

120     public String JavaDoc getLabel() {
121         return label_;
122     }
123
124     /* (non-Javadoc)
125      * @see org.objectweb.util.explorer.core.menu.api.ItemDescription#setTreeChildVisible(boolean)
126      */

127     public void setTreeChildVisible(boolean treeChildVisible) {
128         treeChildVisible_ = treeChildVisible;
129     }
130
131     /* (non-Javadoc)
132      * @see org.objectweb.util.explorer.core.menu.api.ItemDescription#getTreeChildVisible()
133      */

134     public boolean getTreeChildVisible() {
135         return treeChildVisible_;
136     }
137
138     /* (non-Javadoc)
139      * @see org.objectweb.util.explorer.core.menu.api.ItemDescription#setTypeChildVisible(boolean)
140      */

141     public void setTypeChildVisible(boolean typeChildVisible) {
142         typeChildVisible_ = typeChildVisible;
143     }
144
145     /* (non-Javadoc)
146      * @see org.objectweb.util.explorer.core.menu.api.ItemDescription#getTypeChildVisible()
147      */

148     public boolean getTypeChildVisible() {
149         return typeChildVisible_;
150     }
151
152     /* (non-Javadoc)
153      * @see org.objectweb.util.explorer.core.menu.api.ItemDescription#setCodeDescription(org.objectweb.util.explorer.core.code.api.CodeDescription)
154      */

155     public void setCodeDescription(CodeDescription codeDescription) {
156         codeDesc_ = codeDescription;
157     }
158
159     /* (non-Javadoc)
160      * @see org.objectweb.util.explorer.core.menu.api.ItemDescription#getCodeDescription()
161      */

162     public CodeDescription getCodeDescription() {
163         return codeDesc_;
164     }
165
166     /* (non-Javadoc)
167      * @see org.objectweb.util.explorer.core.menu.api.ItemDescription#setIconDescription(org.objectweb.util.explorer.core.icon.api.IconDescription)
168      */

169     public void setIconDescription(IconDescription iconDescription) {
170         iconDesc_ = iconDescription;
171     }
172
173     /* (non-Javadoc)
174      * @see org.objectweb.util.explorer.core.menu.api.ItemDescription#getIconDescription()
175      */

176     public IconDescription getIconDescription() {
177         return iconDesc_;
178     }
179
180     /* (non-Javadoc)
181      * @see org.objectweb.util.explorer.core.menu.api.ItemDescription#setAcceleratorDescription(org.objectweb.util.explorer.core.menu.api.AcceleratorDescription)
182      */

183     public void setAcceleratorDescription(AcceleratorDescription acceleratorDescription) {
184         acceleratorDesc_ = acceleratorDescription;
185     }
186
187     /* (non-Javadoc)
188      * @see org.objectweb.util.explorer.core.menu.api.ItemDescription#getAcceleratorDescription()
189      */

190     public AcceleratorDescription getAcceleratorDescription() {
191         return acceleratorDesc_;
192     }
193
194     /* (non-Javadoc)
195      * @see org.objectweb.util.explorer.core.menu.api.ItemDescription#setMnemonicDescription(org.objectweb.util.explorer.core.menu.api.MnemonicDescription)
196      */

197     public void setMnemonicDescription(MnemonicDescription mnemonicDescription) {
198         mnemonicDesc_ = mnemonicDescription;
199     }
200
201     /* (non-Javadoc)
202      * @see org.objectweb.util.explorer.core.menu.api.ItemDescription#getMnemonicDescription()
203      */

204     public MnemonicDescription getMnemonicDescription() {
205         return mnemonicDesc_;
206     }
207     
208     // ==================================================================
209
//
210
// Public methods surcharging Object class.
211
//
212
// ==================================================================
213

214     /**
215      * Surcharging the Object.equals method.
216      * @see DefaultKey#equals(DefaultKey)
217      */

218     public boolean equals(Object JavaDoc o){
219         if(o!=null && o instanceof BasicItemDescription)
220             return equals((BasicItemDescription)o);
221         return false;
222     }
223     
224     /**
225      * Return a String representation of a BasicItemDescription
226      */

227     public String JavaDoc toString(){
228         return "BasicItemDescription[" +
229                 "label=" + ExplorerUtils.toString(label_) +
230                 ", treeChildVisible=" + treeChildVisible_ +
231                 ", typeChildVisible=" + typeChildVisible_ +
232                 ", codeDesc=" + ExplorerUtils.toString(codeDesc_) +
233                 ", iconDesc=" + ExplorerUtils.toString(iconDesc_) +
234                 ", acceleratorDesc=" + ExplorerUtils.toString(acceleratorDesc_) +
235                 ", mnemonicDesc=" + ExplorerUtils.toString(mnemonicDesc_) +
236                 "]";
237     }
238     
239 }
240
241
242
Popular Tags