📄 a_cmslistdialog.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/list/A_CmsListDialog.java,v $
* Date : $Date: 2006/03/28 07:53:22 $
* Version: $Revision: 1.35 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (c) 2005 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.list;
import org.opencms.i18n.CmsMessageContainer;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.main.CmsException;
import org.opencms.main.CmsRuntimeException;
import org.opencms.util.CmsStringUtil;
import org.opencms.workplace.CmsDialog;
import org.opencms.workplace.CmsWorkplaceSettings;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
/**
* Provides a dialog with a list widget.<p>
*
* @author Michael Moossen
*
* @version $Revision: 1.35 $
*
* @since 6.0.0
*/
public abstract class A_CmsListDialog extends CmsDialog {
/** Value for the action: execute a list item independent action of the list. */
public static final int ACTION_LIST_INDEPENDENT_ACTION = 83;
/** Value for the action: execute an multi action of the list. */
public static final int ACTION_LIST_MULTI_ACTION = 85;
/** Value for the action: search the list. */
public static final int ACTION_LIST_SEARCH = 81;
/** Value for the action: go to a page. */
public static final int ACTION_LIST_SELECT_PAGE = 82;
/** Value for the action: execute a single action of the list. */
public static final int ACTION_LIST_SINGLE_ACTION = 84;
/** Value for the action: sort the list. */
public static final int ACTION_LIST_SORT = 80;
/** Standard list button location. */
public static final String ICON_ACTIVE = "list/active.png";
/** Standard list button location. */
public static final String ICON_ADD = "list/add.png";
/** Standard list button location. */
public static final String ICON_DELETE = "list/delete.png";
/** Standard list button location. */
public static final String ICON_DETAILS_HIDE = "list/details_hide.png";
/** Standard list button location. */
public static final String ICON_DETAILS_SHOW = "list/details_show.png";
/** Standard list button location. */
public static final String ICON_DISABLED = "list/disabled.png";
/** Standard list button location. */
public static final String ICON_INACTIVE = "list/inactive.png";
/** Standard list button location. */
public static final String ICON_MINUS = "list/minus.png";
/** Standard list button location. */
public static final String ICON_MULTI_ACTIVATE = "list/multi_activate.png";
/** Standard list button location. */
public static final String ICON_MULTI_ADD = "list/multi_add.png";
/** Standard list button location. */
public static final String ICON_MULTI_DEACTIVATE = "list/multi_deactivate.png";
/** Standard list button location. */
public static final String ICON_MULTI_DELETE = "list/multi_delete.png";
/** Standard list button location. */
public static final String ICON_MULTI_MINUS = "list/multi_minus.png";
/** Request parameter value for the list action: a list item independent action has been triggered. */
public static final String LIST_INDEPENDENT_ACTION = "listindependentaction";
/** Request parameter value for the list action: a multi action has been triggered. */
public static final String LIST_MULTI_ACTION = "listmultiaction";
/** Request parameter value for the list action: search/filter. */
public static final String LIST_SEARCH = "listsearch";
/** Request parameter value for the list action: select a page. */
public static final String LIST_SELECT_PAGE = "listselectpage";
/** Request parameter value for the list action: a single action has been triggered. */
public static final String LIST_SINGLE_ACTION = "listsingleaction";
/** Request parameter value for the list action: sort. */
public static final String LIST_SORT = "listsort";
/** Request parameter key for the requested page. */
public static final String PARAM_FORMNAME = "formname";
/** Request parameter key for the list action. */
public static final String PARAM_LIST_ACTION = "listaction";
/** Request parameter key for the requested page. */
public static final String PARAM_PAGE = "page";
/** Request parameter key for search the filter. */
public static final String PARAM_SEARCH_FILTER = "searchfilter";
/** Request parameter key for the selected item(s). */
public static final String PARAM_SEL_ITEMS = "selitems";
/** Request parameter key for the column to sort the list. */
public static final String PARAM_SORT_COL = "sortcol";
/** metadata map for all used list metadata objects. */
private static Map m_metadatas = new HashMap();
/** Activation decision Flag. */
private boolean m_active;
/** the internal list. */
private CmsHtmlList m_list;
/** The id of the list. */
private String m_listId;
/** The displayed page. */
private String m_paramFormName;
/** The list action. */
private String m_paramListAction;
/** The displayed page. */
private String m_paramPage;
/** The search filter text. */
private String m_paramSearchFilter;
/** The selected items, comma separated list. */
private String m_paramSelItems;
/** The column to sort the list. */
private String m_paramSortCol;
/** The column to search the list. */
private String m_searchColId;
/**
* Public constructor.<p>
* @param jsp an initialized JSP action element
* @param listId the id of the displayed list
* @param listName the name of the list
* @param sortedColId the a priory sorted column
* @param sortOrder the order of the sorted column
* @param searchableColId the column to search into
*/
protected A_CmsListDialog(
CmsJspActionElement jsp,
String listId,
CmsMessageContainer listName,
String sortedColId,
CmsListOrderEnum sortOrder,
String searchableColId) {
super(jsp);
// set list id
m_listId = listId;
// set active flag for 2 lists dialog
m_active = (getListId() + "-form").equals(getParamFormName());
setParamFormName(getListId() + "-form");
// abort if already forwarded
if (isForwarded()) {
return;
}
m_searchColId = searchableColId;
// try to read the list from the session
listRecovery(listId);
// initialization
if (getList() == null) {
// create the list
setList(new CmsHtmlList(listId, listName, getMetadata(this.getClass().getName(), listId)));
// set the number of items per page from the user settings
getList().setMaxItemsPerPage(getSettings().getUserSettings().getExplorerFileEntries());
// sort the list
if (sortedColId != null && getList().getMetadata().getColumnDefinition(sortedColId) != null) {
getList().setSortedColumn(sortedColId, getLocale());
if (sortOrder != null && sortOrder == CmsListOrderEnum.ORDER_DESCENDING) {
getList().setSortedColumn(sortedColId, getLocale());
}
}
// save the current state of the list
listSave();
}
}
/**
* Returns the list object for the given list dialog, or <code>null</code>
* if no list object has been set.<p>
*
* @param listDialog the list dialog class
* @param settings the wp settings for accessing the session
*
* @return the list object for this list dialog, or <code>null</code>
*/
public static CmsHtmlList getListObject(Class listDialog, CmsWorkplaceSettings settings) {
return (CmsHtmlList)getListObjectMap(settings).get(listDialog.getName());
}
/**
* Returns the (internal use only) map of list objects.<p>
*
* @param settings the wp settings for accessing the session
*
* @return the (internal use only) map of list objects
*/
private static Map getListObjectMap(CmsWorkplaceSettings settings) {
Map objects = (Map)settings.getListObject();
if (objects == null) {
// using hashtable as most efficient version of a synchronized map
objects = new Hashtable();
settings.setListObject(objects);
}
return objects;
}
/**
* Performs the dialog actions depending on the initialized action.<p>
*
* @throws JspException if dialog actions fail
* @throws IOException in case of errros forwarding to the required result page
* @throws ServletException in case of errros forwarding to the required result page
*/
public void actionDialog() throws JspException, ServletException, IOException {
if (getAction() == ACTION_CANCEL) {
// ACTION: cancel button pressed
actionCloseDialog();
return;
}
if (isForwarded()) {
return;
}
// TODO: check the need for this, improve caching
refreshList();
switch (getAction()) {
//////////////////// ACTION: default actions
case ACTION_LIST_SEARCH:
case ACTION_LIST_SORT:
case ACTION_LIST_SELECT_PAGE:
executeDefaultActions();
break;
//////////////////// ACTION: execute single list action
case ACTION_LIST_SINGLE_ACTION:
if (getSelectedItem() != null) {
executeListSingleActions();
}
break;
//////////////////// ACTION: execute multiple list actions
case ACTION_LIST_MULTI_ACTION:
executeListMultiActions();
break;
//////////////////// ACTION: execute independent list actions
case ACTION_LIST_INDEPENDENT_ACTION:
executeListIndepActions();
break;
case ACTION_DEFAULT:
default:
// ACTION: show dialog (default)
setParamAction(DIALOG_INITIAL);
}
}
/**
* Performs the dialog actions depending on the initialized action and displays the dialog form.<p>
*
* @throws JspException if dialog actions fail
* @throws IOException if writing to the JSP out fails, or in case of errros forwarding to the required result page
* @throws ServletException in case of errros forwarding to the required result page
*/
public void displayDialog() throws JspException, IOException, ServletException {
displayDialog(false);
}
/**
* Performs the dialog actions depending on the initialized action and displays the dialog form if needed.<p>
*
* @param writeLater if <code>true</code> no output is written,
* you have to call manually the <code>{@link #defaultActionHtml()}</code> method.
*
* @throws JspException if dialog actions fail
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -