1 /*
2 * (C) 2002 David Carr david@carr.name
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 package net.sourceforge.mflow.confwiz;
20
21 import javax.swing;
22 import net.sourceforge.mflow;
23 import java.awt;
24
25 /**
26 * A ListCellRenderer to show the name of a MsgFlowComponent
27 *
28 * @author <a href="mailto:david@carr.name">David Carr</a>
29 */
30 public class MsgFlowComponentRenderer extends DefaultListCellRenderer {
31 /**
32 * For a MsgFlowComponent, returns a component displaying its name
33 * For everything else, behaves identically to the DefaultListCellRenderer
34 *
35 * @param list the list to render for
36 * @param value the object to render into the list
37 * @param index the index of the object in the list
38 * @param isSelected whether or not the object is selected
39 * @param cellHasFocus whether or not the object has focus
40 * @return a component to display the object in the list
41 */
42 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
43 if(value instanceof MsgFlowComponent) {
44 MsgFlowComponent c = (MsgFlowComponent)value;
45 return super.getListCellRendererComponent(list, c.getName(), index, isSelected, cellHasFocus);
46 } else {
47 return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
48 }
49 }
50 }