⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmsdialog.java

📁 找了很久才找到到源代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*
 * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/CmsDialog.java,v $
 * Date   : $Date: 2007-08-13 16:30:06 $
 * Version: $Revision: 1.100 $
 *
 * This library is part of OpenCms -
 * the Open Source Content Management System
 * Copyright (c) 2002 - 2007 Alkacon Software GmbH (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software GmbH, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *  
 */

package org.opencms.workplace;

import org.opencms.file.CmsResource;
import org.opencms.file.CmsResourceFilter;
import org.opencms.i18n.CmsMessageContainer;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.lock.CmsLockFilter;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;
import org.opencms.main.OpenCms;
import org.opencms.security.CmsPermissionSet;
import org.opencms.util.CmsRequestUtil;
import org.opencms.util.CmsStringUtil;
import org.opencms.workplace.commons.CmsLock;
import org.opencms.workplace.editors.CmsPreEditorAction;
import org.opencms.workplace.tools.CmsToolDialog;
import org.opencms.workplace.tools.CmsToolManager;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;

import org.apache.commons.logging.Log;

/**
 * Provides methods for building the dialog windows of OpenCms.<p> 
 * 
 * @author  Andreas Zahner 
 * 
 * @version $Revision: 1.100 $ 
 * 
 * @since 6.0.0 
 */
public class CmsDialog extends CmsToolDialog {

    /** Value for the action: cancel. */
    public static final int ACTION_CANCEL = 4;

    /** Value for the action: close popup window. */
    public static final int ACTION_CLOSEPOPUP = 6;

    /** Value for the action: save & close popup window. */
    public static final int ACTION_CLOSEPOPUP_SAVE = 7;

    /** Value for the action: confirmed. */
    public static final int ACTION_CONFIRMED = 1;

    /** Value for the action: continue. */
    public static final int ACTION_CONTINUE = 8;

    /** Value for the action: default (show initial dialog form). */
    public static final int ACTION_DEFAULT = 0;

    /** Value for the action: locks confirmed. */
    public static final int ACTION_LOCKS_CONFIRMED = 99;

    /** Value for the action: ok. */
    public static final int ACTION_OK = 3;

    // note: action values 90 - 99 are reserved for reports
    /** Value for the action: begin the report. */
    public static final int ACTION_REPORT_BEGIN = 90;

    /** Value for the action: end the report. */
    public static final int ACTION_REPORT_END = 92;

    /** Value for the action: update the report. */
    public static final int ACTION_REPORT_UPDATE = 91;

    /** Value for the action: button "set" clicked. */
    public static final int ACTION_SET = 5;

    /** Value for the action: wait (show please wait screen). */
    public static final int ACTION_WAIT = 2;

    /** Constant for the "Advanced" button in the build button methods. */
    public static final int BUTTON_ADVANCED = 3;

    /** Constant for the "Back" button in the build button methods. */
    public static final int BUTTON_BACK = 9;

    /** Constant for the "Cancel" button in the build button methods. */
    public static final int BUTTON_CANCEL = 1;

    /** Constant for the "Close" button in the build button methods. */
    public static final int BUTTON_CLOSE = 2;

    /** Constant for the "Continue" button in the build button methods. */
    public static final int BUTTON_CONTINUE = 10;

    /** Constant for the "Details" button in the build button methods. */
    public static final int BUTTON_DETAILS = 5;

    /** Constant for the "Discard" button in the build button methods (same function as "Cancel" button but different text on button. */
    public static final int BUTTON_DISCARD = 8;

    /** Constant for the "Edit" button in the build button methods (same function as "Ok" button but different text on button. */
    public static final int BUTTON_EDIT = 7;

    /** Constant for the "OK" button in the build button methods. */
    public static final int BUTTON_OK = 0;

    /** Constant for the "OK" button in the build button methods (without form submission). */
    public static final int BUTTON_OK_NO_SUBMIT = 6;

    /** Constant for the "Set" button in the build button methods. */
    public static final int BUTTON_SET = 4;

    /** Request parameter value for the action: back. */
    public static final String DIALOG_BACK = "back";

    /** Request parameter value for the action: cancel. */
    public static final String DIALOG_CANCEL = "cancel";

    /** Request parameter value for the action: dialog confirmed. */
    public static final String DIALOG_CONFIRMED = "confirmed";

    /** Request parameter value for the action: continue. */
    public static final String DIALOG_CONTINUE = "continue";

    /** Request parameter value for the action: initial call. */
    public static final String DIALOG_INITIAL = "initial";

    /** Request parameter value for the action: dialog locks confirmed. */
    public static final String DIALOG_LOCKS_CONFIRMED = "locksconfirmed";

    /** Request parameter value for the action: ok. */
    public static final String DIALOG_OK = "ok";

    /** Request parameter value for the action: set. */
    public static final String DIALOG_SET = "set";

    /** Request parameter value for the action: show please wait screen. */
    public static final String DIALOG_WAIT = "wait";

    /** Request parameter name for the action. */
    public static final String PARAM_ACTION = "action";

    /** Request parameter name for the closelink. */
    public static final String PARAM_CLOSELINK = "closelink";

    /** Request parameter name for the dialog type. */
    public static final String PARAM_DIALOGTYPE = "dialogtype";

    /** Request parameter name for the error stack. */
    public static final String PARAM_ERRORSTACK = "errorstack";

    /** Request parameter name for the file. */
    public static final String PARAM_FILE = "file";

    /** Request parameter name for the frame name. */
    public static final String PARAM_FRAMENAME = "framename";

    /** Request parameter name for the "is popup" flag. */
    public static final String PARAM_ISPOPUP = "ispopup";

    /** Request parameter name for the lock. */
    public static final String PARAM_LOCK = "lock";

    /** Request parameter name for the error message. */
    public static final String PARAM_MESSAGE = "message";

    /** Request parameter name for the originalparams. */
    public static final String PARAM_ORIGINALPARAMS = "originalparams";

    /** Request parameter name for the preactiondone. */
    public static final String PARAM_PREACTIONDONE = "preactiondone";

    /** Request parameter name for the redirect flag. */
    public static final String PARAM_REDIRECT = "redirect";

    /** Request parameter name for the resource. */
    public static final String PARAM_RESOURCE = "resource";

    /** Request parameter name for the target. */
    public static final String PARAM_TARGET = "target";

    /** Request parameter name for the thread id. */
    public static final String PARAM_THREAD = "thread";

    /** Request parameter name for indicating if another thread is following the current one. */
    public static final String PARAM_THREAD_HASNEXT = "threadhasnext";

    /** Request parameter name for the dialog title. */
    public static final String PARAM_TITLE = "title";

    /** Request parameter value for the action: begin the report. */
    public static final String REPORT_BEGIN = "reportbegin";

    /** Request parameter value for the action: end the report. */
    public static final String REPORT_END = "reportend";

    /** Request parameter value for the action: update the report. */
    public static final String REPORT_UPDATE = "reportupdate";

    /** Key name for the throwable attribute. */
    protected static final String ATTRIBUTE_THROWABLE = "throwable";

    /** The log object for this class. */
    private static final Log LOG = CmsLog.getLog(CmsDialog.class);

    private int m_action;

    /** 
     * The custom mapping for online help.<p> 
     * 
     * It will be translated to a javascript variable called onlineHelpUriCustom. 
     * If it is set, the top.head javascript for the online help will use this value. <p> 
     */
    private String m_onlineHelpUriCustom;

    private String m_paramAction;
    private String m_paramCloseLink;
    private String m_paramDialogtype;
    private String m_paramFrameName;
    private String m_paramIsPopup;
    private String m_paramMessage;
    private String m_paramOriginalParams;
    private String m_paramPreActionDone;
    private String m_paramRedirect;
    private String m_paramResource;
    private String m_paramTitle;

    /**
     * Public constructor with JSP action element.<p>
     * 
     * @param jsp an initialized JSP action element
     */
    public CmsDialog(CmsJspActionElement jsp) {

        super(jsp);
    }

    /**
     * Public constructor with JSP variables.<p>
     * 
     * @param context the JSP page context
     * @param req the JSP request
     * @param res the JSP response
     */
    public CmsDialog(PageContext context, HttpServletRequest req, HttpServletResponse res) {

        this(new CmsJspActionElement(context, req, res));
    }

    /**
     * Returns an initialized CmsDialog instance that is read from the request attributes.<p>
     * 
     * This method is used by dialog elements. 
     * The dialog elements do not initialize their own workplace class, 
     * but use the initialized instance of the "master" class.
     * This is required to ensure that parameters of the "master" class
     * can properly be kept on the dialog elements.<p>
     * 
     * To prevent null pointer exceptions, an empty dialog is returned if 
     * nothing is found in the request attributes.<p>
     *  
     * @param context the JSP page context
     * @param req the JSP request
     * @param res the JSP response
     * @return an initialized CmsDialog instance that is read from the request attributes
     */
    public static CmsDialog initCmsDialog(PageContext context, HttpServletRequest req, HttpServletResponse res) {

        CmsDialog wp = (CmsDialog)req.getAttribute(CmsWorkplace.SESSION_WORKPLACE_CLASS);
        if (wp == null) {
            // ensure that we don't get null pointers if the page is directly called
            wp = new CmsDialog(new CmsJspActionElement(context, req, res));
            wp.fillParamValues(req);
        }
        return wp;
    }

    /**
     * Used to close the current JSP dialog.<p>
     * 
     * This method tries to include the URI stored in the workplace settings.
     * This URI is determined by the frame name, which has to be set 
     * in the framename parameter.<p>
     * 
     * @throws JspException if including an element fails
     */
    public void actionCloseDialog() throws JspException {

        // create a map with empty "resource" parameter to avoid changing the folder when returning to explorer file list
        Map params = new HashMap();
        params.put(PARAM_RESOURCE, "");
        if (isPopup()) {
            try {
                // try to close the popup
                JspWriter out = getJsp().getJspContext().getOut();
                out.write("<html><head></head>\n");
                out.write("<body onload=\"top.close();\">\n");
                out.write("</body>\n");
                out.write("</html>\n");
            } catch (IOException e) {
                // error redirecting, include explorer file list
                getJsp().include(FILE_EXPLORER_FILELIST, null, params);
            }
        } else if (getParamCloseLink() != null) {
            // close link parameter present
            try {
                if (Boolean.valueOf(getParamRedirect()).booleanValue()) {
                    // redirect parameter is true, redirect to given close link                 
                    getJsp().getResponse().sendRedirect(getParamCloseLink());
                } else {
                    // forward JSP
                    if (!isForwarded()) {
                        setForwarded(true);
                        CmsRequestUtil.forwardRequest(
                            getParamCloseLink(),
                            getJsp().getRequest(),
                            getJsp().getResponse());
                    }
                }
            } catch (Exception e) {
                // forward failed
                throw new JspException(e.getMessage(), e);
            }
        } else if (getParamFramename() != null) {
            // non wp frame mode (currently used for galleries)
            // framename parameter found, get URI
            String frameUri = (String)getSettings().getFrameUris().get(getParamFramename());
            if (frameUri != null) {
                // URI found, include it
                if (frameUri.startsWith(OpenCms.getSystemInfo().getOpenCmsContext())) {
                    // remove context path from URI before inclusion
                    frameUri = frameUri.substring(OpenCms.getSystemInfo().getOpenCmsContext().length());
                }
                // include the found frame URI

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -