KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > administration > CmsAdminMenuItem


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/administration/CmsAdminMenuItem.java,v $
3  * Date : $Date: 2006/03/27 14:52:20 $
4  * Version: $Revision: 1.13 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.workplace.administration;
33
34 import org.opencms.workplace.CmsWorkplace;
35 import org.opencms.workplace.tools.A_CmsHtmlIconButton;
36 import org.opencms.workplace.tools.CmsHtmlIconButtonStyleEnum;
37 import org.opencms.workplace.tools.CmsToolMacroResolver;
38
39 /**
40  * Html icon button implementation that generates the
41  * required html code for a menu item.<p>
42  *
43  * @author Michael Moossen
44  *
45  * @version $Revision: 1.13 $
46  *
47  * @since 6.0.0
48  */

49 public class CmsAdminMenuItem {
50
51     /** Enabled flag. */
52     private boolean m_enabled;
53
54     /** Help text. */
55     private final String JavaDoc m_helpText;
56
57     /** Path to the icon. */
58     private final String JavaDoc m_iconPath;
59
60     /** Dhtml id, from name. */
61     private final String JavaDoc m_id;
62
63     /** Link to follow when selected. */
64     private final String JavaDoc m_link;
65
66     /** Display name of the item. */
67     private final String JavaDoc m_name;
68
69     /** Target frame. */
70     private final String JavaDoc m_target;
71
72     /**
73      * Default Constructor.<p>
74      *
75      * @param id a unique id
76      * @param name the name of the item
77      * @param iconPath the icon to display
78      * @param link the link to open when selected
79      * @param helpText the help text to display
80      * @param enabled if enabled or not
81      * @param target the target frame to open the link into
82      */

83     public CmsAdminMenuItem(
84         String JavaDoc id,
85         String JavaDoc name,
86         String JavaDoc iconPath,
87         String JavaDoc link,
88         String JavaDoc helpText,
89         boolean enabled,
90         String JavaDoc target) {
91
92         m_id = id;
93         m_name = name;
94         m_iconPath = iconPath;
95         m_link = link;
96         m_helpText = helpText;
97         m_enabled = enabled;
98         m_target = target;
99     }
100
101     /**
102      * Returns the help text.<p>
103      *
104      * @return the help text
105      */

106     public String JavaDoc getHelpText() {
107
108         return m_helpText;
109     }
110
111     /**
112      * Returns the path to the icon.<p>
113      *
114      * @return the path to the icon
115      */

116     public String JavaDoc getIconPath() {
117
118         return m_iconPath;
119     }
120
121     /**
122      * Returns the dhtml unique id.<p>
123      *
124      * @return the dhtml unique id
125      */

126     public String JavaDoc getId() {
127
128         return m_id;
129     }
130
131     /**
132      * Returns the link.<p>
133      *
134      * @return the link
135      */

136     public String JavaDoc getLink() {
137
138         return m_link;
139     }
140
141     /**
142      * Returns the display name.<p>
143      *
144      * @return the name
145      */

146     public String JavaDoc getName() {
147
148         return m_name;
149     }
150
151     /**
152      * Returns the target.<p>
153      *
154      * @return the target
155      */

156     public String JavaDoc getTarget() {
157
158         return m_target;
159     }
160
161     /**
162      * Returns if enabled or disabled.<p>
163      *
164      * @return if enabled or disabled
165      */

166     public boolean isEnabled() {
167
168         return m_enabled;
169     }
170
171     /**
172      * Returns the necessary html code.<p>
173      *
174      * @param wp the workplace
175      *
176      * @return html code
177      */

178     public String JavaDoc itemHtml(CmsWorkplace wp) {
179
180         StringBuffer JavaDoc html = new StringBuffer JavaDoc(1024);
181         html.append("<table border='0' cellspacing='0' cellpadding='0' width='100%' class='node' id='");
182         html.append(getId());
183         html.append("'>\n");
184         html.append("\t<tr>\n");
185         html.append("\t\t<td>\n");
186         String JavaDoc onClic = "return openView('" + getId() + "', '" + m_link + "', '" + m_target + "');";
187         html.append(A_CmsHtmlIconButton.defaultButtonHtml(
188             wp.getJsp(),
189             CmsHtmlIconButtonStyleEnum.SMALL_ICON_TEXT,
190             getId(),
191             getName(),
192             getHelpText(),
193             isEnabled(),
194             getIconPath(),
195             null,
196             onClic));
197
198         html.append("\t\t</td>\n");
199         html.append("\t</tr>\n");
200         html.append("</table>\n");
201         return CmsToolMacroResolver.resolveMacros(html.toString(), wp);
202     }
203
204 }
Popular Tags