cmslistmetadata.java
来自「找了很久才找到到源代码」· Java 代码 · 共 895 行 · 第 1/2 页
JAVA
895 行
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());
html.append("\n");
}
html.append("\t</div>\n");
html.append("</td>\n");
return html.toString();
}
/**
* Generates the hml code for an empty table.<p>
*
* @return html code
*/
public String htmlEmptyTable() {
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(getWp().getLocale()).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
*
* @return html code
*/
public String htmlHeader(CmsHtmlList list) {
StringBuffer html = new StringBuffer(1024);
html.append("<tr>\n");
Iterator itCols = m_columns.elementList().iterator();
while (itCols.hasNext()) {
CmsListColumnDefinition col = (CmsListColumnDefinition)itCols.next();
if (!col.isVisible() && !list.isPrintable()) {
continue;
}
if (!col.isPrintable() && list.isPrintable()) {
continue;
}
html.append(col.htmlHeader(list));
}
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 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, boolean odd, boolean isPrintable) {
StringBuffer html = new StringBuffer(1024);
html.append("<tr ");
if (!isPrintable) {
html.append("class='");
html.append(odd ? "oddrowbg" : (getWp().useNewStyle() ? "evenrowbg" : "evenrowbgnew"));
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) {
continue;
}
if (!col.isPrintable() && 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, isPrintable));
html.append("</td>\n");
}
if (!isPrintable && hasCheckMultiActions()) {
width++;
html.append("\t<td class='select' style='text-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.getId().equals(lid.getAtColumn())) {
break;
}
if (!col.isVisible() && !isPrintable) {
continue;
}
if (!col.isPrintable() && isPrintable) {
continue;
}
padCols++;
}
int spanCols = width - padCols;
html.append("<tr ");
if (!isPrintable) {
html.append("class='");
html.append(odd ? "oddrowbg" : (getWp().useNewStyle() ? "evenrowbg" : "evenrowbgnew"));
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, 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>
*
* @return html code
*/
public String htmlMultiActionBar() {
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());
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>
*
* @return html code
*/
public String htmlSearchBar() {
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' id='" + SEARCH_BAR_INPUT_ID + "' value='' size='20' maxlength='245' style='vertical-align: bottom;'>\n");
html.append(m_searchAction.buttonHtml());
I_CmsListAction showAllAction = m_searchAction.getShowAllAction();
if (showAllAction != null) {
html.append(" ");
html.append(showAllAction.buttonHtml());
}
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 the self Managed flag.<p>
*
* @return the self Managed flag
*/
public boolean isSelfManaged() {
return m_selfManaged;
}
/**
* 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;
if (m_searchAction != null) {
m_searchAction.setListId(getListId());
}
}
/**
* Sets the self Managed flag.<p>
*
* @param selfManaged the self Managed flag to set
*/
public void setSelfManaged(boolean selfManaged) {
this.m_selfManaged = selfManaged;
}
/**
* Sets the volatile flag.<p>
*
* @param volatileFlag the volatile flag to set
*/
public void setVolatile(boolean volatileFlag) {
m_volatile = volatileFlag;
}
/**
* Sets the related workplace dialog.<p>
*
* @param wp the related workplace dialog to set
*/
public void setWp(A_CmsListDialog wp) {
m_wp = wp;
Iterator itCols = getColumnDefinitions().iterator();
while (itCols.hasNext()) {
CmsListColumnDefinition column = (CmsListColumnDefinition)itCols.next();
column.setWp(wp);
}
Iterator itDets = getItemDetailDefinitions().iterator();
while (itDets.hasNext()) {
CmsListItemDetails detail = (CmsListItemDetails)itDets.next();
detail.setWp(wp);
}
Iterator itMultiActs = getMultiActions().iterator();
while (itMultiActs.hasNext()) {
CmsListMultiAction action = (CmsListMultiAction)itMultiActs.next();
action.setWp(wp);
}
Iterator itIndActs = getIndependentActions().iterator();
while (itIndActs.hasNext()) {
I_CmsListAction action = (I_CmsListAction)itIndActs.next();
action.setWp(wp);
}
if (m_searchAction != null) {
m_searchAction.setWp(wp);
}
}
/**
* 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 + =
减小字号Ctrl + -
显示快捷键?