KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > tools > CmsToolGroup


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/tools/CmsToolGroup.java,v $
3  * Date : $Date: 2005/06/24 11:24:57 $
4  * Version: $Revision: 1.11 $
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.tools;
33
34 import org.opencms.util.CmsIdentifiableObjectContainer;
35 import org.opencms.util.CmsStringUtil;
36 import org.opencms.workplace.CmsWorkplace;
37
38 import java.util.Iterator JavaDoc;
39 import java.util.List JavaDoc;
40
41 /**
42  * This is an admin tool group, it just generates the html code for
43  * the group structure.<p>
44  *
45  * @author Michael Moossen
46  *
47  * @version $Revision: 1.11 $
48  *
49  * @since 6.0.0
50  */

51 public class CmsToolGroup {
52
53     /** Container for the items. */
54     private final CmsIdentifiableObjectContainer m_container = new CmsIdentifiableObjectContainer(true, true);
55
56     /** Dhtml id. */
57     private final String JavaDoc m_id;
58
59     /** Display name. */
60     private final String JavaDoc m_name;
61
62     /**
63      * Default Constructor.<p>
64      *
65      * @param id a unique id
66      * @param name the name of the group
67      */

68     public CmsToolGroup(String JavaDoc id, String JavaDoc name) {
69
70         m_id = id;
71         m_name = name;
72     }
73
74     /**
75      * Adds an admin tool.<p>
76      *
77      * @param adminTool the admin tool
78      *
79      * @see org.opencms.util.I_CmsIdentifiableObjectContainer#addIdentifiableObject(String, Object)
80      */

81     public void addAdminTool(CmsTool adminTool) {
82
83         m_container.addIdentifiableObject(adminTool.getId(), adminTool);
84     }
85
86     /**
87      * Adds an admin tool at the given position.<p>
88      *
89      * @param adminTool the admin tool
90      * @param position the position
91      *
92      * @see org.opencms.util.I_CmsIdentifiableObjectContainer#addIdentifiableObject(String, Object, float)
93      */

94     public void addAdminTool(CmsTool adminTool, float position) {
95
96         m_container.addIdentifiableObject(adminTool.getId(), adminTool, position);
97     }
98
99     /**
100      * Retuns a list of admin tools.<p>
101      *
102      * @return a list of <code>{@link CmsTool}</code>s
103      */

104     public List JavaDoc getAdminTools() {
105
106         return m_container.elementList();
107     }
108
109     /**
110      * Returns the id.<p>
111      *
112      * @return the id
113      */

114     public String JavaDoc getId() {
115
116         return m_id;
117     }
118
119     /**
120      * Returns the group name.<p>
121      *
122      * @return the group name
123      */

124     public String JavaDoc getName() {
125
126         return m_name;
127     }
128
129     /**
130      * Returns the necessary html code.<p>
131      *
132      * @param wp the jsp page to write the code to
133      *
134      * @return html code
135      */

136     public String JavaDoc groupHtml(CmsWorkplace wp) {
137
138         StringBuffer JavaDoc html = new StringBuffer JavaDoc(2048);
139         Iterator JavaDoc itItem = m_container.elementList().iterator();
140         while (itItem.hasNext()) {
141             CmsTool item = (CmsTool)itItem.next();
142             html.append(item.buttonHtml(wp));
143         }
144         if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(html.toString())) {
145             html.insert(0, ((CmsToolDialog)wp).iconsBlockAreaStart(getName()));
146             html.append(((CmsToolDialog)wp).iconsBlockAreaEnd());
147         }
148         return html.toString();
149     }
150
151 }
Popular Tags