KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/list/A_CmsListSearchAction.java,v $
3  * Date : $Date: 2006/03/27 14:52:28 $
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.list;
33
34 import org.opencms.i18n.CmsMessageContainer;
35 import org.opencms.util.CmsStringUtil;
36 import org.opencms.workplace.CmsWorkplace;
37 import org.opencms.workplace.tools.A_CmsHtmlIconButton;
38 import org.opencms.workplace.tools.CmsHtmlIconButtonStyleEnum;
39
40 /**
41  * Abstract implementation of a search action.<p>
42  *
43  * It provides the default show all action accessor and the rendering method.<p>
44  *
45  * @author Michael Moossen
46  *
47  * @version $Revision: 1.13 $
48  *
49  * @since 6.0.0
50  */

51 public abstract class A_CmsListSearchAction extends CmsListIndependentAction {
52
53     /** The action id for the search action. */
54     public static final String JavaDoc SEARCH_ACTION_ID = "search";
55
56     /** The action id for the show all action. */
57     public static final String JavaDoc SHOWALL_ACTION_ID = "showall";
58
59     /** Default confirmation message for search action. */
60     private static final CmsMessageContainer SEARCH_CONFIRMATION = new CmsMessageContainer(
61         Messages.get(),
62         Messages.GUI_LIST_ACTION_SEARCH_CONF_0);
63
64     /** Default icon for search action. */
65     private static final String JavaDoc SEARCH_ICON = "list/search.png";
66
67     /** Default name for search action. */
68     private static final CmsMessageContainer SEARCH_NAME = new CmsMessageContainer(
69         Messages.get(),
70         Messages.GUI_LIST_ACTION_SEARCH_NAME_0);
71
72     /** Default confirmation message for show all action. */
73     private static final CmsMessageContainer SHOWALL_CONFIRMATION = new CmsMessageContainer(
74         Messages.get(),
75         Messages.GUI_LIST_ACTION_SHOWALL_CONF_0);
76
77     /** Default help text for show all action. */
78     private static final CmsMessageContainer SHOWALL_HELPTEXT = new CmsMessageContainer(
79         Messages.get(),
80         Messages.GUI_LIST_ACTION_SHOWALL_HELP_0);
81
82     /** Default icon for show all action. */
83     private static final String JavaDoc SHOWALL_ICON = "list/showall.png";
84
85     /** Default name for show all action. */
86     private static final CmsMessageContainer SHOWALL_NAME = new CmsMessageContainer(
87         Messages.get(),
88         Messages.GUI_LIST_ACTION_SHOWALL_NAME_0);
89
90     /** A default show all action. */
91     public final I_CmsListAction m_defaultShowAllAction;
92
93     /** Show all action. */
94     private I_CmsListAction m_showAllAction = null;
95
96     /**
97      * Default Constructor.<p>
98      */

99     protected A_CmsListSearchAction() {
100
101         super(SEARCH_ACTION_ID);
102         setName(SEARCH_NAME);
103         setIconPath(SEARCH_ICON);
104         setConfirmationMessage(SEARCH_CONFIRMATION);
105         setHelpText(null);
106
107         m_defaultShowAllAction = createDefaultShowAllAction();
108     }
109
110     /**
111      * @see org.opencms.workplace.tools.I_CmsHtmlIconButton#buttonHtml(CmsWorkplace)
112      */

113     public String JavaDoc buttonHtml(CmsWorkplace wp) {
114
115         if (!isVisible()) {
116             return "";
117         }
118         String JavaDoc onClic = "listSearchAction('"
119             + getListId()
120             + "', '"
121             + getId()
122             + "', '"
123             + CmsStringUtil.escapeJavaScript(wp.resolveMacros(getConfirmationMessage().key(wp.getLocale())))
124             + "');";
125         return A_CmsHtmlIconButton.defaultButtonHtml(
126             wp.getJsp(),
127             CmsHtmlIconButtonStyleEnum.SMALL_ICON_TEXT,
128             getId(),
129             getName().key(wp.getLocale()),
130             getHelpText().key(wp.getLocale()),
131             isEnabled(),
132             getIconPath(),
133             null,
134             onClic);
135     }
136
137     /**
138      * Returns the Show-All action.<p>
139      *
140      * @return the Show-All action
141      */

142     public I_CmsListAction getShowAllAction() {
143
144         return m_showAllAction;
145     }
146
147     /**
148      * @see org.opencms.workplace.list.A_CmsListAction#setListId(java.lang.String)
149      */

150     public void setListId(String JavaDoc listId) {
151
152         super.setListId(listId);
153         m_defaultShowAllAction.setListId(listId);
154     }
155
156     /**
157      * Sets the Show-All action.<p>
158      *
159      * @param showAllAction the Show-All action to set
160      */

161     public void setShowAllAction(I_CmsListAction showAllAction) {
162
163         m_showAllAction = showAllAction;
164     }
165
166     /**
167      * Sets the current used show-all action to the default.<p>
168      */

169     public void useDefaultShowAllAction() {
170
171         m_showAllAction = m_defaultShowAllAction;
172     }
173
174     /**
175      * Creates a default show all action.<p>
176      *
177      * @return default show all action
178      */

179     private I_CmsListAction createDefaultShowAllAction() {
180
181         I_CmsListAction defaultShowAllAction = new CmsListIndependentAction(SHOWALL_ACTION_ID) {
182
183             /**
184              * @see org.opencms.workplace.tools.I_CmsHtmlIconButton#buttonHtml(CmsWorkplace)
185              */

186             public String JavaDoc buttonHtml(CmsWorkplace wp) {
187
188                 if (!isVisible()) {
189                     return "";
190                 }
191                 String JavaDoc onClic = "listSearchAction('"
192                     + getListId()
193                     + "', '"
194                     + getId()
195                     + "', '"
196                     + CmsStringUtil.escapeJavaScript(wp.resolveMacros(getConfirmationMessage().key(wp.getLocale())))
197                     + "');";
198                 return A_CmsHtmlIconButton.defaultButtonHtml(
199                     wp.getJsp(),
200                     CmsHtmlIconButtonStyleEnum.SMALL_ICON_TEXT,
201                     getId(),
202                     getName().key(wp.getLocale()),
203                     getHelpText().key(wp.getLocale()),
204                     isEnabled(),
205                     getIconPath(),
206                     null,
207                     onClic);
208             }
209         };
210         defaultShowAllAction.setName(SHOWALL_NAME);
211         defaultShowAllAction.setHelpText(SHOWALL_HELPTEXT);
212         defaultShowAllAction.setIconPath(SHOWALL_ICON);
213         defaultShowAllAction.setConfirmationMessage(SHOWALL_CONFIRMATION);
214         return defaultShowAllAction;
215     }
216 }
Popular Tags