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, 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.ade.editprovider;
029
030import org.opencms.workplace.editors.directedit.CmsAdvancedDirectEditProvider;
031import org.opencms.workplace.editors.directedit.CmsDirectEditParams;
032import org.opencms.workplace.editors.directedit.I_CmsDirectEditProvider;
033
034import javax.servlet.http.HttpServletRequest;
035import javax.servlet.http.HttpServletResponse;
036import javax.servlet.jsp.JspException;
037import javax.servlet.jsp.PageContext;
038
039/**
040 * A Direct Edit provider class which also offers some limited ADE functionality,
041 * like for example the Publish dialog.<p>
042 *
043 * @since 8.0.0
044 */
045public class CmsToolbarDirectEditProvider extends CmsAdvancedDirectEditProvider {
046
047    /** The module name. */
048    public static final String MODULE_NAME = "editprovider";
049
050    /**
051     * Creates a new instance of this direct edit provider.<p>
052     */
053    public CmsToolbarDirectEditProvider() {
054
055        // ensure that the generated data elements get an id
056        m_useIds = true;
057    }
058
059    /**
060     * Returns the direct edit include HTML to insert in the page beginning.<p>
061     *
062     * @param context the page context
063     * @param params the parameters for the direct edit includes
064     *
065     * @return the direct edit include HTML to insert in the page beginning
066     *
067     * @throws Exception if something goes wrong
068     */
069    public String getIncludes(PageContext context, CmsDirectEditParams params) throws Exception {
070
071        return new CmsEditProviderActionElement(
072            context,
073            (HttpServletRequest)context.getRequest(),
074            (HttpServletResponse)context.getResponse()).exportAll();
075    }
076
077    /**
078     * @see org.opencms.workplace.editors.directedit.I_CmsDirectEditProvider#insertDirectEditIncludes(javax.servlet.jsp.PageContext, org.opencms.workplace.editors.directedit.CmsDirectEditParams)
079     */
080    @Override
081    public void insertDirectEditIncludes(PageContext context, CmsDirectEditParams params) throws JspException {
082
083        JspException error = null;
084        String includeData = "";
085
086        try {
087            includeData = getIncludes(context, params);
088        } catch (JspException e) {
089            error = e;
090        } catch (Exception e) {
091            error = new JspException(e);
092        }
093        if (error != null) {
094            throw error;
095        }
096        print(context, includeData);
097    }
098
099    /**
100     * @see org.opencms.workplace.editors.directedit.I_CmsDirectEditProvider#newInstance()
101     */
102    @Override
103    public I_CmsDirectEditProvider newInstance() {
104
105        CmsToolbarDirectEditProvider result = new CmsToolbarDirectEditProvider();
106        result.m_configurationParameters = m_configurationParameters;
107        return result;
108    }
109
110    /**
111     * @see org.opencms.workplace.editors.directedit.CmsAdvancedDirectEditProvider#hasUploadSupport()
112     */
113    @Override
114    protected boolean hasUploadSupport() {
115
116        return false;
117    }
118
119}