Changeset 8787


Ignore:
Timestamp:
2004-12-13T14:50:39+13:00 (19 years ago)
Author:
mdewsnip
Message:

Fixed up some of the new file tree code for Windows.

Location:
trunk/gli/src/org/greenstone/gatherer/file
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/file/FileNode.java

    r8784 r8787  
    157157
    158158
     159    public void add(MutableTreeNode child)
     160    {
     161    insert(child, child_nodes.size());
     162    }
     163
     164
    159165    protected abstract FileNode addChildNode(File file);
    160166
     
    208214    }
    209215    return path;
    210     }
    211 
    212 
    213     public void insert(MutableTreeNode child) {
    214     insert(child, child_nodes.size());
    215216    }
    216217
  • trunk/gli/src/org/greenstone/gatherer/file/FileSystem.java

    r8783 r8787  
    22
    33import java.io.File;
    4 import javax.swing.filechooser.FileSystemView;
    54import org.greenstone.gatherer.DebugStream;
    65import org.greenstone.gatherer.Dictionary;
     
    1312    static public WorkspaceTreeNode getLocalFilespaceNode(FileSystemModel model)
    1413    {
    15     WorkspaceTreeNode file_system_root = null;
    16 
    1714    // Get all the available roots mounted on the filesystem
    1815    File[] roots = File.listRoots();
     
    2118    }
    2219
    23     // If there is just one root use it as the tree root (Linux)
     20    // If there is just one root use it as the tree root (Unix)
    2421    if (roots.length == 1) {
    25         file_system_root = new WorkspaceTreeNode(roots[0], Dictionary.get("Tree.Root"));
     22        return new WorkspaceTreeNode(roots[0], Dictionary.get("Tree.Root"));
    2623    }
    2724
    28     // Otherwise build a dummy node which has the roots as children
     25    // Otherwise build a dummy node which has the roots as children (Windows)
    2926    else {
    30         file_system_root = new WorkspaceTreeNode(null, Dictionary.get("Tree.Root"));
    31         file_system_root.setModel(model);
    32 
    33         // Sort the roots into alphabetical order
    34         ArrayTools.sort(roots);
    35         for (int i = 0; i < roots.length; i++) {
    36         // Only add root if it isn't a floppy drive
    37         if (!FileSystemView.getFileSystemView().isFloppyDrive(roots[i])) {
    38             file_system_root.insert(new WorkspaceTreeNode(roots[i]));
    39         }
    40         }
     27        return new WorkspaceTreeNode(null, Dictionary.get("Tree.Root"));
    4128    }
    42 
    43     return file_system_root;
    4429    }
    4530
     
    7459    static public WorkspaceTreeNode getDownloadedFilesNode()
    7560    {
    76     return new WorkspaceTreeNode(Utility.getCacheDir(), "Downloaded Files");
     61    // Return a mapping to the downloaded files folder
     62    return new WorkspaceTreeNode(Utility.getCacheDir(), Dictionary.get("Tree.DownloadedFiles"));
    7763    }
    7864}
  • trunk/gli/src/org/greenstone/gatherer/file/WorkspaceTreeModel.java

    r8783 r8787  
    7878    // Add the "Documents in Greenstone Collections" node
    7979    greenstone_collections_node = new WorkspaceTreeNode(null, Dictionary.get("Tree.World"));
    80     workspace_tree_root.insert(greenstone_collections_node);
     80    workspace_tree_root.add(greenstone_collections_node);
    8181
    8282    // Add the "Local Filespace" node
    8383    local_filespace_node = FileSystem.getLocalFilespaceNode(workspace_tree_model);
    84     workspace_tree_root.insert(local_filespace_node);
     84    workspace_tree_root.add(local_filespace_node);
    8585
    8686    // Add the "Home Folder" node
    87     workspace_tree_root.insert(FileSystem.getHomeFolderNode());
     87    workspace_tree_root.add(FileSystem.getHomeFolderNode());
    8888
    8989    // Add the "Downloaded Files" node, if Mirroring is enabled
    9090    if (Gatherer.g_man.mirror_pane != null) {
    9191        downloaded_files_node = FileSystem.getDownloadedFilesNode();
    92         workspace_tree_root.insert(downloaded_files_node);
     92        workspace_tree_root.add(downloaded_files_node);
    9393    }
    9494
  • trunk/gli/src/org/greenstone/gatherer/file/WorkspaceTreeNode.java

    r8785 r8787  
    3030import java.io.*;
    3131import java.util.*;
     32import javax.swing.filechooser.FileSystemView;
    3233import org.greenstone.gatherer.Configuration;
    3334import org.greenstone.gatherer.Dictionary;
     
    9697    public void map()
    9798    {
    98     // Special Case: if the name of this node is the Tree.World string, then we actually map the collections installed in greenstone. The file in this case will actually be the collect directory of greenstone.
     99    // Special Case: "Documents in Greenstone Collections" -- map the collections installed in Greenstone
    99100    if (file == null && title.equals(Dictionary.get("Tree.World"))) {
    100101        // If this node has already been mapped, don't bother doing it again
     
    160161    }
    161162
     163    // Special Case: "Local Filespace" on Windows -- create a node for each filesystem root (drive letter)
     164    else if (file == null && title.equals(Dictionary.get("Tree.Root"))) {
     165        // If this node has already been mapped, don't bother doing it again
     166        if (child_nodes != null) {
     167        return;
     168        }
     169        child_nodes = new ArrayList();
     170
     171        // Sort the roots into alphabetical order
     172        File[] roots = File.listRoots();
     173        ArrayTools.sort(roots);
     174        for (int i = 0; i < roots.length; i++) {
     175        // Only add root if it isn't a floppy drive
     176        if (!FileSystemView.getFileSystemView().isFloppyDrive(roots[i])) {
     177            child_nodes.add(addChildNode(roots[i]));
     178        }
     179        }
     180    }
     181
    162182    // General case
    163183    else {
Note: See TracChangeset for help on using the changeset viewer.