001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software GmbH & Co. KG, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.workplace.tools.searchindex;
029
030import org.opencms.jsp.CmsJspActionElement;
031import org.opencms.widgets.CmsDisplayWidget;
032import org.opencms.widgets.CmsInputWidget;
033import org.opencms.workplace.CmsWidgetDialogParameter;
034
035import javax.servlet.http.HttpServletRequest;
036import javax.servlet.http.HttpServletResponse;
037import javax.servlet.jsp.PageContext;
038
039/**
040 *
041 * Dialog to edit new or existing search indexsource in the administration view.<p>
042 *
043 * @since 6.5.5
044 */
045public class CmsEditFieldConfigurationDialog extends A_CmsFieldConfigurationDialog {
046
047    /**
048     * Public constructor with JSP action element.<p>
049     *
050     * @param jsp the jsp action element
051     */
052    public CmsEditFieldConfigurationDialog(CmsJspActionElement jsp) {
053
054        super(jsp);
055    }
056
057    /**
058     * Public constructor with JSP variables.<p>
059     *
060     * @param context the JSP page context
061     * @param req the JSP request
062     * @param res the JSP response
063     */
064    public CmsEditFieldConfigurationDialog(PageContext context, HttpServletRequest req, HttpServletResponse res) {
065
066        super(context, req, res);
067    }
068
069    /**
070     * Creates the dialog HTML for all defined widgets of the named dialog (page).<p>
071     *
072     * This overwrites the method from the super class to create a layout variation for the widgets.<p>
073     *
074     * @param dialog the dialog (page) to get the HTML for
075     * @return the dialog HTML for all defined widgets of the named dialog (page)
076     */
077    @Override
078    protected String createDialogHtml(String dialog) {
079
080        StringBuffer result = new StringBuffer(1024);
081
082        result.append(createWidgetTableStart());
083        // show error header once if there were validation errors
084        result.append(createWidgetErrorHeader());
085
086        if (dialog.equals(PAGES[0])) {
087            // create the widgets for the first dialog page
088            result.append(dialogBlockStart(key(Messages.GUI_LABEL_FIELDCONFIGURATION_BLOCK_SETTINGS_0)));
089            result.append(createWidgetTableStart());
090            result.append(createDialogRowsHtml(0, 1));
091            result.append(createWidgetTableEnd());
092            result.append(dialogBlockEnd());
093        }
094
095        result.append(createWidgetTableEnd());
096        return result.toString();
097    }
098
099    /**
100     * Creates the list of widgets for this dialog.<p>
101     */
102    @Override
103    protected void defineWidgets() {
104
105        super.defineWidgets();
106
107        // widgets to display
108        if (m_fieldconfiguration.getName() == null) {
109            addWidget(new CmsWidgetDialogParameter(m_fieldconfiguration, "name", PAGES[0], new CmsInputWidget()));
110        } else {
111            addWidget(new CmsWidgetDialogParameter(m_fieldconfiguration, "name", PAGES[0], new CmsDisplayWidget()));
112        }
113        addWidget(
114            new CmsWidgetDialogParameter(
115                m_fieldconfiguration,
116                "description",
117                "",
118                PAGES[0],
119                new CmsInputWidget(),
120                0,
121                1));
122    }
123}