KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > tools > searchindex > CmsRebuildSearchIndexDialog


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/searchindex/CmsRebuildSearchIndexDialog.java,v $
3  * Date : $Date: 2006/03/27 14:52:21 $
4  * Version: $Revision: 1.2 $
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.searchindex;
33
34 import org.opencms.jsp.CmsJspActionElement;
35 import org.opencms.workplace.tools.CmsToolDialog;
36
37 import java.util.ArrayList JavaDoc;
38 import java.util.HashMap JavaDoc;
39 import java.util.List JavaDoc;
40 import java.util.Map JavaDoc;
41
42 import javax.servlet.http.HttpServletRequest JavaDoc;
43 import javax.servlet.http.HttpServletResponse JavaDoc;
44 import javax.servlet.jsp.PageContext JavaDoc;
45
46 /**
47  * A <code>CmsWidgetDialog</code> that starts a (confirmed) rebuild dialog for
48  * a search index.<p>
49  *
50  * @author Achim Westermann
51  *
52  * @version $Revision: 1.2 $
53  *
54  * @since 6.0.0
55  */

56 public class CmsRebuildSearchIndexDialog extends A_CmsEditSearchIndexDialog {
57
58     /**
59      * Public constructor with JSP action element.<p>
60      *
61      * @param jsp an initialized JSP action element
62      */

63
64     public CmsRebuildSearchIndexDialog(CmsJspActionElement jsp) {
65
66         super(jsp);
67
68     }
69
70     /**
71      * Public constructor with JSP variables.<p>
72      *
73      * @param context the JSP page context
74      * @param req the JSP request
75      * @param res the JSP response
76      */

77
78     public CmsRebuildSearchIndexDialog(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
79
80         super(context, req, res);
81
82     }
83
84     /**
85      * Commits the edited search index to the search manager.<p>
86      */

87     public void actionCommit() {
88
89         List JavaDoc errors = new ArrayList JavaDoc();
90
91         try {
92             // forward to the rebuild report page
93
Map JavaDoc params = new HashMap JavaDoc();
94             // rebuild report built for several indexes (comma-separated value string)
95
params.put(CmsRebuildReport.PARAM_INDEXES, m_index.getName());
96             params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
97             getToolManager().jspForwardTool(this, "/searchindex/singleindex/rebuildreport", params);
98
99         } catch (Throwable JavaDoc t) {
100             errors.add(t);
101         }
102         // set the list of errors to display when saving failed
103
setCommitErrors(errors);
104     }
105
106     /**
107      * Creates the dialog HTML for all defined widgets of the named dialog (page).<p>
108      *
109      * This overwrites the method from the super class to create a layout variation for the widgets.<p>
110      *
111      * @param dialog the dialog (page) to get the HTML for
112      * @return the dialog HTML for all defined widgets of the named dialog (page)
113      */

114     protected String JavaDoc createDialogHtml(String JavaDoc dialog) {
115
116         StringBuffer JavaDoc result = new StringBuffer JavaDoc(512);
117
118         result.append(createWidgetTableStart());
119         // show error header once if there were validation errors
120
result.append(createWidgetErrorHeader());
121
122         if (dialog.equals(PAGES[0])) {
123             // create the widgets for the first dialog page
124
result.append(dialogBlockStart(key(Messages.GUI_LIST_SEARCHINDEX_ACTION_REBUILD_NAME_0)));
125             result.append(createWidgetTableStart());
126             result.append(key(
127                 Messages.GUI_LIST_SEARCHINDEX_ACTION_REBUILD_NAME_CONF_1,
128                 new Object JavaDoc[] {m_index.getName()}));
129             result.append(createWidgetTableEnd());
130             result.append(dialogBlockEnd());
131         }
132
133         result.append(createWidgetTableEnd());
134
135         // See CmsWidgetDialog.dialogButtonsCustom(): if no widgets are defined that are non-display-only widgets,
136
// no dialog buttons (Ok, Cancel) will be visible....
137
result.append(dialogButtons(new int[] {BUTTON_OK, BUTTON_CANCEL}, new String JavaDoc[2]));
138         return result.toString();
139     }
140
141 }
142
Popular Tags