📄 cmstabdialog.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/CmsTabDialog.java,v $
* Date : $Date: 2006/03/27 14:52:43 $
* Version: $Revision: 1.21 $
*
* 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;
import org.opencms.i18n.CmsEncoder;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.main.CmsLog;
import org.opencms.util.CmsStringUtil;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext;
import org.apache.commons.logging.Log;
/**
* Provides methods for tab styled dialogs.<p>
*
* Extend this class in order to create a tab styled dialog and provide the methods
* getTabs() and getTabParameterOrder() in the new dialog class which should return lists
* which represent the tabs of the dialog.<p>
*
* This class is used for the following dialogs:
* <ul>
* <li>User preferences (CmsPreferences.java)
* </ul>
* <p>
*
* @author Andreas Zahner
*
* @version $Revision: 1.21 $
*
* @since 6.0.0
*/
public abstract class CmsTabDialog extends CmsDialog {
/** Value for the action: switch the tab. */
public static final int ACTION_SWITCHTAB = 100;
/** Request parameter value for the action: switch the tab. */
public static final String DIALOG_SWITCHTAB = "switchtab";
/** Name of the request parameter for the set button pressed flag. */
public static final String PARAM_SETPRESSED = "setpressed";
/** Name of the request parameter for the current tab. */
public static final String PARAM_TAB = "tab";
/** The log object for this class. */
private static final Log LOG = CmsLog.getLog(CmsTabDialog.class);
/** Stores the currently active tab. */
private int m_activeTab = -1;
/** Determines if the "set" button was pressed. */
private String m_paramSetPressed;
/** Stores the current tab. */
private String m_paramTab;
/**
* Public constructor.<p>
*
* @param jsp an initialized JSP action element
*/
public CmsTabDialog(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 CmsTabDialog(PageContext context, HttpServletRequest req, HttpServletResponse res) {
this(new CmsJspActionElement(context, req, res));
}
/**
* Builds the tab content area of the dialog window.<p>
*
* @param segment the HTML segment (START / END)
* @param title the title String for the dialog window
* @param attributes additional attributes for the content <div> area of the tab dialog
* @return a tab content area start / end segment
*/
public String dialogTabContent(int segment, String title, String attributes) {
if (segment == HTML_START) {
StringBuffer result = new StringBuffer(512);
// null title is ok, we always want the title headline
result.append(dialogHead(title));
result.append("<div class=\"dialogtabstart\" unselectable=\"on\">\n");
result.append("<!-- dialogtabs start -->\n");
result.append(dialogTabRow());
result.append("<div class=\"dialogtabcontent\"");
if (attributes != null) {
result.append(" " + attributes);
}
result.append(">\n");
result.append("<!-- dialogcontent start -->\n");
return result.toString();
} else {
return "\n<!-- dialogcontent end --></div>\n<!-- dialogtabs end --></div>";
}
}
/**
* Returns the end html for the tab content area of the dialog window.<p>
*
* @return the end html for the tab content area of the dialog window
*/
public String dialogTabContentEnd() {
return dialogTabContent(HTML_END, null, null);
}
/**
* Returns the start html for the tab content area of the dialog window.<p>
*
* @param title the title for the dialog
* @return the start html for the tab content area of the dialog window
*/
public String dialogTabContentStart(String title) {
return dialogTabContent(HTML_START, title, null);
}
/**
* Returns the start html for the tab content area of the dialog window.<p>
*
* @param title the title for the dialog
* @param attributes additional attributes for the content <div> area of the tab dialog
* @return the start html for the tab content area of the dialog window
*/
public String dialogTabContentStart(String title, String attributes) {
return dialogTabContent(HTML_START, title, attributes);
}
/**
* Builds the html for the tab row of the tab dialog.<p>
*
* @return the html for the tab row
*/
public String dialogTabRow() {
StringBuffer result = new StringBuffer(512);
StringBuffer lineRow = new StringBuffer(256);
List tabNames = getTabs();
if (tabNames.size() < 2) {
// less than 2 tabs present, do not show them and create a border line
result.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"maxwidth\" style=\"empty-cells: show;\">\n");
result.append("<tr>\n");
result.append("\t<td class=\"dialogtabrow\"></td>\n");
result.append("</tr>\n");
result.append("</table>\n");
return result.toString();
}
Iterator i = tabNames.iterator();
int counter = 1;
int activeTab = getActiveTab();
result.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"maxwidth\" style=\"empty-cells: show;\">\n");
result.append("<tr>\n");
while (i.hasNext()) {
// build a tab entry
String curTab = (String)i.next();
String curTabLink = "javascript:openTab('" + counter + "');";
if (counter == activeTab) {
// create the currently active tab
int addDelta = 0;
result.append("\t<td class=\"dialogtabactive\"");
if (counter == 1) {
// for first tab, add special html for correct layout
result.append(" style=\"border-left-width: 1px;\"");
addDelta = 1;
}
result.append(">");
result.append("<span class=\"tabactive\" unselectable=\"on\"");
result.append(" style=\"width: " + (curTab.length() * 8 + addDelta) + "px;\"");
result.append(">");
result.append(curTab);
result.append("</span></td>\n");
lineRow.append("\t<td></td>\n");
} else {
// create an inactive tab
result.append("\t<td class=\"dialogtab\" unselectable=\"on\">");
result.append("<a class=\"tab\" href=\"" + curTabLink + "\"");
result.append(" style=\"width: " + (curTab.length() * 8) + "px;\"");
result.append(">");
result.append(curTab);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -