KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/searchindex/CmsDeleteIndexSourceDialog.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.CmsToolManager;
36
37 import java.util.ArrayList JavaDoc;
38 import java.util.List JavaDoc;
39
40 import javax.servlet.http.HttpServletRequest JavaDoc;
41 import javax.servlet.http.HttpServletResponse JavaDoc;
42 import javax.servlet.jsp.PageContext JavaDoc;
43
44 /**
45  * A <code>CmsWidgetDialog</code> that starts a (confirmed) delete dialog for
46  * an indexsource.<p>
47  *
48  * The constraint for allowing deletion of the indexsource: It must not be referenced by
49  * any searchindex.<p>
50  *
51  * @author Achim Westermann
52  *
53  * @version $Revision: 1.2 $
54  *
55  * @since 6.0.0
56  */

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

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

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

88     public void actionCommit() {
89
90         List JavaDoc errors = new ArrayList JavaDoc();
91
92         try {
93
94             m_searchManager.removeSearchIndexSource(m_indexsource);
95             clearDialogObject();
96             writeConfiguration();
97             // if we go back to /searchindex/singleindex (overview) the deleted searchindex is not
98
// there any more in the CmsSearchManager and CmsOverviewSearchIndex.getUserObject will
99
// find null -> defineWidgets will provide null as bean...
100
setParamCloseLink(CmsToolManager.linkForToolPath(getJsp(), "/searchindex/indexsources"));
101
102         } catch (Throwable JavaDoc t) {
103             errors.add(t);
104         }
105         // set the list of errors to display when saving failed
106
setCommitErrors(errors);
107     }
108
109     /**
110      * Creates the dialog HTML for all defined widgets of the named dialog (page).<p>
111      *
112      * This overwrites the method from the super class to create a layout variation for the widgets.<p>
113      *
114      * @param dialog the dialog (page) to get the HTML for
115      * @return the dialog HTML for all defined widgets of the named dialog (page)
116      */

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