source: trunk/gli/src/org/greenstone/gatherer/checklist/Entry.java@ 4293

Last change on this file since 4293 was 4293, checked in by jmt12, 21 years ago

Initial revision

  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1package org.greenstone.gatherer.checklist;
2
3import javax.swing.JCheckBox;
4import org.greenstone.gatherer.Gatherer;
5import org.greenstone.gatherer.msm.MetadataSet;
6import org.greenstone.gatherer.msm.MSMUtils;
7import org.greenstone.gatherer.util.Utility;
8import org.w3c.dom.Element;
9/** An Entry encapsulates a single row of the list, both its check box and the object the row represents. */
10public class Entry
11 extends JCheckBox {
12 /** Is this checkboxes state fixed. */
13 private boolean fixed = false;
14 /** The original object this row is based on, and whose toString() is used to generate the check box label. */
15 private Object object = null;
16 /** A sundry string for storing original values (rather than strings retrieved from dictionary). */
17 private String property;
18 /** Constructor. */
19 public Entry(Object object) {
20 super(object.toString());
21 this.object = object;
22 // We also build a special tool tip for metadata sets.
23 if(object instanceof MetadataSet) {
24 MetadataSet set = (MetadataSet) object;
25 // Build tooltip
26 StringBuffer tip = new StringBuffer(Gatherer.dictionary.get("NewCollectionPrompt.Set_Contains"));
27 tip.append(":\n");
28 for(int i = 0; i < set.size(); i++) {
29 Element element = set.getElement(i);
30 tip.append(MSMUtils.getIdentifier(element));
31 if(i < set.size() - 1) {
32 tip.append(", ");
33 }
34 }
35 setToolTipText(Utility.formatHTMLWidth(tip.toString(), 60));
36 }
37 }
38
39 /** Constructor. */
40 public Entry(String text, boolean is_selected) {
41 super(text);
42 setSelected(is_selected);
43 }
44
45 /** Retrieve the object associated with this entry.
46 * @return An <strong>Object</strong>.
47 */
48 public Object getObject() {
49 if(object == null) {
50 return getText();
51 }
52 return object;
53 }
54
55 public String getProperty() {
56 return property;
57 }
58
59 public boolean isFixed() {
60 return fixed;
61 }
62
63 public void setFixed(boolean fixed) {
64 this.fixed = fixed;
65 }
66
67 public void setProperty(String property) {
68 this.property = property;
69 }
70
71 public String toString() {
72 if(object == null) {
73 return getText();
74 }
75 return object.toString();
76 }
77}
Note: See TracBrowser for help on using the repository browser.