Changeset 8262


Ignore:
Timestamp:
2004-10-08T16:54:49+13:00 (20 years ago)
Author:
mdewsnip
Message:

Removed the FileNode functions from ArrayTools as this creates nasty dependencies.

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
3 edited

Legend:

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

    r8243 r8262  
    5858import org.greenstone.gatherer.msm.MSMEvent;
    5959import org.greenstone.gatherer.msm.MSMListener;
    60 import org.greenstone.gatherer.util.ArrayTools;
    6160import org.greenstone.gatherer.util.Codec;
    6261import org.greenstone.gatherer.util.DragGroup;
     
    759758        records = null;
    760759        TreePath paths[] = collection_tree.getSelectionPaths();
     760        records = new FileNode[paths.length];
    761761        for (int i = 0; i < paths.length; i++) {
    762762        FileNode record = (FileNode) paths[i].getLastPathComponent();
    763         records = ArrayTools.add(records, record);
     763        records[i] = record;
    764764        }
    765765
  • trunk/gli/src/org/greenstone/gatherer/gui/table/GTableModel.java

    r8236 r8262  
    4444import org.greenstone.gatherer.msm.MSMListener;
    4545import org.greenstone.gatherer.msm.MSMUtils;
    46 import org.greenstone.gatherer.util.ArrayTools;
    4746import org.greenstone.gatherer.util.Utility;
    4847
     
    266265    public void metadataChanged(MSMEvent event) {
    267266    FileNode file_node = event.getRecord();
     267
    268268    // First check whether this record is one of those that we have showing.
    269     if (file_nodes != null && file_nodes.length > 0 && file_node != null && ArrayTools.contains(file_nodes, file_node)) {
    270         // Brute force solution... rebuild the table.
    271         rebuildModel();
     269    if (file_nodes != null && file_nodes.length > 0 && file_node != null) {
     270        for (int i = 0; i < file_nodes.length; i++) {
     271        if (file_nodes[i].equals(file_node)) {
     272            // Brute force solution... rebuild the table.
     273            rebuildModel();
     274            return;
     275        }
     276        }
    272277    }
    273278    }
  • trunk/gli/src/org/greenstone/gatherer/util/ArrayTools.java

    r7985 r8262  
    1313import java.util.*;
    1414import javax.swing.filechooser.*;
    15 import org.greenstone.gatherer.file.FileNode;
    1615import org.w3c.dom.*;
    1716
     
    122121    }
    123122
    124     /** This method efficiently appends a new FileNode onto the end of a FileNode array.
    125      * @param a The initial <strong>FileNode[]</strong>.
    126      * @param b The new <strong>FileNode</strong>.
    127      * @return An <strong>FileNode[]</strong> containing a followed by b.
    128      */
    129     static public FileNode[] add(FileNode a[], FileNode b) {
    130     FileNode[] c = null;
    131     if(a != null && b != null) {
    132         c = new FileNode[a.length + 1];
    133         System.arraycopy(a, 0, c, 0, a.length);
    134         c[c.length - 1] = b;
    135     }
    136     else if(a == null && b != null) {
    137         c = new FileNode[1];
    138         c[0] = b;
    139     }
    140     else if(a != null && b == null) {
    141         c = a;
    142     }
    143     return c;
    144     }
    145     /** This method efficently appends one FileNode array onto the end of another FileNode array.
    146      * @param a The initial <strong>FileNode[]</strong>.
    147      * @param b The <strong>FileNode[]</strong> to append.
    148      * @return An <strong>FileNode[]</strong> containing a followed by b.
    149      */
    150     static final public FileNode[] add(FileNode a[], FileNode b[]) {
    151     FileNode[] c = null;
    152     if(a != null && b != null) {
    153         c = new FileNode[a.length + b.length];
    154         System.arraycopy(a, 0, c, 0, a.length);
    155         System.arraycopy(b, 0, c, a.length, b.length);
    156     }
    157     else if(a == null && b != null) {
    158         c = b;
    159     }
    160     else if(a != null && b == null) {
    161         c = a;
    162     }
    163     return c;
    164     }
    165     /** Determine if a certain FileNode is present in an array of FileNodes.
    166      * @param array The <strong>FileNode[]</strong>.
    167      * @param a The <strong>FileNode</strong> we are searching for.
    168      * @return <i>true</i> if the FileNode is in the array, <i>false</i> otherwise.
    169      */
    170     static final public boolean contains(FileNode array[], FileNode a) {
    171     for(int i = 0; i < array.length; i++) {
    172         if(array[i].equals(a)) {
    173         return true;
    174         }
    175     }
    176     return false;
    177     }
    178123
    179124    /** This method efficiently appends a new node onto the end of a node array.
Note: See TracChangeset for help on using the changeset viewer.