1 /*
2 * Copyright 2006-2016 The JGUIraffe Team.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License")
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package net.sf.jguiraffe.gui.builder.components.model;
17
18 import net.sf.jguiraffe.gui.forms.ComponentHandler;
19
20 /**
21 * <p>
22 * A specialized component handler interface for components with list-like
23 * structures.
24 * </p>
25 * <p>
26 * This component handler interface extends the base interface by some methods
27 * that allow access to the component's <code>{@link ListModel}</code> and
28 * support its manipulation. This can be useful in cases where an application
29 * needs to update displayed lists at runtime, e.g. in reaction of user input.
30 * </p>
31 * <p>
32 * When dealing with list-like components like combo boxes or list boxes, the
33 * <code>ComponentHandler</code> reference returned by the
34 * <code>ComponentBuilderData</code> instance for these components can be casted into a
35 * <code>ListComponentHandler</code>. Then the additional methods are
36 * available.
37 * </p>
38 *
39 * @author Oliver Heger
40 * @version $Id: ListComponentHandler.java 205 2012-01-29 18:29:57Z oheger $
41 */
42 public interface ListComponentHandler extends ComponentHandler<Object>
43 {
44 /**
45 * Returns the <code>ListModel</code> for this component. From this object
46 * the list's current content can be obtained. Note that the object returned
47 * here need not be identical to or even of the same class than the original
48 * specified list model for the component. A component manager
49 * implementation can provide a different <code>ListModel</code>
50 * implementation.
51 *
52 * @return the component's list model
53 */
54 ListModel getListModel();
55
56 /**
57 * Adds an item to the component's list model. This new item will imediately
58 * be displayed in the component's list.
59 *
60 * @param index the index where the item is to be inserted (0 based)
61 * @param display the display object (to be displayed in the list)
62 * @param value the corresponding value object (to be stored in the form's
63 * data; can be <b>null</b>)
64 */
65 void addItem(int index, Object display, Object value);
66
67 /**
68 * Removes the list item at the given index.
69 *
70 * @param index the index of the item to remove
71 */
72 void removeItem(int index);
73 }