001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/list/CmsListRadioMultiAction.java,v $
003: * Date : $Date: 2008-02-27 12:05:28 $
004: * Version: $Revision: 1.5 $
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.list;
033:
034: import org.opencms.util.CmsStringUtil;
035: import org.opencms.workplace.CmsWorkplace;
036: import org.opencms.workplace.tools.A_CmsHtmlIconButton;
037: import org.opencms.workplace.tools.CmsHtmlIconButtonStyleEnum;
038:
039: import java.util.Iterator;
040: import java.util.List;
041:
042: /**
043: * Default implementation of a list radio multi action.<p>
044: *
045: * @author Michael Moossen
046: *
047: * @version $Revision: 1.5 $
048: *
049: * @since 6.0.0
050: */
051: public class CmsListRadioMultiAction extends CmsListMultiAction {
052:
053: /** A list of ids of related list item selection action ids. */
054: private final List m_relatedActionIds;
055:
056: /**
057: * Default Constructor.<p>
058: *
059: * @param id the unique id
060: * @param relatedActionIds the ids of the related item selection actions
061: */
062: public CmsListRadioMultiAction(String id, List relatedActionIds) {
063:
064: super (id);
065: m_relatedActionIds = relatedActionIds;
066: }
067:
068: /**
069: * @see org.opencms.workplace.tools.I_CmsHtmlIconButton#buttonHtml(CmsWorkplace)
070: */
071: public String buttonHtml(CmsWorkplace wp) {
072:
073: if (!isVisible()) {
074: return "";
075: }
076: if (isEnabled()) {
077: String onClic = "listRSelMAction('"
078: + getListId()
079: + "','"
080: + getId()
081: + "', '"
082: + CmsStringUtil.escapeJavaScript(wp
083: .resolveMacros(getConfirmationMessage()
084: .key(wp.getLocale()))) + "', "
085: + CmsHtmlList.NO_SELECTION_MATCH_HELP_VAR + getId()
086: + ", '" + getRelatedActionIds() + "');";
087: return A_CmsHtmlIconButton.defaultButtonHtml(
088: CmsHtmlIconButtonStyleEnum.SMALL_ICON_TEXT,
089: getId(), getName().key(wp.getLocale()),
090: getHelpText().key(wp.getLocale()), isEnabled(),
091: getIconPath(), null, onClic);
092: }
093: return "";
094: }
095:
096: /**
097: * Returns the number of expected selections.<p>
098: *
099: * @return the number of expected selections
100: */
101: public int getSelections() {
102:
103: return m_relatedActionIds.size();
104: }
105:
106: /**
107: * Returns a comma separated list of related list iem selection action ids.<p>
108: *
109: * @return a comma separated list of related list iem selection action ids
110: */
111: private String getRelatedActionIds() {
112:
113: StringBuffer ret = new StringBuffer(32);
114: Iterator it = m_relatedActionIds.iterator();
115: while (it.hasNext()) {
116: ret.append(it.next().toString().trim());
117: if (it.hasNext()) {
118: ret.append(',');
119: }
120: }
121: return ret.toString();
122: }
123: }
|