001: /*
002: * This file is part of the Echo Web Application Framework (hereinafter "Echo").
003: * Copyright (C) 2002-2005 NextApp, Inc.
004: *
005: * Version: MPL 1.1/GPL 2.0/LGPL 2.1
006: *
007: * The contents of this file are subject to the Mozilla Public License Version
008: * 1.1 (the "License"); you may not use this file except in compliance with
009: * the License. You may obtain a copy of the License at
010: * http://www.mozilla.org/MPL/
011: *
012: * Software distributed under the License is distributed on an "AS IS" basis,
013: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
014: * for the specific language governing rights and limitations under the
015: * License.
016: *
017: * Alternatively, the contents of this file may be used under the terms of
018: * either the GNU General Public License Version 2 or later (the "GPL"), or
019: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
020: * in which case the provisions of the GPL or the LGPL are applicable instead
021: * of those above. If you wish to allow use of your version of this file only
022: * under the terms of either the GPL or the LGPL, and not to allow others to
023: * use your version of this file under the terms of the MPL, indicate your
024: * decision by deleting the provisions above and replace them with the notice
025: * and other provisions required by the GPL or the LGPL. If you do not delete
026: * the provisions above, a recipient may use your version of this file under
027: * the terms of any one of the MPL, the GPL or the LGPL.
028: */
029:
030: package nextapp.echo2.app.list;
031:
032: import java.io.Serializable;
033:
034: import nextapp.echo2.app.event.ChangeListener;
035:
036: /**
037: * A representation of the selected items in a list component.
038: */
039: public interface ListSelectionModel extends Serializable {
040:
041: public static final int SINGLE_SELECTION = 0;
042: public static final int MULTIPLE_SELECTION = 2;
043:
044: /**
045: * Adds a <code>ChangeListenerb</code> to the selection model, which will
046: * be notified when the selection changes.
047: *
048: * @param l the <code>ChangeListener</code> to add
049: */
050: public void addChangeListener(ChangeListener l);
051:
052: /**
053: * Deselects all items.
054: */
055: public void clearSelection();
056:
057: /**
058: * Returns the maximum selected index.
059: * Returns -1 when no items are selected.
060: *
061: * @return the maximum selected index
062: */
063: public int getMaxSelectedIndex();
064:
065: /**
066: * Returns the minimum selected index.
067: * Returns -1 when no items are selected.
068: *
069: * @return the minimum selected index
070: */
071: public int getMinSelectedIndex();
072:
073: /**
074: * Returns the selection mode.
075: *
076: * @return the selection mode, one of the following values:
077: * <ul>
078: * <li><code>ListSelectionModel.SINGLE_SELECTION</code>: only
079: * one list element may be selected.</li>
080: * <li><code>ListSelectionModel.MULTIPLE_SELECTION</code>:
081: * multiple list elements may be selected.</li>
082: * </ul>
083: */
084: public int getSelectionMode();
085:
086: /**
087: * Determines whether an index is selected.
088: *
089: * @param index the index
090: * @return true if the index is selected
091: */
092: public boolean isSelectedIndex(int index);
093:
094: /**
095: * Determines if no items are selected.
096: *
097: * @return true if no items are selected
098: */
099: public boolean isSelectionEmpty();
100:
101: /**
102: * Removes a <code>ChangeListener</code> from being notified of when the
103: * selection changes.
104: *
105: * @param l the <code>ChangeListener</code> to remove
106: */
107: public void removeChangeListener(ChangeListener l);
108:
109: /**
110: * Sets the selection state of the given index.
111: *
112: * @param index the index
113: * @param selected the new selection state
114: */
115: public void setSelectedIndex(int index, boolean selected);
116:
117: /**
118: * Sets the selection mode.
119: *
120: * @param selectionMode the selection mode, one of the following values:
121: * <ul>
122: * <li><code>ListSelectionModel.SINGLE_SELECTION</code>: only one list element
123: * may be selected.</li>
124: * <li><code>ListSelectionModel.MULTIPLE_SELECTION</code>: multiple list elements
125: * may be selected.</li>
126: * </ul>
127: */
128: public void setSelectionMode(int selectionMode);
129: }
|