source: trunk/gli/src/org/greenstone/gatherer/file/WorkspaceTreeModel.java@ 5898

Last change on this file since 5898 was 5898, checked in by mdewsnip, 20 years ago

A quick and ugly hack to assign a model to the root drives under Windows. I'll tidy this up when I get the chance.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1package org.greenstone.gatherer.file;
2
3import org.greenstone.gatherer.collection.CollectionManager;
4import org.greenstone.gatherer.file.FileNode;
5import org.greenstone.gatherer.gui.MirrorPane;
6import org.greenstone.gatherer.util.SynchronizedTreeModelTools;
7
8
9public class WorkspaceTreeModel
10 extends FileSystemModel {
11
12 static private FileNode workspace_tree_root = null;
13 static private WorkspaceTreeModel workspace_tree_model = null;
14 static private FileNode greenstone_collections_mapping = null;
15 static private FileNode public_web_cache_mapping = null;
16 static private FileNode private_web_cache_mapping = null;
17 static private FileNode[] collection_specific_mappings = null;
18
19
20 public WorkspaceTreeModel(FileNode root)
21 {
22 super(root);
23 }
24
25
26 static public WorkspaceTreeModel getWorkspaceTreeModel()
27 {
28 // Create a root node to contain the various nodes in the workspace tree
29 workspace_tree_root = new FileNode("ABS_ROOT");
30 workspace_tree_model = new WorkspaceTreeModel(workspace_tree_root);
31
32 // Add the Greenstone Collections mapping
33 greenstone_collections_mapping = CollectionManager.getGreenstoneCollectionsMapping();
34 workspace_tree_root.insert(greenstone_collections_mapping);
35
36 // Add the local filespace
37 workspace_tree_root.insert(FileSystem.getLocalFileSystem(workspace_tree_model));
38
39 // Add a mapping to the user home folder
40 workspace_tree_root.insert(FileSystem.getUserHomeMapping());
41
42 // Add public and private web caches if applicable
43 loadWebCacheMappings();
44
45 // Add any collection specific mappings
46 loadCollectionSpecificMappings();
47
48 return workspace_tree_model;
49 }
50
51
52 static private void loadWebCacheMappings()
53 {
54 // If mirroring is enabled show the public and private caches
55 public_web_cache_mapping = MirrorPane.getPublicWebCacheMapping();
56 if (public_web_cache_mapping != null) {
57 workspace_tree_root.insert(public_web_cache_mapping);
58 }
59 private_web_cache_mapping = MirrorPane.getPrivateWebCacheMapping();
60 if (private_web_cache_mapping != null) {
61 workspace_tree_root.insert(private_web_cache_mapping);
62 }
63 }
64
65
66 static private void loadCollectionSpecificMappings()
67 {
68 // Add the current collection specific mappings
69 collection_specific_mappings = CollectionManager.getCollectionSpecificMappings();
70 if (collection_specific_mappings != null) {
71 for (int i = 0; i < collection_specific_mappings.length; i++) {
72 SynchronizedTreeModelTools.insertNodeInto(workspace_tree_model,
73 workspace_tree_root,
74 collection_specific_mappings[i]);
75 }
76 }
77 }
78
79
80 // !! NEEDS WORK !!
81 static public void refreshGreenstoneCollectionsMapping()
82 {
83 greenstone_collections_mapping.unmap();
84 greenstone_collections_mapping.map();
85 }
86
87
88 // !! NEEDS WORK !!
89 static public void refreshWebCacheMappings()
90 {
91 if (public_web_cache_mapping != null) {
92 SynchronizedTreeModelTools.removeNodeFromParent(workspace_tree_model,
93 public_web_cache_mapping);
94 }
95 if (private_web_cache_mapping != null) {
96 SynchronizedTreeModelTools.removeNodeFromParent(workspace_tree_model,
97 private_web_cache_mapping);
98 }
99
100 loadWebCacheMappings();
101 }
102
103
104 // !! NEEDS WORK !!
105 static public void refreshCollectionSpecificMappings()
106 {
107 // Remove all the old collection specific mappings
108 if (collection_specific_mappings != null) {
109 for (int i = 0; i < collection_specific_mappings.length; i++) {
110 SynchronizedTreeModelTools.removeNodeFromParent(workspace_tree_model,
111 collection_specific_mappings[i]);
112 }
113 }
114
115 loadCollectionSpecificMappings();
116 }
117}
Note: See TracBrowser for help on using the repository browser.