⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 selectlistmodel.java

📁 GridSphere 门户 提供一个基于 portlet 的高级开放源代码门户。GridSphere 是在欧盟提供基金的 GridLab 项目下开发的
💻 JAVA
字号:
/* * @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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -