KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > list > A_CmsListAction


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/list/A_CmsListAction.java,v $
3  * Date : $Date: 2005/06/27 23:22:25 $
4  * Version: $Revision: 1.16 $
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.list;
33
34 import org.opencms.i18n.CmsMessageContainer;
35 import org.opencms.main.CmsIllegalArgumentException;
36 import org.opencms.util.CmsStringUtil;
37 import org.opencms.workplace.tools.A_CmsHtmlIconButton;
38
39 /**
40  * The default skeleton for a list action.<p>
41  *
42  * @author Michael Moossen
43  *
44  * @version $Revision: 1.16 $
45  *
46  * @since 6.0.0
47  */

48 public abstract class A_CmsListAction extends A_CmsHtmlIconButton implements I_CmsListAction {
49
50     /** Confirmation Message. */
51     private CmsMessageContainer m_confirmationMsg;
52
53     /** The id of the associated list. */
54     private String JavaDoc m_listId;
55
56     /**
57      * Default Constructor.<p>
58      *
59      * @param id unique id
60      */

61     public A_CmsListAction(String JavaDoc id) {
62
63         super(id);
64         if (CmsStringUtil.isEmptyOrWhitespaceOnly(id)) {
65             throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_LIST_INVALID_NULL_ARG_1, "id"));
66         }
67         setConfirmationMessage(null);
68     }
69
70     /**
71      * Generates html for the confirmation message when having one confirmation message
72      * for several actions.<p>
73      *
74      * @param confId the id of the confirmation message
75      * @param confText the confirmation message
76      *
77      * @return html code
78      */

79     public static String JavaDoc defaultConfirmationHtml(String JavaDoc confId, String JavaDoc confText) {
80
81         StringBuffer JavaDoc html = new StringBuffer JavaDoc(1024);
82         html.append("<div class='hide' id='conf");
83         html.append(confId);
84         html.append("'>");
85         html.append(CmsStringUtil.isEmptyOrWhitespaceOnly(confText) ? "null" : confText);
86         html.append("</div>\n");
87         return html.toString();
88     }
89
90     /**
91      * @see org.opencms.workplace.list.I_CmsListAction#getConfirmationMessage()
92      */

93     public CmsMessageContainer getConfirmationMessage() {
94
95         return m_confirmationMsg;
96     }
97
98     /**
99      * @see org.opencms.workplace.list.I_CmsListAction#getListId()
100      */

101     public String JavaDoc getListId() {
102
103         return m_listId;
104     }
105
106     /**
107      * @see org.opencms.workplace.list.I_CmsListAction#setConfirmationMessage(org.opencms.i18n.CmsMessageContainer)
108      */

109     public void setConfirmationMessage(CmsMessageContainer confirmationMsg) {
110
111         if (confirmationMsg == null) {
112             confirmationMsg = EMPTY_MESSAGE;
113         }
114         m_confirmationMsg = confirmationMsg;
115     }
116
117     /**
118      * @see org.opencms.workplace.list.I_CmsListAction#setListId(java.lang.String)
119      */

120     public void setListId(String JavaDoc listId) {
121
122         if (CmsStringUtil.isEmptyOrWhitespaceOnly(listId)) {
123             throw new CmsIllegalArgumentException(Messages.get().container(
124                 Messages.ERR_LIST_INVALID_NULL_ARG_1,
125                 "listId"));
126         }
127         m_listId = listId;
128     }
129 }
Popular Tags