cmspreferencespanels.java

来自「java 编写的程序」· Java 代码 · 共 1,289 行 · 第 1/4 页

JAVA
1,289
字号
                if(oldPanel.equals("start")) {
                    Hashtable startSettings = getStartSettings(cms, parameters);
                    if(startSettings != null) {
                        session.putValue("STARTSETTINGS", startSettings);
                    }
                }
            }
            session.putValue(C_PARA_OLDPANEL, panel);
        }

        // if the OK or cancel buttons are pressed return to the explorer and clear
        // the data in the session.
        if((parameters.get("OK") != null) || (parameters.get("CANCEL") != null)) {
            session.removeValue("EXPLORERSETTINGS");
            session.removeValue("TASKSETTINGS");
            session.removeValue("USERSETTINGS");
            session.removeValue("STARTSETTINGS");
            session.removeValue(C_PARA_OLDPANEL);
            try {
                cms.getRequestContext().getResponse().sendCmsRedirect(getConfigFile(cms).getWorkplaceActionPath()
                        + C_WP_RELOAD);
            }
            catch(Exception e) {
                throw new CmsException("Redirect fails :" + getConfigFile(cms).getWorkplaceActionPath()
                        + C_WP_RELOAD, CmsException.C_UNKNOWN_EXCEPTION, e);
            }
            return null;
        }
        return startProcessing(cms, xmlTemplateDocument, "", parameters, template);
    }

    /**
     * Gets all groups of the currently logged in user.
     * <P>
     * The given vectors <code>names</code> and <code>values</code> will
     * be filled with the appropriate information to be used for building
     * a select box.
     * <P>
     * Both <code>names</code> and <code>values</code> will contain
     * the group names after returning from this method.
     * <P>
     *
     * @param cms CmsObject Object for accessing system resources.
     * @param lang reference to the currently valid language file
     * @param names Vector to be filled with the appropriate values in this method.
     * @param values Vector to be filled with the appropriate values in this method.
     * @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
     * @return Index representing the user's current group in the vectors.
     * @exception CmsException
     */

    public Integer getDefaultGroup(CmsObject cms, CmsXmlLanguageFile lang, Vector names,
            Vector values, Hashtable parameters) throws CmsException {
        CmsRequestContext reqCont = cms.getRequestContext();
        I_CmsSession session = cms.getRequestContext().getSession(true);
        String group = null;

        // Get a vector of all of the user's groups by asking the request context
        CmsGroup currentGroup = reqCont.currentUser().getDefaultGroup();
        Vector allGroups = cms.getGroupsOfUser(reqCont.currentUser().getName());

        // try to get an existing value for the default value
        Hashtable startSettings = null;
        startSettings = (Hashtable)session.getValue("STARTSETTINGS");

        // if this fails, get the settings from the user obeject
        if(startSettings == null) {
            startSettings = (Hashtable)reqCont.currentUser().getAdditionalInfo(C_ADDITIONAL_INFO_STARTSETTINGS);
        }
        if(startSettings != null) {
            group = (String)startSettings.get(C_START_DEFAULTGROUP);
        }
        if(group == null) {
            group = currentGroup.getName();
        }

        // Now loop through all groups and fill the result vectors
        int numGroups = allGroups.size();
        int currentGroupNum = 0;
        for(int i = 0;i < numGroups;i++) {
            CmsGroup loopGroup = (CmsGroup)allGroups.elementAt(i);
            String loopGroupName = loopGroup.getName();
            values.addElement(loopGroupName);
            names.addElement(loopGroupName);
            if(loopGroup.getName().equals(group)) {

                // Fine. The group of this loop is the user's current group. Save it!
                currentGroupNum = i;
            }
        }
        return new Integer(currentGroupNum);
    }

    /**
     * Calculates the settings for the explorer filelist from the data submitted in
     * the preference explorer panel.
     * @param parameters Hashtable containing all request parameters
     * @return Explorer filelist flags.
     */

    private int getExplorerSettings(Hashtable parameters) {
        int explorerSettings = C_FILELIST_NAME;
        if(parameters.get("CBTITLE") != null) {
            explorerSettings += C_FILELIST_TITLE;
        }
        if(parameters.get("CBTYPE") != null) {
            explorerSettings += C_FILELIST_TYPE;
        }
        if(parameters.get("CBCHANGED") != null) {
            explorerSettings += C_FILELIST_CHANGED;
        }
        if(parameters.get("CBSIZE") != null) {
            explorerSettings += C_FILELIST_SIZE;
        }
        if(parameters.get("CBSTATE") != null) {
            explorerSettings += C_FILELIST_STATE;
        }
        if(parameters.get("CBOWNER") != null) {
            explorerSettings += C_FILELIST_OWNER;
        }
        if(parameters.get("CBGROUP") != null) {
            explorerSettings += C_FILELIST_GROUP;
        }
        if(parameters.get("CBACCESS") != null) {
            explorerSettings += C_FILELIST_ACCESS;
        }
        if(parameters.get("CBLOCKEDBY") != null) {
            explorerSettings += C_FILELIST_LOCKED;
        }
        return explorerSettings;
    }

    /**
     * Gets all filters available in the task screen.
     * <P>
     * The given vectors <code>names</code> and <code>values</code> will
     * be filled with the appropriate information to be used for building
     * a select box.
     *
     * @param cms CmsObject Object for accessing system resources.
     * @param lang reference to the currently valid language file
     * @param names Vector to be filled with the appropriate values in this method.
     * @param values Vector to be filled with the appropriate values in this method.
     * @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
     * @return Index representing the user's current filter view in the vectors.
     * @exception CmsException
     */

    public Integer getFilters(CmsObject cms, CmsXmlLanguageFile lang, Vector values,
            Vector names, Hashtable parameters) throws CmsException {

        // Let's see if we have a session
        I_CmsSession session = cms.getRequestContext().getSession(true);
        String filter = null;

        // try to get the default value
        Hashtable taskSettings = null;
        taskSettings = (Hashtable)session.getValue("TASKSETTINGS");

        // if this fails, get the settings from the user obeject
        if(taskSettings == null) {
            taskSettings = (Hashtable)cms.getRequestContext().currentUser().getAdditionalInfo(C_ADDITIONAL_INFO_TASKSETTINGS);
        }
        if(taskSettings != null) {
            filter = (String)taskSettings.get(C_TASK_FILTER);
        }
        else {
            filter = (String)session.getValue(C_SESSION_TASK_FILTER);
        }
        int selected = 0;
        names.addElement("a1");
        values.addElement(lang.getLanguageValue(C_TASK_FILTER + "a1"));
        if("a1".equals(filter)) {
            selected = 0;
        }
        names.addElement("b1");
        values.addElement(lang.getLanguageValue(C_TASK_FILTER + "b1"));
        if("b1".equals(filter)) {
            selected = 1;
        }
        names.addElement("c1");
        values.addElement(lang.getLanguageValue(C_TASK_FILTER + "c1"));
        if("c1".equals(filter)) {
            selected = 2;
        }
        names.addElement("-");
        values.addElement(C_SPACER);
        names.addElement("a2");
        values.addElement(lang.getLanguageValue(C_TASK_FILTER + "a2"));
        if("a2".equals(filter)) {
            selected = 4;
        }
        names.addElement("b2");
        values.addElement(lang.getLanguageValue(C_TASK_FILTER + "b2"));
        if("b2".equals(filter)) {
            selected = 5;
        }
        names.addElement("c2");
        values.addElement(lang.getLanguageValue(C_TASK_FILTER + "c2"));
        if("c2".equals(filter)) {
            selected = 6;
        }
        names.addElement("-");
        values.addElement(C_SPACER);
        names.addElement("a3");
        values.addElement(lang.getLanguageValue(C_TASK_FILTER + "a3"));
        if("a3".equals(filter)) {
            selected = 8;
        }
        names.addElement("b3");
        values.addElement(lang.getLanguageValue(C_TASK_FILTER + "b3"));
        if("b3".equals(filter)) {
            selected = 9;
        }
        names.addElement("c3");
        values.addElement(lang.getLanguageValue(C_TASK_FILTER + "c3"));
        if("c3".equals(filter)) {
            selected = 10;
        }
        names.addElement("-");
        values.addElement(C_SPACER);
        names.addElement("d1");
        values.addElement(lang.getLanguageValue(C_TASK_FILTER + "d1"));
        if("d1".equals(filter)) {
            selected = 12;
        }
        names.addElement("d2");
        values.addElement(lang.getLanguageValue(C_TASK_FILTER + "d2"));
        if("d2".equals(filter)) {
            selected = 13;
        }
        names.addElement("d3");
        values.addElement(lang.getLanguageValue(C_TASK_FILTER + "d3"));
        if("d3".equals(filter)) {
            selected = 14;
        }
        return (new Integer(selected));
    }

    /**
     * Gets all groups of the currently logged in user.
     * <P>
     * The given vectors <code>names</code> and <code>values</code> will
     * be filled with the appropriate information to be used for building
     * a select box.
     * <P>
     * Both <code>names</code> and <code>values</code> will contain
     * the group names after returning from this method.
     * <P>
     *
     * @param cms CmsObject Object for accessing system resources.
     * @param lang reference to the currently valid language file
     * @param names Vector to be filled with the appropriate values in this method.
     * @param values Vector to be filled with the appropriate values in this method.
     * @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
     * @return Index representing the user's current group in the vectors.
     * @exception CmsException
     */

    public Integer getGroups(CmsObject cms, CmsXmlLanguageFile lang, Vector names, Vector values,
            Hashtable parameters) throws CmsException {
        CmsRequestContext reqCont = cms.getRequestContext();
        I_CmsSession session = cms.getRequestContext().getSession(true);
        String group = (String)session.getValue("USERSETTINGS");

        // Get a vector of all of the user's groups by asking the request context
        CmsGroup currentGroup = reqCont.currentGroup();
        Vector allGroups = cms.getGroupsOfUser(reqCont.currentUser().getName());
        if(group == null) {
            group = currentGroup.getName();
        }

        // Now loop through all groups and fill the result vectors
        int numGroups = allGroups.size();
        int currentGroupNum = 0;
        for(int i = 0;i < numGroups;i++) {
            CmsGroup loopGroup = (CmsGroup)allGroups.elementAt(i);
            String loopGroupName = loopGroup.getName();
            values.addElement(loopGroupName);
            names.addElement(loopGroupName);
            if(loopGroup.getName().equals(group)) {

                // Fine. The group of this loop is the user's current group. Save it!
                currentGroupNum = i;
            }
        }
        return new Integer(currentGroupNum);
    }

    /**
     * Gets all available langages in the system.
     * <P>
     * The given vectors <code>names</code> and <code>values</code> will
     * be filled with the appropriate information to be used for building
     * a select box.
     * @param cms CmsObject Object for accessing system resources.
     * @param lang reference to the currently valid language file
     * @param names Vector to be filled with the appropriate values in this method.
     * @param values Vector to be filled with the appropriate values in this method.
     * @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
     * @return Index representing the user's current group in the vectors.
     * @exception CmsException
     */

    public Integer getLanguageFiles(CmsObject cms, CmsXmlLanguageFile lang, Vector names,
            Vector values, Hashtable parameters) throws CmsException {
        CmsXmlWpConfigFile conf = new CmsXmlWpConfigFile(cms);
        Vector allLangFiles = null;

        // get all folders with language files

        //Vector allLangFolders = cms.getSubFolders(conf.getLanguagePath());
        Vector allLangFolders = cms.getSubFolders(conf.getLanguagePath());
        String langName = null;
        Hashtable startSettings = null;
        I_CmsSession session = cms.getRequestContext().getSession(true);
        startSettings = (Hashtable)session.getValue("STARTSETTINGS");

        // if this fails, get the settings from the user obeject
        if(startSettings == null) {
            startSettings = (Hashtable)cms.getRequestContext().currentUser().getAdditionalInfo(C_ADDITIONAL_INFO_STARTSETTINGS);
        }
        if(startSettings != null) {

⌨️ 快捷键说明

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