Ignore:
Timestamp:
2003-06-25T13:17:33+12:00 (21 years ago)
Author:
jmt12
Message:

bug#2030154: GComboBox now uses dataModel data member rather than its own reference. Thus the calls should never occur on a null model. I also removed the offending method, getMaximumRowCount(), because I cannot, for the life of me, figure out why it was overridden in the first place.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/GComboBox.java

    r4675 r4798  
    5454    private Color selection_foreground = null;
    5555
    56     private Model model;
    57 
    5856    public GComboBox() {
    5957    super();
     
    6159    }
    6260
    63     public GComboBox(Gatherer gatherer) {
    64     this();
    65     }
    66 
    6761    public GComboBox(ArrayList data) {
    6862    super(data.toArray());
     
    8680
    8781    public int add(Object object) {
    88     return model.add(object);
     82    if(dataModel instanceof Model) {
     83        return ((Model)dataModel).add(object);
     84    }
     85    else {
     86        return -1;
     87    }
    8988    }
    9089
    9190    public Object get(int index) {
    92     return model.getElementAt(index);
    93     }
    94 
    95     public int getMaximumRowCount() {
    96     int size = model.getSize();
    97     if(size == 0) {
    98         return 1;
    99     }
    100     else if(size < maximumRowCount) {
    101         return model.getSize();
    102     }
    103     return maximumRowCount;
     91    return dataModel.getElementAt(index);
    10492    }
    10593
    10694    public void clear() {
    107     model.clear();
     95    if(dataModel instanceof Model) {
     96        ((Model)dataModel).clear();
     97    }
    10898    }
    10999
    110100    public int count() {
    111     return model.getSize();
     101    return dataModel.getSize();
    112102    }
    113103
     
    137127
    138128    public void init() {
    139     this.model = new Model();
     129    Model model = new Model();
    140130    ComboBoxModel old_model = (ComboBoxModel) getModel();
    141131    setModel(model);
     
    191181        int position = 0;
    192182        String extension_str = extension.toString().toLowerCase();
    193         while(extension != null && position < size()) {
     183        while(extension != null && position < getSize()) {
    194184        String sibling = getElementAt(position).toString().toLowerCase();
    195185        int order = extension_str.compareTo(sibling);
     
    209199        }
    210200        if(extension != null) {
    211         position = size();
     201        position = getSize();
    212202        addElement(extension);
    213203        }
     
    217207    public void clear() {
    218208        removeAllElements();
    219     }
    220 
    221     public int size() {
    222         return getSize();
    223209    }
    224210    }
Note: See TracChangeset for help on using the changeset viewer.