001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/tools/CmsToolGroup.java,v $
003: * Date : $Date: 2008-02-27 12:05:31 $
004: * Version: $Revision: 1.14 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.workplace.tools;
033:
034: import org.opencms.util.CmsStringUtil;
035: import org.opencms.workplace.CmsWorkplace;
036:
037: import java.util.Iterator;
038: import java.util.List;
039:
040: /**
041: * This is an admin tool group, it just generates the html code for
042: * the group structure.<p>
043: *
044: * @author Michael Moossen
045: *
046: * @version $Revision: 1.14 $
047: *
048: * @since 6.0.0
049: */
050: public class CmsToolGroup {
051:
052: /** Container for the items. */
053: private final CmsIdentifiableObjectContainer m_container = new CmsIdentifiableObjectContainer(
054: true, true);
055:
056: /** Dhtml id. */
057: private final String m_id;
058:
059: /** Display name. */
060: private final String m_name;
061:
062: /**
063: * Default Constructor.<p>
064: *
065: * @param id a unique id
066: * @param name the name of the group
067: */
068: public CmsToolGroup(String id, String name) {
069:
070: m_id = id;
071: m_name = name;
072: }
073:
074: /**
075: * Adds an admin tool.<p>
076: *
077: * @param adminTool the admin tool
078: *
079: * @see org.opencms.workplace.tools.I_CmsIdentifiableObjectContainer#addIdentifiableObject(String, Object)
080: */
081: public void addAdminTool(CmsTool adminTool) {
082:
083: m_container.addIdentifiableObject(adminTool.getId(), adminTool);
084: }
085:
086: /**
087: * Adds an admin tool at the given position.<p>
088: *
089: * @param adminTool the admin tool
090: * @param position the position
091: *
092: * @see org.opencms.workplace.tools.I_CmsIdentifiableObjectContainer#addIdentifiableObject(String, Object, float)
093: */
094: public void addAdminTool(CmsTool adminTool, float position) {
095:
096: m_container.addIdentifiableObject(adminTool.getId(), adminTool,
097: position);
098: }
099:
100: /**
101: * Retuns a list of admin tools.<p>
102: *
103: * @return a list of <code>{@link CmsTool}</code>s
104: */
105: public List getAdminTools() {
106:
107: return m_container.elementList();
108: }
109:
110: /**
111: * Returns the id.<p>
112: *
113: * @return the id
114: */
115: public String getId() {
116:
117: return m_id;
118: }
119:
120: /**
121: * Returns the group name.<p>
122: *
123: * @return the group name
124: */
125: public String getName() {
126:
127: return m_name;
128: }
129:
130: /**
131: * Returns the necessary html code.<p>
132: *
133: * @param wp the jsp page to write the code to
134: *
135: * @return html code
136: */
137: public String groupHtml(CmsWorkplace wp) {
138:
139: StringBuffer html = new StringBuffer(2048);
140: Iterator itItem = m_container.elementList().iterator();
141: while (itItem.hasNext()) {
142: CmsTool item = (CmsTool) itItem.next();
143: html.append(item.buttonHtml(wp));
144: }
145: if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(html.toString())) {
146: html.insert(0, ((CmsToolDialog) wp)
147: .iconsBlockAreaStart(getName()));
148: html.append(((CmsToolDialog) wp).iconsBlockAreaEnd());
149: }
150: return html.toString();
151: }
152:
153: }
|