selectlistmodel.java
来自「GridSphere 门户 提供一个基于 portlet 的高级开放源代码门户。」· Java 代码 · 共 58 行
JAVA
58 行
/* * @author <a href="mailto:novotny@gridsphere.org">Jason Novotny</a> * @version $Id: SelectListModel.java 4496 2006-02-08 20:27:04Z wehrens $ */package org.gridsphere.provider.portletui.model;import org.gridsphere.provider.portletui.beans.ListBoxItemBean;import java.util.ArrayList;import java.util.Iterator;import java.util.List;/** * A <code>SelectListModel</code> is a list model that tags elements of the list as selected */public class SelectListModel extends DefaultListModel { /** * Set an item in the list to be selected * * @param index the items location in the list * @param flag is true if the list item is selected, false otherwise */ public void setSelected(int index, boolean flag) { ((ListBoxItemBean) list.get(index)).setSelected(flag); } /** * Deselects all items in the list */ public void unselectAll() { Iterator it = list.iterator(); while (it.hasNext()) { ((ListBoxItemBean) it.next()).setSelected(false); } } /** * Return a list of selected items * * @return a list of selected items */ public List getSelectedItems() { Iterator it = list.iterator(); List selectedList = new ArrayList(); while (it.hasNext()) { ListBoxItemBean item = (ListBoxItemBean) it.next(); if (item.isSelected()) { selectedList.add(item); } } return selectedList; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?