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

Last change on this file since 18372 was 18372, checked in by kjdon, 15 years ago

set the ComponentOrientation for a few things, for RTL gli

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