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.cells;
21  
22  import com.cosylab.util.NumericStringComparator;
23  
24  /**
25   * DeviceCell holds place for device: an entitiy providion identifier and
26   * possibly commands.
27   *
28   * @author <a href="mailto:igor.kriznar@cosylab.com">Igor Kriznar</a>
29   */
30  public class DeviceCell extends TableCell
31  {
32  	
33  	private boolean highlightCell;
34  	
35  	/**
36  	 * Constructs a new DeviceCell.
37  	 *
38  	 */
39  	public DeviceCell()
40  	{
41  		super();
42  	}
43  
44  	/**
45  	 * Constructs a new DeviceCell.
46  	 *
47  	 * @param identifier
48  	 * @param dataSource
49  	 * @param value
50  	 * @param commands
51  	 */
52  	public DeviceCell(String identifier, Object dataSource, Object value,
53  	    Command[] commands)
54  	{
55  		super(identifier, dataSource, value, commands);
56  	}
57  
58  	/**
59  	 * Returns identifier.
60  	 *
61  	 * @see com.cosylab.gui.components.table.cells.TableCell#toString()
62  	 */
63  	public String toString()
64  	{
65  		return getIdentifier();
66  	}
67  
68  	NumericStringComparator numericStringComparator = new NumericStringComparator();
69  
70  	/* (non-Javadoc)
71  	 * @see com.cosylab.gui.components.table.cells.TableCell#compareTo(java.lang.Object)
72  	 */
73  	public int compareTo(Object o)
74  	{
75  		if (o instanceof DeviceCell) {
76  			return numericStringComparator.compare(getIdentifier(),((DeviceCell)o).getIdentifier());
77  		}
78  
79  		return super.compareTo(o);
80  	}
81  
82  	/**
83  	 * Returnst true if this cell is highlighted (selected).
84  	 * 
85  	 * @return true if highlighted
86  	 */
87  	public boolean isHighlightCell() {
88  		return highlightCell;
89  	}
90  
91  	/**
92  	 * Highlights this cell. This method does not fire any events. Upon changing the 
93  	 * highlight property the cell should be repainted.
94  	 * 
95  	 * @param cellSelected
96  	 */
97  	public void setHighlightCell(boolean cellSelected) {
98  		this.highlightCell = cellSelected;
99  	}
100 }
101 
102 /* __oOo__ */