View Javadoc

1   /*
2    * Copyright (c) 2003-2008 by Cosylab d. d.
3    *
4    * This file is part of CosyBeans-Common.
5    *
6    * CosyBeans-Common is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU General Public License as published by
8    * the Free Software Foundation, either version 3 of the License, or
9    * (at your option) any later version.
10   *
11   * CosyBeans-Common is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.
15   *
16   * You should have received a copy of the GNU General Public License
17   * along with CosyBeans-Common.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  
20  package com.cosylab.gui.components.introspection;
21  
22  import java.awt.Component;
23  import java.lang.reflect.Member;
24  
25  import javax.swing.DefaultListCellRenderer;
26  
27  import com.cosylab.introspection.DataFormatter;
28  
29  /**
30   * Creation date: (12.1.2002 2:56:04)
31   * 
32   * @author <a href="mailto:miha.kadunc@cosylab.com">Miha Kadunc</a>
33   * @version $id$
34   */
35  public class MemberListCellRenderer extends DefaultListCellRenderer {
36  
37  	private static final long serialVersionUID = 1L;
38  	private boolean fShowType=true;
39  	private boolean fShowParameters=false;
40  /**
41   * MemberListCellRenderer constructor comment.
42   * @param showType boolean
43   * @param showParameters boolean
44   */
45  public MemberListCellRenderer(boolean showType, boolean showParameters) {
46  	super();
47  	fShowType=showType;
48  	fShowParameters=showParameters;
49  }
50  /**
51   * Creation date: (12.1.2002 2:56:47)
52   * @param list javax.swing.JList
53   * @param value Object
54   * @param index int
55   * @param isSelected boolean
56   * @param cellHasFocus boolean
57   * @return Component
58   * @see javax.swing.ListCellRenderer#getListCellRendererComponent(JList, Object, int, boolean, boolean)
59   */
60  public Component getListCellRendererComponent(
61    javax.swing.JList list,
62    Object value,
63    int index,
64    boolean isSelected,
65    boolean cellHasFocus) {
66  	  
67  	return super.getListCellRendererComponent(list,toString((Member)value),index,isSelected,cellHasFocus);
68  }
69  /**
70   * Creation date: (12.1.2002 2:56:47)
71   * @param aMember Member
72   * @return String
73   */
74  public String toString(Member aMember) {
75  	return DataFormatter.toString(aMember,fShowType,fShowParameters);
76  }
77  }