source: trunk/gli/src/org/greenstone/gatherer/util/CheckListEntry.java@ 9045

Last change on this file since 9045 was 8884, checked in by mdewsnip, 19 years ago

Moved the two CheckList classes into the util package, and removed the checklist package.

  • Property svn:keywords set to Author Date Id Revision
File size: 2.0 KB
Line 
1package org.greenstone.gatherer.util;
2
3import javax.swing.JCheckBox;
4
5/** A CheckListEntry encapsulates a single row of the list, both its check box and the object the row represents. */
6public class CheckListEntry
7 extends JCheckBox
8 implements Comparable {
9
10 /** Is this checkboxes state fixed. */
11 private boolean fixed = false;
12 /** The original object this row is based on, and whose toString() is used to generate the check box label. */
13 private Object object = null;
14 /** A sundry string for storing original values (rather than strings retrieved from dictionary). */
15 private String property;
16 /** Constructor. */
17 public CheckListEntry(Object object) {
18 super(object.toString());
19 this.object = object;
20 }
21
22 /** Constructor. */
23 public CheckListEntry(String text, boolean is_selected) {
24 super(text);
25 setSelected(is_selected);
26 }
27
28 /** Test this CheckListEntry against an Object for ordering.
29 * @param obj the other Object.
30 * @return <0, 0 or >0 if this CheckListEntry is before, equal to or after the given object.
31 */
32 public int compareTo(Object obj) {
33 return toString().toLowerCase().compareTo(obj.toString().toLowerCase());
34 }
35 /** Test this CheckListEntry against an Object for equality.
36 * @param obj the other Object.
37 * @return true if the two are equal, false otherwise.
38 */
39 public boolean equals(Object obj) {
40 return toString().equalsIgnoreCase(obj.toString());
41 }
42
43 /** Retrieve the object associated with this entry.
44 * @return An <strong>Object</strong>.
45 */
46 public Object getObject() {
47 if(object == null) {
48 return getText();
49 }
50 return object;
51 }
52
53 public String getProperty() {
54 return property;
55 }
56
57 public boolean isFixed() {
58 return fixed;
59 }
60
61 public void setFixed(boolean fixed) {
62 this.fixed = fixed;
63 }
64
65 public void setProperty(String property) {
66 this.property = property;
67 }
68
69 public String toString() {
70 if(object == null) {
71 return getText();
72 }
73 return object.toString();
74 }
75}
Note: See TracBrowser for help on using the repository browser.