📄 cmspreferencespanels.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/com/opencms/workplace/CmsPreferencesPanels.java,v $
* Date : $Date: 2003/02/16 02:23:17 $
* Version: $Revision: 1.46 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (C) 2001 The OpenCms Group
*
* 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 OpenCms, please see the
* OpenCms 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 com.opencms.workplace;
import com.opencms.core.CmsException;
import com.opencms.core.I_CmsConstants;
import com.opencms.core.I_CmsSession;
import com.opencms.file.CmsFolder;
import com.opencms.file.CmsGroup;
import com.opencms.file.CmsObject;
import com.opencms.file.CmsProject;
import com.opencms.file.CmsRequestContext;
import com.opencms.file.CmsUser;
import com.opencms.template.A_CmsXmlContent;
import java.util.Hashtable;
import java.util.Vector;
/**
* Template class for displaying the preference panels screen of the OpenCms workplace.<P>
* Reads template files of the content type <code>CmsXmlWpTemplateFile</code>.
*
* @author Michael Emmerich
* @version $Revision: 1.46 $ $Date: 2003/02/16 02:23:17 $
*/
public class CmsPreferencesPanels extends CmsWorkplaceDefault implements I_CmsWpConstants,I_CmsConstants {
/** Datablock value for checked */
private static final String C_CHECKED = "CHECKED";
/** Datablock value for checkbox title */
private static final String C_CHECKTITLE = "CHECKTITLE";
/** Datablock value for checkbox type */
private static final String C_CHECKTYPE = "CHECKTYPE";
/** Datablock value for checkbox changed */
private static final String C_CHECKCHANGED = "CHECKCHANGED";
/** Datablock value for checkbox size */
private static final String C_CHECKSIZE = "CHECKSIZE";
/** Datablock value for checkbox state */
private static final String C_CHECKSTATE = "CHECKSTATE";
/** Datablock value for checkbox owner */
private static final String C_CHECKOWNER = "CHECKOWNER";
/** Datablock value for checkbox group */
private static final String C_CHECKGROUP = "CHECKGROUP";
/** Datablock value for checkbox access */
private static final String C_CHECKACCESS = "CHECKACCESS";
/** Datablock value for checkbox lockedby */
private static final String C_CHECKLOCKEDBY = "CHECKLOCKEDBY";
/** Datablock value for checkbox view all */
private static final String C_CHVIEWALL = "CHVIEWALL";
/** Datablock value for checkbox message accepted */
private static final String C_CHMESSAGEACCEPTED = "CHMESSAGEACCEPTED";
/** Datablock value for checkbox message forwared */
private static final String C_CHMESSAGEFORWARDED = "CHMESSAGEFORWARDED";
/** Datablock value for checkbox message completed */
private static final String C_CHMESSAGECOMPLETED = "CHMESSAGECOMPLETED";
/** Datablock value for checkbox message memebers */
private static final String C_CHMESSAGEMEMEBERS = "CHMESSAGEMEMEBERS";
/** Datablock value for checkbox user read */
private static final String C_CHECKUR = "CHECKUR";
/** Datablock value for checkbox user write */
private static final String C_CHECKUW = "CHECKUW";
/** Datablock value for checkbox user visible */
private static final String C_CHECKUV = "CHECKUV";
/** Datablock value for checkbox group read */
private static final String C_CHECKGR = "CHECKGR";
/** Datablock value for checkbox group write */
private static final String C_CHECKGW = "CHECKGW";
/** Datablock value for checkbox group visible */
private static final String C_CHECKGV = "CHECKGV";
/** Datablock value for checkbox public read */
private static final String C_CHECKPR = "CHECKPR";
/** Datablock value for checkbox public write */
private static final String C_CHECKPW = "CHECKPW";
/** Datablock value for checkbox public visible */
private static final String C_CHECKPV = "CHECKPV";
/** Datablock value for checkbox internal flag */
private static final String C_CHECKIF = "CHECKIF";
/** Datablock value for checkbox internal flag */
private static final String C_LOCKDIALOG = "checklockdialog";
/** Constant for filter */
private static final String C_TASK_FILTER = "task.filter.";
/** Constant for filter */
private static final String C_SPACER = "------------------------------------------------";
/** Vector storing all view names */
Vector m_viewNames = null;
/** Vector storing all view values */
Vector m_viewLinks = null;
/**
* Overwrites the getContent method of the CmsWorkplaceDefault.<br>
* Gets the content of the preferences panels template and processed the data input.
* @param cms The CmsObject.
* @param templateFile The preferences panels template file
* @param elementName not used
* @param parameters Parameters of the request and the template.
* @param templateSelector Selector of the template tag to be displayed.
* @return Bytearre containgine the processed data of the template.
* @throws Throws CmsException if something goes wrong.
*/
public byte[] getContent(CmsObject cms, String templateFile, String elementName,
Hashtable parameters, String templateSelector) throws CmsException {
// get request context and session
CmsRequestContext reqCont = cms.getRequestContext();
I_CmsSession session = cms.getRequestContext().getSession(true);
// define varialbes to store template and panel
String template = "";
String panel;
String oldPanel;
String button = "" + parameters.get("CLICKED_BUTTON");
// clear session values on first load
String initial = (String)parameters.get(C_PARA_INITIAL);
if(initial != null) {
// remove all session values
session.removeValue("EXPLORERSETTINGS");
session.removeValue("TASKSETTINGS");
session.removeValue("USERSETTINGS");
session.removeValue("STARTSETTINGS");
session.removeValue(C_PARA_OLDPANEL);
session.removeValue("lasturl");
panel="explorer";
}else{
// get the active panel value. This indicates which panel to be displayed.
panel = (String)parameters.get(C_PARA_PANEL);
}
CmsXmlWpTemplateFile xmlTemplateDocument = new CmsXmlWpTemplateFile(cms, templateFile);
// check if the submit or ok button is selected. If so, update all values
if(C_PARA_SUBMIT.equals(button) || C_PARA_OK.equals(button)) {
// get the data values form the active panel and store them in the session.
// this is nescessary to save this data in the next step.
if(panel != null) {
// the active panel is the explorer settings, save its data
if(panel.equals(C_PANEL_EXPLORER)) {
int explorerSettings = getExplorerSettings(parameters);
session.putValue(C_PARA_EXPLORERSETTINGS, new Integer(explorerSettings).toString());
}
// the active panel is the task settings, save its data
if(panel.equals(C_PANEL_TASK)) {
Hashtable taskSettings = getTaskSettings(parameters, session);
if(taskSettings != null) {
session.putValue(C_PARA_TASKSETTINGS, taskSettings);
}
}
// the active panel is the starup settings, save its data
if(panel.equals(C_PANEL_START)) {
Hashtable startSettings = getStartSettings(cms, parameters);
if(startSettings != null) {
session.putValue(C_PARA_STARTSETTINGS, startSettings);
String lang = (String)startSettings.get(C_START_LANGUAGE);
if (lang != null) {
session.putValue(C_START_LANGUAGE, lang);
}
// ensure encoding from language file is set in session
CmsXmlLanguageFile langFile = new CmsXmlLanguageFile(cms, lang);
reqCont.setEncoding(langFile.getEncoding(), true);
}
}
}
// update the actual user data with those values taken from the preferences
// panles. All data set in the panels is now available in the session, so
// check which data is available and set it.
// now update the explorer settings
String explorerSettings = (String)session.getValue(C_PARA_EXPLORERSETTINGS);
if(explorerSettings != null) {
reqCont.currentUser().setAdditionalInfo(C_ADDITIONAL_INFO_EXPLORERSETTINGS, explorerSettings);
}
// now update the task settings
Hashtable taskSettings = (Hashtable)session.getValue(C_PARA_TASKSETTINGS);
if(taskSettings != null) {
reqCont.currentUser().setAdditionalInfo(C_ADDITIONAL_INFO_TASKSETTINGS, taskSettings);
}
// now update the start settings
Hashtable startSettings = (Hashtable)session.getValue(C_PARA_STARTSETTINGS);
if(startSettings != null) {
reqCont.currentUser().setAdditionalInfo(C_ADDITIONAL_INFO_STARTSETTINGS, startSettings);
String defaultGroup = (String)startSettings.get(C_START_DEFAULTGROUP);
reqCont.currentUser().setDefaultGroup(cms.readGroup(defaultGroup));
}
// finally store the updated user object in the database
cms.writeUser(reqCont.currentUser());
}
// check which panel of the preferences should be displayed and update the
// data on this panel with the default values or values already set in the
// preferences before.
if(panel != null) {
// set the template to the active panel.
// by doing this, the correct panel will be displayed when the template
// is processed.
template = panel;
if(panel.equals(C_PANEL_EXPLORER)) {
// this is the panel for setting the explorer preferences
setExplorerSettings(session, parameters, reqCont, xmlTemplateDocument);
}
else {
if(panel.equals(C_PANEL_TASK)) {
// this is the panel for setting the task preferences
setTaskSettings(session, parameters, reqCont, xmlTemplateDocument);
}
else {
if(panel.equals(C_PANEL_START)) {
// this is the panel for setting the start preferences
setStartSettings(cms, session, parameters, reqCont, xmlTemplateDocument);
}
else {
if(panel.equals(C_PANEL_USER)) {
// this is the panel for setting the user preferences
setUserSettings(session, parameters, reqCont, xmlTemplateDocument);
}
}
}
}
// finally store the given data into the session
oldPanel = (String)session.getValue(C_PARA_OLDPANEL);
if(oldPanel != null) {
// the previous panel was the explorer panel, save all the data form there
if(oldPanel.equals("explorer")) {
int explorerSettings = getExplorerSettings(parameters);
session.putValue("EXPLORERSETTINGS", new Integer(explorerSettings).toString());
}
// the previous panel was the task panel, save all the data form there
if(oldPanel.equals("task")) {
Hashtable taskSettings = getTaskSettings(parameters, session);
if(taskSettings != null) {
session.putValue("TASKSETTINGS", taskSettings);
}
}
// // the previous panel was the user panel, save all the data form there
// if(oldPanel.equals("user")) {
// String userSettings=getUserSettings(parameters);
// if (userSettings != null) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -