Changeset 4496 for trunk


Ignore:
Timestamp:
2003-06-06T09:55:23+12:00 (21 years ago)
Author:
jmt12
Message:

2030104: Modified to support SuperCollections needs.

Location:
trunk/gli/src/org/greenstone/gatherer/checklist
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/checklist/CheckList.java

    r4366 r4496  
    7878    }
    7979    /** Constructor.
    80       * @param list_data An <strong>ArrayList</strong> of entries for this checklist.
    81       * @see org.greenstone.gatherer.checklist.CheckList.Entry
    82       */
     80     * @param list_data An ArrayList of entries for this checklist.
     81     * @see org.greenstone.gatherer.checklist.CheckList.Entry
     82     */
    8383    public CheckList(ArrayList list_data) {
    8484    super();
     
    8686    DefaultListModel model = new DefaultListModel();
    8787    for(int i = 0; i < list_data.size(); i++) {
    88         Entry entry = new Entry(list_data.get(i));
     88        Entry entry = null;
     89        Object temp = list_data.get(i);
     90        if(temp instanceof Entry) {
     91        entry = (Entry) temp;
     92        }
     93        else {
     94        entry = new Entry(list_data.get(i));
     95        }
     96        temp = null;
    8997        String name = entry.toString();
    9098        int index = 0;
  • trunk/gli/src/org/greenstone/gatherer/checklist/Entry.java

    r4366 r4496  
    99/** An Entry encapsulates a single row of the list, both its check box and the object the row represents. */
    1010public class Entry
    11     extends JCheckBox {
     11    extends JCheckBox
     12    implements Comparable {
     13
    1214    /** Is this checkboxes state fixed. */
    13     private boolean fixed = false;
     15    protected boolean fixed = false;
    1416    /** The original object this row is based on, and whose toString() is used to generate the check box label. */
    15     private Object object = null;
     17    protected Object object = null;
    1618    /** A sundry string for storing original values (rather than strings retrieved from dictionary). */
    17     private String property;
     19    protected String property;
    1820    /** Constructor. */
    1921    public Entry(Object object) {
     
    4143    super(text);
    4244    setSelected(is_selected);
     45    }
     46
     47    /** Test this Entry against an Object for ordering.
     48     * @param obj the other Object.
     49     * @return <0, 0 or >0 if this Entry is before, equal to or after the given object.
     50     */
     51    public int compareTo(Object obj) {
     52    return toString().toLowerCase().compareTo(obj.toString().toLowerCase());
     53    }
     54    /** Test this Entry against an Object for equality.
     55     * @param obj the other Object.
     56     * @return true if the two are equal, false otherwise.
     57     */
     58    public boolean equals(Object obj) {
     59    return toString().equalsIgnoreCase(obj.toString());
    4360    }
    4461
Note: See TracChangeset for help on using the changeset viewer.