📄 treemodel.java
字号:
/* * Copyright 2004 original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.extremecomponents.tree.core;import java.util.ArrayList;import java.util.Collection;import java.util.Map;import javax.servlet.jsp.PageContext;import org.extremecomponents.base.BaseModel;import org.extremecomponents.base.BaseProperties;import org.extremecomponents.base.BaseResourceBundle;import org.extremecomponents.base.BaseSortHandler;import org.extremecomponents.base.BaseViewHandler;import org.extremecomponents.table.callback.RetrieveRowsCallback;import org.extremecomponents.table.core.ParameterRegistry;import org.extremecomponents.tree.handler.SortHandler;import org.extremecomponents.tree.handler.ViewHandler;/** * org.extremecomponents.tree.model.TreeModel.java - * * @author Paul Horn */public class TreeModel extends BaseModel { public static final String FILTERED_COUNT = "FILTERED_COUNT"; private String parentAttribute; private String identifier; private String extendedValue; private Map openNodes; private TreeProperties properties = new TreeProperties(this); private TreeResourceBundle resourceBundle = new TreeResourceBundle(this); private SortHandler sortHandler = new SortHandler(this); private ViewHandler viewHandler = new ViewHandler(this); public TreeModel(PageContext pageContext) { super(pageContext); } /** * Do all the filtering and sorting and return the rows of the table that * need to be displayed. */ public Collection execute() throws Exception { openNodes = getRegistry().getParameters(ParameterRegistry.OPEN); RetrieveRowsCallback retrieveRowsCallback = (RetrieveRowsCallback) getCallback(getTableHandler().getTable() .getRetrieveRowsCallback()); getTableHandler().setCollectionOfBeans(retrieveRowsCallback.retrieveRows(this)); //make a copy for thread safety Collection rows = new ArrayList(getTableHandler().getCollectionOfBeans()); if (getFilterHandler().doFilter() && !getFilterHandler().doClear()) { rows = getFilterHandler().filterRows(this, rows); rows = TreeModelUtils.findParents(this, rows); rows = TreeModelUtils.loadTreeStructure(this, rows); TreeModelUtils.addClosedChildren(this, rows); } else { rows = TreeModelUtils.loadTreeStructure(this, rows); } getSortHandler().sortRows(rows); //sort the list setFilteredCount(rows); getTableHandler().setTableSections(rows.size()); viewHandler.setView(); return rows; } private void setFilteredCount(Collection filteredSortedRows) { if (filteredSortedRows == null) { getTableHandler().getTable().addAttribute(FILTERED_COUNT, "0"); return; } getTableHandler().getTable().addAttribute(FILTERED_COUNT, filteredSortedRows.size() + ""); } public void destroy() { properties = null; resourceBundle = null; sortHandler = null; viewHandler = null; super.destroy(); } public BaseSortHandler getSortHandler() { return sortHandler; } public void setSortHandler(SortHandler sortHandler) { this.sortHandler = sortHandler; } public BaseViewHandler getViewHandler() { return viewHandler; } public void setViewHandler(ViewHandler viewHandler) { this.viewHandler = viewHandler; } public TreeProperties getTreeProperties() { return properties; } public String getParentAttribute() { return parentAttribute; } public void setParentAttribute(String parentAttribute) { this.parentAttribute = parentAttribute; } public void setProperties(TreeProperties properties) { this.properties = properties; } public Map getOpenNodes() { return openNodes; } public void setOpenNodes(Map openNodes) { this.openNodes = openNodes; } public String getIdentifier() { return identifier; } public void setIdentifier(String identifier) { this.identifier = identifier; } public String getExtendedValue() { return extendedValue; } public void setExtendedValue(String extendedValue) { this.extendedValue = extendedValue; } public BaseProperties getProperties() { return properties; } public BaseResourceBundle getResourceBundle() { return resourceBundle; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -