📄 cmslistmetadata.java
字号:
}
return false;
}
/**
* Returns the html code for the action bar.<p>
*
* @param wp the workplace context
*
* @return html code
*/
public String htmlActionBar(CmsWorkplace wp) {
StringBuffer html = new StringBuffer(1024);
html.append("<td class='misc'>\n");
html.append("\t<div>\n");
Iterator itDetails = m_itemDetails.elementList().iterator();
while (itDetails.hasNext()) {
I_CmsListAction detailAction = ((CmsListItemDetails)itDetails.next()).getAction();
html.append("\t\t");
html.append(detailAction.buttonHtml(wp));
if (itDetails.hasNext()) {
html.append(" ");
}
html.append("\n");
}
Iterator itActions = m_indepActions.elementList().iterator();
while (itActions.hasNext()) {
I_CmsListAction indepAction = (I_CmsListAction)itActions.next();
html.append("\t\t");
html.append(" ");
html.append(indepAction.buttonHtml(wp));
html.append("\n");
}
html.append("\t</div>\n");
html.append("</td>\n");
return html.toString();
}
/**
* Generates the hml code for an empty table.<p>
*
* @param locale for localization
*
* @return html code
*/
public String htmlEmptyTable(Locale locale) {
StringBuffer html = new StringBuffer(512);
html.append("<tr class='oddrowbg'>\n");
html.append("\t<td align='center' colspan='");
html.append(getWidth());
html.append("'>\n");
html.append(Messages.get().getBundle(locale).key(Messages.GUI_LIST_EMPTY_0));
html.append("\t</td>\n");
html.append("</tr>\n");
return html.toString();
}
/**
* Returns the html code for the header of the list.<p>
*
* @param list the list to generate the code for
* @param wp the workplace instance
*
* @return html code
*/
public String htmlHeader(CmsHtmlList list, CmsWorkplace wp) {
StringBuffer html = new StringBuffer(1024);
html.append("<tr>\n");
Iterator itCols = m_columns.elementList().iterator();
while (itCols.hasNext()) {
CmsListColumnDefinition col = (CmsListColumnDefinition)itCols.next();
if (!list.isPrintable() || col.isPrintable()) {
html.append(col.htmlHeader(list, wp));
}
}
if (!list.isPrintable() && hasCheckMultiActions()) {
html.append("\t<th width='0' class='select'>\n");
html.append("\t\t<input type='checkbox' class='checkbox' name='listSelectAll' value='true' onClick=\"listSelect('");
html.append(list.getId());
html.append("')\">\n");
html.append("\t</th>\n");
}
html.append("</tr>\n");
return html.toString();
}
/**
* Returns the html code for a list item.<p>
*
* @param item the list item to render
* @param wp the workplace context
* @param odd if the position is odd or even
* @param isPrintable if the list is to be printed
*
* @return html code
*/
public String htmlItem(CmsListItem item, CmsWorkplace wp, boolean odd, boolean isPrintable) {
StringBuffer html = new StringBuffer(1024);
html.append("<tr ");
if (!isPrintable) {
html.append("class='");
html.append(odd ? "oddrowbg" : "evenrowbg");
html.append("'");
}
html.append(">\n");
Iterator itCols = m_columns.elementList().iterator();
int width = 0;
while (itCols.hasNext()) {
CmsListColumnDefinition col = (CmsListColumnDefinition)itCols.next();
if (!col.isVisible() || (isPrintable && !col.isPrintable())) {
continue;
}
width++;
StringBuffer style = new StringBuffer(64);
html.append("<td");
CmsListColumnAlignEnum align = col.getAlign();
if (align != CmsListColumnAlignEnum.ALIGN_LEFT && CmsStringUtil.isNotEmpty(align.toString())) {
style.append("text-align: ");
style.append(col.getAlign());
style.append("; ");
}
if (col.isTextWrapping()) {
style.append("white-space: normal;");
}
if (isPrintable) {
style.append("border-top: 1px solid black;");
}
if (style.length() > 0) {
html.append(" style='");
html.append(style);
html.append("'");
}
html.append(">\n");
html.append(col.htmlCell(item, wp, isPrintable));
html.append("</td>\n");
}
if (!isPrintable && hasCheckMultiActions()) {
width++;
html.append("\t<td class='select' align='center'>\n");
html.append("\t\t<input type='checkbox' class='checkbox' name='listMultiAction' value='");
html.append(item.getId());
html.append("'>\n");
html.append("\t</td>\n");
}
html.append("</tr>\n");
Iterator itDet = m_itemDetails.elementList().iterator();
while (itDet.hasNext()) {
CmsListItemDetails lid = (CmsListItemDetails)itDet.next();
if (lid.isVisible()
&& item.get(lid.getId()) != null
&& CmsStringUtil.isNotEmptyOrWhitespaceOnly(item.get(lid.getId()).toString())) {
int padCols = 0;
itCols = m_columns.elementList().iterator();
while (itCols.hasNext()) {
CmsListColumnDefinition col = (CmsListColumnDefinition)itCols.next();
if (!col.isVisible() || (isPrintable && !col.isPrintable())) {
continue;
}
if (col.getId().equals(lid.getAtColumn())) {
break;
}
padCols++;
}
int spanCols = width - padCols;
html.append("<tr ");
if (!isPrintable) {
html.append("class='");
html.append(odd ? "oddrowbg" : "evenrowbg");
html.append("'");
}
html.append(">\n");
if (padCols > 0) {
html.append("<td colspan='");
html.append(padCols);
html.append("'> </td>\n");
}
html.append("<td colspan='");
html.append(spanCols);
html.append("' style='padding-left: 20px; white-space:normal;'>\n");
html.append(lid.htmlCell(item, wp, isPrintable));
html.append("\n</td>\n");
html.append("\n");
html.append("</tr>\n");
}
}
return html.toString();
}
/**
* Returns the html code for the multi action bar.<p>
*
* @param wp the workplace context
*
* @return html code
*/
public String htmlMultiActionBar(CmsWorkplace wp) {
StringBuffer html = new StringBuffer(1024);
html.append("<td class='misc'>\n");
html.append("\t<div>\n");
Iterator itActions = m_multiActions.elementList().iterator();
while (itActions.hasNext()) {
CmsListMultiAction multiAction = (CmsListMultiAction)itActions.next();
html.append("\t\t");
html.append(multiAction.buttonHtml(wp));
if (itActions.hasNext()) {
html.append(" ");
}
html.append("\n");
}
html.append("\t</div>\n");
html.append("</td>\n");
return html.toString();
}
/**
* Generates the html code for the search bar.<p>
*
* @param wp the workplace context
*
* @return html code
*/
public String htmlSearchBar(CmsWorkplace wp) {
if (!isSearchable()) {
return "";
}
StringBuffer html = new StringBuffer(1024);
html.append("<td class='main'>\n");
html.append("\t<div>\n");
html.append("\t\t<input type='text' name='listSearchFilter' value='' size='20' maxlength='245' style='vertical-align: bottom;'>\n");
html.append(m_searchAction.buttonHtml(wp));
I_CmsListAction showAllAction = m_searchAction.getShowAllAction();
if (showAllAction != null) {
html.append(" ");
html.append(showAllAction.buttonHtml(wp));
}
html.append("\t</div>\n");
html.append("</td>\n");
return html.toString();
}
/**
* Returns <code>true</code> if the list is searchable.<p>
*
* @return <code>true</code> if the list is searchable
*/
public boolean isSearchable() {
return m_searchAction != null;
}
/**
* Returns <code>true</code> if any column is sorteable.<p>
*
* @return <code>true</code> if any column is sorteable
*/
public boolean isSorteable() {
Iterator itCols = m_columns.elementList().iterator();
while (itCols.hasNext()) {
CmsListColumnDefinition col = (CmsListColumnDefinition)itCols.next();
if (col.isSorteable()) {
return true;
}
}
return false;
}
/**
* Returns <code>true</code> if this metadata object should not be cached.<p>
*
* @return <code>true</code> if this metadata object should not be cached.<p>
*/
public boolean isVolatile() {
return m_volatile;
}
/**
* Sets the search action.<p>
*
* @param searchAction the search action to set
*/
public void setSearchAction(CmsListSearchAction searchAction) {
m_searchAction = searchAction;
m_searchAction.setListId(getListId());
}
/**
* Sets the volatile flag.<p>
*
* @param volatileFlag the volatile flag to set
*/
public void setVolatile(boolean volatileFlag) {
m_volatile = volatileFlag;
}
/**
* Toggles the given item detail state from visible to hidden or
* from hidden to visible.<p>
*
* @param itemDetailId the item detail id
*/
public void toogleDetailState(String itemDetailId) {
CmsListItemDetails lid = (CmsListItemDetails)m_itemDetails.getObject(itemDetailId);
lid.setVisible(!lid.isVisible());
}
/**
* Throws a runtime exception if there are 2 identical ids.<p>
*
* This includes:<p>
* <ul>
* <li><code>{@link CmsListIndependentAction}</code>s</li>
* <li><code>{@link CmsListMultiAction}</code>s</li>
* <li><code>{@link CmsListItemDetails}</code></li>
* <li><code>{@link CmsListColumnDefinition}</code>s</li>
* <li><code>{@link CmsListDefaultAction}</code>s</li>
* <li><code>{@link CmsListDirectAction}</code>s</li>
* </ul>
*/
/*package*/void checkIds() {
Set ids = new TreeSet();
// indep actions
Iterator itIndepActions = getIndependentActions().iterator();
while (itIndepActions.hasNext()) {
String id = ((CmsListIndependentAction)itIndepActions.next()).getId();
if (ids.contains(id)) {
throw new CmsIllegalStateException(Messages.get().container(Messages.ERR_DUPLICATED_ID_1, id));
}
ids.add(id);
}
// multi actions
Iterator itMultiActions = getMultiActions().iterator();
while (itMultiActions.hasNext()) {
String id = ((CmsListMultiAction)itMultiActions.next()).getId();
if (ids.contains(id)) {
throw new CmsIllegalStateException(Messages.get().container(Messages.ERR_DUPLICATED_ID_1, id));
}
ids.add(id);
}
// details
Iterator itItemDetails = getItemDetailDefinitions().iterator();
while (itItemDetails.hasNext()) {
String id = ((CmsListItemDetails)itItemDetails.next()).getId();
if (ids.contains(id)) {
throw new CmsIllegalStateException(Messages.get().container(Messages.ERR_DUPLICATED_ID_1, id));
}
ids.add(id);
}
// columns
Iterator itColumns = getColumnDefinitions().iterator();
while (itColumns.hasNext()) {
CmsListColumnDefinition col = (CmsListColumnDefinition)itColumns.next();
if (ids.contains(col.getId())) {
throw new CmsIllegalStateException(Messages.get().container(Messages.ERR_DUPLICATED_ID_1, col.getId()));
}
ids.add(col.getId());
// default actions
Iterator itDefaultActions = col.getDefaultActions().iterator();
while (itDefaultActions.hasNext()) {
CmsListDefaultAction action = (CmsListDefaultAction)itDefaultActions.next();
if (ids.contains(action.getId())) {
throw new CmsIllegalStateException(Messages.get().container(
Messages.ERR_DUPLICATED_ID_1,
action.getId()));
}
ids.add(action.getId());
}
// direct actions
Iterator itDirectActions = col.getDirectActions().iterator();
while (itDirectActions.hasNext()) {
CmsListDirectAction action = (CmsListDirectAction)itDirectActions.next();
if (ids.contains(action.getId())) {
throw new CmsIllegalStateException(Messages.get().container(
Messages.ERR_DUPLICATED_ID_1,
action.getId()));
}
ids.add(action.getId());
}
}
}
/**
* Sets the list id for all column single actions.<p>
*
* @param col the column to set the list id for
*/
private void setListIdForColumn(CmsListColumnDefinition col) {
col.setListId(getListId());
// default actions
Iterator itDefaultActions = col.getDefaultActions().iterator();
while (itDefaultActions.hasNext()) {
((CmsListDefaultAction)itDefaultActions.next()).setListId(getListId());
}
// direct actions
Iterator itDirectActions = col.getDirectActions().iterator();
while (itDirectActions.hasNext()) {
((CmsListDirectAction)itDirectActions.next()).setListId(getListId());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -