1 | package org.greenstone.gatherer.file;
|
---|
2 |
|
---|
3 | import org.greenstone.gatherer.collection.CollectionManager;
|
---|
4 | import org.greenstone.gatherer.file.FileNode;
|
---|
5 | import org.greenstone.gatherer.gui.MirrorPane;
|
---|
6 | import org.greenstone.gatherer.util.SynchronizedTreeModelTools;
|
---|
7 |
|
---|
8 |
|
---|
9 | public 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 web_cache_mapping = null;
|
---|
16 | static private FileNode[] collection_specific_mappings = null;
|
---|
17 |
|
---|
18 |
|
---|
19 | public WorkspaceTreeModel(FileNode root)
|
---|
20 | {
|
---|
21 | super(root);
|
---|
22 | }
|
---|
23 |
|
---|
24 |
|
---|
25 | static public WorkspaceTreeModel getWorkspaceTreeModel()
|
---|
26 | {
|
---|
27 | // Create a root node to contain the various nodes in the workspace tree
|
---|
28 | workspace_tree_root = new FileNode("ABS_ROOT");
|
---|
29 | workspace_tree_model = new WorkspaceTreeModel(workspace_tree_root);
|
---|
30 |
|
---|
31 | // Add the Greenstone Collections mapping
|
---|
32 | greenstone_collections_mapping = CollectionManager.getGreenstoneCollectionsMapping();
|
---|
33 | workspace_tree_root.insert(greenstone_collections_mapping);
|
---|
34 |
|
---|
35 | // Add the local filespace
|
---|
36 | workspace_tree_root.insert(FileSystem.getLocalFileSystem(workspace_tree_model));
|
---|
37 |
|
---|
38 | // Add a mapping to the user home folder
|
---|
39 | workspace_tree_root.insert(FileSystem.getUserHomeMapping());
|
---|
40 |
|
---|
41 | // Add public and private web caches if applicable
|
---|
42 | loadWebCacheMappings();
|
---|
43 |
|
---|
44 | // Add any collection specific mappings
|
---|
45 | loadCollectionSpecificMappings();
|
---|
46 |
|
---|
47 | return workspace_tree_model;
|
---|
48 | }
|
---|
49 |
|
---|
50 |
|
---|
51 | static private void loadWebCacheMappings()
|
---|
52 | {
|
---|
53 | // If mirroring is enabled show the public and private caches
|
---|
54 | web_cache_mapping = MirrorPane.getWebCacheMapping();
|
---|
55 | if (web_cache_mapping != null) {
|
---|
56 | workspace_tree_root.insert(web_cache_mapping);
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 |
|
---|
61 | static private void loadCollectionSpecificMappings()
|
---|
62 | {
|
---|
63 | ///ystem.err.print("Load Collection Specific Mappings... ");
|
---|
64 | // Add the current collection specific mappings
|
---|
65 | collection_specific_mappings = CollectionManager.getCollectionSpecificMappings();
|
---|
66 | ///ystem.err.print("Retrieved Mappings... ");
|
---|
67 | if (collection_specific_mappings != null) {
|
---|
68 | for (int i = 0; i < collection_specific_mappings.length; i++) {
|
---|
69 | ///ystem.err.print("Setting " + i + " Mapping... ");
|
---|
70 | SynchronizedTreeModelTools.insertNodeInto(workspace_tree_model, workspace_tree_root, collection_specific_mappings[i], false);
|
---|
71 | }
|
---|
72 | }
|
---|
73 | ///ystem.err.println("Done.");
|
---|
74 | }
|
---|
75 |
|
---|
76 |
|
---|
77 | // !! NEEDS WORK !!
|
---|
78 | static public void refreshGreenstoneCollectionsMapping()
|
---|
79 | {
|
---|
80 | greenstone_collections_mapping.unmap();
|
---|
81 | greenstone_collections_mapping.map();
|
---|
82 | }
|
---|
83 |
|
---|
84 |
|
---|
85 | // !! NEEDS WORK !!
|
---|
86 | static public void refreshWebCacheMappings()
|
---|
87 | {
|
---|
88 | if (web_cache_mapping != null) {
|
---|
89 | SynchronizedTreeModelTools.removeNodeFromParent(workspace_tree_model, web_cache_mapping);
|
---|
90 | }
|
---|
91 |
|
---|
92 | loadWebCacheMappings();
|
---|
93 |
|
---|
94 | }
|
---|
95 |
|
---|
96 |
|
---|
97 | // !! NEEDS WORK !!
|
---|
98 | static public void refreshCollectionSpecificMappings()
|
---|
99 | {
|
---|
100 | // Remove all the old collection specific mappings
|
---|
101 | if (collection_specific_mappings != null) {
|
---|
102 | for (int i = 0; i < collection_specific_mappings.length; i++) {
|
---|
103 | SynchronizedTreeModelTools.removeNodeFromParent(workspace_tree_model,
|
---|
104 | collection_specific_mappings[i]);
|
---|
105 | }
|
---|
106 | }
|
---|
107 |
|
---|
108 | loadCollectionSpecificMappings();
|
---|
109 | }
|
---|
110 | }
|
---|