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.table.renderers;
21  
22  import com.cosylab.gui.components.table.cells.StringCell;
23  
24  import java.awt.Component;
25  
26  import javax.swing.JTable;
27  
28  
29  /**
30   * Default table renderer for StringCell. Displays String value
31   *
32   * @author <a href="mailto:ales.pucelj@cosylab.com">Ales Pucelj</a>
33   * @version $id$
34   */
35  public class StringCellRenderer extends DefaultTableCellRenderer
36  {
37  	private static final long serialVersionUID = 1L;
38  
39  	/**
40  	 * Constructs a new StringCellRenderer.
41  	 * 
42  	 * @param decorateBorder if true decorated border will be used
43  	 * @param decorateBackground if true decorated background will be used
44  	 */
45  	public StringCellRenderer(boolean decorateBorder, boolean decorateBackground)
46  	{
47  		super(decorateBorder, decorateBackground);
48  	}
49  
50  	/**
51  	 * Constructs a new StringCellRenderer.
52  	 *
53  	 */
54  	public StringCellRenderer()
55  	{
56  		super();
57  	}
58  
59  	/*
60  	 * (non-Javadoc)
61  	 * @see com.cosylab.gui.components.table.renderers.DefaultTableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
62  	 */
63  	public Component getTableCellRendererComponent(JTable table, Object cell,
64  	    boolean isSelected, boolean hasFocus, int row, int column)
65  	{
66  		super.getTableCellRendererComponent(table, cell, isSelected, hasFocus,
67  		    row, column);
68  
69  		if (cell instanceof StringCell) {
70  			StringCell property = (StringCell)cell;
71  
72  			if (property.isSuspended()) {
73  				setText("");
74  			} else {
75  				setText(property.getStringValue());
76  			}
77  		}
78  
79  		return this;
80  	}
81  }
82  
83  /* __oOo__ */