Changeset 8262
- Timestamp:
- 2004-10-08T16:54:49+13:00 (20 years ago)
- 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 58 58 import org.greenstone.gatherer.msm.MSMEvent; 59 59 import org.greenstone.gatherer.msm.MSMListener; 60 import org.greenstone.gatherer.util.ArrayTools;61 60 import org.greenstone.gatherer.util.Codec; 62 61 import org.greenstone.gatherer.util.DragGroup; … … 759 758 records = null; 760 759 TreePath paths[] = collection_tree.getSelectionPaths(); 760 records = new FileNode[paths.length]; 761 761 for (int i = 0; i < paths.length; i++) { 762 762 FileNode record = (FileNode) paths[i].getLastPathComponent(); 763 records = ArrayTools.add(records, record);763 records[i] = record; 764 764 } 765 765 -
trunk/gli/src/org/greenstone/gatherer/gui/table/GTableModel.java
r8236 r8262 44 44 import org.greenstone.gatherer.msm.MSMListener; 45 45 import org.greenstone.gatherer.msm.MSMUtils; 46 import org.greenstone.gatherer.util.ArrayTools;47 46 import org.greenstone.gatherer.util.Utility; 48 47 … … 266 265 public void metadataChanged(MSMEvent event) { 267 266 FileNode file_node = event.getRecord(); 267 268 268 // 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 } 272 277 } 273 278 } -
trunk/gli/src/org/greenstone/gatherer/util/ArrayTools.java
r7985 r8262 13 13 import java.util.*; 14 14 import javax.swing.filechooser.*; 15 import org.greenstone.gatherer.file.FileNode;16 15 import org.w3c.dom.*; 17 16 … … 122 121 } 123 122 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 }178 123 179 124 /** This method efficiently appends a new node onto the end of a node array.
Note:
See TracChangeset
for help on using the changeset viewer.