Changeset 7691


Ignore:
Timestamp:
2004-07-02T08:11:08+12:00 (20 years ago)
Author:
mdewsnip
Message:

Fixed a bug where switching to a file with no metadata would cause an exception because it was trying to select a non-existant row in the table.

File:
1 edited

Legend:

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

    r7511 r7691  
    175175        builder.select_closest_metadata = metadatum;
    176176    }
    177     // Otherwise, select the appropriate row in the table
     177    // Otherwise, select the appropriate row in the table...
    178178    else {
    179 
    180         // If there was no previous metadata, select the first row (if any)
    181         if(metadatum == null) {
    182         if(current_metadata.size() > 0) {
    183             // We have to put the selection task onto the AWT thread
    184             SelectionTask task = new SelectionTask(0);
    185             SwingUtilities.invokeLater(task);
    186             task = null;
    187         }
     179        // ...but only if there actually is some metadata in the table
     180        if (current_metadata.size() == 0) {
     181        return;
     182        }
     183
     184        // If there was no previous metadata, select the first row
     185        if (metadatum == null) {
     186        // We have to put the selection task onto the AWT thread
     187        SelectionTask task = new SelectionTask(0);
     188        SwingUtilities.invokeLater(task);
     189        task = null;
    188190        return;
    189191        }
     
    205207        // Select the same row as before, except if it would select a different element - in which case select the first element
    206208        ElementWrapper element = metadatum.getElement();
    207         if(i < 0) {
     209        if (i < 0) {
    208210        Gatherer.println("Could not find suitable row to select!");
    209         i=0; // select the first one
    210         //return;
    211         } else {
     211        i = 0; // select the first one
     212        }
     213        else {
    212214        Metadata newly_selected_metadatum = (Metadata) current_metadata.get(i);
    213215        if (!newly_selected_metadatum.getElement().equals(element)) {
    214216            // Try one row previous
    215217            i--;
    216             if(i < 0) {
     218            if (i < 0) {
    217219            Gatherer.println("Could not find suitable row to select!");
    218             i=0;
    219             //return;
    220             } else {
    221            
     220            i = 0;
     221            }
     222            else {
    222223            newly_selected_metadatum = (Metadata) current_metadata.get(i);
    223224            if (!newly_selected_metadatum.getElement().equals(element)) {
    224225                Gatherer.println("Could not find suitable row to select!");
    225                 i=0;
    226                 //return;
     226                i = 0;
    227227            }
    228228            }
Note: See TracChangeset for help on using the changeset viewer.