Changeset 7489
- Timestamp:
- 2004-05-28T15:41:03+12:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/file/FileSystemModel.java
r7208 r7489 213 213 214 214 215 // /** Used to refresh the contents of the FileNode indicated by the tree path. While the refresh itself is a piece of the proverbial, the restoring of expanded folders afterwards is a nightmare, mainly because all of the tree paths are no longer valid (remember that refresh involves throwing away the node currents children and remapping them). 216 // * @param path The TreePath to the node to be refreshed. 217 // */ 218 // public void oldRefresh(TreePath path) { 219 // // If no path is set, take the path to the root node (ie update the whole tree) 220 // if(path == null) { 221 // System.err.println("Refresh entire tree."); 222 // path = new TreePath(((FileNode)root).getPath()); 223 // } 224 // else { 225 // System.err.println("FileSystemModel.refresh: " + path.getLastPathComponent()); 226 // } 227 // // Only a valid action if this model is currently being displayed in a tree. 228 // if(tree != null) { 229 // System.err.println("Refreshing tree " + tree); 230 // // Retrieve the error node. 231 // FileNode node = (FileNode) path.getLastPathComponent(); 232 // // If this error node is a dummy node (ie has no associated file) we can't unmap it, so we iterate through its children refreshing each in turn. The exception being Greenstone Collections, as it is a dummy node but we can map/unmap it 233 // if(node.getFile() == null && !node.toString().equals(Dictionary.get("Tree.World"))) { 234 // for(int i = 0; i < node.getChildCount(); i++) { 235 // FileNode child = (FileNode) node.getChildAt(i); 236 // refresh(new TreePath(child.getPath())); 237 // child = null; 238 // } 239 // } 240 // // Otherwise we refresh this node. 241 // else { 242 // // Record all of the expanded paths under this node. How come getExpandedDescendants returns more results each time. 243 // Enumeration old_tree_paths = tree.getExpandedDescendants(path); 244 // // Refresh the tree structure. 245 // node.unmap(); 246 // node.map(); 247 // // Fire the appropriate event. 248 // nodeStructureChanged(node); 249 // // Then (painfully) restore the expanded paths. Note that the paths stored in the enumeration no longer exist, so I have to restore by node matching. 250 // //counter = 0; 251 // ///ystem.err.println("After:"); 252 // while(old_tree_paths != null && old_tree_paths.hasMoreElements()) { 253 // //counter++; 254 // FileNode current_node = node; 255 // TreePath old_tree_path = (TreePath) old_tree_paths.nextElement(); 256 // ///ystem.err.println(counter + ". " + old_tree_path); 257 // TreePath new_tree_path = new TreePath(path.getPath()); // Why isn't there a treepath copy constructor! 258 // boolean not_found = false; 259 // while(!not_found && old_tree_path.getPathCount() > new_tree_path.getPathCount()) { 260 // // Retrieve the new node in the old tree path 261 // FileNode old_path_node = (FileNode) old_tree_path.getPathComponent(new_tree_path.getPathCount()); 262 // // Ensure the current node is mapped 263 // current_node.map(); 264 // // Now attempt to match it to a child of the new paths last node. 265 // boolean found = false; 266 // for(int i = 0; !found && i < current_node.getChildCount(); i++) { 267 // FileNode target = (FileNode) current_node.getChildAt(i); 268 // ///ystem.err.println("Comparing " + old_path_node.toString() + " with " + target); 269 // if(target.toString().equals(old_path_node.toString())) { 270 // current_node = target; 271 // found = true; 272 // } 273 // target = null; 274 // } 275 // old_path_node = null; 276 // // If we found a match, we add that to the new Tree Path and continue. 277 // if(found) { 278 // ///ystem.err.println("Found a match!"); 279 // new_tree_path = new_tree_path.pathByAddingChild(current_node); 280 // } 281 // // We also have to record if we were unable to find a match in the current nodes children. 282 // else { 283 // ///ystem.err.println("Node not found."); 284 // not_found = true; 285 // } 286 // } 287 // old_tree_path = null; 288 // // If we've got this far, and haven't hit a not found, then we can assume we have the appropriate path, and ask the program to expand the new tree path 289 // if(!not_found) { 290 // tree.expandPath(new_tree_path); 291 // ///ystem.err.println(" -> Expanded " + new_tree_path); 292 // } 293 // else { 294 // ///ystem.err.println(" -> Cannot Expand " + new_tree_path); 295 // } 296 // new_tree_path = null; 297 // current_node = null; 298 // } 299 // node = null; 300 // } 301 // } 302 // else { 303 // ///ystem.err.println("No Tree!"); 304 // } 305 // } 306 307 public void setFilter(String pattern) { 215 public void setFilter(String pattern) { 308 216 if(pattern != null) { 309 217 current_filter = new FileFilter(pattern, false); … … 313 221 } 314 222 filters = null; 315 } 316 317 /* private void setPermanentFilter(String pattern) { 318 if(pattern != null) { 319 FileFilter new_filter = new FileFilter(pattern, false); 320 FileFilter temp[] = new FileFilter[default_filters.length + 1]; 321 System.arraycopy(default_filters, 0, temp, 0, default_filters.length); 322 temp[default_filters.length] = new_filter; 323 default_filters = temp; 324 temp = null; 325 } 326 filters = null; 327 } */ 223 } 328 224 329 225 public void setTree(DragTree tree) {
Note:
See TracChangeset
for help on using the changeset viewer.