KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > swing > JXList


1 /*
2  * $Id: JXList.java,v 1.1.1.1 2004/06/16 01:43:39 davidson1 Exp $
3  *
4  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5  * Santa Clara, California 95054, U.S.A. All rights reserved.
6  */

7
8 package org.jdesktop.swing;
9
10 import java.util.Vector JavaDoc;
11
12 import javax.swing.JList JavaDoc;
13 import javax.swing.ListModel JavaDoc;
14
15 import org.jdesktop.swing.decorator.ComponentAdapter;
16 import org.jdesktop.swing.decorator.FilterPipeline;
17 import org.jdesktop.swing.decorator.Highlighter;
18 import org.jdesktop.swing.decorator.HighlighterPipeline;
19
20 /**
21  * JXList
22  *
23  * @author Ramesh Gupta
24  */

25 public class JXList extends JList JavaDoc {
26     /**
27      * Array of {@link Highlighter} objects that will be used to highlight
28      * the cell renderer for this component.
29      */

30     protected FilterPipeline filters = null;
31     protected HighlighterPipeline highlighters = null;
32
33     // MUST ALWAYS ACCESS dataAdapter through accessor method!!!
34
private final ComponentAdapter dataAdapter = new ListAdapter(this);
35
36     public JXList() {
37     }
38
39     public JXList(ListModel JavaDoc dataModel) {
40         super(dataModel);
41     }
42
43     public JXList(Object JavaDoc[] listData) {
44         super(listData);
45     }
46
47     public JXList(Vector JavaDoc listData) {
48         super(listData);
49     }
50
51     public FilterPipeline getFilters() {
52         return filters;
53     }
54
55     public void setFilters(FilterPipeline pipeline) {
56         /**@todo setFilters
57         TableModel model = getModel();
58         adjustListeners(pipeline, model, model);
59         */

60         filters = pipeline;
61     }
62
63     public HighlighterPipeline getHighlighters() {
64         return highlighters;
65     }
66
67     public void setHighlighters(HighlighterPipeline pipeline) {
68         highlighters = pipeline;
69     }
70
71     protected ComponentAdapter getComponentAdapter() {
72         // MUST ALWAYS ACCESS dataAdapter through accessor method!!!
73
return dataAdapter;
74     }
75
76
77     static class ListAdapter extends ComponentAdapter {
78         private final JList JavaDoc list;
79
80         /**
81          * Constructs a <code>ListDataAdapter</code> for the specified
82          * target component.
83          *
84          * @param component the target component
85          */

86         public ListAdapter(JList JavaDoc component) {
87             super(component);
88             list = component;
89         }
90
91         /**
92          * Typesafe accessor for the target component.
93          *
94          * @return the target component as a {@link javax.swing.JList}
95          */

96         public JList JavaDoc getList() {
97             return list;
98         }
99
100         /**
101          * {@inheritDoc}
102          */

103         public boolean hasFocus() {
104             /** @todo Think through printing implications */
105             return list.isFocusOwner() && (row == list.getLeadSelectionIndex());
106         }
107
108         public int getRowCount() {
109             return list.getModel().getSize();
110         }
111
112         /**
113          * {@inheritDoc}
114          */

115         public Object JavaDoc getValueAt(int row, int column) {
116             return list.getModel().getElementAt(row);
117         }
118
119         public Object JavaDoc getFilteredValueAt(int row, int column) {
120             /** @todo Implement getFilteredValueAt */
121             throw new UnsupportedOperationException JavaDoc(
122                 "Method getFilteredValueAt() not yet implemented.");
123         }
124
125         public void setValueAt(Object JavaDoc aValue, int row, int column) {
126             /** @todo Implement getFilteredValueAt */
127             throw new UnsupportedOperationException JavaDoc(
128                 "Method getFilteredValueAt() not yet implemented.");
129         }
130
131         public boolean isCellEditable(int row, int column) {
132             /** @todo Implement getFilteredValueAt */
133             return false;
134         }
135
136         /**
137          * {@inheritDoc}
138          */

139         public boolean isSelected() {
140             /** @todo Think through printing implications */
141             return list.isSelectedIndex(row);
142         }
143
144     }
145 }
146
Popular Tags